Fix flatpak properly
This commit is contained in:
parent
81b50c0387
commit
3672dbc5af
@ -582,6 +582,8 @@ SET(LAUNCHER_SOURCES
|
||||
ApplicationMessage.cpp
|
||||
|
||||
# GUI - general utilities
|
||||
Flatpak.h
|
||||
Flatpak.cpp
|
||||
DesktopServices.h
|
||||
DesktopServices.cpp
|
||||
VersionProxyModel.h
|
||||
|
@ -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
|
||||
|
14
launcher/Flatpak.cpp
Normal file
14
launcher/Flatpak.cpp
Normal file
@ -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
|
||||
}
|
||||
}
|
4
launcher/Flatpak.h
Normal file
4
launcher/Flatpak.h
Normal file
@ -0,0 +1,4 @@
|
||||
namespace Flatpak
|
||||
{
|
||||
bool IsFlatpak();
|
||||
}
|
Loading…
Reference in New Issue
Block a user