summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPier Luigi Fiorini <pierluigi.fiorini@gmail.com>2015-08-29 18:17:00 +0200
committerPier Luigi Fiorini <pierluigi.fiorini@gmail.com>2016-01-11 20:05:33 +0000
commit1d95a31985c29a78d0e7552dac38c8f399dd4493 (patch)
treeb1dd95cfcc194d83628519ee1f782ae67482f33c
parent0a1ea270b6d7d886f6f8ab39faeeeb5b24e045b3 (diff)
Set appId according to QGuiApplication::desktopFileName()
Since qtbase 61ad604ad41607be97efea5a18cd4d9fb7ddca73, QGuiApplication has got a new property: desktopFileName. Applications can now specify the desktop file name. In that case we have a reliable information: use it for the appId removing the ".desktop" suffix. Otherwise, just use the logic we previously established. Change-Id: I03c89009620b33bc68ee97ed414cfee1c1794632 Reviewed-by: Paul Olav Tvete <paul.tvete@theqtcompany.com>
-rw-r--r--src/client/qwaylandwindow.cpp41
1 files changed, 26 insertions, 15 deletions
diff --git a/src/client/qwaylandwindow.cpp b/src/client/qwaylandwindow.cpp
index 5c06f66db..097320c5b 100644
--- a/src/client/qwaylandwindow.cpp
+++ b/src/client/qwaylandwindow.cpp
@@ -50,6 +50,7 @@
#include <QtCore/QFileInfo>
#include <QtCore/QPointer>
+#include <QtCore/QRegularExpression>
#include <QtGui/QWindow>
#include <QGuiApplication>
@@ -131,22 +132,32 @@ void QWaylandWindow::initWindow()
mShellSurface->setTitle(window()->title());
// The appId is the desktop entry identifier that should follow the
- // reverse DNS convention (see http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html),
- // use the application domain if available, otherwise the executable base name.
- // According to xdg-shell the appId is only the name, without the .desktop suffix.
- QFileInfo fi = QCoreApplication::instance()->applicationFilePath();
- QStringList domainName =
- QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'),
- QString::SkipEmptyParts);
-
- if (domainName.isEmpty()) {
- mShellSurface->setAppId(fi.baseName());
+ // reverse DNS convention (see http://standards.freedesktop.org/desktop-entry-spec/latest/ar01s02.html).
+ // According to xdg-shell the appId is only the name, without
+ // the .desktop suffix.
+ //
+ // If the application specifies the desktop file name use that
+ // removing the ".desktop" suffix, otherwise fall back to the
+ // executable name and prepend the reversed organization domain
+ // when available.
+ if (!QGuiApplication::desktopFileName().isEmpty()) {
+ QString name = QGuiApplication::desktopFileName();
+ mShellSurface->setAppId(name.replace(QRegularExpression(QLatin1String("\\.desktop$")), QString()));
} else {
- QString appId;
- for (int i = 0; i < domainName.count(); ++i)
- appId.prepend(QLatin1Char('.')).prepend(domainName.at(i));
- appId.append(fi.baseName());
- mShellSurface->setAppId(appId);
+ QFileInfo fi = QCoreApplication::instance()->applicationFilePath();
+ QStringList domainName =
+ QCoreApplication::instance()->organizationDomain().split(QLatin1Char('.'),
+ QString::SkipEmptyParts);
+
+ if (domainName.isEmpty()) {
+ mShellSurface->setAppId(fi.baseName());
+ } else {
+ QString appId;
+ for (int i = 0; i < domainName.count(); ++i)
+ appId.prepend(QLatin1Char('.')).prepend(domainName.at(i));
+ appId.append(fi.baseName());
+ mShellSurface->setAppId(appId);
+ }
}
}