From 5652c8440ec61b7932f4f8e158d752aa657b5e3d Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Sat, 23 May 2020 11:10:03 +0200 Subject: [PATCH] Added new CDockManger config flag FocusStyling --- src/DockManager.cpp | 14 +++++++++----- src/DockManager.h | 17 ++++++++++++++++- src/ads_globals.h | 1 + 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/DockManager.cpp b/src/DockManager.cpp index 5fe0df7..8e56373 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -540,8 +540,12 @@ CDockManager::CDockManager(QWidget *parent) : d->ContainerOverlay = new CDockOverlay(this, CDockOverlay::ModeContainerOverlay); d->Containers.append(this); d->loadStylesheet(); - connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), - this, SLOT(onFocusChanged(QWidget*, QWidget*))); + + if (CDockManager::configFlags().testFlag(CDockManager::FocusStyling)) + { + connect(QApplication::instance(), SIGNAL(focusChanged(QWidget*, QWidget*)), + this, SLOT(onFocusChanged(QWidget*, QWidget*))); + } } //============================================================================ @@ -1030,7 +1034,7 @@ void CDockManager::onFocusedDockAreaViewToggled(bool Open) return; } - OpenedDockAreas[0]->currentDockWidget()->tabWidget()->setFocus(Qt::OtherFocusReason); + CDockManager::setWidgetFocus(OpenedDockAreas[0]->currentDockWidget()->tabWidget()); } @@ -1040,7 +1044,7 @@ void CDockManager::emitWidgetDroppedSignals(QWidget* DroppedWidget) CDockWidget* DockWidget = qobject_cast(DroppedWidget); if (DockWidget) { - DockWidget->tabWidget()->setFocus(Qt::OtherFocusReason); + CDockManager::setWidgetFocus(DockWidget->tabWidget()); emit dockWidgetDropped(DockWidget); return; } @@ -1052,7 +1056,7 @@ void CDockManager::emitWidgetDroppedSignals(QWidget* DroppedWidget) } DockWidget = DockArea->currentDockWidget(); - DockWidget->tabWidget()->setFocus(Qt::OtherFocusReason); + CDockManager::setWidgetFocus(DockWidget->tabWidget()); } diff --git a/src/DockManager.h b/src/DockManager.h index a15753b..7702713 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -171,7 +171,7 @@ public: FloatingContainerHasWidgetIcon = 0x80000, //!< If set, the Floating Widget icon reflects the icon of the current dock widget otherwise it displays application icon HideSingleCentralWidgetTitleBar = 0x100000, //!< If there is only one single visible dock widget in the main dock container (the dock manager) and if this flag is set, then the titlebar of this dock widget will be hidden //!< this only makes sense for non draggable and non floatable widgets and enables the creation of some kind of "central" widget - + FocusStyling = 0x200000, //!< enables styling of focused dock widget tabs or floating widget titlebar DefaultDockAreaButtons = DockAreaHasCloseButton | DockAreaHasUndockButton @@ -415,6 +415,21 @@ public: */ static int startDragDistance(); + /** + * Helper function to set focus depending on the configuration of the + * FocusStyling flag + */ + template + static void setWidgetFocus(QWidgetPtr widget) + { + if (!CDockManager::configFlags().testFlag(CDockManager::FocusStyling)) + { + return; + } + + widget->setFocus(Qt::OtherFocusReason); + } + public slots: /** * Opens the perspective with the given name. diff --git a/src/ads_globals.h b/src/ads_globals.h index e7dee67..f538bbe 100644 --- a/src/ads_globals.h +++ b/src/ads_globals.h @@ -258,6 +258,7 @@ void setButtonIcon(QAbstractButton* Button, QStyle::StandardPixmap StandarPixmap */ void repolishStyle(QWidget* w); + } // namespace internal } // namespace ads