Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[utils.cpp] Avoid creating QSettings too early #65

Merged
merged 1 commit into from
Feb 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ QString albumArtUrl, albumArtArtist, albumArtAlbum;
QString currentArtist, currentSong;
QString searchServer;

QSettings settings;

//extern bool isDBOpened;

Utils::Utils(QQuickItem *parent)
Expand Down Expand Up @@ -442,136 +440,159 @@ void Utils::removePreview()

void Utils::setSettings(QString set, QString val)
{
QSettings settings;
settings.setValue(set, val);
settings.sync();
}

QString Utils::readSettings(QString set, QString val)
{
QSettings settings;
return settings.value(set, val).toString();
}

QString Utils::showReflection()
{
QSettings settings;
return settings.value("ShowReflection", "true").toString();
}

QString Utils::viewmode() const
{
QSettings settings;
return settings.value("ViewMode", "grid").toString();
}

QString Utils::paging() const
{
QSettings settings;
return settings.value("Paging", "multiple").toString();
}

QString Utils::scrobble() const
{
QSettings settings;
return settings.value("Scrobble", "false").toString();
}

QString Utils::order() const
{
QSettings settings;
return settings.value("SortOrder", "album").toString();
}

QString Utils::lang() const
{
QSettings settings;
return settings.value("LastFMlang", "en").toString();
}

QString Utils::updatestart() const
{
QSettings settings;
return settings.value("UpdateOnStartup", "no").toString();
}

QString Utils::autosearch() const
{
QSettings settings;
return settings.value("AutoSearchLyrics", "yes").toString();
}

QString Utils::cleanqueue() const
{
QSettings settings;
return settings.value("CleanQueue", "yes").toString();
}

QString Utils::workoffline() const
{
QSettings settings;
return settings.value("WorkOffline", "no").toString();
}


void Utils::setViewMode(QString val)
{
QSettings settings;
settings.setValue("ViewMode", val);
settings.sync();
emit viewmodeChanged();
}

void Utils::setPaging(QString val)
{
QSettings settings;
settings.setValue("Paging", val);
settings.sync();
emit pagingChanged();
}

void Utils::setScrobble(QString val)
{
QSettings settings;
settings.setValue("Scrobble", val);
settings.sync();
emit scrobbleChanged();
}

void Utils::setOrder(QString val)
{
QSettings settings;
settings.setValue("SortOrder", val);
settings.sync();
emit orderChanged();
}

void Utils::setLang(QString val)
{
QSettings settings;
settings.setValue("LastFMlang", val);
settings.sync();
emit langChanged();
}

void Utils::setUpdateStart(QString val)
{
QSettings settings;
settings.setValue("UpdateOnStartup", val);
settings.sync();
emit updateChanged();
}

void Utils::setAutoSearch(QString val)
{
QSettings settings;
settings.setValue("AutoSearchLyrics", val);
settings.sync();
emit autosearchChanged();
}

void Utils::setCleanQueue(QString val)
{
QSettings settings;
settings.setValue("CleanQueue", val);
settings.sync();
emit queueChanged();
}

void Utils::setWorkOffline(QString val)
{
QSettings settings;
settings.setValue("WorkOffline", val);
settings.sync();
emit workofflineChanged();
}

QString Utils::orientation() const
{
QSettings settings;
return settings.value("Orientation", "auto").toString();
}

void Utils::setOrientation(QString val)
{
QSettings settings;
settings.setValue("Orientation", val);
settings.sync();
emit orientationChanged();
Expand All @@ -586,6 +607,7 @@ QString Utils::plainLyrics(QString text)

QString Utils::version()
{
QSettings settings;
return settings.value("Firmware", "PR10").toString();
}

Expand Down Expand Up @@ -622,6 +644,7 @@ void Utils::removeAlbumArt()

void Utils::getFolders()
{
QSettings settings;
QStringList folders = settings.value("Folders","").toString().split("<separator>");
folders.removeAll("");

Expand Down Expand Up @@ -684,6 +707,7 @@ void Utils::getFolderItems(QString path)

void Utils::addFolderToList(QString path)
{
QSettings settings;
QStringList folders = settings.value("Folders","").toString().split("<separator>");
folders.removeAll("");
folders.append(path);
Expand All @@ -695,6 +719,7 @@ void Utils::addFolderToList(QString path)

void Utils::removeFolder(QString path)
{
QSettings settings;
QStringList folders = settings.value("Folders","").toString().split("<separator>");
folders.removeAll("");
folders.removeAll(path);
Expand Down
Loading