Skip to content

Allow to set a custom title for all FloatingContainer #454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,8 @@ current dock widget.

![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)

Expand Down
17 changes: 17 additions & 0 deletions src/DockManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ enum eStateFileVersion

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

static QString FloatingContainersTitle;

/**
* Private data class of CDockManager class (pimpl)
*/
Expand Down Expand Up @@ -1255,6 +1257,21 @@ CDockFocusController* CDockManager::dockFocusController() const
return d->FocusController;
}

//===========================================================================
void CDockManager::setFloatingContainersTitle(const QString& Title)
{
FloatingContainersTitle = Title;
}

//===========================================================================
QString CDockManager::floatingContainersTitle()
{
if (FloatingContainersTitle.isEmpty())
return qApp->applicationDisplayName();

return FloatingContainersTitle;
}

} // namespace ads

//---------------------------------------------------------------------------
Expand Down
17 changes: 16 additions & 1 deletion src/DockManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
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)
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
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
Expand Down Expand Up @@ -528,6 +528,21 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
*/
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:
/**
* Opens the perspective with the given name.
Expand Down
18 changes: 15 additions & 3 deletions src/FloatingDockContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ struct FloatingDockContainerPrivate
}
else
{
setWindowTitle(qApp->applicationDisplayName());
setWindowTitle(floatingContainersTitle());
}

// reflect CurrentWidget's icon if configured to do so, otherwise display application icon as window icon
Expand All @@ -453,6 +453,18 @@ struct FloatingDockContainerPrivate
* Handles escape key press when dragging around the floating widget
*/
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

Expand Down Expand Up @@ -985,7 +997,7 @@ void CFloatingDockContainer::onDockAreasAddedOrRemoved()
SLOT(onDockAreaCurrentChanged(int)));
d->SingleDockArea = nullptr;
}
d->setWindowTitle(qApp->applicationDisplayName());
d->setWindowTitle(d->floatingContainersTitle());
setWindowIcon(QApplication::windowIcon());
}
}
Expand All @@ -1012,7 +1024,7 @@ void CFloatingDockContainer::updateWindowTitle()
}
else
{
d->setWindowTitle(qApp->applicationDisplayName());
d->setWindowTitle(d->floatingContainersTitle());
setWindowIcon(QApplication::windowIcon());
}
}
Expand Down