Skip to content

Commit

Permalink
Merge pull request #51 from sailfishos-applications/config
Browse files Browse the repository at this point in the history
Change the organisation name
  • Loading branch information
Olf0 authored Feb 8, 2024
2 parents 080c241 + 1802118 commit aeb427e
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 21 deletions.
63 changes: 61 additions & 2 deletions src/FlowPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,78 @@
bool isDBOpened;
bool databaseWorking;

static void migrateSettings()
{
const QString oldSettings = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/cepiperez/flowplayer.conf";
const QString newSettings = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + ".conf";
if (QFile::exists(oldSettings)) {
if (QDir().mkpath(QFileInfo(newSettings).path())
&& !QFile::rename(oldSettings, newSettings)) {
qWarning() << "unable to move old configuration from" << oldSettings << "to" << newSettings;
}
QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)).rmdir("cepiperez");
}
}

static void migrateDatabase()
{
const QString olderDb = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/cepiperez/flowplayer.db";
const QString oldDb = QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/flowplayer/flowplayer/flowplayer.db";
const QString newDb = QStandardPaths::writableLocation(QStandardPaths::AppConfigLocation) + "/flowplayer.db";
if (QFile::exists(oldDb)) {
if (QDir().mkpath(QFileInfo(newDb).path())
&& !QFile::rename(oldDb, newDb)) {
qWarning() << "unable to move old database from" << oldDb << "to" << newDb;
}
QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation) + "/flowplayer").rmdir("flowplayer");
QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)).rmdir("flowplayer");
} else if (QFile::exists(olderDb)) {
if (QDir().mkpath(QFileInfo(newDb).path())
&& !QFile::rename(olderDb, newDb)) {
qWarning() << "unable to move old database from" << olderDb << "to" << newDb;
}
QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)).rmdir("cepiperez");
}
}

static void migrateCache()
{
const QString olderCache = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/flowplayer";
const QString oldCache = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/flowplayer/flowplayer";
const QString newCache = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
if (QFileInfo(oldCache).isDir()) {
if (QDir().mkpath(QFileInfo(newCache).path())
&& !QDir().rename(oldCache, newCache)) {
qWarning() << "unable to move old cache from" << oldCache << "to" << newCache;
}
QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + "/flowplayer").rmdir("flowplayer");
QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).rmdir("flowplayer");
} else if (QFileInfo(olderCache).isDir()) {
if (QDir().mkpath(QFileInfo(newCache).path())
&& !QDir().rename(olderCache, newCache)) {
qWarning() << "unable to move old cache from" << olderCache << "to" << newCache;
}
QDir(QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation)).rmdir("flowplayer");
}
}

int main(int argc, char *argv[])
{
QTextCodec *linuxCodec = QTextCodec::codecForName("UTF-8");
QTextCodec::setCodecForLocale(linuxCodec);

QGuiApplication *app = SailfishApp::application(argc, argv);
app->setOrganizationName("flowplayer");
app->setOrganizationName("sailfishos-applications");
app->setApplicationName("flowplayer");

migrateSettings();
migrateDatabase();
migrateCache();

QString lang;
QTranslator translator;

QSettings settings("cepiperez", "flowplayer");
QSettings settings;
lang = settings.value("Language", "undefined").toString();

if (lang=="undefined")
Expand Down
2 changes: 1 addition & 1 deletion src/coversearch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ void CoverSearch::remove(const QString &file)
QString nf = file;
if ( nf.startsWith("//") )
nf.remove(0, 1);
QSettings settings("cepiperez", "flowplayer");
QSettings settings;
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 @@ -237,7 +237,7 @@ void DataReader::run()
favFiles.clear();
map.clear();

QSettings settings("cepiperez", "flowplayer");
QSettings settings;
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("cepiperez", "flowplayer");
QSettings settings;
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("cepiperez", "flowplayer");
QSettings settings;
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("cepiperez", "flowplayer");
QSettings settings;
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("cepiperez", "flowplayer");
QSettings sets;
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("cepiperez", "flowplayer");
QSettings sets;
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("cepiperez", "flowplayer");
QSettings sets;
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("cepiperez", "flowplayer");
QSettings sets;
lang = sets.value("LastFMlang", "en").toString();
songInfo = tr("Fetching track information");
songInfoLarge = "";
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("cepiperez", "flowplayer");
QSettings sets;
QString torder = sets.value("TrackOrder", "title").toString();
QString order;
if (torder=="title") order="title";
Expand Down
6 changes: 3 additions & 3 deletions src/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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("cepiperez", "flowplayer");
QSettings sets;
if (sets.value("GaplessPlayback", "no").toString()=="no")
return;

Expand Down Expand Up @@ -421,7 +421,7 @@ void Player::backend_deinit()
void Player::setEq(bool enabled)
{
qDebug() << "Setting eq: " << enabled;
QSettings sets("cepiperez", "flowplayer");
QSettings sets;
sets.setValue("Equalizer", enabled? "Yes" : "No");
sets.sync();

Expand Down Expand Up @@ -472,7 +472,7 @@ void Player::setEqualizerReal(int band, int value)

void Player::loadEqualizer()
{
QSettings sets("cepiperez", "flowplayer");
QSettings sets;
m_eqenabled = sets.value("Equalizer", "No").toString()=="Yes";
emit eqEnabledChanged();

Expand Down
2 changes: 1 addition & 1 deletion src/playlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QXmlStreamReader>
#include <QDir>

QSettings sets("cepiperez", "flowplayer");
QSettings sets;
QList<int> randomlist;
int currentItem, currentRandom;

Expand Down
6 changes: 2 additions & 4 deletions src/playlistmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
extern bool databaseWorking;
extern bool isDBOpened;

QSettings pmsets("cepiperez", "flowplayer");

PlaylistManager::PlaylistManager(QQuickItem *parent)
: QQuickItem(parent)
{
Expand Down Expand Up @@ -91,7 +89,7 @@ void PlaylistManager::addAlbumToList(QString list, QString artist, QString album

if (!isDBOpened) openDatabase();

QSettings sets("cepiperez", "flowplayer");
QSettings sets;
QString torder = sets.value("TrackOrder", "title").toString();
QString order;
if (torder=="title") order="title";
Expand Down Expand Up @@ -433,7 +431,7 @@ void PlaylistManager::loadAlbum(QString artist, QString album, QString various)

if (!isDBOpened) openDatabase();

QSettings sets("cepiperez", "flowplayer");
QSettings sets;
QString torder = sets.value("TrackOrder", "title").toString();
QString order;
if (torder=="title") order="title";
Expand Down
2 changes: 1 addition & 1 deletion src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ QString albumArtUrl, albumArtArtist, albumArtAlbum;
QString currentArtist, currentSong;
QString searchServer;

QSettings settings("cepiperez", "flowplayer");
QSettings settings;

//extern bool isDBOpened;

Expand Down

0 comments on commit aeb427e

Please sign in to comment.