Skip to content

Commit 537828e

Browse files
authored
Allow to set a custom title for all FloatingContainer (#454)
1 parent 6444e74 commit 537828e

File tree

4 files changed

+50
-5
lines changed

4 files changed

+50
-5
lines changed

doc/user-guide.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ current dock widget.
287287

288288
![FloatingContainerHasWidgetTitle true](cfg_flag_FloatingContainerHasWidgetTitle_true.png)
289289

290-
otherwise it displays application name as window title.
290+
otherwise it displays the title set with `CDockManager::setFloatingContainersTitle` or
291+
application name as window title.
291292

292293
![FloatingContainerHasWidgetTitle false](cfg_flag_FloatingContainerHasWidgetTitle_false.png)
293294

src/DockManager.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ enum eStateFileVersion
9292

9393
static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultNonOpaqueConfig;
9494

95+
static QString FloatingContainersTitle;
96+
9597
/**
9698
* Private data class of CDockManager class (pimpl)
9799
*/
@@ -1255,6 +1257,21 @@ CDockFocusController* CDockManager::dockFocusController() const
12551257
return d->FocusController;
12561258
}
12571259

1260+
//===========================================================================
1261+
void CDockManager::setFloatingContainersTitle(const QString& Title)
1262+
{
1263+
FloatingContainersTitle = Title;
1264+
}
1265+
1266+
//===========================================================================
1267+
QString CDockManager::floatingContainersTitle()
1268+
{
1269+
if (FloatingContainersTitle.isEmpty())
1270+
return qApp->applicationDisplayName();
1271+
1272+
return FloatingContainersTitle;
1273+
}
1274+
12581275
} // namespace ads
12591276

12601277
//---------------------------------------------------------------------------

src/DockManager.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
186186
DockAreaHasTabsMenuButton = 0x8000, //!< If the flag is set each dock area has a tabs menu button
187187
DockAreaHideDisabledButtons = 0x10000, //!< If the flag is set disabled dock area buttons will not appear on the toolbar at all (enabling them will bring them back)
188188
DockAreaDynamicTabsMenuButtonVisibility = 0x20000, //!< If the flag is set, the tabs menu button will be shown only when it is required - that means, if the tabs are elided. If the tabs are not elided, it is hidden
189-
FloatingContainerHasWidgetTitle = 0x40000, //!< If set, the Floating Widget window title reflects the title of the current dock widget otherwise it displays application name as window title
189+
FloatingContainerHasWidgetTitle = 0x40000, //!< If set, the Floating Widget window title reflects the title of the current dock widget otherwise it displays the title set with `CDockManager::setFloatingContainersTitle` or application name as window title
190190
FloatingContainerHasWidgetIcon = 0x80000, //!< If set, the Floating Widget icon reflects the icon of the current dock widget otherwise it displays application icon
191191
HideSingleCentralWidgetTitleBar = 0x100000, //!< If there is only one single visible dock widget in the main dock container (the dock manager) and if this flag is set, then the titlebar of this dock widget will be hidden
192192
//!< this only makes sense for non draggable and non floatable widgets and enables the creation of some kind of "central" widget
@@ -528,6 +528,21 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
528528
*/
529529
void setSplitterSizes(CDockAreaWidget *ContainedArea, const QList<int>& sizes);
530530

531+
/**
532+
* Set a custom title for all FloatingContainer that does not reflect
533+
* the title of the current dock widget.
534+
*/
535+
static void setFloatingContainersTitle(const QString& Title);
536+
537+
/**
538+
* Returns the title used by all FloatingContainer that does not
539+
* reflect the title of the current dock widget.
540+
*
541+
* If not title was set with setFloatingContainersTitle(), it returns
542+
* QGuiApplication::applicationDisplayName().
543+
*/
544+
static QString floatingContainersTitle();
545+
531546
public Q_SLOTS:
532547
/**
533548
* Opens the perspective with the given name.

src/FloatingDockContainer.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ struct FloatingDockContainerPrivate
433433
}
434434
else
435435
{
436-
setWindowTitle(qApp->applicationDisplayName());
436+
setWindowTitle(floatingContainersTitle());
437437
}
438438

439439
// reflect CurrentWidget's icon if configured to do so, otherwise display application icon as window icon
@@ -453,6 +453,18 @@ struct FloatingDockContainerPrivate
453453
* Handles escape key press when dragging around the floating widget
454454
*/
455455
void handleEscapeKey();
456+
457+
/**
458+
* Returns the title used by all FloatingContainer that does not
459+
* reflect the title of the current dock widget.
460+
*
461+
* If not title was set with CDockManager::setFloatingContainersTitle(),
462+
* it returns QGuiApplication::applicationDisplayName().
463+
*/
464+
static QString floatingContainersTitle()
465+
{
466+
return CDockManager::floatingContainersTitle();
467+
}
456468
};
457469
// struct FloatingDockContainerPrivate
458470

@@ -985,7 +997,7 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved()
985997
SLOT(onDockAreaCurrentChanged(int)));
986998
d->SingleDockArea = nullptr;
987999
}
988-
d->setWindowTitle(qApp->applicationDisplayName());
1000+
d->setWindowTitle(d->floatingContainersTitle());
9891001
setWindowIcon(QApplication::windowIcon());
9901002
}
9911003
}
@@ -1012,7 +1024,7 @@ void CFloatingDockContainer::updateWindowTitle()
10121024
}
10131025
else
10141026
{
1015-
d->setWindowTitle(qApp->applicationDisplayName());
1027+
d->setWindowTitle(d->floatingContainersTitle());
10161028
setWindowIcon(QApplication::windowIcon());
10171029
}
10181030
}

0 commit comments

Comments
 (0)