Removed Insight window activation/deactivation (it was no longer needed since we removed TC suspension)
This commit is contained in:
@@ -32,14 +32,7 @@ namespace Bloom
|
||||
, environmentConfig(environmentConfig)
|
||||
, insightConfig(insightConfig)
|
||||
, insightProjectSettings(insightProjectSettings)
|
||||
{}
|
||||
|
||||
void Insight::showMainWindow() {
|
||||
this->mainWindow->show();
|
||||
this->mainWindow->activateWindow();
|
||||
}
|
||||
|
||||
void Insight::activate() {
|
||||
{
|
||||
Logger::info("Starting Insight");
|
||||
|
||||
this->eventListener.registerCallbackForEventType<Events::TargetExecutionStopped>(
|
||||
@@ -73,16 +66,6 @@ namespace Bloom
|
||||
QApplication::setQuitOnLastWindowClosed(false);
|
||||
QApplication::setStyle(new BloomProxyStyle());
|
||||
|
||||
auto globalStylesheet = QFile(
|
||||
QString::fromStdString(
|
||||
Services::PathService::compiledResourcesPath() + "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/Global.qss"
|
||||
)
|
||||
);
|
||||
|
||||
if (!globalStylesheet.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open global stylesheet file");
|
||||
}
|
||||
|
||||
qRegisterMetaType<Bloom::Targets::TargetDescriptor>();
|
||||
qRegisterMetaType<Bloom::Targets::TargetPinDescriptor>();
|
||||
qRegisterMetaType<Bloom::Targets::TargetPinState>();
|
||||
@@ -133,17 +116,17 @@ namespace Bloom
|
||||
QString::fromStdString(Services::PathService::resourcesDirPath() + "/fonts/Ubuntu/Ubuntu-Th.ttf")
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
this->mainWindow,
|
||||
&InsightWindow::activatedSignal,
|
||||
this,
|
||||
&Insight::onInsightWindowActivated
|
||||
auto globalStylesheet = QFile(
|
||||
QString::fromStdString(
|
||||
Services::PathService::compiledResourcesPath() + "/src/Insight/UserInterfaces/InsightWindow/Stylesheets/Global.qss"
|
||||
)
|
||||
);
|
||||
|
||||
this->mainWindow->setStyleSheet(globalStylesheet.readAll());
|
||||
if (!globalStylesheet.open(QFile::ReadOnly)) {
|
||||
throw Exception("Failed to open global stylesheet file");
|
||||
}
|
||||
|
||||
this->mainWindow->setInsightConfig(this->insightConfig);
|
||||
this->mainWindow->setEnvironmentConfig(this->environmentConfig);
|
||||
this->globalStylesheet = globalStylesheet.readAll();
|
||||
|
||||
// Construct and start worker threads
|
||||
for (std::uint8_t i = 0; i < Insight::INSIGHT_WORKER_COUNT; ++i) {
|
||||
@@ -162,14 +145,35 @@ namespace Bloom
|
||||
workerThread->start();
|
||||
}
|
||||
|
||||
this->mainWindow->init(this->targetControllerService.getTargetDescriptor());
|
||||
this->activateMainWindow();
|
||||
}
|
||||
|
||||
void Insight::activateMainWindow() {
|
||||
if (this->mainWindow == nullptr) {
|
||||
this->mainWindow = new InsightWindow(
|
||||
this->environmentConfig,
|
||||
this->insightConfig,
|
||||
this->insightProjectSettings,
|
||||
this->targetDescriptor
|
||||
);
|
||||
|
||||
this->mainWindow->setStyleSheet(this->globalStylesheet);
|
||||
|
||||
QObject::connect(this->mainWindow, &QObject::destroyed, this, &Insight::onInsightWindowDestroyed);
|
||||
|
||||
this->refreshTargetState();
|
||||
}
|
||||
|
||||
this->mainWindow->show();
|
||||
this->mainWindow->activateWindow();
|
||||
}
|
||||
|
||||
void Insight::shutdown() {
|
||||
Logger::info("Shutting down Insight");
|
||||
|
||||
this->mainWindow->close();
|
||||
if (this->mainWindow != nullptr) {
|
||||
this->mainWindow->close();
|
||||
}
|
||||
|
||||
for (auto& [workerId, workerPair] : this->insightWorkersById) {
|
||||
auto* workerThread = workerPair.second;
|
||||
@@ -183,7 +187,7 @@ namespace Bloom
|
||||
}
|
||||
}
|
||||
|
||||
void Insight::onInsightWindowActivated() {
|
||||
void Insight::refreshTargetState() {
|
||||
const auto getTargetStateTask = QSharedPointer<GetTargetState>(new GetTargetState(), &QObject::deleteLater);
|
||||
QObject::connect(
|
||||
getTargetStateTask.get(),
|
||||
@@ -198,6 +202,10 @@ namespace Bloom
|
||||
InsightWorker::queueTask(getTargetStateTask);
|
||||
}
|
||||
|
||||
void Insight::onInsightWindowDestroyed() {
|
||||
this->mainWindow = nullptr;
|
||||
}
|
||||
|
||||
void Insight::onTargetStoppedEvent(const Events::TargetExecutionStopped& event) {
|
||||
if (this->lastTargetState == TargetState::STOPPED) {
|
||||
return;
|
||||
|
||||
@@ -57,15 +57,10 @@ namespace Bloom
|
||||
QApplication* parent
|
||||
);
|
||||
|
||||
/**
|
||||
* Entry point for Insight.
|
||||
*/
|
||||
void activate();
|
||||
|
||||
/**
|
||||
* Opens main window and obtains focus.
|
||||
*/
|
||||
void showMainWindow();
|
||||
void activateMainWindow();
|
||||
|
||||
/**
|
||||
* Shuts down Insight. Called when the user closes the Insight window or a ShutdownApplication event is fired.
|
||||
@@ -84,13 +79,12 @@ namespace Bloom
|
||||
EventListener& eventListener;
|
||||
Services::TargetControllerService targetControllerService = Services::TargetControllerService();
|
||||
|
||||
Targets::TargetDescriptor targetDescriptor = this->targetControllerService.getTargetDescriptor();
|
||||
|
||||
QString globalStylesheet;
|
||||
|
||||
std::map<decltype(InsightWorker::id), std::pair<InsightWorker*, QThread*>> insightWorkersById;
|
||||
InsightWindow* mainWindow = new InsightWindow(
|
||||
this->environmentConfig,
|
||||
this->insightConfig,
|
||||
this->insightProjectSettings,
|
||||
this->targetControllerService.getTargetDescriptor()
|
||||
);
|
||||
InsightWindow* mainWindow = nullptr;
|
||||
|
||||
Targets::TargetState lastTargetState = Targets::TargetState::UNKNOWN;
|
||||
bool targetStepping = false;
|
||||
@@ -98,7 +92,8 @@ namespace Bloom
|
||||
|
||||
InsightSignals* insightSignals = InsightSignals::instance();
|
||||
|
||||
void onInsightWindowActivated();
|
||||
void refreshTargetState();
|
||||
void onInsightWindowDestroyed();
|
||||
void onTargetStoppedEvent(const Events::TargetExecutionStopped& event);
|
||||
void onTargetResumedEvent(const Events::TargetExecutionResumed& event);
|
||||
void onTargetResetEvent(const Events::TargetReset& event);
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace Bloom
|
||||
, targetDescriptor(targetDescriptor)
|
||||
{
|
||||
this->setObjectName("main-window");
|
||||
this->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
this->setWindowTitle("Bloom Insight");
|
||||
|
||||
auto windowSize = QSize(1000, 500);
|
||||
@@ -169,6 +170,66 @@ namespace Bloom
|
||||
this->windowContainer->setFixedSize(windowSize);
|
||||
this->layoutContainer->setFixedSize(windowSize);
|
||||
|
||||
// InsightSignal connections
|
||||
auto* insightSignals = InsightSignals::instance();
|
||||
|
||||
QObject::connect(
|
||||
insightSignals,
|
||||
&InsightSignals::targetStateUpdated,
|
||||
this,
|
||||
&InsightWindow::onTargetStateUpdate
|
||||
);
|
||||
QObject::connect(
|
||||
insightSignals,
|
||||
&InsightSignals::targetReset,
|
||||
this,
|
||||
[this] {
|
||||
this->refreshProgramCounter();
|
||||
}
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
insightSignals,
|
||||
&InsightSignals::programmingModeEnabled,
|
||||
this,
|
||||
&InsightWindow::onProgrammingModeEnabled
|
||||
);
|
||||
QObject::connect(
|
||||
insightSignals,
|
||||
&InsightSignals::programmingModeDisabled,
|
||||
this,
|
||||
&InsightWindow::onProgrammingModeDisabled
|
||||
);
|
||||
|
||||
this->targetNameLabel->setText(QString::fromStdString(this->targetDescriptor.name));
|
||||
this->targetIdLabel->setText("0x" + QString::fromStdString(this->targetDescriptor.id).remove("0x").toUpper());
|
||||
|
||||
this->ioUnavailableWidget->hide();
|
||||
|
||||
this->populateVariantMenu();
|
||||
this->variantMenu->setEnabled(true);
|
||||
|
||||
Logger::debug("Number of target variants supported by Insight: "
|
||||
+ std::to_string(supportedVariantsByName.size()));
|
||||
|
||||
if (this->supportedVariantsByName.empty()) {
|
||||
if (this->targetDescriptor.variants.empty()) {
|
||||
this->variantMenu->parentWidget()->hide();
|
||||
}
|
||||
|
||||
this->ioUnavailableWidget->setText(
|
||||
"GPIO inspection is not available for this target. "
|
||||
"Please report this to Bloom developers by clicking Help -> Report An Issue"
|
||||
);
|
||||
this->ioUnavailableWidget->show();
|
||||
|
||||
} else {
|
||||
this->selectDefaultVariant();
|
||||
}
|
||||
|
||||
this->createPanes();
|
||||
this->setUiDisabled(true);
|
||||
|
||||
// Main menu connections
|
||||
QObject::connect(
|
||||
quitAction,
|
||||
@@ -254,42 +315,6 @@ namespace Bloom
|
||||
this,
|
||||
&InsightWindow::toggleFlashInspectionPane
|
||||
);
|
||||
|
||||
// InsightSignal connections
|
||||
auto* insightSignals = InsightSignals::instance();
|
||||
|
||||
QObject::connect(
|
||||
insightSignals,
|
||||
&InsightSignals::targetStateUpdated,
|
||||
this,
|
||||
&InsightWindow::onTargetStateUpdate
|
||||
);
|
||||
QObject::connect(
|
||||
insightSignals,
|
||||
&InsightSignals::targetReset,
|
||||
this,
|
||||
[this] {
|
||||
this->refreshProgramCounter();
|
||||
}
|
||||
);
|
||||
|
||||
QObject::connect(
|
||||
insightSignals,
|
||||
&InsightSignals::programmingModeEnabled,
|
||||
this,
|
||||
&InsightWindow::onProgrammingModeEnabled
|
||||
);
|
||||
QObject::connect(
|
||||
insightSignals,
|
||||
&InsightSignals::programmingModeDisabled,
|
||||
this,
|
||||
&InsightWindow::onProgrammingModeDisabled
|
||||
);
|
||||
}
|
||||
|
||||
void InsightWindow::init(TargetDescriptor targetDescriptor) {
|
||||
this->targetDescriptor = std::move(targetDescriptor);
|
||||
this->activate();
|
||||
}
|
||||
|
||||
void InsightWindow::resizeEvent(QResizeEvent* event) {
|
||||
@@ -304,19 +329,11 @@ namespace Bloom
|
||||
}
|
||||
|
||||
void InsightWindow::showEvent(QShowEvent* event) {
|
||||
if (!this->activated) {
|
||||
this->activate();
|
||||
}
|
||||
|
||||
this->adjustPanels();
|
||||
this->adjustMinimumSize();
|
||||
}
|
||||
|
||||
void InsightWindow::closeEvent(QCloseEvent* event) {
|
||||
if (this->activated) {
|
||||
this->deactivate();
|
||||
}
|
||||
|
||||
return QMainWindow::closeEvent(event);
|
||||
}
|
||||
|
||||
@@ -380,40 +397,6 @@ namespace Bloom
|
||||
}
|
||||
}
|
||||
|
||||
void InsightWindow::activate() {
|
||||
this->targetNameLabel->setText(QString::fromStdString(this->targetDescriptor.name));
|
||||
this->targetIdLabel->setText("0x" + QString::fromStdString(this->targetDescriptor.id).remove("0x").toUpper());
|
||||
|
||||
this->ioUnavailableWidget->hide();
|
||||
|
||||
this->populateVariantMenu();
|
||||
this->variantMenu->setEnabled(true);
|
||||
|
||||
Logger::debug("Number of target variants supported by Insight: "
|
||||
+ std::to_string(supportedVariantsByName.size()));
|
||||
|
||||
if (this->supportedVariantsByName.empty()) {
|
||||
if (this->targetDescriptor.variants.empty()) {
|
||||
this->variantMenu->parentWidget()->hide();
|
||||
}
|
||||
|
||||
this->ioUnavailableWidget->setText(
|
||||
"GPIO inspection is not available for this target. "
|
||||
"Please report this to Bloom developers by clicking Help -> Report An Issue"
|
||||
);
|
||||
this->ioUnavailableWidget->show();
|
||||
|
||||
} else {
|
||||
this->selectDefaultVariant();
|
||||
}
|
||||
|
||||
this->createPanes();
|
||||
|
||||
this->setUiDisabled(this->targetState != TargetState::STOPPED);
|
||||
this->activated = true;
|
||||
emit this->activatedSignal();
|
||||
}
|
||||
|
||||
void InsightWindow::populateVariantMenu() {
|
||||
/*
|
||||
* We don't want to present the user with duplicate target variants.
|
||||
@@ -736,92 +719,6 @@ namespace Bloom
|
||||
}
|
||||
}
|
||||
|
||||
void InsightWindow::destroyPanes() {
|
||||
if (this->targetRegistersSidePane != nullptr) {
|
||||
this->targetRegistersSidePane->deactivate();
|
||||
this->targetRegistersSidePane->deleteLater();
|
||||
this->targetRegistersSidePane = nullptr;
|
||||
|
||||
this->leftPanel->setVisible(false);
|
||||
this->targetRegistersButton->setChecked(false);
|
||||
this->targetRegistersButton->setDisabled(true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Before we destroy the memory inspection pane widgets, we take a copy of their current settings (memory
|
||||
* regions, hex viewer settings, etc), in order to persist them through debug sessions.
|
||||
*/
|
||||
if (this->ramInspectionPane != nullptr) {
|
||||
this->ramInspectionPane->deactivate();
|
||||
this->ramInspectionPane->deleteLater();
|
||||
this->ramInspectionPane = nullptr;
|
||||
|
||||
this->bottomPanel->setVisible(false);
|
||||
this->ramInspectionButton->setChecked(false);
|
||||
this->ramInspectionButton->setDisabled(true);
|
||||
}
|
||||
|
||||
if (this->eepromInspectionPane != nullptr) {
|
||||
this->eepromInspectionPane->deactivate();
|
||||
this->eepromInspectionPane->deleteLater();
|
||||
this->eepromInspectionPane = nullptr;
|
||||
|
||||
this->bottomPanel->setVisible(false);
|
||||
this->eepromInspectionButton->setChecked(false);
|
||||
this->eepromInspectionButton->setDisabled(true);
|
||||
}
|
||||
|
||||
if (this->flashInspectionPane != nullptr) {
|
||||
this->flashInspectionPane->deactivate();
|
||||
this->flashInspectionPane->deleteLater();
|
||||
this->flashInspectionPane = nullptr;
|
||||
|
||||
this->bottomPanel->setVisible(false);
|
||||
this->flashInspectionButton->setChecked(false);
|
||||
this->flashInspectionButton->setDisabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
void InsightWindow::deactivate() {
|
||||
const auto insightProjectSettings = this->insightProjectSettings;
|
||||
const auto childWidgets = this->findChildren<QWidget*>();
|
||||
|
||||
for (auto* widget : childWidgets) {
|
||||
if (widget->windowFlags() & Qt::Window) {
|
||||
widget->close();
|
||||
}
|
||||
}
|
||||
|
||||
if (this->selectedVariant != nullptr) {
|
||||
this->previouslySelectedVariant = *(this->selectedVariant);
|
||||
this->selectedVariant = nullptr;
|
||||
}
|
||||
|
||||
if (this->targetPackageWidget != nullptr) {
|
||||
this->targetPackageWidget->hide();
|
||||
this->targetPackageWidget->deleteLater();
|
||||
this->targetPackageWidget = nullptr;
|
||||
this->ioContainerWidget->setPackageWidget(this->targetPackageWidget);
|
||||
}
|
||||
|
||||
this->destroyPanes();
|
||||
|
||||
this->ioUnavailableWidget->setText("Insight deactivated");
|
||||
this->ioUnavailableWidget->show();
|
||||
|
||||
this->targetStatusLabel->setText("Unknown");
|
||||
this->programCounterValueLabel->setText("-");
|
||||
|
||||
this->variantMenu->clear();
|
||||
this->variantMenu->setEnabled(false);
|
||||
|
||||
this->supportedVariantsByName.clear();
|
||||
|
||||
this->setUiDisabled(true);
|
||||
this->activated = false;
|
||||
this->insightProjectSettings = insightProjectSettings;
|
||||
}
|
||||
|
||||
void InsightWindow::adjustPanels() {
|
||||
const auto targetPackageWidgetSize = (this->targetPackageWidget != nullptr)
|
||||
? this->targetPackageWidget->size() : QSize();
|
||||
@@ -909,6 +806,7 @@ namespace Bloom
|
||||
|
||||
} else {
|
||||
this->targetStatusLabel->setText("Unknown");
|
||||
this->programCounterValueLabel->setText("-");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,20 +39,6 @@ namespace Bloom
|
||||
const Targets::TargetDescriptor& targetDescriptor
|
||||
);
|
||||
|
||||
void setEnvironmentConfig(const EnvironmentConfig& environmentConfig) {
|
||||
this->environmentConfig = environmentConfig;
|
||||
this->targetConfig = environmentConfig.targetConfig;
|
||||
}
|
||||
|
||||
void setInsightConfig(const InsightConfig& insightConfig) {
|
||||
this->insightConfig = insightConfig;
|
||||
}
|
||||
|
||||
void init(Targets::TargetDescriptor targetDescriptor);
|
||||
|
||||
signals:
|
||||
void activatedSignal();
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent* event) override;
|
||||
void showEvent(QShowEvent* event) override;
|
||||
@@ -65,9 +51,7 @@ namespace Bloom
|
||||
EnvironmentConfig environmentConfig;
|
||||
TargetConfig targetConfig;
|
||||
|
||||
bool activated = false;
|
||||
|
||||
Targets::TargetDescriptor targetDescriptor;
|
||||
const Targets::TargetDescriptor& targetDescriptor;
|
||||
Targets::TargetState targetState = Targets::TargetState::UNKNOWN;
|
||||
|
||||
QWidget* windowContainer = nullptr;
|
||||
@@ -118,13 +102,10 @@ namespace Bloom
|
||||
|
||||
void setUiDisabled(bool disable);
|
||||
|
||||
void activate();
|
||||
void populateVariantMenu();
|
||||
void selectDefaultVariant();
|
||||
void selectVariant(const Targets::TargetVariant* variant);
|
||||
void createPanes();
|
||||
void destroyPanes();
|
||||
void deactivate();
|
||||
|
||||
void adjustPanels();
|
||||
void adjustMinimumSize();
|
||||
|
||||
Reference in New Issue
Block a user