From 960052fac4cdb09c12f45ea2f92e1064cef32442 Mon Sep 17 00:00:00 2001 From: Damien Caliste Date: Tue, 18 Jun 2024 17:06:00 +0200 Subject: [PATCH] Use the app config dir to save the QSettings file. Sailjail is not mounting the generic config dir, so the QSettings file should be under org/app/ dir and not under the org/ dir. --- src/FlowPlayer.cpp | 4 ++- src/coversearch.cpp | 3 ++- src/datareader.cpp | 2 +- src/datos.cpp | 6 ++--- src/lfm.cpp | 8 +++--- src/loadimage.cpp | 1 - src/loadwebimage.cpp | 1 - src/missing.cpp | 1 - src/musicmodel.cpp | 2 +- src/player.cpp | 7 +++--- src/playlist.cpp | 8 +++--- src/playlistmanager.cpp | 5 ++-- src/utils.cpp | 54 ++++++++++++++++++++--------------------- 13 files changed, 52 insertions(+), 50 deletions(-) diff --git a/src/FlowPlayer.cpp b/src/FlowPlayer.cpp index a862eff..11477df 100644 --- a/src/FlowPlayer.cpp +++ b/src/FlowPlayer.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include #include "playlistmanager.h" #include "utils.h" @@ -34,7 +36,7 @@ int main(int argc, char *argv[]) QString lang; QTranslator translator; - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); lang = settings.value("Language", "undefined").toString(); if (lang=="undefined") diff --git a/src/coversearch.cpp b/src/coversearch.cpp index f01e95c..5b0ef66 100644 --- a/src/coversearch.cpp +++ b/src/coversearch.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #define BING_ID "A16EECFD14108C2794E4BC29D4DE59C308685B4A" @@ -165,7 +166,7 @@ void CoverSearch::remove(const QString &file) QString nf = file; if ( nf.startsWith("//") ) nf.remove(0, 1); - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); QStringList entries = settings.value("CoverSearch","").toStringList(); QStringList newfiles; for (int i=0; i< entries.count(); ++i) diff --git a/src/datareader.cpp b/src/datareader.cpp index c15bf09..8614f1e 100644 --- a/src/datareader.cpp +++ b/src/datareader.cpp @@ -271,7 +271,7 @@ void DataReader::run() favFiles.clear(); map.clear(); - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); QStringList folders = settings.value("Folders","").toString().split(""); folders.removeAll(""); diff --git a/src/datos.cpp b/src/datos.cpp index f202fbf..6e50681 100644 --- a/src/datos.cpp +++ b/src/datos.cpp @@ -233,7 +233,7 @@ void Datos::addFilterToQueue() }*/ QString norder; - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); QString order = settings.value("TrackOrder", "title").toString(); if (order=="title") norder="title"; @@ -429,7 +429,7 @@ QString Datos::getArtistsCovers() dato1.append(coverart); } - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); int first = settings.value("LastArtistItem", 0).toInt(); if (first >= dato1.count()) { @@ -463,7 +463,7 @@ QString Datos::getAlbumsCovers() dato1.append(coverart); } - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); int first = settings.value("LastAlbumItem", 0).toInt(); if (first >= dato1.count()) { diff --git a/src/lfm.cpp b/src/lfm.cpp index 34f4fe8..942a814 100644 --- a/src/lfm.cpp +++ b/src/lfm.cpp @@ -31,7 +31,7 @@ LFM::LFM(QQuickItem *parent) //connect(datos5, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloaded5(QNetworkReply*))); //connect(datos6, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloaded6(QNetworkReply*))); - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); lang = sets.value("LastFMlang", "en").toString(); } @@ -277,7 +277,7 @@ void LFM::getBio(QString artist) //if ( reply1 && reply1->isRunning() ) // reply1->abort(); - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); lang = sets.value("Language", "en").toString(); artistInfo = tr("Fetching artist information"); artistInfoLarge = ""; @@ -301,7 +301,7 @@ void LFM::getAlbumBio(QString artist, QString album) { /*if ( reply2 && reply2->isRunning() ) reply2->abort(); - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); lang = sets.value("LastFMlang", "en").toString(); albumInfo = tr("Fetching album information"); albumInfoLarge = ""; @@ -316,7 +316,7 @@ void LFM::getSongBio(QString artist, QString song) { /*if ( reply3 && reply3->isRunning() ) reply3->abort(); - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); lang = sets.value("LastFMlang", "en").toString(); songInfo = tr("Fetching track information"); songInfoLarge = ""; diff --git a/src/loadimage.cpp b/src/loadimage.cpp index ab21f6e..aefb58c 100644 --- a/src/loadimage.cpp +++ b/src/loadimage.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include diff --git a/src/loadwebimage.cpp b/src/loadwebimage.cpp index 600a1c9..ec3c7c1 100644 --- a/src/loadwebimage.cpp +++ b/src/loadwebimage.cpp @@ -7,7 +7,6 @@ #include #include #include -#include #include #include #include diff --git a/src/missing.cpp b/src/missing.cpp index 23e6eaf..dac16ae 100644 --- a/src/missing.cpp +++ b/src/missing.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include bool namefileLess(const QStringList &d1, const QStringList &d2) diff --git a/src/musicmodel.cpp b/src/musicmodel.cpp index 31d0f87..5ccf8ce 100644 --- a/src/musicmodel.cpp +++ b/src/musicmodel.cpp @@ -57,7 +57,7 @@ void MusicModel::loadData(QString artist, QString album, QString various) if (!isDBOpened) openDatabase(); - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); QString torder = sets.value("TrackOrder", "title").toString(); QString order; if (torder=="title") order="title"; diff --git a/src/player.cpp b/src/player.cpp index 1cddc58..0732592 100644 --- a/src/player.cpp +++ b/src/player.cpp @@ -3,6 +3,7 @@ #include #include +#include #include "QVariantMap" extern bool databaseWorking; @@ -20,7 +21,7 @@ static gboolean bus_cb (GstBus *bus, GstMessage *msg, gpointer data) static void prepare_next_stream(GstElement *obj, gpointer data) { qDebug() << "ABOUT TO FINISH"; - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); if (sets.value("GaplessPlayback", "no").toString()=="no") return; @@ -421,7 +422,7 @@ void Player::backend_deinit() void Player::setEq(bool enabled) { qDebug() << "Setting eq: " << enabled; - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); sets.setValue("Equalizer", enabled? "Yes" : "No"); sets.sync(); @@ -472,7 +473,7 @@ void Player::setEqualizerReal(int band, int value) void Player::loadEqualizer() { - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); m_eqenabled = sets.value("Equalizer", "No").toString()=="Yes"; emit eqEnabledChanged(); diff --git a/src/playlist.cpp b/src/playlist.cpp index dab9d31..8f2269d 100644 --- a/src/playlist.cpp +++ b/src/playlist.cpp @@ -24,14 +24,14 @@ int Playlist::current() QString Playlist::active() const { - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); QString t = sets.value("Active", "false").toString(); return t; } QString Playlist::unknown() const { - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); QString t = sets.value("Unknown", "false").toString(); return t; } @@ -416,7 +416,7 @@ void Playlist::changeUnknown(bool active) { //qDebug() << "CHANGING UKNOWN: " << active; - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); sets.setValue("Unknown", active); sets.sync(); } @@ -425,7 +425,7 @@ void Playlist::changeMode(QString mode) { //qDebug() << "CHANGING MODE: " << mode; - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); sets.setValue("Mode", mode); sets.sync(); } diff --git a/src/playlistmanager.cpp b/src/playlistmanager.cpp index 68167ad..38b514e 100644 --- a/src/playlistmanager.cpp +++ b/src/playlistmanager.cpp @@ -1,6 +1,7 @@ #include "playlistmanager.h" #include +#include #include #include #include @@ -89,7 +90,7 @@ void PlaylistManager::addAlbumToList(QString list, QString artist, QString album if (!isDBOpened) openDatabase(); - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); QString torder = sets.value("TrackOrder", "title").toString(); QString order; if (torder=="title") order="title"; @@ -431,7 +432,7 @@ void PlaylistManager::loadAlbum(QString artist, QString album, QString various) if (!isDBOpened) openDatabase(); - QSettings sets; + QSettings sets(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); QString torder = sets.value("TrackOrder", "title").toString(); QString order; if (torder=="title") order="title"; diff --git a/src/utils.cpp b/src/utils.cpp index 84a82fa..80472b8 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -440,81 +440,81 @@ void Utils::removePreview() void Utils::setSettings(QString set, QString val) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); settings.setValue(set, val); settings.sync(); } QString Utils::readSettings(QString set, QString val) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); return settings.value(set, val).toString(); } QString Utils::showReflection() { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); return settings.value("ShowReflection", "true").toString(); } QString Utils::viewmode() const { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); return settings.value("ViewMode", "grid").toString(); } QString Utils::paging() const { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); return settings.value("Paging", "multiple").toString(); } QString Utils::scrobble() const { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); return settings.value("Scrobble", "false").toString(); } QString Utils::order() const { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); return settings.value("SortOrder", "album").toString(); } QString Utils::lang() const { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); return settings.value("LastFMlang", "en").toString(); } QString Utils::updatestart() const { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); return settings.value("UpdateOnStartup", "no").toString(); } QString Utils::autosearch() const { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); return settings.value("AutoSearchLyrics", "yes").toString(); } QString Utils::cleanqueue() const { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); return settings.value("CleanQueue", "yes").toString(); } QString Utils::workoffline() const { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); return settings.value("WorkOffline", "no").toString(); } void Utils::setViewMode(QString val) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); settings.setValue("ViewMode", val); settings.sync(); emit viewmodeChanged(); @@ -522,7 +522,7 @@ void Utils::setViewMode(QString val) void Utils::setPaging(QString val) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); settings.setValue("Paging", val); settings.sync(); emit pagingChanged(); @@ -530,7 +530,7 @@ void Utils::setPaging(QString val) void Utils::setScrobble(QString val) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); settings.setValue("Scrobble", val); settings.sync(); emit scrobbleChanged(); @@ -538,7 +538,7 @@ void Utils::setScrobble(QString val) void Utils::setOrder(QString val) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); settings.setValue("SortOrder", val); settings.sync(); emit orderChanged(); @@ -546,7 +546,7 @@ void Utils::setOrder(QString val) void Utils::setLang(QString val) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); settings.setValue("LastFMlang", val); settings.sync(); emit langChanged(); @@ -554,7 +554,7 @@ void Utils::setLang(QString val) void Utils::setUpdateStart(QString val) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); settings.setValue("UpdateOnStartup", val); settings.sync(); emit updateChanged(); @@ -562,7 +562,7 @@ void Utils::setUpdateStart(QString val) void Utils::setAutoSearch(QString val) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); settings.setValue("AutoSearchLyrics", val); settings.sync(); emit autosearchChanged(); @@ -570,7 +570,7 @@ void Utils::setAutoSearch(QString val) void Utils::setCleanQueue(QString val) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); settings.setValue("CleanQueue", val); settings.sync(); emit queueChanged(); @@ -578,7 +578,7 @@ void Utils::setCleanQueue(QString val) void Utils::setWorkOffline(QString val) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); settings.setValue("WorkOffline", val); settings.sync(); emit workofflineChanged(); @@ -586,13 +586,13 @@ void Utils::setWorkOffline(QString val) QString Utils::orientation() const { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); return settings.value("Orientation", "auto").toString(); } void Utils::setOrientation(QString val) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); settings.setValue("Orientation", val); settings.sync(); emit orientationChanged(); @@ -607,7 +607,7 @@ QString Utils::plainLyrics(QString text) QString Utils::version() { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); return settings.value("Firmware", "PR10").toString(); } @@ -644,7 +644,7 @@ void Utils::removeAlbumArt() void Utils::getFolders() { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); QStringList folders = settings.value("Folders","").toString().split(""); folders.removeAll(""); @@ -708,7 +708,7 @@ void Utils::getFolderItems(QString path) void Utils::addFolderToList(QString path) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); QStringList folders = settings.value("Folders","").toString().split(""); folders.removeAll(""); folders.append(path); @@ -720,7 +720,7 @@ void Utils::addFolderToList(QString path) void Utils::removeFolder(QString path) { - QSettings settings; + QSettings settings(QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.conf", QSettings::NativeFormat); QStringList folders = settings.value("Folders","").toString().split(""); folders.removeAll(""); folders.removeAll(path);