Skip to content

Commit 0e566cb

Browse files
Fixed #420 - Floating docks title doesn't update
added tests for DockWidget->setWindowTitle() in demo application
1 parent 23f8033 commit 0e566cb

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

demo/MainWindow.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,7 @@ void MainWindowPrivate::createContent()
433433
int Width = Splitter->width();
434434
Splitter->setSizes({Width * 2/3, Width * 1/3});
435435
});
436+
DockWidget->setWindowTitle(QString("My " + DockWidget->windowTitle()));
436437

437438
// Now we add a custom button to the dock area title bar that will create
438439
// new editor widgets when clicked
@@ -474,6 +475,7 @@ void MainWindowPrivate::createContent()
474475
// Test visible floating dock widget
475476
DockWidget = createCalendarDockWidget();
476477
DockManager->addDockWidgetFloating(DockWidget);
478+
DockWidget->setWindowTitle(QString("My " + DockWidget->windowTitle()));
477479

478480

479481
#ifdef Q_OS_WIN

src/DockContainerWidget.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ class CFloatingDragPreview;
5151
struct FloatingDragPreviewPrivate;
5252
class CDockingStateReader;
5353

54+
5455
/**
5556
* Container that manages a number of dock areas with single dock widgets
5657
* or tabyfied dock widgets in each area.

src/DockWidget.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,14 @@ CDockContainerWidget* CDockWidget::dockContainer() const
456456
}
457457

458458

459+
//============================================================================
460+
CFloatingDockContainer* CDockWidget::floatingDockContainer() const
461+
{
462+
auto DockContainer = dockContainer();
463+
return DockContainer ? DockContainer->floatingWidget() : nullptr;
464+
}
465+
466+
459467
//============================================================================
460468
CDockAreaWidget* CDockWidget::dockAreaWidget() const
461469
{
@@ -670,6 +678,12 @@ bool CDockWidget::event(QEvent *e)
670678
{
671679
d->DockArea->markTitleBarMenuOutdated();//update tabs menu
672680
}
681+
682+
auto FloatingWidget = floatingDockContainer();
683+
if (FloatingWidget)
684+
{
685+
FloatingWidget->updateWindowTitle();
686+
}
673687
Q_EMIT titleChanged(title);
674688
}
675689
break;

src/DockWidget.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,12 @@ private Q_SLOTS:
331331
*/
332332
CDockContainerWidget* dockContainer() const;
333333

334+
/**
335+
* This function return the floating DockContainer if is isFloating() is true
336+
* and a nullptr if this dock widget is not floating.
337+
*/
338+
CFloatingDockContainer* floatingDockContainer() const;
339+
334340
/**
335341
* Returns the dock area widget this dock widget belongs to or 0
336342
* if this dock widget has not been docked yet

0 commit comments

Comments
 (0)