Skip to content

Commit

Permalink
Use the app config dir to save the QSettings file.
Browse files Browse the repository at this point in the history
Sailjail is not mounting the generic config dir,
so the QSettings file should be under org/app/
dir and not under the org/ dir.
  • Loading branch information
dcaliste committed Jun 18, 2024
1 parent 19a9ec1 commit 960052f
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 50 deletions.
4 changes: 3 additions & 1 deletion src/FlowPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <sailfishapp.h>
#include <QObject>
#include <QTextCodec>
#include <QSettings>
#include <QStandardPaths>

#include "playlistmanager.h"
#include "utils.h"
Expand Down Expand Up @@ -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")
Expand Down
3 changes: 2 additions & 1 deletion src/coversearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <QStringList>
#include <QJsonDocument>
#include <QJsonObject>
#include <QSettings>
#include <QStandardPaths>

#define BING_ID "A16EECFD14108C2794E4BC29D4DE59C308685B4A"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/datareader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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("<separator>");
folders.removeAll("");

Expand Down
6 changes: 3 additions & 3 deletions src/datos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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()) {
Expand Down
8 changes: 4 additions & 4 deletions src/lfm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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 = "";
Expand All @@ -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 = "";
Expand All @@ -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 = "";
Expand Down
1 change: 0 additions & 1 deletion src/loadimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include <qfileinfo.h>
#include <qdir.h>
#include <QImage>
#include <QSettings>
#include <QDebug>
#include <QStandardPaths>

Expand Down
1 change: 0 additions & 1 deletion src/loadwebimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <qfileinfo.h>
#include <qdir.h>
#include <QImage>
#include <QSettings>
#include <QDebug>
#include <QDateTime>
#include <QStandardPaths>
Expand Down
1 change: 0 additions & 1 deletion src/missing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <QImage>
#include <QStringList>
#include <QXmlStreamReader>
#include <QSettings>
#include <QStandardPaths>

bool namefileLess(const QStringList &d1, const QStringList &d2)
Expand Down
2 changes: 1 addition & 1 deletion src/musicmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
7 changes: 4 additions & 3 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include <QTimer>
#include <QSettings>
#include <QStandardPaths>
#include "QVariantMap"

extern bool databaseWorking;
Expand All @@ -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;

Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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();

Expand Down
8 changes: 4 additions & 4 deletions src/playlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down
5 changes: 3 additions & 2 deletions src/playlistmanager.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "playlistmanager.h"

#include <QSettings>
#include <QStandardPaths>
#include <QFileInfo>
#include <QXmlStreamReader>
#include <QDir>
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
Loading

0 comments on commit 960052f

Please sign in to comment.