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
This commit is contained in:
Vanellope 2019-02-24 16:15:40 +09:00 committed by Itay Cohen
parent 6a77db67ff
commit fa708143ac
5 changed files with 31 additions and 4 deletions

View File

@ -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();

View File

@ -264,6 +264,7 @@ private:
void showZenDocks();
void showDebugDocks();
void enableDebugWidgetsMenu(bool enable);
void enableOverviewMenu(bool enable);
void toggleDockWidget(QDockWidget *dock_widget, bool show);

View File

@ -125,7 +125,6 @@ public:
void loadCurrentGraph();
QString windowTitle;
bool isGraphEmpty();
QTextEdit *header = nullptr;
int getWidth() { return width; }

View File

@ -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();
}

View File

@ -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