|
18 | 18 |
|
19 | 19 | namespace OCC { |
20 | 20 |
|
| 21 | +QString Utility::appImagePath() |
| 22 | +{ |
| 23 | + return qEnvironmentVariable("APPIMAGE"); |
| 24 | +} |
| 25 | + |
| 26 | +bool Utility::isRunningInAppImage() |
| 27 | +{ |
| 28 | + const auto currentAppImagePath = appImagePath(); |
| 29 | + return !currentAppImagePath.isEmpty() && QFile::exists(currentAppImagePath); |
| 30 | +} |
| 31 | + |
21 | 32 | QVector<Utility::ProcessInfosForOpenFile> Utility::queryProcessInfosKeepingFileOpen(const QString &filePath) |
22 | 33 | { |
23 | 34 | Q_UNUSED(filePath) |
@@ -99,9 +110,9 @@ void Utility::setLaunchOnStartup(const QString &appName, const QString &guiName, |
99 | 110 | } |
100 | 111 | // When running inside an AppImage, we need to set the path to the |
101 | 112 | // AppImage instead of the path to the executable |
102 | | - const QString appImagePath = qEnvironmentVariable("APPIMAGE"); |
103 | | - const bool runningInsideAppImage = !appImagePath.isNull() && QFile::exists(appImagePath); |
104 | | - const QString executablePath = runningInsideAppImage ? appImagePath : QCoreApplication::applicationFilePath(); |
| 113 | + const auto currentAppImagePath = appImagePath(); |
| 114 | + const auto runningInsideAppImage = isRunningInAppImage(); |
| 115 | + const auto executablePath = runningInsideAppImage ? currentAppImagePath : QCoreApplication::applicationFilePath(); |
105 | 116 |
|
106 | 117 | QTextStream ts(&iniFile); |
107 | 118 | ts << QLatin1String("[Desktop Entry]\n") |
@@ -134,10 +145,7 @@ QString Utility::getCurrentUserName() |
134 | 145 |
|
135 | 146 | void Utility::registerUriHandlerForLocalEditing() |
136 | 147 | { |
137 | | - const auto appImagePath = qEnvironmentVariable("APPIMAGE"); |
138 | | - const auto runningInsideAppImage = !appImagePath.isNull() && QFile::exists(appImagePath); |
139 | | - |
140 | | - if (!runningInsideAppImage) { |
| 148 | + if (!isRunningInAppImage()) { |
141 | 149 | // only register x-scheme-handler if running inside appImage |
142 | 150 | return; |
143 | 151 | } |
|
0 commit comments