diff --git a/src/DockManager.cpp b/src/DockManager.cpp index 0064ba1..0ddb1cc 100644 --- a/src/DockManager.cpp +++ b/src/DockManager.cpp @@ -504,6 +504,7 @@ void DockManagerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget) updateDockWidgetFocusStyle(FocusedDockWidget, false); } + CDockWidget* old = FocusedDockWidget; if (DockWidget != FocusedDockWidget) { std::cout << "!!!!!!!!!!!! focusedDockWidgetChanged " << (FocusedDockWidget ? FocusedDockWidget->objectName().toStdString() : "-") @@ -554,6 +555,11 @@ void DockManagerPrivate::updateDockWidgetFocus(CDockWidget* DockWidget) updateFloatingWidgetFocusStyle(FloatingWidget, true); } #endif + + if (old != DockWidget) + { + emit _this->focusedDockWidgetChanged(old, DockWidget); + } } @@ -720,6 +726,10 @@ bool CDockManager::restoreState(const QByteArray &state, int version) show(); } + if (d->FocusedDockWidget) + { + updateDockWidgetFocusStyle(d->FocusedDockWidget, false); + } return Result; } @@ -1019,6 +1029,10 @@ CIconProvider& CDockManager::iconProvider() //=========================================================================== void CDockManager::onApplicationFocusChanged(QWidget* focusedOld, QWidget* focusedNow) { + if (isRestoringState()) + { + return; + } std::cout << "CDockManager::onFocusChanged" << std::endl; Q_UNUSED(focusedOld) if (!focusedNow) @@ -1060,6 +1074,11 @@ void CDockManager::onApplicationFocusChanged(QWidget* focusedOld, QWidget* focus //=========================================================================== void CDockManager::onFocusedDockAreaViewToggled(bool Open) { + if (isRestoringState()) + { + return; + } + CDockAreaWidget* DockArea = qobject_cast(sender()); if (!DockArea || Open) { @@ -1079,6 +1098,10 @@ void CDockManager::onFocusedDockAreaViewToggled(bool Open) //=========================================================================== void CDockManager::notifyWidgetOrAreaRelocation(QWidget* DroppedWidget) { + if (isRestoringState()) + { + return; + } std::cout << "\n\nCDockManager::notifyWidgetDrop" << std::endl; CDockWidget* DockWidget = qobject_cast(DroppedWidget); if (DockWidget) @@ -1104,7 +1127,7 @@ void CDockManager::notifyWidgetOrAreaRelocation(QWidget* DroppedWidget) void CDockManager::notifyFloatingWidgetDrop(CFloatingDockContainer* FloatingWidget) { std::cout << "\n\nCDockManager::notifyFloatingWidgetDrop" << std::endl; - if (!FloatingWidget) + if (!FloatingWidget || isRestoringState()) { return; } diff --git a/src/DockManager.h b/src/DockManager.h index 8242df4..05f4c82 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -517,6 +517,13 @@ signals: * docking system but it is not deleted yet. */ void dockWidgetRemoved(CDockWidget* DockWidget); + + /** + * This signal is emitted if the focused dock widget changed. + * Both old and now can be nullptr. + * The focused dock widget is the one that is highlighted in the GUI + */ + void focusedDockWidgetChanged(CDockWidget* old, CDockWidget* now); }; // class DockManager } // namespace ads //----------------------------------------------------------------------------- diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index bb8a381..f4bbde5 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -466,7 +466,31 @@ void CDockWidgetTab::setActiveTab(bool active) bool AllTabsHaveCloseButton = d->testConfigFlag(CDockManager::AllTabsHaveCloseButton); bool TabHasCloseButton = (ActiveTabHasCloseButton && active) | AllTabsHaveCloseButton; d->CloseButton->setVisible(DockWidgetClosable && TabHasCloseButton); - if (d->IsActiveTab == active) + + /*if (d->IsActiveTab == active) + { + return; + }*/ + + if (CDockManager::configFlags().testFlag(CDockManager::FocusStyling) && !d->DockWidget->dockManager()->isRestoringState()) + { + bool UpdateFocusStyle = false; + if (active && !hasFocus()) + { + setFocus(Qt::OtherFocusReason); + UpdateFocusStyle = true; + } + + if (d->IsActiveTab == active) + { + if (UpdateFocusStyle) + { + updateStyle(); + } + return; + } + } + else if (d->IsActiveTab == active) { return; }