Allow to set a custom title for all FloatingContainer (#454)

This commit is contained in:
tytan652 2022-10-20 19:35:31 +00:00 committed by GitHub
parent 6444e7424f
commit 537828ef3d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 5 deletions

View File

@ -287,7 +287,8 @@ current dock widget.
![FloatingContainerHasWidgetTitle true](cfg_flag_FloatingContainerHasWidgetTitle_true.png) ![FloatingContainerHasWidgetTitle true](cfg_flag_FloatingContainerHasWidgetTitle_true.png)
otherwise it displays application name as window title. otherwise it displays the title set with `CDockManager::setFloatingContainersTitle` or
application name as window title.
![FloatingContainerHasWidgetTitle false](cfg_flag_FloatingContainerHasWidgetTitle_false.png) ![FloatingContainerHasWidgetTitle false](cfg_flag_FloatingContainerHasWidgetTitle_false.png)

View File

@ -92,6 +92,8 @@ enum eStateFileVersion
static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultNonOpaqueConfig; static CDockManager::ConfigFlags StaticConfigFlags = CDockManager::DefaultNonOpaqueConfig;
static QString FloatingContainersTitle;
/** /**
* Private data class of CDockManager class (pimpl) * Private data class of CDockManager class (pimpl)
*/ */
@ -1255,6 +1257,21 @@ CDockFocusController* CDockManager::dockFocusController() const
return d->FocusController; return d->FocusController;
} }
//===========================================================================
void CDockManager::setFloatingContainersTitle(const QString& Title)
{
FloatingContainersTitle = Title;
}
//===========================================================================
QString CDockManager::floatingContainersTitle()
{
if (FloatingContainersTitle.isEmpty())
return qApp->applicationDisplayName();
return FloatingContainersTitle;
}
} // namespace ads } // namespace ads
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@ -186,7 +186,7 @@ public:
DockAreaHasTabsMenuButton = 0x8000, //!< If the flag is set each dock area has a tabs menu button DockAreaHasTabsMenuButton = 0x8000, //!< If the flag is set each dock area has a tabs menu button
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) 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)
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 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
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 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
FloatingContainerHasWidgetIcon = 0x80000, //!< If set, the Floating Widget icon reflects the icon of the current dock widget otherwise it displays application icon FloatingContainerHasWidgetIcon = 0x80000, //!< If set, the Floating Widget icon reflects the icon of the current dock widget otherwise it displays application icon
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 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
//!< this only makes sense for non draggable and non floatable widgets and enables the creation of some kind of "central" widget //!< 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 @@ public:
*/ */
void setSplitterSizes(CDockAreaWidget *ContainedArea, const QList<int>& sizes); void setSplitterSizes(CDockAreaWidget *ContainedArea, const QList<int>& sizes);
/**
* Set a custom title for all FloatingContainer that does not reflect
* the title of the current dock widget.
*/
static void setFloatingContainersTitle(const QString& Title);
/**
* Returns the title used by all FloatingContainer that does not
* reflect the title of the current dock widget.
*
* If not title was set with setFloatingContainersTitle(), it returns
* QGuiApplication::applicationDisplayName().
*/
static QString floatingContainersTitle();
public Q_SLOTS: public Q_SLOTS:
/** /**
* Opens the perspective with the given name. * Opens the perspective with the given name.

View File

@ -433,7 +433,7 @@ struct FloatingDockContainerPrivate
} }
else else
{ {
setWindowTitle(qApp->applicationDisplayName()); setWindowTitle(floatingContainersTitle());
} }
// reflect CurrentWidget's icon if configured to do so, otherwise display application icon as window icon // reflect CurrentWidget's icon if configured to do so, otherwise display application icon as window icon
@ -453,6 +453,18 @@ struct FloatingDockContainerPrivate
* Handles escape key press when dragging around the floating widget * Handles escape key press when dragging around the floating widget
*/ */
void handleEscapeKey(); void handleEscapeKey();
/**
* Returns the title used by all FloatingContainer that does not
* reflect the title of the current dock widget.
*
* If not title was set with CDockManager::setFloatingContainersTitle(),
* it returns QGuiApplication::applicationDisplayName().
*/
static QString floatingContainersTitle()
{
return CDockManager::floatingContainersTitle();
}
}; };
// struct FloatingDockContainerPrivate // struct FloatingDockContainerPrivate
@ -985,7 +997,7 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved()
SLOT(onDockAreaCurrentChanged(int))); SLOT(onDockAreaCurrentChanged(int)));
d->SingleDockArea = nullptr; d->SingleDockArea = nullptr;
} }
d->setWindowTitle(qApp->applicationDisplayName()); d->setWindowTitle(d->floatingContainersTitle());
setWindowIcon(QApplication::windowIcon()); setWindowIcon(QApplication::windowIcon());
} }
} }
@ -1012,7 +1024,7 @@ void CFloatingDockContainer::updateWindowTitle()
} }
else else
{ {
d->setWindowTitle(qApp->applicationDisplayName()); d->setWindowTitle(d->floatingContainersTitle());
setWindowIcon(QApplication::windowIcon()); setWindowIcon(QApplication::windowIcon());
} }
} }