Fixed #420 - Floating docks title doesn't update

added tests for DockWidget->setWindowTitle() in demo application
This commit is contained in:
Uwe Kindler 2022-05-10 13:41:19 +02:00
parent 23f80334f6
commit 0e566cb8a3
4 changed files with 23 additions and 0 deletions

View File

@ -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

View File

@ -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.

View File

@ -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;

View File

@ -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