summaryrefslogtreecommitdiffstats
path: root/src/widgets/kernel
diff options
context:
space:
mode:
authorDavid Faure <faure@kde.org>2012-11-30 19:37:02 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-12-14 08:56:02 +0100
commit92bd9aecfb69ebe525ba88dc78ce85e3ca7ed9c2 (patch)
tree782443b776a374680e2e4ec87a4409fea027ea4d /src/widgets/kernel
parent1a653225f6c73d7ca32aa6cdcde45ba9462a7b72 (diff)
Fix empty window title regression, add application display name to window title
This increases consistency a lot: all windows and dialogs from a Qt application will show the app display name in the caption, on Windows and X11. This helps identifying which app a dialog belongs to, which is especially useful when the dialog is very generic and shows up unexpectedly. For compatibility reasons, the app name is added to the caption only if setApplicationDisplayName() was called -- or if the caption would be completely empty. The standard Qt4 case (setWindowTitle + no display name) is unchanged. Change-Id: Ib284c62c1f4c0bc923e5bc2d10247d95e9aa76c1 Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/widgets/kernel')
-rw-r--r--src/widgets/kernel/qwidget.cpp39
1 files changed, 8 insertions, 31 deletions
diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp
index ab7330594f..38d3198f2f 100644
--- a/src/widgets/kernel/qwidget.cpp
+++ b/src/widgets/kernel/qwidget.cpp
@@ -5474,18 +5474,6 @@ void QWidget::unsetLocale()
d->resolveLocale();
}
-static QString constructWindowTitleFromFilePath(const QString &filePath)
-{
- QFileInfo fi(filePath);
- QString windowTitle = fi.fileName() + QLatin1String("[*]");
-#ifndef Q_WS_MAC
- QString appName = QApplication::applicationName();
- if (!appName.isEmpty())
- windowTitle += QLatin1Char(' ') + QChar(0x2014) + QLatin1Char(' ') + appName;
-#endif
- return windowTitle;
-}
-
/*!
\property QWidget::windowTitle
\brief the window title (caption)
@@ -5502,6 +5490,11 @@ static QString constructWindowTitleFromFilePath(const QString &filePath)
windowModified property is false (the default), the placeholder
is simply removed.
+ On some desktop platforms (including Windows and Unix), the application name
+ (from QGuiApplication::applicationDisplayName) is added at the end of the
+ window title, if set. This is done by the QPA plugin, so it is shown to the
+ user, but isn't part of the \l windowTitle string.
+
\sa windowIcon, windowIconText, windowModified, windowFilePath
*/
QString QWidget::windowTitle() const
@@ -5511,7 +5504,7 @@ QString QWidget::windowTitle() const
if (!d->extra->topextra->caption.isEmpty())
return d->extra->topextra->caption;
if (!d->extra->topextra->filePath.isEmpty())
- return constructWindowTitleFromFilePath(d->extra->topextra->filePath);
+ return QFileInfo(d->extra->topextra->filePath).fileName() + QLatin1String("[*]");
}
return QString();
}
@@ -5683,24 +5676,8 @@ QString QWidget::windowIconText() const
This property only makes sense for windows. It associates a file path with
a window. If you set the file path, but have not set the window title, Qt
- sets the window title to contain a string created using the following
- components.
-
- On Mac OS X:
-
- \list
- \li The file name of the specified path, obtained using QFileInfo::fileName().
- \endlist
-
- On Windows and X11:
-
- \list
- \li The file name of the specified path, obtained using QFileInfo::fileName().
- \li An optional \c{*} character, if the \l windowModified property is set.
- \li The \c{0x2014} unicode character, padded either side by spaces.
- \li The application name, obtained from the application's
- \l{QCoreApplication::}{applicationName} property.
- \endlist
+ sets the window title to the file name of the specified path, obtained using
+ QFileInfo::fileName().
If the window title is set at any point, then the window title takes precedence and
will be shown instead of the file path string.