aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/function/GlobalSettingStation.cpp7
-rw-r--r--src/core/utils/CommonUtils.cpp4
-rw-r--r--src/core/utils/CommonUtils.h8
-rw-r--r--src/ui/GpgFrontendUIInit.cpp20
4 files changed, 29 insertions, 10 deletions
diff --git a/src/core/function/GlobalSettingStation.cpp b/src/core/function/GlobalSettingStation.cpp
index 20bbfc55..7632f7dc 100644
--- a/src/core/function/GlobalSettingStation.cpp
+++ b/src/core/function/GlobalSettingStation.cpp
@@ -32,6 +32,7 @@
//
#include "core/module/ModuleManager.h"
+#include "core/utils/CommonUtils.h"
#include "core/utils/FilesystemUtils.h"
namespace GpgFrontend {
@@ -52,7 +53,7 @@ class GlobalSettingStation::Impl {
LOG_I() << "GpgFrontend runs in the portable mode now";
#if defined(__linux__)
- if (!qEnvironmentVariable("APPIMAGE").isEmpty()) {
+ if (IsAppImageENV()) {
LOG_I() << "app image path: " << qEnvironmentVariable("APPIMAGE");
QFileInfo info(
QString::fromUtf8(qEnvironmentVariable("APPIMAGE").toUtf8()));
@@ -159,11 +160,11 @@ class GlobalSettingStation::Impl {
#if defined(__linux__)
// AppImage
- if (!qEnvironmentVariable("APPIMAGE").isEmpty()) {
+ if (IsAppImageENV()) {
return qEnvironmentVariable("APPDIR") + "/usr/lib/modules";
}
// Flatpak
- if (!qEnvironmentVariable("container").isEmpty()) {
+ if (IsFlatpakENV()) {
return "/app/lib/gpgfrontend/modules";
}
#endif
diff --git a/src/core/utils/CommonUtils.cpp b/src/core/utils/CommonUtils.cpp
index eec5deef..569d79e1 100644
--- a/src/core/utils/CommonUtils.cpp
+++ b/src/core/utils/CommonUtils.cpp
@@ -104,6 +104,10 @@ auto GPGFRONTEND_CORE_EXPORT IsFlatpakENV() -> bool {
return QString::fromLocal8Bit(qgetenv("container")) == "flatpak";
}
+auto GPGFRONTEND_CORE_EXPORT IsAppImageENV() -> bool {
+ return !QString::fromLocal8Bit(qgetenv("APPIMAGE")).isEmpty();
+}
+
auto GPGFRONTEND_CORE_EXPORT ParseHexEncodedVersionTuple(const QString& s)
-> int {
// s is a hex-encoded, unsigned int-packed version tuple,
diff --git a/src/core/utils/CommonUtils.h b/src/core/utils/CommonUtils.h
index b7d18891..a0b46d3c 100644
--- a/src/core/utils/CommonUtils.h
+++ b/src/core/utils/CommonUtils.h
@@ -76,6 +76,14 @@ auto GPGFRONTEND_CORE_EXPORT IsFlatpakENV() -> bool;
/**
* @brief
*
+ * @return true
+ * @return false
+ */
+auto GPGFRONTEND_CORE_EXPORT IsAppImageENV() -> bool;
+
+/**
+ * @brief
+ *
* @param s
* @return int
*/
diff --git a/src/ui/GpgFrontendUIInit.cpp b/src/ui/GpgFrontendUIInit.cpp
index 03863516..498640c5 100644
--- a/src/ui/GpgFrontendUIInit.cpp
+++ b/src/ui/GpgFrontendUIInit.cpp
@@ -35,6 +35,7 @@
#include "core/function/GlobalSettingStation.h"
#include "core/model/GpgPassphraseContext.h"
#include "core/module/ModuleManager.h"
+#include "core/utils/CommonUtils.h"
#include "ui/UIModuleManager.h"
#include "ui/UISignalStation.h"
#include "ui/UserInterfaceUtils.h"
@@ -123,13 +124,7 @@ void PreInitGpgFrontendUI() {
"QWidget", {});
}
-void InitGpgFrontendUI(QApplication* app) {
- // init locale
- InitUITranslations();
-
- auto settings = GetSettings();
- auto theme = settings.value("appearance/theme").toString();
-
+void SetFusionAsDefaultStyle() {
// Set Fusion style for better dark mode support across platforms
QApplication::setStyle(QStyleFactory::create("Fusion"));
@@ -164,6 +159,17 @@ void InitGpgFrontendUI(QApplication* app) {
// Apply the dark palette
QApplication::setPalette(dark_palette);
}
+}
+
+void InitGpgFrontendUI(QApplication* app) {
+ // init locale
+ InitUITranslations();
+
+ auto settings = GetSettings();
+ auto theme = settings.value("appearance/theme").toString();
+
+ // make appimage version look better
+ if (IsAppImageENV()) SetFusionAsDefaultStyle();
// If user has explicitly set a theme in settings, use that instead
auto available_styles = QStyleFactory::keys();