This is for use in window titles.
Change-Id: I0070a08abd379ae2edcfab4413c182bd9e840678
Reviewed-by: Gunnar Sletta <gunnar.sletta@nokia.com>
static unsigned applicationResourceFlags = 0;
QString *QGuiApplicationPrivate::platform_name = 0;
+QString *QGuiApplicationPrivate::displayName = 0;
QPalette *QGuiApplicationPrivate::app_pal = 0; // default application palette
delete QGuiApplicationPrivate::platform_name;
QGuiApplicationPrivate::platform_name = 0;
+ delete QGuiApplicationPrivate::displayName;
+ QGuiApplicationPrivate::displayName = 0;
}
QGuiApplicationPrivate::QGuiApplicationPrivate(int &argc, char **argv, int flags)
}
/*!
+ \property QGuiApplication::applicationDisplayName
+ \brief the user-visible name of this application
+ \since 5.0
+
+ This name is shown to the user, for instance in window titles.
+ It can be translated, if necessary.
+
+ If not set, the application display name defaults to the application name.
+
+ \sa applicationName
+*/
+void QGuiApplication::setApplicationDisplayName(const QString &name)
+{
+ if (!QGuiApplicationPrivate::displayName)
+ QGuiApplicationPrivate::displayName = new QString;
+ *QGuiApplicationPrivate::displayName = name;
+}
+
+QString QGuiApplication::applicationDisplayName()
+{
+ return QGuiApplicationPrivate::displayName ? *QGuiApplicationPrivate::displayName : applicationName();
+}
+
+/*!
Returns the most recently shown modal window. If no modal windows are
visible, this function returns zero.
class Q_GUI_EXPORT QGuiApplication : public QCoreApplication
{
Q_OBJECT
+ Q_PROPERTY(QString applicationDisplayName READ applicationDisplayName WRITE setApplicationDisplayName)
Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection)
Q_PROPERTY(QString platformName READ platformName STORED false)
Q_PROPERTY(bool quitOnLastWindowClosed READ quitOnLastWindowClosed WRITE setQuitOnLastWindowClosed)
QGuiApplication(int &argc, char **argv, int = ApplicationFlags);
virtual ~QGuiApplication();
+ static void setApplicationDisplayName(const QString &name);
+ static QString applicationDisplayName();
+
static QWindowList allWindows();
static QWindowList topLevelWindows();
static QWindow *topLevelAt(const QPoint &pos);
static QGuiApplicationPrivate *instance() { return self; }
static QString *platform_name;
+ static QString *displayName;
QWindowList modalWindowList;
static void showModalWindow(QWindow *window);
Q_OBJECT
private slots:
+ void displayName();
void focusObject();
void allWindows();
void topLevelWindows();
void quitOnLastWindowClosed();
};
+void tst_QGuiApplication::displayName()
+{
+ int argc = 1;
+ char *argv[] = { const_cast<char*>("tst_qguiapplication") };
+ QGuiApplication app(argc, argv);
+ QCOMPARE(::qAppName(), QString::fromLatin1("tst_qguiapplication"));
+ QCOMPARE(QGuiApplication::applicationName(), QString::fromLatin1("tst_qguiapplication"));
+ QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("tst_qguiapplication"));
+ QGuiApplication::setApplicationDisplayName("The GUI Application");
+ QCOMPARE(QGuiApplication::applicationDisplayName(), QString::fromLatin1("The GUI Application"));
+}
+
class DummyWindow : public QWindow
{
public: