Skip to content
This repository has been archived by the owner on Jul 8, 2024. It is now read-only.

Commit

Permalink
sailfish: Fix Sailjail and use new settings location, migrate the old…
Browse files Browse the repository at this point in the history
… settings
  • Loading branch information
DeathByDenim authored and Thaodan committed Feb 14, 2023
1 parent 0fdf15b commit 22e5be0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion sailfish/harbour-quickddit.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Name=Quickddit
Icon=harbour-quickddit
Exec=harbour-quickddit

[X-SailJail]
[X-Sailjail]
Permissions=Internet;Audio;Pictures;WebView
OrganizationName=nl.outrightsolutions
ApplicationName=Quickddit
29 changes: 26 additions & 3 deletions src/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,34 @@
#include "settings.h"

#include <QtCore/QSettings>
#include <QDebug>
#include <QStandardPaths>
#include <QCoreApplication>
#include <QFile>
#include <QDir>

Settings::Settings(QObject *parent) :
QObject(parent), m_settings(new QSettings(this))
{
QObject(parent)
{
const QString settings_path =
QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation)
+ "/" + QCoreApplication::applicationName() + ".conf";
QFile settings_file(settings_path);

// Migrate old settings and delete them
const QString old_settings_path =
QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) +
"/harbour-quickddit/harbour-quickddit.conf";
QFile old_settings_file(old_settings_path);

if(old_settings_file.exists() && !settings_file.exists()) {
QDir().mkpath(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation));
if(old_settings_file.copy(settings_path)) {
old_settings_file.remove();
QDir().rmdir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/harbour-quickddit");
}
}

m_settings = new QSettings(settings_path, QSettings::NativeFormat, this);
m_commentsTapToHide = m_settings->value("commentsTapToHide", true).toBool();
m_fontSize = static_cast<FontSize>(m_settings->value("fontSize", Settings::SmallFontSize).toInt());
m_redditUsername = m_settings->value("redditUsername").toString();
Expand Down

0 comments on commit 22e5be0

Please sign in to comment.