Fix Flatpak config issues

Remove #ifdef guards from Config.h/cpp (no harm to non-Flatpak distros)

Cleanup #ifdef usage in NixUtils.cpp
This commit is contained in:
Jonathan White 2024-05-06 22:24:31 -04:00
parent 8cd45f57b7
commit a5c7f7bb50
3 changed files with 8 additions and 18 deletions

View File

@ -98,9 +98,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
{Config::GUI_HidePreviewPanel, {QS("GUI/HidePreviewPanel"), Roaming, false}}, {Config::GUI_HidePreviewPanel, {QS("GUI/HidePreviewPanel"), Roaming, false}},
{Config::GUI_AlwaysOnTop, {QS("GUI/GUI_AlwaysOnTop"), Local, false}}, {Config::GUI_AlwaysOnTop, {QS("GUI/GUI_AlwaysOnTop"), Local, false}},
{Config::GUI_ToolButtonStyle, {QS("GUI/ToolButtonStyle"), Roaming, Qt::ToolButtonIconOnly}}, {Config::GUI_ToolButtonStyle, {QS("GUI/ToolButtonStyle"), Roaming, Qt::ToolButtonIconOnly}},
#ifdef KEEPASSXC_DIST_FLATPAK
{Config::GUI_LaunchAtStartup, {QS("GUI/LaunchAtStartup"), Roaming, false}}, {Config::GUI_LaunchAtStartup, {QS("GUI/LaunchAtStartup"), Roaming, false}},
#endif
{Config::GUI_ShowTrayIcon, {QS("GUI/ShowTrayIcon"), Roaming, false}}, {Config::GUI_ShowTrayIcon, {QS("GUI/ShowTrayIcon"), Roaming, false}},
{Config::GUI_TrayIconAppearance, {QS("GUI/TrayIconAppearance"), Roaming, {}}}, {Config::GUI_TrayIconAppearance, {QS("GUI/TrayIconAppearance"), Roaming, {}}},
{Config::GUI_MinimizeToTray, {QS("GUI/MinimizeToTray"), Roaming, false}}, {Config::GUI_MinimizeToTray, {QS("GUI/MinimizeToTray"), Roaming, false}},

View File

@ -80,9 +80,7 @@ public:
GUI_HidePreviewPanel, GUI_HidePreviewPanel,
GUI_AlwaysOnTop, GUI_AlwaysOnTop,
GUI_ToolButtonStyle, GUI_ToolButtonStyle,
#ifdef KEEPASSXC_DIST_FLATPAK
GUI_LaunchAtStartup, GUI_LaunchAtStartup,
#endif
GUI_ShowTrayIcon, GUI_ShowTrayIcon,
GUI_TrayIconAppearance, GUI_TrayIconAppearance,
GUI_MinimizeToTray, GUI_MinimizeToTray,

View File

@ -18,19 +18,17 @@
#include "NixUtils.h" #include "NixUtils.h"
#include "config-keepassx.h" #include "config-keepassx.h"
#include "core/Config.h"
#include <QApplication> #include <QApplication>
#include <QDBusInterface> #include <QDBusInterface>
#include <QDebug> #include <QDebug>
#include <QDir> #include <QDir>
#include <QPointer> #include <QPointer>
#include <QRandomGenerator>
#include <QStandardPaths> #include <QStandardPaths>
#include <QStyle> #include <QStyle>
#include <QTextStream> #include <QTextStream>
#ifdef KEEPASSXC_DIST_FLATPAK
#include "core/Config.h"
#include <QRandomGenerator>
#endif
#ifdef WITH_XC_X11 #ifdef WITH_XC_X11
#include <QX11Info> #include <QX11Info>
@ -127,9 +125,8 @@ QString NixUtils::getAutostartDesktopFilename(bool createDirs) const
bool NixUtils::isLaunchAtStartupEnabled() const bool NixUtils::isLaunchAtStartupEnabled() const
{ {
#if !defined(KEEPASSXC_DIST_FLATPAK) #ifndef KEEPASSXC_DIST_FLATPAK
return QFile::exists(getAutostartDesktopFilename()); return QFile::exists(getAutostartDesktopFilename());
;
#else #else
return config()->get(Config::GUI_LaunchAtStartup).toBool(); return config()->get(Config::GUI_LaunchAtStartup).toBool();
#endif #endif
@ -137,7 +134,7 @@ bool NixUtils::isLaunchAtStartupEnabled() const
void NixUtils::setLaunchAtStartup(bool enable) void NixUtils::setLaunchAtStartup(bool enable)
{ {
#if !defined(KEEPASSXC_DIST_FLATPAK) #ifndef KEEPASSXC_DIST_FLATPAK
if (enable) { if (enable) {
QFile desktopFile(getAutostartDesktopFilename(true)); QFile desktopFile(getAutostartDesktopFilename(true));
if (!desktopFile.open(QIODevice::WriteOnly)) { if (!desktopFile.open(QIODevice::WriteOnly)) {
@ -199,7 +196,7 @@ void NixUtils::setLaunchAtStartup(bool enable)
SLOT(launchAtStartupRequested(uint, QVariantMap))); SLOT(launchAtStartupRequested(uint, QVariantMap)));
if (!res) { if (!res) {
qDebug() << "Could not connect to org.freedesktop.portal.Request::Response signal"; qDebug() << "DBus Error: could not connect to org.freedesktop.portal.Request";
} }
#endif #endif
} }
@ -207,14 +204,11 @@ void NixUtils::setLaunchAtStartup(bool enable)
void NixUtils::launchAtStartupRequested(uint response, const QVariantMap& results) void NixUtils::launchAtStartupRequested(uint response, const QVariantMap& results)
{ {
if (response > 0) { if (response > 0) {
qDebug() << "The interaction was cancelled"; qDebug() << "DBus Error: the request to autostart was cancelled.";
return; return;
} }
bool isLauchedAtStartup = results["autostart"].value<bool>();
qDebug() << "The autostart value is set to:" << isLauchedAtStartup; config()->set(Config::GUI_LaunchAtStartup, results["autostart"].value<bool>());
#if defined(KEEPASSXC_DIST_FLATPAK)
config()->set(Config::GUI_LaunchAtStartup, isLauchedAtStartup);
#endif
} }
bool NixUtils::isCapslockEnabled() bool NixUtils::isCapslockEnabled()