2026-01-18 12:13:07 +00:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
// SPDX-FileCopyrightText: 2026 A-La-Karte Contributors
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include <KConfigGroup>
|
|
|
|
|
#include <KSharedConfig>
|
|
|
|
|
|
|
|
|
|
Config::Config(QObject *parent)
|
|
|
|
|
: QObject(parent)
|
|
|
|
|
{
|
|
|
|
|
load();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Config::ViewMode Config::viewMode() const
|
|
|
|
|
{
|
|
|
|
|
return m_viewMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setViewMode(ViewMode mode)
|
|
|
|
|
{
|
|
|
|
|
if (m_viewMode != mode) {
|
|
|
|
|
m_viewMode = mode;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT viewModeChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-24 12:27:30 +00:00
|
|
|
Config::UiMode Config::uiMode() const
|
|
|
|
|
{
|
|
|
|
|
return m_uiMode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setUiMode(UiMode mode)
|
|
|
|
|
{
|
|
|
|
|
if (m_uiMode != mode) {
|
|
|
|
|
m_uiMode = mode;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT uiModeChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-18 12:13:07 +00:00
|
|
|
int Config::gridSize() const
|
|
|
|
|
{
|
|
|
|
|
return m_gridSize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setGridSize(int size)
|
|
|
|
|
{
|
|
|
|
|
size = qBound(100, size, 300);
|
|
|
|
|
if (m_gridSize != size) {
|
|
|
|
|
m_gridSize = size;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT gridSizeChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::showPlatformBadges() const
|
|
|
|
|
{
|
|
|
|
|
return m_showPlatformBadges;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setShowPlatformBadges(bool show)
|
|
|
|
|
{
|
|
|
|
|
if (m_showPlatformBadges != show) {
|
|
|
|
|
m_showPlatformBadges = show;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT showPlatformBadgesChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::autoImportOnStartup() const
|
|
|
|
|
{
|
|
|
|
|
return m_autoImportOnStartup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setAutoImportOnStartup(bool import)
|
|
|
|
|
{
|
|
|
|
|
if (m_autoImportOnStartup != import) {
|
|
|
|
|
m_autoImportOnStartup = import;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT autoImportOnStartupChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::importSteam() const
|
|
|
|
|
{
|
|
|
|
|
return m_importSteam;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setImportSteam(bool import)
|
|
|
|
|
{
|
|
|
|
|
if (m_importSteam != import) {
|
|
|
|
|
m_importSteam = import;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT importSteamChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::importLutris() const
|
|
|
|
|
{
|
|
|
|
|
return m_importLutris;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setImportLutris(bool import)
|
|
|
|
|
{
|
|
|
|
|
if (m_importLutris != import) {
|
|
|
|
|
m_importLutris = import;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT importLutrisChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::importHeroic() const
|
|
|
|
|
{
|
|
|
|
|
return m_importHeroic;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setImportHeroic(bool import)
|
|
|
|
|
{
|
|
|
|
|
if (m_importHeroic != import) {
|
|
|
|
|
m_importHeroic = import;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT importHeroicChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::importDesktop() const
|
|
|
|
|
{
|
|
|
|
|
return m_importDesktop;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setImportDesktop(bool import)
|
|
|
|
|
{
|
|
|
|
|
if (m_importDesktop != import) {
|
|
|
|
|
m_importDesktop = import;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT importDesktopChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::importBottles() const
|
|
|
|
|
{
|
|
|
|
|
return m_importBottles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setImportBottles(bool import)
|
|
|
|
|
{
|
|
|
|
|
if (m_importBottles != import) {
|
|
|
|
|
m_importBottles = import;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT importBottlesChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::importFlatpak() const
|
|
|
|
|
{
|
|
|
|
|
return m_importFlatpak;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setImportFlatpak(bool import)
|
|
|
|
|
{
|
|
|
|
|
if (m_importFlatpak != import) {
|
|
|
|
|
m_importFlatpak = import;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT importFlatpakChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::importItch() const
|
|
|
|
|
{
|
|
|
|
|
return m_importItch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setImportItch(bool import)
|
|
|
|
|
{
|
|
|
|
|
if (m_importItch != import) {
|
|
|
|
|
m_importItch = import;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT importItchChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::importLegendary() const
|
|
|
|
|
{
|
|
|
|
|
return m_importLegendary;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setImportLegendary(bool import)
|
|
|
|
|
{
|
|
|
|
|
if (m_importLegendary != import) {
|
|
|
|
|
m_importLegendary = import;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT importLegendaryChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::importRetroArch() const
|
|
|
|
|
{
|
|
|
|
|
return m_importRetroArch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setImportRetroArch(bool import)
|
|
|
|
|
{
|
|
|
|
|
if (m_importRetroArch != import) {
|
|
|
|
|
m_importRetroArch = import;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT importRetroArchChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::exitAfterLaunch() const
|
|
|
|
|
{
|
|
|
|
|
return m_exitAfterLaunch;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setExitAfterLaunch(bool exit)
|
|
|
|
|
{
|
|
|
|
|
if (m_exitAfterLaunch != exit) {
|
|
|
|
|
m_exitAfterLaunch = exit;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT exitAfterLaunchChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::coverLaunchesGame() const
|
|
|
|
|
{
|
|
|
|
|
return m_coverLaunchesGame;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setCoverLaunchesGame(bool launch)
|
|
|
|
|
{
|
|
|
|
|
if (m_coverLaunchesGame != launch) {
|
|
|
|
|
m_coverLaunchesGame = launch;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT coverLaunchesGameChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::highQualityImages() const
|
|
|
|
|
{
|
|
|
|
|
return m_highQualityImages;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setHighQualityImages(bool hq)
|
|
|
|
|
{
|
|
|
|
|
if (m_highQualityImages != hq) {
|
|
|
|
|
m_highQualityImages = hq;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT highQualityImagesChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Config::animatedCovers() const
|
|
|
|
|
{
|
|
|
|
|
return m_animatedCovers;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setAnimatedCovers(bool animated)
|
|
|
|
|
{
|
|
|
|
|
if (m_animatedCovers != animated) {
|
|
|
|
|
m_animatedCovers = animated;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT animatedCoversChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString Config::theme() const
|
|
|
|
|
{
|
|
|
|
|
return m_theme;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::setTheme(const QString &theme)
|
|
|
|
|
{
|
|
|
|
|
if (m_theme != theme) {
|
|
|
|
|
m_theme = theme;
|
|
|
|
|
save();
|
|
|
|
|
Q_EMIT themeChanged();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::save()
|
|
|
|
|
{
|
|
|
|
|
const auto config = KSharedConfig::openConfig(QStringLiteral("alakarterc"));
|
|
|
|
|
|
|
|
|
|
KConfigGroup generalGroup(config, QStringLiteral("General"));
|
|
|
|
|
generalGroup.writeEntry(QStringLiteral("viewMode"), static_cast<int>(m_viewMode));
|
2026-01-24 12:27:30 +00:00
|
|
|
generalGroup.writeEntry(QStringLiteral("uiMode"), static_cast<int>(m_uiMode));
|
2026-01-18 12:13:07 +00:00
|
|
|
generalGroup.writeEntry(QStringLiteral("gridSize"), m_gridSize);
|
|
|
|
|
generalGroup.writeEntry(QStringLiteral("showPlatformBadges"), m_showPlatformBadges);
|
|
|
|
|
generalGroup.writeEntry(QStringLiteral("theme"), m_theme);
|
|
|
|
|
|
|
|
|
|
KConfigGroup importGroup(config, QStringLiteral("Import"));
|
|
|
|
|
importGroup.writeEntry(QStringLiteral("autoImportOnStartup"), m_autoImportOnStartup);
|
|
|
|
|
importGroup.writeEntry(QStringLiteral("steam"), m_importSteam);
|
|
|
|
|
importGroup.writeEntry(QStringLiteral("lutris"), m_importLutris);
|
|
|
|
|
importGroup.writeEntry(QStringLiteral("heroic"), m_importHeroic);
|
|
|
|
|
importGroup.writeEntry(QStringLiteral("desktop"), m_importDesktop);
|
|
|
|
|
importGroup.writeEntry(QStringLiteral("bottles"), m_importBottles);
|
|
|
|
|
importGroup.writeEntry(QStringLiteral("flatpak"), m_importFlatpak);
|
|
|
|
|
importGroup.writeEntry(QStringLiteral("itch"), m_importItch);
|
|
|
|
|
importGroup.writeEntry(QStringLiteral("legendary"), m_importLegendary);
|
|
|
|
|
importGroup.writeEntry(QStringLiteral("retroarch"), m_importRetroArch);
|
|
|
|
|
|
|
|
|
|
KConfigGroup behaviorGroup(config, QStringLiteral("Behavior"));
|
|
|
|
|
behaviorGroup.writeEntry(QStringLiteral("highQualityImages"), m_highQualityImages);
|
|
|
|
|
behaviorGroup.writeEntry(QStringLiteral("animatedCovers"), m_animatedCovers);
|
|
|
|
|
behaviorGroup.writeEntry(QStringLiteral("exitAfterLaunch"), m_exitAfterLaunch);
|
|
|
|
|
behaviorGroup.writeEntry(QStringLiteral("coverLaunchesGame"), m_coverLaunchesGame);
|
|
|
|
|
|
|
|
|
|
config->sync();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::load()
|
|
|
|
|
{
|
|
|
|
|
const auto config = KSharedConfig::openConfig(QStringLiteral("alakarterc"));
|
|
|
|
|
|
|
|
|
|
const KConfigGroup generalGroup(config, QStringLiteral("General"));
|
|
|
|
|
m_viewMode = static_cast<ViewMode>(generalGroup.readEntry(QStringLiteral("viewMode"), static_cast<int>(GridView)));
|
2026-01-24 12:27:30 +00:00
|
|
|
m_uiMode = static_cast<UiMode>(generalGroup.readEntry(QStringLiteral("uiMode"), static_cast<int>(Auto)));
|
2026-01-18 12:13:07 +00:00
|
|
|
m_gridSize = generalGroup.readEntry(QStringLiteral("gridSize"), 180);
|
|
|
|
|
m_showPlatformBadges = generalGroup.readEntry(QStringLiteral("showPlatformBadges"), true);
|
|
|
|
|
m_theme = generalGroup.readEntry(QStringLiteral("theme"), QString());
|
|
|
|
|
|
|
|
|
|
const KConfigGroup importGroup(config, QStringLiteral("Import"));
|
|
|
|
|
m_autoImportOnStartup = importGroup.readEntry(QStringLiteral("autoImportOnStartup"), false);
|
|
|
|
|
m_importSteam = importGroup.readEntry(QStringLiteral("steam"), true);
|
|
|
|
|
m_importLutris = importGroup.readEntry(QStringLiteral("lutris"), true);
|
|
|
|
|
m_importHeroic = importGroup.readEntry(QStringLiteral("heroic"), true);
|
|
|
|
|
m_importDesktop = importGroup.readEntry(QStringLiteral("desktop"), true);
|
|
|
|
|
m_importBottles = importGroup.readEntry(QStringLiteral("bottles"), true);
|
|
|
|
|
m_importFlatpak = importGroup.readEntry(QStringLiteral("flatpak"), true);
|
|
|
|
|
m_importItch = importGroup.readEntry(QStringLiteral("itch"), true);
|
|
|
|
|
m_importLegendary = importGroup.readEntry(QStringLiteral("legendary"), true);
|
|
|
|
|
m_importRetroArch = importGroup.readEntry(QStringLiteral("retroarch"), true);
|
|
|
|
|
|
|
|
|
|
const KConfigGroup behaviorGroup(config, QStringLiteral("Behavior"));
|
|
|
|
|
m_highQualityImages = behaviorGroup.readEntry(QStringLiteral("highQualityImages"), true);
|
|
|
|
|
m_animatedCovers = behaviorGroup.readEntry(QStringLiteral("animatedCovers"), false);
|
|
|
|
|
m_exitAfterLaunch = behaviorGroup.readEntry(QStringLiteral("exitAfterLaunch"), false);
|
|
|
|
|
m_coverLaunchesGame = behaviorGroup.readEntry(QStringLiteral("coverLaunchesGame"), false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Config::resetToDefaults()
|
|
|
|
|
{
|
|
|
|
|
m_viewMode = GridView;
|
2026-01-24 12:27:30 +00:00
|
|
|
m_uiMode = Auto;
|
2026-01-18 12:13:07 +00:00
|
|
|
m_gridSize = 180;
|
|
|
|
|
m_showPlatformBadges = true;
|
|
|
|
|
m_autoImportOnStartup = false;
|
|
|
|
|
m_importSteam = true;
|
|
|
|
|
m_importLutris = true;
|
|
|
|
|
m_importHeroic = true;
|
|
|
|
|
m_importDesktop = true;
|
|
|
|
|
m_importBottles = true;
|
|
|
|
|
m_importFlatpak = true;
|
|
|
|
|
m_importItch = true;
|
|
|
|
|
m_importLegendary = true;
|
|
|
|
|
m_importRetroArch = true;
|
|
|
|
|
m_exitAfterLaunch = false;
|
|
|
|
|
m_coverLaunchesGame = false;
|
|
|
|
|
m_highQualityImages = true;
|
|
|
|
|
m_animatedCovers = false;
|
|
|
|
|
m_theme.clear();
|
|
|
|
|
|
|
|
|
|
save();
|
|
|
|
|
|
|
|
|
|
Q_EMIT viewModeChanged();
|
2026-01-24 12:27:30 +00:00
|
|
|
Q_EMIT uiModeChanged();
|
2026-01-18 12:13:07 +00:00
|
|
|
Q_EMIT gridSizeChanged();
|
|
|
|
|
Q_EMIT showPlatformBadgesChanged();
|
|
|
|
|
Q_EMIT autoImportOnStartupChanged();
|
|
|
|
|
Q_EMIT importSteamChanged();
|
|
|
|
|
Q_EMIT importLutrisChanged();
|
|
|
|
|
Q_EMIT importHeroicChanged();
|
|
|
|
|
Q_EMIT importDesktopChanged();
|
|
|
|
|
Q_EMIT importBottlesChanged();
|
|
|
|
|
Q_EMIT importFlatpakChanged();
|
|
|
|
|
Q_EMIT importItchChanged();
|
|
|
|
|
Q_EMIT importLegendaryChanged();
|
|
|
|
|
Q_EMIT importRetroArchChanged();
|
|
|
|
|
Q_EMIT exitAfterLaunchChanged();
|
|
|
|
|
Q_EMIT coverLaunchesGameChanged();
|
|
|
|
|
Q_EMIT highQualityImagesChanged();
|
|
|
|
|
Q_EMIT animatedCoversChanged();
|
|
|
|
|
Q_EMIT themeChanged();
|
|
|
|
|
}
|