From fa708143acf2b94c9126bca36d2dd0c0046b367b Mon Sep 17 00:00:00 2001 From: Vanellope Date: Sun, 24 Feb 2019 16:15:40 +0900 Subject: [PATCH] Overview does not disappear anymore when it is moved to the same dock as Graph (#1212) * Overview does not disappear anymore when it is moved to same dock as Graph, Gray out Overview menu when Graph is not active --- src/core/MainWindow.cpp | 17 ++++++++++++++--- src/core/MainWindow.h | 1 + src/widgets/DisassemblerGraphView.h | 1 - src/widgets/GraphWidget.cpp | 9 +++++++++ src/widgets/GraphWidget.h | 7 +++++++ 5 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/core/MainWindow.cpp b/src/core/MainWindow.cpp index dc510038..3df2b419 100644 --- a/src/core/MainWindow.cpp +++ b/src/core/MainWindow.cpp @@ -288,10 +288,16 @@ void MainWindow::toggleOverview(bool visibility, GraphWidget *targetGraph) return; } targetGraphDock = targetGraph; - ui->actionOverview->setChecked(visibility); - if (visibility) { + enableOverviewMenu(visibility); + if (visibility && !core->isGraphEmpty()) { connect(targetGraphDock->graphView, SIGNAL(refreshBlock()), this, SLOT(adjustOverview())); connect(targetGraphDock->graphView, SIGNAL(viewZoomed()), this, SLOT(adjustOverview())); + connect(targetGraphDock, &GraphWidget::graphClose, [this]() { + overviewDock->hide(); + }); + connect(targetGraphDock, &GraphWidget::graphEmpty, [this]() { + overviewDock->hide(); + }); connect(overviewDock->graphView, SIGNAL(mouseMoved()), this, SLOT(adjustGraph())); connect(overviewDock, &QDockWidget::dockLocationChanged, this, &MainWindow::adjustOverview); connect(overviewDock, SIGNAL(resized()), this, SLOT(adjustOverview())); @@ -302,7 +308,6 @@ void MainWindow::toggleOverview(bool visibility, GraphWidget *targetGraph) disconnect(overviewDock->graphView, SIGNAL(mouseMoved()), this, SLOT(adjustGraph())); disconnect(overviewDock, &QDockWidget::dockLocationChanged, this, &MainWindow::adjustOverview); disconnect(overviewDock, SIGNAL(resized()), this, SLOT(adjustOverview())); - overviewDock->hide(); } } @@ -773,6 +778,12 @@ void MainWindow::enableDebugWidgetsMenu(bool enable) ui->menuAddDebugWidgets->setEnabled(enable); } +void MainWindow::enableOverviewMenu(bool enable) +{ + ui->actionOverview->setEnabled(enable); + ui->actionOverview->setChecked(enable); +} + void MainWindow::resetToDefaultLayout() { hideAllDocks(); diff --git a/src/core/MainWindow.h b/src/core/MainWindow.h index 552fa27c..def3d81f 100644 --- a/src/core/MainWindow.h +++ b/src/core/MainWindow.h @@ -264,6 +264,7 @@ private: void showZenDocks(); void showDebugDocks(); void enableDebugWidgetsMenu(bool enable); + void enableOverviewMenu(bool enable); void toggleDockWidget(QDockWidget *dock_widget, bool show); diff --git a/src/widgets/DisassemblerGraphView.h b/src/widgets/DisassemblerGraphView.h index fc6e4112..e06fb1c8 100644 --- a/src/widgets/DisassemblerGraphView.h +++ b/src/widgets/DisassemblerGraphView.h @@ -125,7 +125,6 @@ public: void loadCurrentGraph(); QString windowTitle; - bool isGraphEmpty(); QTextEdit *header = nullptr; int getWidth() { return width; } diff --git a/src/widgets/GraphWidget.cpp b/src/widgets/GraphWidget.cpp index 53bcd6ab..6030b700 100644 --- a/src/widgets/GraphWidget.cpp +++ b/src/widgets/GraphWidget.cpp @@ -35,6 +35,9 @@ GraphWidget::GraphWidget(MainWindow *main, QAction *action) : connect(Core(), &CutterCore::raisePrioritizedMemoryWidget, this, [ = ](CutterCore::MemoryWidgetType type) { bool emptyGraph = (type == CutterCore::MemoryWidgetType::Graph && Core()->isGraphEmpty()); + if (emptyGraph) { + emit graphEmpty(); + } if (type == CutterCore::MemoryWidgetType::Graph && !emptyGraph) { this->raise(); this->graphView->setFocus(); @@ -43,3 +46,9 @@ GraphWidget::GraphWidget(MainWindow *main, QAction *action) : } GraphWidget::~GraphWidget() {} + +void GraphWidget::closeEvent(QCloseEvent *event) +{ + CutterDockWidget::closeEvent(event); + emit graphClose(); +} diff --git a/src/widgets/GraphWidget.h b/src/widgets/GraphWidget.h index 105fadfb..20bb8a3d 100644 --- a/src/widgets/GraphWidget.h +++ b/src/widgets/GraphWidget.h @@ -14,6 +14,13 @@ public: explicit GraphWidget(MainWindow *main, QAction *action = nullptr); ~GraphWidget(); DisassemblerGraphView *graphView; + +private: + void closeEvent(QCloseEvent *event) override; + +signals: + void graphClose(); + void graphEmpty(); }; #endif // GRAPHWIDGET_H