diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qplatformwindow.cpp | 24 | ||||
-rw-r--r-- | src/gui/kernel/qplatformwindow.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowswindow.cpp | 13 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 12 |
4 files changed, 28 insertions, 23 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) diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 5d6d4620b7..2708d7d428 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -1216,18 +1216,7 @@ void QWindowsWindow::setWindowTitle(const QString &title) if (QWindowsContext::verboseWindows) qDebug() << __FUNCTION__ << this << window() <<title; if (m_data.hwnd) { - - QString fullTitle = title; - if (QGuiApplicationPrivate::displayName) { - // Append display name, if set. - if (!fullTitle.isEmpty()) - fullTitle += QStringLiteral(" - "); - 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(); - } - + const QString fullTitle = formatWindowTitle(title, QStringLiteral(" - ")); SetWindowText(m_data.hwnd, (const wchar_t*)fullTitle.utf16()); } } diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 60cc547979..b7668e6270 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1122,18 +1122,8 @@ void QXcbWindow::setParent(const QPlatformWindow *parent) void QXcbWindow::setWindowTitle(const QString &title) { - QString fullTitle = title; - if (QGuiApplicationPrivate::displayName) { - // Append display name, if set. - if (!fullTitle.isEmpty()) - fullTitle += QString::fromUtf8(" \xe2\x80\x94 "); // unicode character U+2014, EM DASH - 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(); - } + const QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); // unicode character U+2014, EM DASH const QByteArray ba = fullTitle.toUtf8(); - Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, |