diff options
author | David Faure <faure@kde.org> | 2012-12-14 18:25:03 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-02-06 18:39:32 +0100 |
commit | ca19cba2ac3cf9785b9a2211c4ba7d1e14d87bf2 (patch) | |
tree | 68d008d03971e2a98699ccf1128f59043e22d058 /src/gui | |
parent | 132ba92ec2d672c44c3fc26b43b0293045d36586 (diff) |
Factorize code for formatting window titles into QPlatformWindow.
Change-Id: I0dcccd08916fc2ea1b795681e9b98a9550ef51b6
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 24 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.h | 2 |
2 files changed, 26 insertions, 0 deletions
diff --git a/src/gui/kernel/qplatformwindow.cpp b/src/gui/kernel/qplatformwindow.cpp index 01377d1aa0..b710701e7f 100644 --- a/src/gui/kernel/qplatformwindow.cpp +++ b/src/gui/kernel/qplatformwindow.cpp @@ -42,6 +42,7 @@ #include "qplatformwindow.h" #include "qplatformwindow_p.h" +#include <private/qguiapplication_p.h> #include <qpa/qwindowsysteminterface.h> #include <QtGui/qwindow.h> #include <QtGui/qscreen.h> @@ -425,6 +426,29 @@ bool QPlatformWindow::frameStrutEventsEnabled() const } /*! + Call this method to put together a window title composed of + \a title + \a separator + the application display name + + If the display name isn't set, and the title is empty, the raw app name is used. +*/ +QString QPlatformWindow::formatWindowTitle(const QString &title, const QString &separator) +{ + QString fullTitle = title; + if (QGuiApplicationPrivate::displayName) { + // Append display name, if set. + if (!fullTitle.isEmpty()) + fullTitle += separator; + fullTitle += *QGuiApplicationPrivate::displayName; + } else if (fullTitle.isEmpty()) { + // Don't let the window title be completely empty, use the app name as fallback. + fullTitle = QCoreApplication::applicationName(); + } + return fullTitle; +} + +/*! \class QPlatformWindow \since 4.8 \internal diff --git a/src/gui/kernel/qplatformwindow.h b/src/gui/kernel/qplatformwindow.h index d435198349..fe62d7b67b 100644 --- a/src/gui/kernel/qplatformwindow.h +++ b/src/gui/kernel/qplatformwindow.h @@ -131,6 +131,8 @@ public: virtual bool frameStrutEventsEnabled() const; protected: + static QString formatWindowTitle(const QString &title, const QString &separator); + QScopedPointer<QPlatformWindowPrivate> d_ptr; private: Q_DISABLE_COPY(QPlatformWindow) |