From 57ec4f0a4aa3411f98bd58b7df8182862fd61279 Mon Sep 17 00:00:00 2001 From: Nav Date: Wed, 8 Dec 2021 00:18:59 +0000 Subject: [PATCH] Moved global insight refresh into member function. Also enabled spinning animation on the refresh button --- .../InsightWindow/InsightWindow.cpp | 57 +++++++++++-------- .../InsightWindow/InsightWindow.hpp | 4 +- 2 files changed, 35 insertions(+), 26 deletions(-) diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp index 8e6c14b0..8e9bf635 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.cpp @@ -88,32 +88,9 @@ InsightWindow::InsightWindow(InsightWorker& insightWorker): QMainWindow(nullptr) connect(openAboutWindowAction, &QAction::triggered, this, &InsightWindow::openAboutWindow); this->header = this->windowContainer->findChild("header"); - this->refreshIoInspectionButton = this->header->findChild("refresh-io-inspection-btn"); + this->refreshIoInspectionButton = this->header->findChild("refresh-io-inspection-btn"); - connect(this->refreshIoInspectionButton, &QToolButton::clicked, this, [this] { - // TODO: Move this into a member function - getting too big for a lambda - if (this->targetState == TargetState::STOPPED && this->selectedVariant != nullptr) { - this->toggleUi(true); - if (this->targetPackageWidget != nullptr) { - this->targetPackageWidget->setDisabled(true); - this->targetPackageWidget->refreshPinStates([this] { - if (this->targetState == TargetState::STOPPED) { - this->targetPackageWidget->setDisabled(false); - - if (this->targetRegistersSidePane == nullptr || !this->targetRegistersSidePane->activated) { - this->toggleUi(false); - } - } - }); - } - - if (this->targetRegistersSidePane != nullptr && this->targetRegistersSidePane->activated) { - this->targetRegistersSidePane->refreshRegisterValues([this] { - this->toggleUi(false); - }); - } - } - }); + connect(this->refreshIoInspectionButton, &QToolButton::clicked, this, &InsightWindow::refresh); this->leftMenuBar = this->container->findChild("left-side-menu-bar"); this->leftPanel = this->container->findChild("left-panel"); @@ -186,6 +163,36 @@ void InsightWindow::onTargetProgramCounterUpdate(quint32 programCounter) { ); } +void InsightWindow::refresh() { + if (this->targetState != TargetState::STOPPED || this->selectedVariant == nullptr) { + return; + } + + this->toggleUi(true); + this->refreshIoInspectionButton->startSpin(); + + if (this->targetPackageWidget != nullptr) { + this->targetPackageWidget->setDisabled(true); + this->targetPackageWidget->refreshPinStates([this] { + if (this->targetState == TargetState::STOPPED) { + this->targetPackageWidget->setDisabled(false); + + if (this->targetRegistersSidePane == nullptr || !this->targetRegistersSidePane->activated) { + this->refreshIoInspectionButton->stopSpin(); + this->toggleUi(false); + } + } + }); + } + + if (this->targetRegistersSidePane != nullptr && this->targetRegistersSidePane->activated) { + this->targetRegistersSidePane->refreshRegisterValues([this] { + this->refreshIoInspectionButton->stopSpin(); + this->toggleUi(false); + }); + } +} + void InsightWindow::openReportIssuesUrl() { auto url = QUrl(QString::fromStdString(Paths::homeDomainName() + "/report-issue")); /* diff --git a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp index 442c4f3f..35e05dfa 100644 --- a/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp +++ b/src/Insight/UserInterfaces/InsightWindow/InsightWindow.hpp @@ -15,6 +15,7 @@ #include "Widgets/PanelWidget.hpp" +#include "Widgets/SvgToolButton.hpp" #include "Widgets/TargetWidgets/TargetPackageWidgetContainer.hpp" #include "Widgets/TargetWidgets/TargetPackageWidget.hpp" #include "Widgets/TargetRegistersPane/TargetRegistersPaneWidget.hpp" @@ -46,6 +47,7 @@ namespace Bloom void onTargetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor); void onTargetStateUpdate(Targets::TargetState newState); void onTargetProgramCounterUpdate(quint32 programCounter); + void refresh(); void openReportIssuesUrl(); void openGettingStartedUrl(); void openAboutWindow(); @@ -80,7 +82,7 @@ namespace Bloom AboutWindow* aboutWindowWidget = nullptr; QWidget* header = nullptr; - QToolButton* refreshIoInspectionButton = nullptr; + Widgets::SvgToolButton* refreshIoInspectionButton = nullptr; QWidget* leftMenuBar = nullptr; Widgets::PanelWidget* leftPanel = nullptr;