Merge pull request #1294 from ashuntu/develop
This commit is contained in:
commit
39d7bc6c24
@ -281,7 +281,16 @@ Application::Application(int &argc, char **argv) : QApplication(argc, argv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QDir foo(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), ".."));
|
QDir foo;
|
||||||
|
if (DesktopServices::isSnap())
|
||||||
|
{
|
||||||
|
foo = QDir(getenv("SNAP_USER_COMMON"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foo = QDir(FS::PathCombine(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation), ".."));
|
||||||
|
}
|
||||||
|
|
||||||
dataPath = foo.absolutePath();
|
dataPath = foo.absolutePath();
|
||||||
adjustedBy = "Persistent data path";
|
adjustedBy = "Persistent data path";
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ bool openDirectory(const QString &path, bool ensureExists)
|
|||||||
return QDesktopServices::openUrl(QUrl::fromLocalFile(dir.absolutePath()));
|
return QDesktopServices::openUrl(QUrl::fromLocalFile(dir.absolutePath()));
|
||||||
};
|
};
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
||||||
if(!isFlatpak())
|
if(!isSandbox())
|
||||||
{
|
{
|
||||||
return IndirectOpen(f);
|
return IndirectOpen(f);
|
||||||
}
|
}
|
||||||
@ -139,7 +139,7 @@ bool openFile(const QString &path)
|
|||||||
return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
return QDesktopServices::openUrl(QUrl::fromLocalFile(path));
|
||||||
};
|
};
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
||||||
if(!isFlatpak())
|
if(!isSandbox())
|
||||||
{
|
{
|
||||||
return IndirectOpen(f);
|
return IndirectOpen(f);
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ bool openFile(const QString &application, const QString &path, const QString &wo
|
|||||||
qDebug() << "Opening file" << path << "using" << application;
|
qDebug() << "Opening file" << path << "using" << application;
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
#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
|
// FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
|
||||||
if(!isFlatpak())
|
if(!isSandbox())
|
||||||
{
|
{
|
||||||
return IndirectOpen([&]()
|
return IndirectOpen([&]()
|
||||||
{
|
{
|
||||||
@ -177,7 +177,7 @@ bool run(const QString &application, const QStringList &args, const QString &wor
|
|||||||
{
|
{
|
||||||
qDebug() << "Running" << application << "with args" << args.join(' ');
|
qDebug() << "Running" << application << "with args" << args.join(' ');
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
||||||
if(!isFlatpak())
|
if(!isSandbox())
|
||||||
{
|
{
|
||||||
// FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
|
// FIXME: the pid here is fake. So if something depends on it, it will likely misbehave
|
||||||
return IndirectOpen([&]()
|
return IndirectOpen([&]()
|
||||||
@ -202,7 +202,7 @@ bool openUrl(const QUrl &url)
|
|||||||
return QDesktopServices::openUrl(url);
|
return QDesktopServices::openUrl(url);
|
||||||
};
|
};
|
||||||
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
|
||||||
if(!isFlatpak())
|
if(!isSandbox())
|
||||||
{
|
{
|
||||||
return IndirectOpen(f);
|
return IndirectOpen(f);
|
||||||
}
|
}
|
||||||
@ -224,4 +224,18 @@ bool isFlatpak()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isSnap()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_LINUX
|
||||||
|
return getenv("SNAP");
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool isSandbox()
|
||||||
|
{
|
||||||
|
return isSnap() || isFlatpak();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,5 +34,18 @@ namespace DesktopServices
|
|||||||
*/
|
*/
|
||||||
bool openUrl(const QUrl &url);
|
bool openUrl(const QUrl &url);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the launcher is running in a Flatpak environment
|
||||||
|
*/
|
||||||
bool isFlatpak();
|
bool isFlatpak();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the launcher is running in a Snap environment
|
||||||
|
*/
|
||||||
|
bool isSnap();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether the launcher is running in a sandboxed (Flatpak or Snap) environment
|
||||||
|
*/
|
||||||
|
bool isSandbox();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user