Reset last seen memory widget during layout switching. (#2303)

This commit is contained in:
karliss 2020-07-21 12:40:53 +03:00 committed by GitHub
parent c923576b7e
commit f92c42d09e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 26 deletions

View File

@ -612,16 +612,9 @@ void MainWindow::finalizeOpen()
Config()->adjustColorThemeDarkness();
setViewLayout(getViewLayout(LAYOUT_DEFAULT));
// Set focus to disasm or graph widget
// Use for loop to cover cases when main disasm/graph
// (MainWindow::disassemblyDock and MainWindow::graphDock)
// widgets are invisible but extra ones are visible
// Graph with function in it has focus priority over DisasmWidget
// if there are both graph and disasm.
// Otherwise Disasm has focus priority over Graph
// Graph with function in it has focus priority over DisasmWidget.
// If there are no graph/disasm widgets focus on MainWindow
setFocus();
@ -629,20 +622,17 @@ void MainWindow::finalizeOpen()
for (auto dockWidget : dockWidgets) {
const QString className = dockWidget->metaObject()->className();
auto graphWidget = qobject_cast<GraphWidget *>(dockWidget);
if (graphWidget && !dockWidget->visibleRegion().isNull()) {
if (graphWidget && dockWidget->isVisibleToUser()) {
graphContainsFunc = !graphWidget->getGraphView()->getBlocks().empty();
if (graphContainsFunc) {
dockWidget->widget()->setFocus();
dockWidget->raiseMemoryWidget();
break;
}
}
auto disasmWidget = qobject_cast<DisassemblyWidget *>(dockWidget);
if (disasmWidget && !dockWidget->visibleRegion().isNull()) {
if (!graphContainsFunc) {
disasmWidget->setFocus();
} else {
break;
}
if (disasmWidget && dockWidget->isVisibleToUser()) {
disasmWidget->raiseMemoryWidget();
// continue looping in case there is a graph wiget
}
}
}
@ -1378,6 +1368,8 @@ void MainWindow::setViewLayout(const CutterLayout &layout)
for (auto dock : dockWidgets) {
dock->ignoreVisibilityStatus(false);
}
lastSyncMemoryWidget = nullptr;
lastMemoryWidget = nullptr;
}
void MainWindow::loadLayouts(QSettings &settings)

View File

@ -20,13 +20,6 @@ AddressableDockWidget::AddressableDockWidget(MainWindow *parent)
setContextMenuPolicy(Qt::ContextMenuPolicy::DefaultContextMenu);
}
void AddressableDockWidget::raiseMemoryWidget()
{
show();
raise();
widgetToFocusOnRaise()->setFocus(Qt::FocusReason::TabFocusReason);
}
QVariantMap AddressableDockWidget::serializeViewProprties()
{
auto result = CutterDockWidget::serializeViewProprties();

View File

@ -17,8 +17,6 @@ public:
CutterSeekable *getSeekable() const;
void raiseMemoryWidget();
QVariantMap serializeViewProprties() override;
void deserializeViewProperties(const QVariantMap &properties) override;
public slots:

View File

@ -49,6 +49,13 @@ void CutterDockWidget::ignoreVisibilityStatus(bool ignore)
updateIsVisibleToUser();
}
void CutterDockWidget::raiseMemoryWidget()
{
show();
raise();
widgetToFocusOnRaise()->setFocus(Qt::FocusReason::TabFocusReason);
}
void CutterDockWidget::toggleDockWidget(bool show)
{
if (!show) {

View File

@ -92,6 +92,8 @@ public:
* @param ignored - set to true for enabling ignoring mode
*/
void ignoreVisibilityStatus(bool ignored);
void raiseMemoryWidget();
signals:
void becameVisibleToUser();
void closed();