Auto-hide overlays when clicking elsewhere

That's what auto-hide is all about
This commit is contained in:
Sergio Martins
2020-09-20 17:25:40 +01:00
parent b303af738c
commit eb1f4c5a14
2 changed files with 29 additions and 0 deletions

View File

@@ -541,7 +541,35 @@ bool DockRegistry::eventFilter(QObject *watched, QEvent *event)
m_nestedWindows.append(fw);
}
}
} else if (event->type() == QEvent::MouseButtonPress) {
if (!(Config::self().flags() & Config::Flag_internal_AutoHideSupport))
return false;
auto p = watched;
while (p) {
if (auto dw = qobject_cast<DockWidgetBase*>(p)) {
onDockWidgetPressed(dw);
return false;
}
p = p->parent();
}
}
return false;
}
void DockRegistry::onDockWidgetPressed(DockWidgetBase *dw)
{
// Here we implement "auto-hide". If there's a overlayed dock widget, we hide it if some other
// dock widget is clicked.
MainWindowBase *mainWindow = dw->mainWindow();
if (!mainWindow) // Only docked widgets are interesting
return;
DockWidgetBase *overlayedDockWidget = mainWindow->overlayedDockWidget();
if (overlayedDockWidget && dw != overlayedDockWidget) {
mainWindow->clearSideBarOverlay();
}
}

View File

@@ -176,6 +176,7 @@ protected:
bool eventFilter(QObject *watched, QEvent *event) override;
private:
explicit DockRegistry(QObject *parent = nullptr);
void onDockWidgetPressed(DockWidgetBase *dw);
void maybeDelete();
void onFocusObjectChanged(QObject *);
bool m_isProcessingAppQuitEvent = false;