Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Flatpak config issues #10688

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading