Skip to content

Commit b6b8b34

Browse files
committed
Set QGuiApplication desktopFileName
This is supposed to set the desktop file association for the Wayland backend. Note: I don't think Wayland is actually enabled in our build yet.
1 parent 9ccff4d commit b6b8b34

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

linux.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <QDir>
2323
#include <QDebug>
2424
#include <QCoreApplication>
25+
#include <QGuiApplication>
2526
#include <QProcess>
2627
#include <QRegularExpression>
2728
#include <QStandardPaths>
@@ -31,6 +32,8 @@ namespace Sys {
3132

3233
namespace {
3334

35+
const QString DESKTOP_FILE_NAME = "net.unvanquished.Unvanquished.desktop";
36+
3437
// Use QProcess::splitCommand in Qt 5.15+
3538
QStringList splitArgs(const QString& command) {
3639
QRegularExpression argPart(R"regex((")""|"([^\"]*)"?|([^ ]))regex");
@@ -155,15 +158,14 @@ bool installShortcuts()
155158
qDebug() << "Created directory for desktop files" << desktopDirString;
156159
}
157160

158-
QString desktopFileName = "net.unvanquished.Unvanquished.desktop";
159-
QFile desktopFile(":resources/" + desktopFileName);
161+
QFile desktopFile(":resources/" + DESKTOP_FILE_NAME);
160162
if (!desktopFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
161-
qDebug() << "missing resource" << desktopFileName;
163+
qDebug() << "missing resource" << DESKTOP_FILE_NAME;
162164
return false;
163165
}
164166
QString desktopStr = QString(desktopFile.readAll().data()).arg(settings.installPath());
165167
{
166-
QFile outputFile(desktopDir.filePath(desktopFileName));
168+
QFile outputFile(desktopDir.filePath(DESKTOP_FILE_NAME));
167169
if (!outputFile.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate)) {
168170
qDebug() << "error opening" << outputFile.fileName();
169171
return false;
@@ -177,7 +179,7 @@ bool installShortcuts()
177179

178180
int ret = QProcess::execute("xdg-mime",
179181
{QString("default"),
180-
desktopDir.filePath(desktopFileName),
182+
desktopDir.filePath(DESKTOP_FILE_NAME),
181183
QString("x-scheme-handler/unv")});
182184
qDebug() << "xdg-mime returned" << ret;
183185
ret = QProcess::execute("update-desktop-database", {desktopDirString});
@@ -289,6 +291,9 @@ void initApplicationName()
289291
{
290292
QCoreApplication::setOrganizationName("unvanquished");
291293
QCoreApplication::setApplicationName("updater");
294+
295+
// for Wayland backend
296+
QGuiApplication::setDesktopFileName(DESKTOP_FILE_NAME);
292297
}
293298

294299
// Settings are stored in ~/.config/unvanquished/updater.conf

0 commit comments

Comments
 (0)