aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordada513 <dada513@protonmail.com>2022-03-27 12:43:49 +0200
committerdada513 <dada513@protonmail.com>2022-03-27 12:43:49 +0200
commit3672dbc5af1403c8ea1a1f36d2890fed7dd4c6a1 (patch)
treebf9c6629039c2aea0d80d1634510114c2aff9f47
parent81b50c0387c86de3acb1bf5a96b0045bf5f0aca7 (diff)
downloadPrismLauncher-3672dbc5af1403c8ea1a1f36d2890fed7dd4c6a1.tar.gz
PrismLauncher-3672dbc5af1403c8ea1a1f36d2890fed7dd4c6a1.tar.bz2
PrismLauncher-3672dbc5af1403c8ea1a1f36d2890fed7dd4c6a1.zip
Fix flatpak properly
-rw-r--r--launcher/CMakeLists.txt2
-rw-r--r--launcher/DesktopServices.cpp48
-rw-r--r--launcher/Flatpak.cpp14
-rw-r--r--launcher/Flatpak.h4
4 files changed, 62 insertions, 6 deletions
diff --git a/launcher/CMakeLists.txt b/launcher/CMakeLists.txt
index 98cb0a3b..1a16485e 100644
--- a/launcher/CMakeLists.txt
+++ b/launcher/CMakeLists.txt
@@ -582,6 +582,8 @@ SET(LAUNCHER_SOURCES
ApplicationMessage.cpp
# GUI - general utilities
+ Flatpak.h
+ Flatpak.cpp
DesktopServices.h
DesktopServices.cpp
VersionProxyModel.h
diff --git a/launcher/DesktopServices.cpp b/launcher/DesktopServices.cpp
index dcc1b0ce..5de97210 100644
--- a/launcher/DesktopServices.cpp
+++ b/launcher/DesktopServices.cpp
@@ -3,6 +3,7 @@
#include <QDesktopServices>
#include <QProcess>
#include <QDebug>
+#include "Flatpak.h"
/**
* This shouldn't exist, but until QTBUG-9328 and other unreported bugs are fixed, it needs to be a thing.
@@ -84,7 +85,14 @@ bool openDirectory(const QString &path, bool ensureExists)
return QDesktopServices::openUrl(QUrl::fromLocalFile(dir.absolutePath()));
};
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
- return IndirectOpen(f);
+ if(!Flatpak::IsFlatpak())
+ {
+ return IndirectOpen(f);
+ }
+ else
+ {
+ return f();
+ }
#else
return f();
#endif
@@ -98,7 +106,14 @@ bool openFile(const QString &path)
return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
};
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
- return IndirectOpen(f);
+ if(!Flatpak::IsFlatpak())
+ {
+ return IndirectOpen(f);
+ }
+ else
+ {
+ return f();
+ }
#else
return f();
#endif
@@ -109,10 +124,17 @@ bool openFile(const QString &application, const QString &path, const QString &wo
qDebug() << "Opening file" << path << "using" << application;
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
// FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
- return IndirectOpen([&]()
+ if(!Flatpak::IsFlatpak())
{
- return QProcess::startDetached(application, QStringList() << path, workingDirectory);
- }, pid);
+ return IndirectOpen([&]()
+ {
+ return QProcess::startDetached(application, QStringList() << path, workingDirectory);
+ }, pid);
+ }
+ else
+ {
+ return QProcess::startDetached(application, QStringList() << path, workingDirectory, pid);
+ }
#else
return QProcess::startDetached(application, QStringList() << path, workingDirectory, pid);
#endif
@@ -122,11 +144,18 @@ bool run(const QString &application, const QStringList &args, const QString &wor
{
qDebug() << "Running" << application << "with args" << args.join(' ');
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
+ if(!Flatpak::IsFlatpak())
+ {
// FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
return IndirectOpen([&]()
{
return QProcess::startDetached(application, args, workingDirectory);
}, pid);
+ }
+ else
+ {
+ return QProcess::startDetached(application, args, workingDirectory, pid);
+ }
#else
return QProcess::startDetached(application, args, workingDirectory, pid);
#endif
@@ -140,7 +169,14 @@ bool openUrl(const QUrl &url)
return QDesktopServices::openUrl(url);
};
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
- return IndirectOpen(f);
+ if(!Flatpak::IsFlatpak())
+ {
+ return IndirectOpen(f);
+ }
+ else
+ {
+ return f();
+ }
#else
return f();
#endif
diff --git a/launcher/Flatpak.cpp b/launcher/Flatpak.cpp
new file mode 100644
index 00000000..8b61f903
--- /dev/null
+++ b/launcher/Flatpak.cpp
@@ -0,0 +1,14 @@
+#include <QFileInfo>
+
+namespace Flatpak
+{
+ bool IsFlatpak()
+ {
+ #ifdef Q_OS_LINUX
+ QFileInfo check_file("/.flatpak-info");
+ return check_file.exists();
+ #else
+ return false;
+ #endif
+ }
+}
diff --git a/launcher/Flatpak.h b/launcher/Flatpak.h
new file mode 100644
index 00000000..da6eb7c3
--- /dev/null
+++ b/launcher/Flatpak.h
@@ -0,0 +1,4 @@
+namespace Flatpak
+{
+ bool IsFlatpak();
+} \ No newline at end of file