Skip to content

Commit

Permalink
Fix Flatpak config issues
Browse files Browse the repository at this point in the history
Remove #ifdef guards from Config.h/cpp (no harm to non-Flatpak distros)

Cleanup #ifdef usage in NixUtils.cpp
  • Loading branch information
droidmonkey committed May 27, 2024
1 parent 8cd45f5 commit a5c7f7b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
2 changes: 0 additions & 2 deletions src/core/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
{Config::GUI_HidePreviewPanel, {QS("GUI/HidePreviewPanel"), Roaming, false}},
{Config::GUI_AlwaysOnTop, {QS("GUI/GUI_AlwaysOnTop"), Local, false}},
{Config::GUI_ToolButtonStyle, {QS("GUI/ToolButtonStyle"), Roaming, Qt::ToolButtonIconOnly}},
#ifdef KEEPASSXC_DIST_FLATPAK
{Config::GUI_LaunchAtStartup, {QS("GUI/LaunchAtStartup"), Roaming, false}},
#endif
{Config::GUI_ShowTrayIcon, {QS("GUI/ShowTrayIcon"), Roaming, false}},
{Config::GUI_TrayIconAppearance, {QS("GUI/TrayIconAppearance"), Roaming, {}}},
{Config::GUI_MinimizeToTray, {QS("GUI/MinimizeToTray"), Roaming, false}},
Expand Down
2 changes: 0 additions & 2 deletions src/core/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,7 @@ class Config : public QObject
GUI_HidePreviewPanel,
GUI_AlwaysOnTop,
GUI_ToolButtonStyle,
#ifdef KEEPASSXC_DIST_FLATPAK
GUI_LaunchAtStartup,
#endif
GUI_ShowTrayIcon,
GUI_TrayIconAppearance,
GUI_MinimizeToTray,
Expand Down
22 changes: 8 additions & 14 deletions src/gui/osutils/nixutils/NixUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@
#include "NixUtils.h"

#include "config-keepassx.h"
#include "core/Config.h"

#include <QApplication>
#include <QDBusInterface>
#include <QDebug>
#include <QDir>
#include <QPointer>
#include <QRandomGenerator>
#include <QStandardPaths>
#include <QStyle>
#include <QTextStream>
#ifdef KEEPASSXC_DIST_FLATPAK
#include "core/Config.h"
#include <QRandomGenerator>
#endif
#ifdef WITH_XC_X11
#include <QX11Info>

Expand Down Expand Up @@ -127,17 +125,16 @@ QString NixUtils::getAutostartDesktopFilename(bool createDirs) const

bool NixUtils::isLaunchAtStartupEnabled() const
{
#if !defined(KEEPASSXC_DIST_FLATPAK)
#ifndef KEEPASSXC_DIST_FLATPAK
return QFile::exists(getAutostartDesktopFilename());
;
#else
return config()->get(Config::GUI_LaunchAtStartup).toBool();
#endif
}

void NixUtils::setLaunchAtStartup(bool enable)
{
#if !defined(KEEPASSXC_DIST_FLATPAK)
#ifndef KEEPASSXC_DIST_FLATPAK
if (enable) {
QFile desktopFile(getAutostartDesktopFilename(true));
if (!desktopFile.open(QIODevice::WriteOnly)) {
Expand Down Expand Up @@ -199,22 +196,19 @@ void NixUtils::setLaunchAtStartup(bool enable)
SLOT(launchAtStartupRequested(uint, QVariantMap)));

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
}

void NixUtils::launchAtStartupRequested(uint response, const QVariantMap& results)
{
if (response > 0) {
qDebug() << "The interaction was cancelled";
qDebug() << "DBus Error: the request to autostart was cancelled.";
return;
}
bool isLauchedAtStartup = results["autostart"].value<bool>();
qDebug() << "The autostart value is set to:" << isLauchedAtStartup;
#if defined(KEEPASSXC_DIST_FLATPAK)
config()->set(Config::GUI_LaunchAtStartup, isLauchedAtStartup);
#endif

config()->set(Config::GUI_LaunchAtStartup, results["autostart"].value<bool>());
}

bool NixUtils::isCapslockEnabled()
Expand Down

0 comments on commit a5c7f7b

Please sign in to comment.