This commit is contained in:
Nav
2021-12-08 00:33:13 +00:00
parent 57ec4f0a4a
commit 3b80954f72
5 changed files with 286 additions and 224 deletions

View File

@@ -15,6 +15,7 @@ Checks: >
performance-*,
readability-*,
-modernize-use-trailing-return-type,
-modernize-avoid-bind,
-readability-named-parameter,
-readability-magic-numbers,
-cppcoreguidelines-avoid-magic-numbers,
@@ -24,4 +25,6 @@ CheckOptions:
value: 1
- key: cppcoreguidelines-non-private-member-variables-in-classes.IgnorePublicMemberVariables
value: 1
- key: readability-function-cognitive-complexity.DescribeBasicIncrements
value: 1
FormatStyle: 'none'

View File

@@ -117,12 +117,6 @@ void Insight::startup() {
QObject::connect(eventDispatchTimer, &QTimer::timeout, this, &Insight::dispatchEvents);
eventDispatchTimer->start(100);
QObject::connect(this->insightWorker, &InsightWorker::targetControllerSuspended, this->mainWindow, &InsightWindow::onTargetControllerSuspended);
QObject::connect(this->insightWorker, &InsightWorker::targetControllerResumed, this->mainWindow, &InsightWindow::onTargetControllerResumed);
QObject::connect(this->insightWorker, &InsightWorker::targetStateUpdated, this->mainWindow, &InsightWindow::onTargetStateUpdate);
QObject::connect(this->insightWorker, &InsightWorker::targetProgramCounterUpdated, this->mainWindow, &InsightWindow::onTargetProgramCounterUpdate);
QObject::connect(this->mainWindow, &InsightWindow::refreshTargetPinStates, this->insightWorker, &InsightWorker::requestPinStates);
this->mainWindow->setInsightConfig(this->insightConfig);
this->mainWindow->setEnvironmentConfig(this->environmentConfig);

View File

@@ -75,44 +75,32 @@ InsightWindow::InsightWindow(InsightWorker& insightWorker): QMainWindow(nullptr)
);
this->ioUnavailableWidget = this->windowContainer->findChild<QLabel*>("io-inspection-unavailable");
auto fileMenu = this->mainMenuBar->findChild<QMenu*>("file-menu");
auto helpMenu = this->mainMenuBar->findChild<QMenu*>("help-menu");
auto quitAction = fileMenu->findChild<QAction*>("close-insight");
auto openReportIssuesUrlAction = helpMenu->findChild<QAction*>("open-report-issues-url");
auto openGettingStartedUrlAction = helpMenu->findChild<QAction*>("open-getting-started-url");
auto openAboutWindowAction = helpMenu->findChild<QAction*>("open-about-dialogue");
connect(quitAction, &QAction::triggered, this, &InsightWindow::close);
connect(openReportIssuesUrlAction, &QAction::triggered, this, &InsightWindow::openReportIssuesUrl);
connect(openGettingStartedUrlAction, &QAction::triggered, this, &InsightWindow::openGettingStartedUrl);
connect(openAboutWindowAction, &QAction::triggered, this, &InsightWindow::openAboutWindow);
auto* fileMenu = this->mainMenuBar->findChild<QMenu*>("file-menu");
auto* helpMenu = this->mainMenuBar->findChild<QMenu*>("help-menu");
auto* quitAction = fileMenu->findChild<QAction*>("close-insight");
auto* openReportIssuesUrlAction = helpMenu->findChild<QAction*>("open-report-issues-url");
auto* openGettingStartedUrlAction = helpMenu->findChild<QAction*>("open-getting-started-url");
auto* openAboutWindowAction = helpMenu->findChild<QAction*>("open-about-dialogue");
this->header = this->windowContainer->findChild<QWidget*>("header");
this->refreshIoInspectionButton = this->header->findChild<SvgToolButton*>("refresh-io-inspection-btn");
connect(this->refreshIoInspectionButton, &QToolButton::clicked, this, &InsightWindow::refresh);
this->leftMenuBar = this->container->findChild<QWidget*>("left-side-menu-bar");
this->leftPanel = this->container->findChild<PanelWidget*>("left-panel");
this->targetRegistersButton = this->container->findChild<QToolButton*>("target-registers-btn");
auto targetRegisterButtonLayout = this->targetRegistersButton->findChild<QVBoxLayout*>();
auto* targetRegisterButtonLayout = this->targetRegistersButton->findChild<QVBoxLayout*>();
auto* registersBtnLabel = new RotatableLabel(270, "Registers", this->targetRegistersButton);
registersBtnLabel->setObjectName("target-registers-btn-label");
registersBtnLabel->setContentsMargins(5,0,9,0);
targetRegisterButtonLayout->insertWidget(0, registersBtnLabel, 0, Qt::AlignTop);
connect(this->targetRegistersButton, &QToolButton::clicked, this, &InsightWindow::toggleTargetRegistersPane);
this->bottomMenuBar = this->container->findChild<QWidget*>("bottom-menu-bar");
this->bottomPanel = this->container->findChild<PanelWidget*>("bottom-panel");
this->ramInspectionButton = this->container->findChild<QToolButton*>("ram-inspection-btn");
this->eepromInspectionButton = this->container->findChild<QToolButton*>("eeprom-inspection-btn");
connect(this->ramInspectionButton, &QToolButton::clicked, this, &InsightWindow::toggleRamInspectionPane);
connect(this->eepromInspectionButton, &QToolButton::clicked, this, &InsightWindow::toggleEepromInspectionPane);
this->footer = this->windowContainer->findChild<QWidget*>("footer");
this->targetStatusLabel = this->footer->findChild<QLabel*>("target-state");
this->programCounterValueLabel = this->footer->findChild<QLabel*>("target-program-counter-value");
@@ -120,6 +108,86 @@ InsightWindow::InsightWindow(InsightWorker& insightWorker): QMainWindow(nullptr)
const auto windowSize = this->size();
this->windowContainer->setFixedSize(windowSize);
this->layoutContainer->setFixedSize(windowSize);
// Main menu connections
QObject::connect(
quitAction,
&QAction::triggered,
this,
&InsightWindow::close
);
QObject::connect(
openReportIssuesUrlAction,
&QAction::triggered,
this,
&InsightWindow::openReportIssuesUrl
);
QObject::connect(
openGettingStartedUrlAction,
&QAction::triggered,
this,
&InsightWindow::openGettingStartedUrl
);
QObject::connect(
openAboutWindowAction,
&QAction::triggered,
this,
&InsightWindow::openAboutWindow
);
// Tool bar button connections
QObject::connect(
this->refreshIoInspectionButton,
&QToolButton::clicked,
this,
&InsightWindow::refresh
);
// Panel button connections
QObject::connect(
this->targetRegistersButton,
&QToolButton::clicked,
this,
&InsightWindow::toggleTargetRegistersPane
);
QObject::connect(
this->ramInspectionButton,
&QToolButton::clicked,
this,
&InsightWindow::toggleRamInspectionPane
);
QObject::connect(
this->eepromInspectionButton,
&QToolButton::clicked,
this,
&InsightWindow::toggleEepromInspectionPane
);
// InsightWorker connections
QObject::connect(
&(this->insightWorker),
&InsightWorker::targetControllerSuspended,
this,
&InsightWindow::onTargetControllerSuspended
);
QObject::connect(
&(this->insightWorker),
&InsightWorker::targetControllerResumed,
this,
&InsightWindow::onTargetControllerResumed
);
QObject::connect(
&(this->insightWorker),
&InsightWorker::targetStateUpdated,
this,
&InsightWindow::onTargetStateUpdate
);
QObject::connect(
&(this->insightWorker),
&InsightWorker::targetProgramCounterUpdated,
this,
&InsightWindow::onTargetProgramCounterUpdate
);
}
void InsightWindow::init(TargetDescriptor targetDescriptor) {
@@ -127,177 +195,6 @@ void InsightWindow::init(TargetDescriptor targetDescriptor) {
this->activate();
}
void InsightWindow::onTargetControllerSuspended() {
if (this->activated) {
this->deactivate();
}
}
void InsightWindow::onTargetControllerResumed(const TargetDescriptor& targetDescriptor) {
if (!this->activated) {
this->targetDescriptor = targetDescriptor;
this->activate();
}
}
void InsightWindow::onTargetStateUpdate(TargetState newState) {
this->targetState = newState;
if (newState == TargetState::RUNNING) {
this->targetStatusLabel->setText("Running");
this->programCounterValueLabel->setText("-");
this->toggleUi(true);
} else if (newState == TargetState::STOPPED) {
this->targetStatusLabel->setText("Stopped");
this->toggleUi(false);
} else {
this->targetStatusLabel->setText("Unknown");
}
}
void InsightWindow::onTargetProgramCounterUpdate(quint32 programCounter) {
this->programCounterValueLabel->setText(
"0x" + QString::number(programCounter, 16).toUpper() + " (" + QString::number(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"));
/*
* The https://bloom.oscillate.io/report-issue URL just redirects to the Bloom GitHub issue page.
*
* We can use query parameters in the URL to pre-fill the body of the issue. We use this to include some
* target information.
*/
auto urlQuery = QUrlQuery();
auto issueBody = QString("Issue reported via Bloom Insight.\nTarget name: "
+ QString::fromStdString(this->targetDescriptor.name) + "\n"
+ "Target ID: " + QString::fromStdString(this->targetDescriptor.id) + "\n"
);
if (this->selectedVariant != nullptr) {
issueBody += "Target variant: " + QString::fromStdString(this->selectedVariant->name) + "\n";
}
issueBody += "\nPlease describe your issue below. Include as much detail as possible.";
urlQuery.addQueryItem("body", issueBody);
url.setQuery(urlQuery);
QDesktopServices::openUrl(url);
}
void InsightWindow::openGettingStartedUrl() {
QDesktopServices::openUrl(QUrl(QString::fromStdString(Paths::homeDomainName() + "/docs/getting-started")));
}
void InsightWindow::openAboutWindow() {
if (this->aboutWindowWidget == nullptr) {
this->aboutWindowWidget = new AboutWindow(this);
}
this->aboutWindowWidget->show();
}
void InsightWindow::toggleTargetRegistersPane() {
if (this->targetRegistersSidePane->activated) {
this->targetRegistersSidePane->deactivate();
this->targetRegistersButton->setChecked(false);
/*
* Given that the target registers side pane is currently the only pane in the left panel, the panel will be
* empty so no need to leave it visible.
*/
this->leftPanel->setVisible(false);
} else {
this->targetRegistersSidePane->activate();
this->targetRegistersButton->setChecked(true);
this->leftPanel->setVisible(true);
}
}
void InsightWindow::toggleRamInspectionPane() {
if (this->ramInspectionPane->activated) {
this->ramInspectionPane->deactivate();
this->bottomPanel->hide();
this->ramInspectionButton->setChecked(false);
} else {
if (this->eepromInspectionPane != nullptr && this->eepromInspectionPane->activated) {
this->toggleEepromInspectionPane();
}
this->ramInspectionPane->activate();
this->bottomPanel->show();
this->ramInspectionButton->setChecked(true);
if (this->targetPackageWidget != nullptr) {
this->setMinimumHeight(std::max(
this->minimumHeight(),
this->targetPackageWidget->height() + this->header->height() + this->footer->height()
+ this->menuBar()->height() + this->bottomPanel->getMinimumResize() + 30
));
}
}
}
void InsightWindow::toggleEepromInspectionPane() {
if (this->eepromInspectionPane->activated) {
this->eepromInspectionPane->deactivate();
this->bottomPanel->hide();
this->eepromInspectionButton->setChecked(false);
} else {
if (this->ramInspectionPane != nullptr && this->ramInspectionPane->activated) {
this->toggleRamInspectionPane();
}
this->eepromInspectionPane->activate();
this->bottomPanel->show();
this->eepromInspectionButton->setChecked(true);
if (this->targetPackageWidget != nullptr) {
this->setMinimumHeight(std::max(
this->minimumHeight(),
this->targetPackageWidget->height() + this->header->height() + this->footer->height()
+ this->menuBar()->height() + this->bottomPanel->getMinimumResize() + 30
));
}
}
}
void InsightWindow::resizeEvent(QResizeEvent* event) {
const auto windowSize = this->size();
@@ -407,7 +304,7 @@ void InsightWindow::selectVariant(const TargetVariant* variant) {
}
}
void InsightWindow::toggleUi(bool disable) {
void InsightWindow::setUiDisabled(bool disable) {
this->uiDisabled = disable;
if (this->refreshIoInspectionButton != nullptr) {
@@ -417,8 +314,8 @@ void InsightWindow::toggleUi(bool disable) {
}
void InsightWindow::activate() {
auto targetNameLabel = this->footer->findChild<QLabel*>("target-name");
auto targetIdLabel = this->footer->findChild<QLabel*>("target-id");
auto* targetNameLabel = this->footer->findChild<QLabel*>("target-name");
auto* targetIdLabel = this->footer->findChild<QLabel*>("target-id");
targetNameLabel->setText(QString::fromStdString(this->targetDescriptor.name));
targetIdLabel->setText("0x" + QString::fromStdString(this->targetDescriptor.id).remove("0x").toUpper());
this->variantMenu = this->footer->findChild<QMenu*>("target-variant-menu");
@@ -473,11 +370,11 @@ void InsightWindow::activate() {
);
if (InsightWindow::isVariantSupported(targetVariant)) {
auto supportedVariantPtr = &(this->supportedVariantsByName.insert(
auto* supportedVariantPtr = &(this->supportedVariantsByName.insert(
std::pair(QString::fromStdString(targetVariant.name).toLower(), targetVariant)
).first->second);
connect(
QObject::connect(
variantAction,
&QAction::triggered,
this,
@@ -538,7 +435,7 @@ void InsightWindow::activate() {
this->ioUnavailableWidget->show();
}
auto leftPanelLayout = this->leftPanel->layout();
auto* leftPanelLayout = this->leftPanel->layout();
this->targetRegistersSidePane = new TargetRegistersPaneWidget(
this->targetDescriptor,
this->insightWorker,
@@ -548,7 +445,7 @@ void InsightWindow::activate() {
this->targetRegistersButton->setChecked(false);
this->targetRegistersButton->setDisabled(false);
auto bottomPanelLayout = this->bottomPanel->layout();
auto* bottomPanelLayout = this->bottomPanel->layout();
if (this->targetDescriptor.memoryDescriptorsByType.contains(TargetMemoryType::RAM)) {
auto& ramDescriptor = this->targetDescriptor.memoryDescriptorsByType.at(TargetMemoryType::RAM);
this->ramInspectionPane = new TargetMemoryInspectionPane(
@@ -575,7 +472,7 @@ void InsightWindow::activate() {
this->eepromInspectionButton->setDisabled(false);
}
this->toggleUi(this->targetState != TargetState::STOPPED);
this->setUiDisabled(this->targetState != TargetState::STOPPED);
this->activated = true;
}
@@ -606,7 +503,7 @@ void InsightWindow::deactivate() {
this->variantMenu->clear();
this->variantMenu->setEnabled(false);
this->toggleUi(true);
this->setUiDisabled(true);
this->activated = false;
}
@@ -637,3 +534,175 @@ void InsightWindow::adjustPanels() {
)
);
}
void InsightWindow::onTargetControllerSuspended() {
if (this->activated) {
this->deactivate();
}
}
void InsightWindow::onTargetControllerResumed(const TargetDescriptor& targetDescriptor) {
if (!this->activated) {
this->targetDescriptor = targetDescriptor;
this->activate();
}
}
void InsightWindow::onTargetStateUpdate(TargetState newState) {
this->targetState = newState;
if (newState == TargetState::RUNNING) {
this->targetStatusLabel->setText("Running");
this->programCounterValueLabel->setText("-");
this->setUiDisabled(true);
} else if (newState == TargetState::STOPPED) {
this->targetStatusLabel->setText("Stopped");
this->setUiDisabled(false);
} else {
this->targetStatusLabel->setText("Unknown");
}
}
void InsightWindow::onTargetProgramCounterUpdate(quint32 programCounter) {
this->programCounterValueLabel->setText(
"0x" + QString::number(programCounter, 16).toUpper() + " (" + QString::number(programCounter) + ")"
);
}
void InsightWindow::refresh() {
if (this->targetState != TargetState::STOPPED || this->selectedVariant == nullptr) {
return;
}
this->setUiDisabled(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->setUiDisabled(false);
}
}
});
}
if (this->targetRegistersSidePane != nullptr && this->targetRegistersSidePane->activated) {
this->targetRegistersSidePane->refreshRegisterValues([this] {
this->refreshIoInspectionButton->stopSpin();
this->setUiDisabled(false);
});
}
}
void InsightWindow::openReportIssuesUrl() {
auto url = QUrl(QString::fromStdString(Paths::homeDomainName() + "/report-issue"));
/*
* The https://bloom.oscillate.io/report-issue URL just redirects to the Bloom GitHub issue page.
*
* We can use query parameters in the URL to pre-fill the body of the issue. We use this to include some
* target information.
*/
auto urlQuery = QUrlQuery();
auto issueBody = QString("Issue reported via Bloom Insight.\nTarget name: "
+ QString::fromStdString(this->targetDescriptor.name) + "\n"
+ "Target ID: " + QString::fromStdString(this->targetDescriptor.id) + "\n"
);
if (this->selectedVariant != nullptr) {
issueBody += "Target variant: " + QString::fromStdString(this->selectedVariant->name) + "\n";
}
issueBody += "\nPlease describe your issue below. Include as much detail as possible.";
urlQuery.addQueryItem("body", issueBody);
url.setQuery(urlQuery);
QDesktopServices::openUrl(url);
}
void InsightWindow::openGettingStartedUrl() {
QDesktopServices::openUrl(QUrl(QString::fromStdString(Paths::homeDomainName() + "/docs/getting-started")));
}
void InsightWindow::openAboutWindow() {
if (this->aboutWindowWidget == nullptr) {
this->aboutWindowWidget = new AboutWindow(this);
}
this->aboutWindowWidget->show();
}
void InsightWindow::toggleTargetRegistersPane() {
if (this->targetRegistersSidePane->activated) {
this->targetRegistersSidePane->deactivate();
this->targetRegistersButton->setChecked(false);
/*
* Given that the target registers side pane is currently the only pane in the left panel, the panel will be
* empty so no need to leave it visible.
*/
this->leftPanel->setVisible(false);
} else {
this->targetRegistersSidePane->activate();
this->targetRegistersButton->setChecked(true);
this->leftPanel->setVisible(true);
}
}
void InsightWindow::toggleRamInspectionPane() {
if (this->ramInspectionPane->activated) {
this->ramInspectionPane->deactivate();
this->bottomPanel->hide();
this->ramInspectionButton->setChecked(false);
} else {
if (this->eepromInspectionPane != nullptr && this->eepromInspectionPane->activated) {
this->toggleEepromInspectionPane();
}
this->ramInspectionPane->activate();
this->bottomPanel->show();
this->ramInspectionButton->setChecked(true);
if (this->targetPackageWidget != nullptr) {
this->setMinimumHeight(std::max(
this->minimumHeight(),
this->targetPackageWidget->height() + this->header->height() + this->footer->height()
+ this->menuBar()->height() + this->bottomPanel->getMinimumResize() + 30
));
}
}
}
void InsightWindow::toggleEepromInspectionPane() {
if (this->eepromInspectionPane->activated) {
this->eepromInspectionPane->deactivate();
this->bottomPanel->hide();
this->eepromInspectionButton->setChecked(false);
} else {
if (this->ramInspectionPane != nullptr && this->ramInspectionPane->activated) {
this->toggleRamInspectionPane();
}
this->eepromInspectionPane->activate();
this->bottomPanel->show();
this->eepromInspectionButton->setChecked(true);
if (this->targetPackageWidget != nullptr) {
this->setMinimumHeight(std::max(
this->minimumHeight(),
this->targetPackageWidget->height() + this->header->height() + this->footer->height()
+ this->menuBar()->height() + this->bottomPanel->getMinimumResize() + 30
));
}
}
}

View File

@@ -42,22 +42,6 @@ namespace Bloom
void init(Targets::TargetDescriptor targetDescriptor);
public slots:
void onTargetControllerSuspended();
void onTargetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
void onTargetStateUpdate(Targets::TargetState newState);
void onTargetProgramCounterUpdate(quint32 programCounter);
void refresh();
void openReportIssuesUrl();
void openGettingStartedUrl();
void openAboutWindow();
void toggleTargetRegistersPane();
void toggleRamInspectionPane();
void toggleEepromInspectionPane();
signals:
void refreshTargetPinStates(int variantId);
protected:
void resizeEvent(QResizeEvent* event) override;
void showEvent(QShowEvent* event) override;
@@ -112,10 +96,22 @@ namespace Bloom
void selectVariant(const Targets::TargetVariant* variant);
void toggleUi(bool disable);
void setUiDisabled(bool disable);
void activate();
void deactivate();
void adjustPanels();
void onTargetControllerSuspended();
void onTargetControllerResumed(const Bloom::Targets::TargetDescriptor& targetDescriptor);
void onTargetStateUpdate(Targets::TargetState newState);
void onTargetProgramCounterUpdate(quint32 programCounter);
void refresh();
void openReportIssuesUrl();
void openGettingStartedUrl();
void openAboutWindow();
void toggleTargetRegistersPane();
void toggleRamInspectionPane();
void toggleEepromInspectionPane();
};
}

View File

@@ -61,8 +61,8 @@ HexViewerWidget::HexViewerWidget(
this->hoveredAddressLabel = this->bottomBar->findChild<QLabel*>("byte-address-label");
auto byteItemGraphicsViewContainer = this->container->findChild<QWidget*>("graphics-view-container");
auto byteItemGraphicsViewLayout = byteItemGraphicsViewContainer->findChild<QVBoxLayout*>(
auto* byteItemGraphicsViewContainer = this->container->findChild<QWidget*>("graphics-view-container");
auto* byteItemGraphicsViewLayout = byteItemGraphicsViewContainer->findChild<QVBoxLayout*>(
"byte-item-container-layout"
);
this->byteItemGraphicsView = new ByteItemContainerGraphicsView(