From 9aa958e8b028d9c7611c107e2ab599bf2b60eaed Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Sat, 23 May 2020 11:17:31 +0200 Subject: [PATCH] Made all focus related code optional - only if FocusStyling flag is enabled --- demo/MainWindow.cpp | 2 ++ src/DockManager.cpp | 1 + src/DockWidgetTab.cpp | 33 ++++++++++++++++++++------------- src/FloatingDockContainer.cpp | 2 ++ 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 35d814d..fa87277 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -571,6 +571,8 @@ CMainWindow::CMainWindow(QWidget *parent) : // dock widget. // CDockManager::setConfigFlag(CDockManager::HideSingleCentralWidgetTitleBar, true); + CDockManager::setConfigFlag(CDockManager::FocusStyling, true); + // Now create the dock manager and its content d->DockManager = new CDockManager(this); diff --git a/src/DockManager.cpp b/src/DockManager.cpp index 8e56373..c0efc46 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -984,6 +984,7 @@ CIconProvider& CDockManager::iconProvider() //=========================================================================== void CDockManager::onFocusChanged(QWidget* focusedOld, QWidget* focusedNow) { + std::cout << "CDockManager::onFocusChanged" << std::endl; Q_UNUSED(focusedOld) if (!focusedNow) { diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index 8d892c4..378cc59 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -285,7 +285,10 @@ CDockWidgetTab::CDockWidgetTab(CDockWidget* DockWidget, QWidget *parent) : setAttribute(Qt::WA_NoMousePropagation, true); d->DockWidget = DockWidget; d->createLayout(); - setFocusPolicy(Qt::ClickFocus); + if (CDockManager::configFlags().testFlag(CDockManager::FocusStyling)) + { + setFocusPolicy(Qt::ClickFocus); + } } //============================================================================ @@ -464,21 +467,25 @@ void CDockWidgetTab::setActiveTab(bool active) bool TabHasCloseButton = (ActiveTabHasCloseButton && active) | AllTabsHaveCloseButton; d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton); - bool UpdateFocusStyle = false; - if (active && !hasFocus()) + if (CDockManager::configFlags().testFlag(CDockManager::FocusStyling)) { - setFocus(Qt::OtherFocusReason); - UpdateFocusStyle = true; + bool UpdateFocusStyle = false; + if (active && !hasFocus()) + { + setFocus(Qt::OtherFocusReason); + UpdateFocusStyle = true; + } + + if (d->IsActiveTab == active) + { + if (UpdateFocusStyle) + { + updateStyle(); + } + return; + } } - if (d->IsActiveTab == active) - { - if (UpdateFocusStyle) - { - updateStyle(); - } - return; - } d->IsActiveTab = active; updateStyle(); update(); diff --git a/src/FloatingDockContainer.cpp b/src/FloatingDockContainer.cpp index fa2510b..3c458a2 100644 --- a/src/FloatingDockContainer.cpp +++ b/src/FloatingDockContainer.cpp @@ -57,6 +57,7 @@ namespace ads { #ifdef Q_OS_WIN +#if 0 /** * Just for debuging to convert windows message identifiers to strings */ @@ -350,6 +351,7 @@ static const char* windowsMessageString(int MessageId) return "unknown WM_ message"; } #endif +#endif static unsigned int zOrderCounter = 0;