From 0e566cb8a392fe805b32bcca288ea73ff395d169 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Tue, 10 May 2022 13:41:19 +0200 Subject: [PATCH] Fixed #420 - Floating docks title doesn't update added tests for DockWidget->setWindowTitle() in demo application --- demo/MainWindow.cpp | 2 ++ src/DockContainerWidget.h | 1 + src/DockWidget.cpp | 14 ++++++++++++++ src/DockWidget.h | 6 ++++++ 4 files changed, 23 insertions(+) diff --git a/demo/MainWindow.cpp b/demo/MainWindow.cpp index 52605f0..b7a2b2b 100644 --- a/demo/MainWindow.cpp +++ b/demo/MainWindow.cpp @@ -433,6 +433,7 @@ void MainWindowPrivate::createContent() int Width = Splitter->width(); Splitter->setSizes({Width * 2/3, Width * 1/3}); }); + DockWidget->setWindowTitle(QString("My " + DockWidget->windowTitle())); // Now we add a custom button to the dock area title bar that will create // new editor widgets when clicked @@ -474,6 +475,7 @@ void MainWindowPrivate::createContent() // Test visible floating dock widget DockWidget = createCalendarDockWidget(); DockManager->addDockWidgetFloating(DockWidget); + DockWidget->setWindowTitle(QString("My " + DockWidget->windowTitle())); #ifdef Q_OS_WIN diff --git a/src/DockContainerWidget.h b/src/DockContainerWidget.h index 73c8982..a9ebea4 100644 --- a/src/DockContainerWidget.h +++ b/src/DockContainerWidget.h @@ -51,6 +51,7 @@ class CFloatingDragPreview; struct FloatingDragPreviewPrivate; class CDockingStateReader; + /** * Container that manages a number of dock areas with single dock widgets * or tabyfied dock widgets in each area. diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index 0d4ead4..c1b5206 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -456,6 +456,14 @@ CDockContainerWidget* CDockWidget::dockContainer() const } +//============================================================================ +CFloatingDockContainer* CDockWidget::floatingDockContainer() const +{ + auto DockContainer = dockContainer(); + return DockContainer ? DockContainer->floatingWidget() : nullptr; +} + + //============================================================================ CDockAreaWidget* CDockWidget::dockAreaWidget() const { @@ -670,6 +678,12 @@ bool CDockWidget::event(QEvent *e) { d->DockArea->markTitleBarMenuOutdated();//update tabs menu } + + auto FloatingWidget = floatingDockContainer(); + if (FloatingWidget) + { + FloatingWidget->updateWindowTitle(); + } Q_EMIT titleChanged(title); } break; diff --git a/src/DockWidget.h b/src/DockWidget.h index c20028b..abf8766 100644 --- a/src/DockWidget.h +++ b/src/DockWidget.h @@ -331,6 +331,12 @@ public: */ CDockContainerWidget* dockContainer() const; + /** + * This function return the floating DockContainer if is isFloating() is true + * and a nullptr if this dock widget is not floating. + */ + CFloatingDockContainer* floatingDockContainer() const; + /** * Returns the dock area widget this dock widget belongs to or 0 * if this dock widget has not been docked yet