#include "core/logging.h"
+#include "core/settings.h"
#include "lyricsprovider.h"
#include "lyricsproviders.h"
@@ -55,7 +56,7 @@ void LyricsProviders::ReloadSettings() {
all_providers.insert(provider->order(), provider->name());
}
- QSettings s;
+ Settings s;
s.beginGroup(LyricsSettingsPage::kSettingsGroup);
QStringList providers_enabled = s.value("providers", QStringList() << all_providers.values()).toStringList();
s.endGroup();
diff --git a/src/lyrics/musixmatchlyricsprovider.cpp b/src/lyrics/musixmatchlyricsprovider.cpp
index 0d9a18aebe..1be41f0e26 100644
--- a/src/lyrics/musixmatchlyricsprovider.cpp
+++ b/src/lyrics/musixmatchlyricsprovider.cpp
@@ -79,12 +79,12 @@ void MusixmatchLyricsProvider::CancelSearch(const int id) { Q_UNUSED(id); }
bool MusixmatchLyricsProvider::SendSearchRequest(LyricsSearchContextPtr search) {
QUrlQuery url_query;
- url_query.addQueryItem(QStringLiteral("apikey"), QByteArray::fromBase64(kApiKey));
- url_query.addQueryItem(QStringLiteral("q_artist"), QUrl::toPercentEncoding(search->request.artist));
- url_query.addQueryItem(QStringLiteral("q_track"), QUrl::toPercentEncoding(search->request.title));
+ url_query.addQueryItem(QStringLiteral("apikey"), QString::fromUtf8(QByteArray::fromBase64(kApiKey)));
+ url_query.addQueryItem(QStringLiteral("q_artist"), QString::fromUtf8(QUrl::toPercentEncoding(search->request.artist)));
+ url_query.addQueryItem(QStringLiteral("q_track"), QString::fromUtf8(QUrl::toPercentEncoding(search->request.title)));
url_query.addQueryItem(QStringLiteral("f_has_lyrics"), QStringLiteral("1"));
- QUrl url(QString(kApiUrl) + QStringLiteral("/track.search"));
+ QUrl url(QString::fromUtf8(kApiUrl) + QStringLiteral("/track.search"));
url.setQuery(url_query);
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
@@ -290,16 +290,16 @@ void MusixmatchLyricsProvider::HandleLyricsReply(QNetworkReply *reply, LyricsSea
return;
}
- QByteArray data = reply->readAll();
+ const QByteArray data = reply->readAll();
if (data.isEmpty()) {
Error(QStringLiteral("Empty reply received from server."));
EndSearch(search, url);
return;
}
- QString content = data;
- QString data_begin = QStringLiteral("");
+ const QString content = QString::fromUtf8(data);
+ const QString data_begin = QStringLiteral("");
qint64 begin_idx = content.indexOf(data_begin);
QString content_json;
if (begin_idx > 0) {
diff --git a/src/lyrics/ovhlyricsprovider.cpp b/src/lyrics/ovhlyricsprovider.cpp
index 6cde42d984..9c06e893eb 100644
--- a/src/lyrics/ovhlyricsprovider.cpp
+++ b/src/lyrics/ovhlyricsprovider.cpp
@@ -53,7 +53,7 @@ OVHLyricsProvider::~OVHLyricsProvider() {
bool OVHLyricsProvider::StartSearch(const int id, const LyricsSearchRequest &request) {
- QUrl url(kUrlSearch + QString(QUrl::toPercentEncoding(request.artist)) + "/" + QString(QUrl::toPercentEncoding(request.title)));
+ QUrl url(QString::fromUtf8(kUrlSearch) + QString::fromUtf8(QUrl::toPercentEncoding(request.artist)) + QStringLiteral("/") + QString::fromUtf8(QUrl::toPercentEncoding(request.title)));
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
QNetworkReply *reply = network_->get(req);
diff --git a/src/lyrics/songlyricscomlyricsprovider.cpp b/src/lyrics/songlyricscomlyricsprovider.cpp
index b2f1e79a61..ef606abaa5 100644
--- a/src/lyrics/songlyricscomlyricsprovider.cpp
+++ b/src/lyrics/songlyricscomlyricsprovider.cpp
@@ -27,28 +27,30 @@
#include "lyricssearchrequest.h"
#include "songlyricscomlyricsprovider.h"
-const char SongLyricsComLyricsProvider::kUrl[] = "https://www.songlyrics.com/";
-const char SongLyricsComLyricsProvider::kStartTag[] = "]*>";
-const char SongLyricsComLyricsProvider::kEndTag[] = "<\\/p>";
-const char SongLyricsComLyricsProvider::kLyricsStart[] = "
]+>";
+namespace {
+constexpr char kUrl[] = "https://www.songlyrics.com/";
+constexpr char kStartTag[] = "
]*>";
+constexpr char kEndTag[] = "<\\/p>";
+constexpr char kLyricsStart[] = "
]+>";
+} // namespace
SongLyricsComLyricsProvider::SongLyricsComLyricsProvider(SharedPtr network, QObject *parent)
- : HtmlLyricsProvider(QStringLiteral("songlyrics.com"), true, kStartTag, kEndTag, kLyricsStart, false, network, parent) {}
+ : HtmlLyricsProvider(QStringLiteral("songlyrics.com"), true, QLatin1String(kStartTag), QLatin1String(kEndTag), QLatin1String(kLyricsStart), false, network, parent) {}
QUrl SongLyricsComLyricsProvider::Url(const LyricsSearchRequest &request) {
- return QUrl(kUrl + StringFixup(request.artist) + "/" + StringFixup(request.title) + "-lyrics/");
+ return QUrl(QLatin1String(kUrl) + StringFixup(request.artist) + QLatin1Char('/') + StringFixup(request.title) + QStringLiteral("-lyrics/"));
}
QString SongLyricsComLyricsProvider::StringFixup(QString text) {
- return text.replace('/', '-')
- .replace('\'', '-')
+ return text.replace(QLatin1Char('/'), QLatin1Char('-'))
+ .replace(QLatin1Char('\''), QLatin1Char('-'))
.remove(QRegularExpression(QStringLiteral("[^\\w0-9\\- ]")))
.replace(QRegularExpression(QStringLiteral(" {2,}")), QStringLiteral(" "))
.simplified()
- .replace(' ', '-')
+ .replace(QLatin1Char(' '), QLatin1Char('-'))
.replace(QRegularExpression(QStringLiteral("(-)\\1+")), QStringLiteral("-"))
.toLower();
diff --git a/src/lyrics/songlyricscomlyricsprovider.h b/src/lyrics/songlyricscomlyricsprovider.h
index 7a1580d389..1b62c2ed2b 100644
--- a/src/lyrics/songlyricscomlyricsprovider.h
+++ b/src/lyrics/songlyricscomlyricsprovider.h
@@ -41,12 +41,6 @@ class SongLyricsComLyricsProvider : public HtmlLyricsProvider {
private:
QString StringFixup(QString text);
-
- private:
- static const char kUrl[];
- static const char kStartTag[];
- static const char kEndTag[];
- static const char kLyricsStart[];
};
#endif // SONGLYRICSCOMLYRICSPROVIDER_H
diff --git a/src/main.cpp b/src/main.cpp
index 82f9f40616..43b14ae0ed 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -69,6 +69,7 @@
#include "core/scoped_ptr.h"
#include "core/shared_ptr.h"
+#include "core/settings.h"
#include "utilities/envutils.h"
@@ -216,7 +217,7 @@ int main(int argc, char *argv[]) {
QCoreApplication::setAttribute(Qt::AA_DontShowIconsInMenus, false);
{
- QSettings s;
+ Settings s;
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
QString style = s.value(AppearanceSettingsPage::kStyle).toString();
if (style.isEmpty()) {
@@ -224,7 +225,7 @@ int main(int argc, char *argv[]) {
s.setValue(AppearanceSettingsPage::kStyle, style);
}
s.endGroup();
- if (style != "default") {
+ if (style != QStringLiteral("default")) {
QApplication::setStyle(style);
}
if (QApplication::style()) qLog(Debug) << "Style:" << QApplication::style()->objectName();
@@ -234,7 +235,7 @@ int main(int argc, char *argv[]) {
// On Windows these are stored in the registry instead.
#ifdef Q_OS_UNIX
{
- QSettings s;
+ Settings s;
if (QFile::exists(s.fileName())) {
if (!QFile::setPermissions(s.fileName(), QFile::ReadOwner | QFile::WriteOwner)) {
qLog(Error) << "Could not set permissions for settingsfile" << s.fileName();
@@ -258,7 +259,7 @@ int main(int argc, char *argv[]) {
#ifdef HAVE_TRANSLATIONS
QString override_language = options.language();
if (override_language.isEmpty()) {
- QSettings s;
+ Settings s;
s.beginGroup(BehaviourSettingsPage::kSettingsGroup);
override_language = s.value("language").toString();
s.endGroup();
@@ -266,21 +267,21 @@ int main(int argc, char *argv[]) {
QString system_language = QLocale::system().uiLanguages().empty() ? QLocale::system().name() : QLocale::system().uiLanguages().first();
// uiLanguages returns strings with "-" as separators for language/region; however QTranslator needs "_" separators
- system_language.replace("-", "_");
+ system_language.replace(QLatin1Char('-'), QLatin1Char('_'));
const QString language = override_language.isEmpty() ? system_language : override_language;
ScopedPtr translations(new Translations);
# if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
- translations->LoadTranslation("qt", QLibraryInfo::path(QLibraryInfo::TranslationsPath), language);
+ translations->LoadTranslation(QStringLiteral("qt"), QLibraryInfo::path(QLibraryInfo::TranslationsPath), language);
# else
- translations->LoadTranslation("qt", QLibraryInfo::location(QLibraryInfo::TranslationsPath), language);
+ translations->LoadTranslation(QStringLiteral("qt"), QLibraryInfo::location(QLibraryInfo::TranslationsPath), language);
# endif
- translations->LoadTranslation("strawberry", ":/translations", language);
- translations->LoadTranslation("strawberry", TRANSLATIONS_DIR, language);
- translations->LoadTranslation("strawberry", QCoreApplication::applicationDirPath(), language);
- translations->LoadTranslation("strawberry", QDir::currentPath(), language);
+ translations->LoadTranslation(QStringLiteral("strawberry"), QStringLiteral(":/translations"), language);
+ translations->LoadTranslation(QStringLiteral("strawberry"), QLatin1String(TRANSLATIONS_DIR), language);
+ translations->LoadTranslation(QStringLiteral("strawberry"), QCoreApplication::applicationDirPath(), language);
+ translations->LoadTranslation(QStringLiteral("strawberry"), QDir::currentPath(), language);
# ifdef HAVE_QTSPARKLE
//qtsparkle::LoadTranslations(language);
diff --git a/src/moodbar/moodbarcontroller.cpp b/src/moodbar/moodbarcontroller.cpp
index 2251346528..1b0fd1cc2f 100644
--- a/src/moodbar/moodbarcontroller.cpp
+++ b/src/moodbar/moodbarcontroller.cpp
@@ -44,7 +44,7 @@ MoodbarController::MoodbarController(Application *app, QObject *parent)
void MoodbarController::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(MoodbarSettingsPage::kSettingsGroup);
enabled_ = s.value("enabled", false).toBool();
s.endGroup();
diff --git a/src/moodbar/moodbaritemdelegate.cpp b/src/moodbar/moodbaritemdelegate.cpp
index 92b1c1ba42..353665a465 100644
--- a/src/moodbar/moodbaritemdelegate.cpp
+++ b/src/moodbar/moodbaritemdelegate.cpp
@@ -32,6 +32,7 @@
#include
#include "core/application.h"
+#include "core/settings.h"
#include "playlist/playlist.h"
#include "playlist/playlistview.h"
#include "playlist/playlistfilter.h"
@@ -59,7 +60,7 @@ MoodbarItemDelegate::MoodbarItemDelegate(Application *app, PlaylistView *view, Q
void MoodbarItemDelegate::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(MoodbarSettingsPage::kSettingsGroup);
enabled_ = s.value("enabled", false).toBool();
const MoodbarRenderer::MoodbarStyle new_style = static_cast(s.value("style", static_cast(MoodbarRenderer::MoodbarStyle::Normal)).toInt());
diff --git a/src/moodbar/moodbarloader.cpp b/src/moodbar/moodbarloader.cpp
index 2d239318bd..b6980cde8e 100644
--- a/src/moodbar/moodbarloader.cpp
+++ b/src/moodbar/moodbarloader.cpp
@@ -40,6 +40,7 @@
#include "core/logging.h"
#include "core/scoped_ptr.h"
#include "core/application.h"
+#include "core/settings.h"
#include "moodbarpipeline.h"
@@ -58,7 +59,7 @@ MoodbarLoader::MoodbarLoader(Application *app, QObject *parent)
kMaxActiveRequests(qMax(1, QThread::idealThreadCount() / 2)),
save_(false) {
- cache_->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/moodbar");
+ cache_->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/moodbar"));
cache_->setMaximumCacheSize(60 * 1024 * 1024); // 60MB - enough for 20,000 moodbars
QObject::connect(app, &Application::SettingsChanged, this, &MoodbarLoader::ReloadSettings);
@@ -73,7 +74,7 @@ MoodbarLoader::~MoodbarLoader() {
void MoodbarLoader::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(MoodbarSettingsPage::kSettingsGroup);
save_ = s.value("save", false).toBool();
s.endGroup();
@@ -86,15 +87,15 @@ QStringList MoodbarLoader::MoodFilenames(const QString &song_filename) {
const QFileInfo file_info(song_filename);
const QString dir_path(file_info.dir().path());
- const QString mood_filename = file_info.completeBaseName() + ".mood";
+ const QString mood_filename = file_info.completeBaseName() + QStringLiteral(".mood");
- return QStringList() << dir_path + "/." + mood_filename << dir_path + "/" + mood_filename;
+ return QStringList() << dir_path + QStringLiteral("/.") + mood_filename << dir_path + QLatin1Char('/') + mood_filename;
}
QUrl MoodbarLoader::CacheUrlEntry(const QString &filename) {
- return QUrl(QUrl::toPercentEncoding(filename));
+ return QUrl(QString::fromUtf8(QUrl::toPercentEncoding(filename)));
}
diff --git a/src/moodbar/moodbarpipeline.cpp b/src/moodbar/moodbarpipeline.cpp
index d73330a464..56516eb598 100644
--- a/src/moodbar/moodbarpipeline.cpp
+++ b/src/moodbar/moodbarpipeline.cpp
@@ -71,7 +71,7 @@ GstElement *MoodbarPipeline::CreateElement(const QString &factory_name) {
QByteArray MoodbarPipeline::ToGstUrl(const QUrl &url) {
if (url.isLocalFile() && !url.host().isEmpty()) {
- QString str = "file:////" + url.host() + url.path();
+ QString str = QStringLiteral("file:////") + url.host() + url.path();
return str.toUtf8();
}
diff --git a/src/moodbar/moodbarproxystyle.cpp b/src/moodbar/moodbarproxystyle.cpp
index f16a47974e..35c01a6545 100644
--- a/src/moodbar/moodbarproxystyle.cpp
+++ b/src/moodbar/moodbarproxystyle.cpp
@@ -37,6 +37,7 @@
#include
#include "core/application.h"
+#include "core/settings.h"
#include "moodbarproxystyle.h"
#include "moodbarrenderer.h"
@@ -74,7 +75,7 @@ MoodbarProxyStyle::MoodbarProxyStyle(Application *app, QSlider *slider, QObject*
void MoodbarProxyStyle::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(MoodbarSettingsPage::kSettingsGroup);
// Get the enabled/disabled setting, and start the timelines if there's a change.
enabled_ = s.value("show", false).toBool();
@@ -107,7 +108,7 @@ void MoodbarProxyStyle::SetMoodbarEnabled(const bool enabled) {
enabled_ = enabled;
// Save the enabled setting.
- QSettings s;
+ Settings s;
s.beginGroup(MoodbarSettingsPage::kSettingsGroup);
s.setValue("show", enabled);
s.endGroup();
@@ -403,7 +404,7 @@ void MoodbarProxyStyle::ShowContextMenu(const QPoint pos) {
void MoodbarProxyStyle::ChangeStyle(QAction *action) {
- QSettings s;
+ Settings s;
s.beginGroup(MoodbarSettingsPage::kSettingsGroup);
s.setValue("style", action->data().toInt());
s.endGroup();
diff --git a/src/musicbrainz/acoustidclient.cpp b/src/musicbrainz/acoustidclient.cpp
index c83ecf0fc9..15285c3422 100644
--- a/src/musicbrainz/acoustidclient.cpp
+++ b/src/musicbrainz/acoustidclient.cpp
@@ -48,9 +48,11 @@
#include "acoustidclient.h"
-const char *AcoustidClient::kClientId = "0qjUoxbowg";
-const char *AcoustidClient::kUrl = "https://api.acoustid.org/v2/lookup";
-const int AcoustidClient::kDefaultTimeout = 5000; // msec
+namespace {
+constexpr char kClientId[] = "0qjUoxbowg";
+constexpr char kUrl[] = "https://api.acoustid.org/v2/lookup";
+constexpr int kDefaultTimeout = 5000; // msec
+} // namespace
AcoustidClient::AcoustidClient(SharedPtr network, QObject *parent)
: QObject(parent),
@@ -70,15 +72,15 @@ void AcoustidClient::Start(const int id, const QString &fingerprint, int duratio
using Param = QPair;
using ParamList = QList;
- const ParamList params = ParamList() << Param("format", "json")
- << Param("client", kClientId)
- << Param("duration", QString::number(duration_msec / kMsecPerSec))
- << Param("meta", "recordingids+sources")
- << Param("fingerprint", fingerprint);
+ const ParamList params = ParamList() << Param(QStringLiteral("format"), QStringLiteral("json"))
+ << Param(QStringLiteral("client"), QLatin1String(kClientId))
+ << Param(QStringLiteral("duration"), QString::number(duration_msec / kMsecPerSec))
+ << Param(QStringLiteral("meta"), QStringLiteral("recordingids+sources"))
+ << Param(QStringLiteral("fingerprint"), fingerprint);
QUrlQuery url_query;
url_query.setQueryItems(params);
- QUrl url(kUrl);
+ QUrl url(QString::fromLatin1(kUrl));
url.setQuery(url_query);
QNetworkRequest req(url);
@@ -149,7 +151,7 @@ void AcoustidClient::RequestFinished(QNetworkReply *reply, const int request_id)
QJsonObject json_object = json_document.object();
QString status = json_object[QStringLiteral("status")].toString();
- if (status != "ok") {
+ if (status != QStringLiteral("ok")) {
emit Finished(request_id, QStringList(), status);
return;
}
diff --git a/src/musicbrainz/acoustidclient.h b/src/musicbrainz/acoustidclient.h
index a0374b5349..06e39286f5 100644
--- a/src/musicbrainz/acoustidclient.h
+++ b/src/musicbrainz/acoustidclient.h
@@ -67,10 +67,6 @@ class AcoustidClient : public QObject {
void RequestFinished(QNetworkReply *reply, const int id);
private:
- static const char *kClientId;
- static const char *kUrl;
- static const int kDefaultTimeout;
-
SharedPtr network_;
NetworkTimeouts *timeouts_;
QMap requests_;
diff --git a/src/musicbrainz/musicbrainzclient.cpp b/src/musicbrainz/musicbrainzclient.cpp
index e62502964a..fb63eb9a4d 100644
--- a/src/musicbrainz/musicbrainzclient.cpp
+++ b/src/musicbrainz/musicbrainzclient.cpp
@@ -49,12 +49,14 @@
#include "utilities/xmlutils.h"
#include "musicbrainzclient.h"
-const char *MusicBrainzClient::kTrackUrl = "https://musicbrainz.org/ws/2/recording/";
-const char *MusicBrainzClient::kDiscUrl = "https://musicbrainz.org/ws/2/discid/";
-const char *MusicBrainzClient::kDateRegex = "^[12]\\d{3}";
-const int MusicBrainzClient::kRequestsDelay = 1200;
-const int MusicBrainzClient::kDefaultTimeout = 8000;
-const int MusicBrainzClient::kMaxRequestPerTrack = 3;
+namespace {
+constexpr char kTrackUrl[] = "https://musicbrainz.org/ws/2/recording/";
+constexpr char kDiscUrl[] = "https://musicbrainz.org/ws/2/discid/";
+constexpr char kDateRegex[] = "^[12]\\d{3}";
+constexpr int kRequestsDelay = 1200;
+constexpr int kDefaultTimeout = 8000;
+constexpr int kMaxRequestPerTrack = 3;
+} // namespace
MusicBrainzClient::MusicBrainzClient(SharedPtr network, QObject *parent)
: QObject(parent),
@@ -151,11 +153,11 @@ void MusicBrainzClient::Start(const int id, const QStringList &mbid_list) {
void MusicBrainzClient::StartDiscIdRequest(const QString &discid) {
- const ParamList params = ParamList() << Param("inc", "artists+recordings");
+ const ParamList params = ParamList() << Param(QStringLiteral("inc"), QStringLiteral("artists+recordings"));
QUrlQuery url_query;
url_query.setQueryItems(params);
- QUrl url(kDiscUrl + discid);
+ QUrl url(QString::fromLatin1(kDiscUrl) + discid);
url.setQuery(url_query);
QNetworkRequest req(url);
@@ -173,11 +175,11 @@ void MusicBrainzClient::FlushRequests() {
Request request = requests_pending_.take(requests_pending_.firstKey());
- const ParamList params = ParamList() << Param("inc", "artists+releases+media");
+ const ParamList params = ParamList() << Param(QStringLiteral("inc"), QStringLiteral("artists+releases+media"));
QUrlQuery url_query;
url_query.setQueryItems(params);
- QUrl url(kTrackUrl + request.mbid);
+ QUrl url(QString::fromLatin1(kTrackUrl) + request.mbid);
url.setQuery(url_query);
QNetworkRequest req(url);
@@ -210,7 +212,7 @@ void MusicBrainzClient::RequestFinished(QNetworkReply *reply, const int id, cons
QXmlStreamReader reader(data);
ResultList res;
while (!reader.atEnd()) {
- if (reader.readNext() == QXmlStreamReader::StartElement && reader.name().toString() == "recording") {
+ if (reader.readNext() == QXmlStreamReader::StartElement && reader.name().toString() == QStringLiteral("recording")) {
ResultList tracks = ParseTrack(&reader);
for (const Result &track : tracks) {
if (!track.title_.isEmpty()) {
@@ -265,20 +267,20 @@ void MusicBrainzClient::DiscIdRequestFinished(const QString &discid, QNetworkRep
QXmlStreamReader::TokenType type = reader.readNext();
if (type == QXmlStreamReader::StartElement) {
QString name = reader.name().toString();
- if (name == "title") {
+ if (name == QStringLiteral("title")) {
album = reader.readElementText();
}
- else if (name == "date") {
- QRegularExpression regex(kDateRegex);
+ else if (name == QStringLiteral("date")) {
+ QRegularExpression regex(QString::fromLatin1(kDateRegex));
QRegularExpressionMatch re_match = regex.match(reader.readElementText());
if (re_match.capturedStart() == 0) {
year = re_match.captured(0).toInt();
}
}
- else if (name == "artist-credit") {
+ else if (name == QStringLiteral("artist-credit")) {
ParseArtist(&reader, &artist);
}
- else if (name == "medium-list") {
+ else if (name == QStringLiteral("medium-list")) {
break;
}
}
@@ -287,7 +289,7 @@ void MusicBrainzClient::DiscIdRequestFinished(const QString &discid, QNetworkRep
while (!reader.atEnd()) {
QXmlStreamReader::TokenType token = reader.readNext();
QString name = reader.name().toString();
- if (token == QXmlStreamReader::StartElement && name == "medium") {
+ if (token == QXmlStreamReader::StartElement && name == QStringLiteral("medium")) {
// Get the medium with a matching discid.
if (MediumHasDiscid(discid, &reader)) {
ResultList tracks = ParseMedium(&reader);
@@ -301,7 +303,7 @@ void MusicBrainzClient::DiscIdRequestFinished(const QString &discid, QNetworkRep
Utilities::ConsumeCurrentElement(&reader);
}
}
- else if (token == QXmlStreamReader::EndElement && name == "medium-list") {
+ else if (token == QXmlStreamReader::EndElement && name == QStringLiteral("medium-list")) {
break;
}
}
@@ -323,10 +325,10 @@ bool MusicBrainzClient::MediumHasDiscid(const QString &discid, QXmlStreamReader
QXmlStreamReader::TokenType type = reader->readNext();
QString name = reader->name().toString();
- if (type == QXmlStreamReader::StartElement && name == "disc" && reader->attributes().value("id").toString() == discid) {
+ if (type == QXmlStreamReader::StartElement && name == QStringLiteral("disc") && reader->attributes().value(QStringLiteral("id")).toString() == discid) {
return true;
}
- else if (type == QXmlStreamReader::EndElement && name == "disc-list") {
+ else if (type == QXmlStreamReader::EndElement && name == QStringLiteral("disc-list")) {
return false;
}
}
@@ -343,14 +345,14 @@ MusicBrainzClient::ResultList MusicBrainzClient::ParseMedium(QXmlStreamReader *r
QString name = reader->name().toString();
if (type == QXmlStreamReader::StartElement) {
- if (name == "track") {
+ if (name == QStringLiteral("track")) {
Result result;
result = ParseTrackFromDisc(reader);
ret << result;
}
}
- if (type == QXmlStreamReader::EndElement && name == "track-list") {
+ if (type == QXmlStreamReader::EndElement && name == QStringLiteral("track-list")) {
break;
}
}
@@ -368,18 +370,18 @@ MusicBrainzClient::Result MusicBrainzClient::ParseTrackFromDisc(QXmlStreamReader
QString name = reader->name().toString();
if (type == QXmlStreamReader::StartElement) {
- if (name == "position") {
+ if (name == QStringLiteral("position")) {
result.track_ = reader->readElementText().toInt();
}
- else if (name == "length") {
+ else if (name == QStringLiteral("length")) {
result.duration_msec_ = reader->readElementText().toInt();
}
- else if (name == "title") {
+ else if (name == QStringLiteral("title")) {
result.title_ = reader->readElementText();
}
}
- if (type == QXmlStreamReader::EndElement && name == "track") {
+ if (type == QXmlStreamReader::EndElement && name == QStringLiteral("track")) {
break;
}
}
@@ -398,21 +400,21 @@ MusicBrainzClient::ResultList MusicBrainzClient::ParseTrack(QXmlStreamReader *re
if (type == QXmlStreamReader::StartElement) {
- if (name == "title") {
+ if (name == QStringLiteral("title")) {
result.title_ = reader->readElementText();
}
- else if (name == "length") {
+ else if (name == QStringLiteral("length")) {
result.duration_msec_ = reader->readElementText().toInt();
}
- else if (name == "artist-credit") {
+ else if (name == QStringLiteral("artist-credit")) {
ParseArtist(reader, &result.artist_);
}
- else if (name == "release") {
+ else if (name == QStringLiteral("release")) {
releases << ParseRelease(reader);
}
}
- if (type == QXmlStreamReader::EndElement && name == "recording") {
+ if (type == QXmlStreamReader::EndElement && name == QStringLiteral("recording")) {
break;
}
}
@@ -439,15 +441,15 @@ void MusicBrainzClient::ParseArtist(QXmlStreamReader *reader, QString *artist) {
while (!reader->atEnd()) {
QXmlStreamReader::TokenType type = reader->readNext();
QString name = reader->name().toString();
- if (type == QXmlStreamReader::StartElement && name == "name-credit") {
- join_phrase = reader->attributes().value("joinphrase").toString();
+ if (type == QXmlStreamReader::StartElement && name == QStringLiteral("name-credit")) {
+ join_phrase = reader->attributes().value(QStringLiteral("joinphrase")).toString();
}
- if (type == QXmlStreamReader::StartElement && name == "name") {
+ if (type == QXmlStreamReader::StartElement && name == QStringLiteral("name")) {
*artist += reader->readElementText() + join_phrase;
}
- if (type == QXmlStreamReader::EndElement && name == "artist-credit") {
+ if (type == QXmlStreamReader::EndElement && name == QStringLiteral("artist-credit")) {
return;
}
}
@@ -462,26 +464,26 @@ MusicBrainzClient::Release MusicBrainzClient::ParseRelease(QXmlStreamReader *rea
QString name = reader->name().toString();
if (type == QXmlStreamReader::StartElement) {
- if (name == "title") {
+ if (name == QStringLiteral("title")) {
ret.album_ = reader->readElementText();
}
- else if (name == "status") {
+ else if (name == QStringLiteral("status")) {
ret.SetStatusFromString(reader->readElementText());
}
- else if (name == "date") {
- QRegularExpression regex(kDateRegex);
+ else if (name == QStringLiteral("date")) {
+ QRegularExpression regex(QString::fromLatin1(kDateRegex));
QRegularExpressionMatch re_match = regex.match(reader->readElementText());
if (re_match.capturedStart() == 0) {
ret.year_ = re_match.captured(0).toInt();
}
}
- else if (name == "track-list") {
- ret.track_ = reader->attributes().value("offset").toString().toInt() + 1;
+ else if (name == QStringLiteral("track-list")) {
+ ret.track_ = reader->attributes().value(QStringLiteral("offset")).toString().toInt() + 1;
Utilities::ConsumeCurrentElement(reader);
}
}
- if (type == QXmlStreamReader::EndElement && name == "release") {
+ if (type == QXmlStreamReader::EndElement && name == QStringLiteral("release")) {
break;
}
}
diff --git a/src/musicbrainz/musicbrainzclient.h b/src/musicbrainz/musicbrainzclient.h
index b37f6589a1..608276bc88 100644
--- a/src/musicbrainz/musicbrainzclient.h
+++ b/src/musicbrainz/musicbrainzclient.h
@@ -202,14 +202,6 @@ class MusicBrainzClient : public QObject {
static void Error(const QString &error, const QVariant &debug = QVariant());
private:
-
- static const char *kTrackUrl;
- static const char *kDiscUrl;
- static const char *kDateRegex;
- static const int kRequestsDelay;
- static const int kDefaultTimeout;
- static const int kMaxRequestPerTrack;
-
SharedPtr network_;
NetworkTimeouts *timeouts_;
QMultiMap requests_pending_;
diff --git a/src/organize/organize.cpp b/src/organize/organize.cpp
index 5c88ccb8f0..cd6799ec1d 100644
--- a/src/organize/organize.cpp
+++ b/src/organize/organize.cpp
@@ -248,7 +248,7 @@ void Organize::ProcessSomeFiles() {
}
if (!job.cover_source_.isEmpty()) {
- job.cover_dest_ = QFileInfo(job.destination_).path() + "/" + QFileInfo(job.cover_source_).fileName();
+ job.cover_dest_ = QFileInfo(job.destination_).path() + QLatin1Char('/') + QFileInfo(job.cover_source_).fileName();
}
job.progress_ = std::bind(&Organize::SetSongProgress, this, std::placeholders::_1, !task.transcoded_filename_.isEmpty());
@@ -258,7 +258,7 @@ void Organize::ProcessSomeFiles() {
if (job.remove_original_ && song.is_collection_song() && destination_->source() == Song::Source::Collection) {
// Notify other aspects of system that song has been invalidated
QString root = destination_->LocalPath();
- QFileInfo new_file = QFileInfo(root + "/" + task.song_info_.new_filename_);
+ QFileInfo new_file = QFileInfo(root + QLatin1Char('/') + task.song_info_.new_filename_);
emit SongPathChanged(song, new_file, destination_->collection_directory_id());
}
}
diff --git a/src/organize/organizedialog.cpp b/src/organize/organizedialog.cpp
index a02caeb83c..bf3af266bb 100644
--- a/src/organize/organizedialog.cpp
+++ b/src/organize/organizedialog.cpp
@@ -59,6 +59,7 @@
#include "core/iconloader.h"
#include "core/musicstorage.h"
#include "core/tagreaderclient.h"
+#include "core/settings.h"
#include "utilities/strutils.h"
#include "utilities/screenutils.h"
#include "widgets/freespacebar.h"
@@ -75,8 +76,10 @@
using std::make_unique;
-constexpr char OrganizeDialog::kSettingsGroup[] = "OrganizeDialog";
-constexpr char OrganizeDialog::kDefaultFormat[] = "%albumartist/%album{ (Disc %disc)}/{%track - }{%albumartist - }%album{ (Disc %disc)} - %title.%extension";
+namespace {
+constexpr char kSettingsGroup[] = "OrganizeDialog";
+constexpr char kDefaultFormat[] = "%albumartist/%album{ (Disc %disc)}/{%track - }{%albumartist - }%album{ (Disc %disc)} - %title.%extension";
+}
OrganizeDialog::OrganizeDialog(SharedPtr task_manager, SharedPtr collection_backend, QWidget *parentwindow, QWidget *parent)
: QDialog(parent),
@@ -213,7 +216,7 @@ void OrganizeDialog::LoadGeometry() {
AdjustSize();
}
else {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
if (s.contains("geometry")) {
restoreGeometry(s.value("geometry").toByteArray());
@@ -231,7 +234,7 @@ void OrganizeDialog::LoadGeometry() {
void OrganizeDialog::SaveGeometry() {
if (parentwindow_) {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("geometry", saveGeometry());
s.endGroup();
@@ -270,7 +273,7 @@ void OrganizeDialog::AdjustSize() {
void OrganizeDialog::RestoreDefaults() {
- ui_->naming->setPlainText(kDefaultFormat);
+ ui_->naming->setPlainText(QLatin1String(kDefaultFormat));
ui_->remove_problematic->setChecked(true);
ui_->remove_non_fat->setChecked(false);
ui_->remove_non_ascii->setChecked(false);
@@ -284,9 +287,9 @@ void OrganizeDialog::RestoreDefaults() {
void OrganizeDialog::LoadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
- ui_->naming->setPlainText(s.value("format", kDefaultFormat).toString());
+ ui_->naming->setPlainText(s.value("format", QLatin1String(kDefaultFormat)).toString());
ui_->remove_problematic->setChecked(s.value("remove_problematic", true).toBool());
ui_->remove_non_fat->setChecked(s.value("remove_non_fat", false).toBool());
ui_->remove_non_ascii->setChecked(s.value("remove_non_ascii", false).toBool());
@@ -310,7 +313,7 @@ void OrganizeDialog::LoadSettings() {
void OrganizeDialog::SaveSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("format", ui_->naming->toPlainText());
s.setValue("remove_problematic", ui_->remove_problematic->isChecked());
@@ -430,7 +433,7 @@ void OrganizeDialog::SetPlaylist(const QString &playlist) {
}
void OrganizeDialog::InsertTag(const QString &tag) {
- ui_->naming->insertPlainText("%" + tag);
+ ui_->naming->insertPlainText(QLatin1Char('%') + tag);
}
Organize::NewSongInfoList OrganizeDialog::ComputeNewSongsFilenames(const SongList &songs, const OrganizeFormat &format, const QString &extension) {
@@ -449,7 +452,7 @@ Organize::NewSongInfoList OrganizeDialog::ComputeNewSongsFilenames(const SongLis
if (result.unique_filename) {
if (filenames.contains(result.filename)) {
QString song_number = QString::number(++filenames[result.filename]);
- result.filename = Utilities::PathWithoutFilenameExtension(result.filename) + "(" + song_number + ")." + QFileInfo(result.filename).suffix();
+ result.filename = Utilities::PathWithoutFilenameExtension(result.filename) + QStringLiteral("(") + song_number + QStringLiteral(").") + QFileInfo(result.filename).suffix();
}
else {
filenames.insert(result.filename, 1);
@@ -529,7 +532,7 @@ void OrganizeDialog::UpdatePreviews() {
ui_->groupbox_naming->setVisible(has_local_destination);
if (has_local_destination) {
for (const Organize::NewSongInfo &song_info : new_songs_info_) {
- QString filename = storage->LocalPath() + "/" + song_info.new_filename_;
+ QString filename = storage->LocalPath() + QLatin1Char('/') + song_info.new_filename_;
QListWidgetItem *item = new QListWidgetItem(song_info.unique_filename_ ? IconLoader::Load(QStringLiteral("dialog-ok-apply")) : IconLoader::Load(QStringLiteral("dialog-warning")), QDir::toNativeSeparators(filename), ui_->preview);
ui_->preview->addItem(item);
if (!song_info.unique_filename_) {
diff --git a/src/organize/organizedialog.h b/src/organize/organizedialog.h
index 92d06a2d9b..d53185171f 100644
--- a/src/organize/organizedialog.h
+++ b/src/organize/organizedialog.h
@@ -105,9 +105,6 @@ class OrganizeDialog : public QDialog {
void AllowExtASCII(const bool checked);
private:
- static const char kSettingsGroup[];
- static const char kDefaultFormat[];
-
QWidget *parentwindow_;
Ui_OrganizeDialog *ui_;
SharedPtr task_manager_;
diff --git a/src/organize/organizeformat.cpp b/src/organize/organizeformat.cpp
index 76837ae671..01a14762d3 100644
--- a/src/organize/organizeformat.cpp
+++ b/src/organize/organizeformat.cpp
@@ -43,8 +43,10 @@
#include "organizeformat.h"
-constexpr char OrganizeFormat::kBlockPattern[] = "\\{([^{}]+)\\}";
-constexpr char OrganizeFormat::kTagPattern[] = "\\%([a-zA-Z]*)";
+namespace {
+static constexpr char kBlockPattern[] = "\\{([^{}]+)\\}";
+static constexpr char kTagPattern[] = "\\%([a-zA-Z]*)";
+}
const QStringList OrganizeFormat::kKnownTags = QStringList() << QStringLiteral("title")
<< QStringLiteral("album")
@@ -88,7 +90,7 @@ OrganizeFormat::OrganizeFormat(const QString &format)
void OrganizeFormat::set_format(const QString &v) {
format_ = v;
- format_.replace('\\', '/');
+ format_.replace(QLatin1Char('\\'), QLatin1Char('/'));
}
bool OrganizeFormat::IsValid() const {
@@ -119,21 +121,21 @@ OrganizeFormat::GetFilenameForSongResult OrganizeFormat::GetFilenameForSong(cons
filepath.clear();
if (!path.isEmpty()) {
filepath.append(path);
- if (path.right(1) != '/') {
- filepath.append('/');
+ if (path.right(1) != QLatin1Char('/')) {
+ filepath.append(QLatin1Char('/'));
}
}
filepath.append(song.basefilename());
}
}
- if (filepath.isEmpty() || (filepath.contains('/') && (filepath.section('/', 0, -2).isEmpty() || filepath.section('/', 0, -2).isEmpty()))) {
+ if (filepath.isEmpty() || (filepath.contains(QLatin1Char('/')) && (filepath.section(QLatin1Char('/'), 0, -2).isEmpty() || filepath.section(QLatin1Char('/'), 0, -2).isEmpty()))) {
return GetFilenameForSongResult();
}
- if (remove_problematic_) filepath = filepath.remove(QRegularExpression(QString(kProblematicCharactersRegex), QRegularExpression::PatternOption::CaseInsensitiveOption));
+ if (remove_problematic_) filepath = filepath.remove(QRegularExpression(QLatin1String(kProblematicCharactersRegex), QRegularExpression::PatternOption::CaseInsensitiveOption));
if (remove_non_fat_ || (remove_non_ascii_ && !allow_ascii_ext_)) filepath = Utilities::Transliterate(filepath);
- if (remove_non_fat_) filepath = filepath.remove(QRegularExpression(QString(kInvalidFatCharactersRegex), QRegularExpression::PatternOption::CaseInsensitiveOption));
+ if (remove_non_fat_) filepath = filepath.remove(QRegularExpression(QLatin1String(kInvalidFatCharactersRegex), QRegularExpression::PatternOption::CaseInsensitiveOption));
if (remove_non_ascii_) {
int ascii = 128;
@@ -168,9 +170,9 @@ OrganizeFormat::GetFilenameForSongResult OrganizeFormat::GetFilenameForSong(cons
extension = info.suffix();
}
}
- if (!info.path().isEmpty() && info.path() != ".") {
+ if (!info.path().isEmpty() && info.path() != QStringLiteral(".")) {
filepath.append(info.path());
- filepath.append("/");
+ filepath.append(QLatin1Char('/'));
}
filepath.append(info.completeBaseName());
@@ -180,7 +182,7 @@ OrganizeFormat::GetFilenameForSongResult OrganizeFormat::GetFilenameForSong(cons
for (int i = 0; i < parts_old.count(); ++i) {
QString part = parts_old[i];
for (int j = 0; j < kInvalidPrefixCharactersCount; ++j) {
- if (part.startsWith(kInvalidPrefixCharacters[j])) {
+ if (part.startsWith(QLatin1Char(kInvalidPrefixCharacters[j]))) {
part = part.remove(0, 1);
break;
}
@@ -204,7 +206,7 @@ QString OrganizeFormat::ParseBlock(QString block, const Song &song, bool *have_t
// Find any blocks first
qint64 pos = 0;
- const QRegularExpression block_regexp(kBlockPattern);
+ const QRegularExpression block_regexp(QString::fromUtf8(kBlockPattern));
QRegularExpressionMatch re_match;
for (re_match = block_regexp.match(block, pos); re_match.hasMatch(); re_match = block_regexp.match(block, pos)) {
pos = re_match.capturedStart();
@@ -221,7 +223,7 @@ QString OrganizeFormat::ParseBlock(QString block, const Song &song, bool *have_t
// Now look for tags
bool empty = false;
pos = 0;
- const QRegularExpression tag_regexp(kTagPattern);
+ const QRegularExpression tag_regexp(QString::fromUtf8(kTagPattern));
for (re_match = tag_regexp.match(block, pos); re_match.hasMatch(); re_match = tag_regexp.match(block, pos)) {
pos = re_match.capturedStart();
const QString tag = re_match.captured(1);
@@ -249,79 +251,79 @@ QString OrganizeFormat::TagValue(const QString &tag, const Song &song) const {
QString value;
- if (tag == "title") {
+ if (tag == QStringLiteral("title")) {
value = song.title();
}
- else if (tag == "album") {
+ else if (tag == QStringLiteral("album")) {
value = song.album();
}
- else if (tag == "artist") {
+ else if (tag == QStringLiteral("artist")) {
value = song.artist();
}
- else if (tag == "composer") {
+ else if (tag == QStringLiteral("composer")) {
value = song.composer();
}
- else if (tag == "performer") {
+ else if (tag == QStringLiteral("performer")) {
value = song.performer();
}
- else if (tag == "grouping") {
+ else if (tag == QStringLiteral("grouping")) {
value = song.grouping();
}
- else if (tag == "lyrics") {
+ else if (tag == QStringLiteral("lyrics")) {
value = song.lyrics();
}
- else if (tag == "genre") {
+ else if (tag == QStringLiteral("genre")) {
value = song.genre();
}
- else if (tag == "comment") {
+ else if (tag == QStringLiteral("comment")) {
value = song.comment();
}
- else if (tag == "year") {
+ else if (tag == QStringLiteral("year")) {
value = QString::number(song.year());
}
- else if (tag == "originalyear") {
+ else if (tag == QStringLiteral("originalyear")) {
value = QString::number(song.effective_originalyear());
}
- else if (tag == "track") {
+ else if (tag == QStringLiteral("track")) {
value = QString::number(song.track());
}
- else if (tag == "disc") {
+ else if (tag == QStringLiteral("disc")) {
value = QString::number(song.disc());
}
- else if (tag == "length") {
+ else if (tag == QStringLiteral("length")) {
value = QString::number(song.length_nanosec() / kNsecPerSec);
}
- else if (tag == "bitrate") {
+ else if (tag == QStringLiteral("bitrate")) {
value = QString::number(song.bitrate());
}
- else if (tag == "samplerate") {
+ else if (tag == QStringLiteral("samplerate")) {
value = QString::number(song.samplerate());
}
- else if (tag == "bitdepth") {
+ else if (tag == QStringLiteral("bitdepth")) {
value = QString::number(song.bitdepth());
}
- else if (tag == "extension") {
+ else if (tag == QStringLiteral("extension")) {
value = QFileInfo(song.url().toLocalFile()).suffix();
}
- else if (tag == "artistinitial") {
+ else if (tag == QStringLiteral("artistinitial")) {
value = song.effective_albumartist().trimmed();
if (!value.isEmpty()) {
value.replace(QRegularExpression(QStringLiteral("^the\\s+"), QRegularExpression::CaseInsensitiveOption), QLatin1String(""));
value = value[0].toUpper();
}
}
- else if (tag == "albumartist") {
+ else if (tag == QStringLiteral("albumartist")) {
value = song.is_compilation() ? QStringLiteral("Various Artists") : song.effective_albumartist();
}
- if (value == "0" || value == "-1") value = QLatin1String("");
+ if (value == QStringLiteral("0") || value == QStringLiteral("-1")) value = QLatin1String("");
// Prepend a 0 to single-digit track numbers
- if (tag == "track" && value.length() == 1) value.prepend('0');
+ if (tag == QStringLiteral("track") && value.length() == 1) value.prepend(QLatin1Char('0'));
// Replace characters that really shouldn't be in paths
- value = value.remove(QRegularExpression(QString(kInvalidDirCharactersRegex), QRegularExpression::PatternOption::CaseInsensitiveOption));
- if (remove_problematic_) value = value.remove('.');
+ value = value.remove(QRegularExpression(QString::fromLatin1(kInvalidDirCharactersRegex), QRegularExpression::PatternOption::CaseInsensitiveOption));
+ if (remove_problematic_) value = value.remove(QLatin1Char('.'));
value = value.trimmed();
return value;
@@ -335,10 +337,10 @@ QValidator::State OrganizeFormat::Validator::validate(QString &input, int&) cons
// Make sure all the blocks match up
int block_level = 0;
for (int i = 0; i < input.length(); ++i) {
- if (input[i] == '{') {
+ if (input[i] == QLatin1Char('{')) {
++block_level;
}
- else if (input[i] == '}') {
+ else if (input[i] == QLatin1Char('}')) {
--block_level;
}
@@ -348,7 +350,7 @@ QValidator::State OrganizeFormat::Validator::validate(QString &input, int&) cons
if (block_level != 0) return QValidator::Invalid;
// Make sure the tags are valid
- const QRegularExpression tag_regexp(kTagPattern);
+ const QRegularExpression tag_regexp(QString::fromLatin1(kTagPattern));
QRegularExpressionMatch re_match;
qint64 pos = 0;
for (re_match = tag_regexp.match(input, pos); re_match.hasMatch(); re_match = tag_regexp.match(input, pos)) {
@@ -384,7 +386,7 @@ void OrganizeFormat::SyntaxHighlighter::highlightBlock(const QString &text) {
setFormat(0, static_cast(text.length()), QTextCharFormat());
// Blocks
- const QRegularExpression block_regexp(kBlockPattern);
+ const QRegularExpression block_regexp(QString::fromLatin1(kBlockPattern));
QRegularExpressionMatch re_match;
qint64 pos = 0;
for (re_match = block_regexp.match(text, pos); re_match.hasMatch(); re_match = block_regexp.match(text, pos)) {
@@ -394,7 +396,7 @@ void OrganizeFormat::SyntaxHighlighter::highlightBlock(const QString &text) {
}
// Tags
- const QRegularExpression tag_regexp(kTagPattern);
+ const QRegularExpression tag_regexp(QString::fromLatin1(kTagPattern));
pos = 0;
for (re_match = tag_regexp.match(text, pos); re_match.hasMatch(); re_match = tag_regexp.match(text, pos)) {
pos = re_match.capturedStart();
diff --git a/src/organize/organizeformat.h b/src/organize/organizeformat.h
index 39712bcce1..d61f601043 100644
--- a/src/organize/organizeformat.h
+++ b/src/organize/organizeformat.h
@@ -85,8 +85,6 @@ class OrganizeFormat {
};
private:
- static const char kBlockPattern[];
- static const char kTagPattern[];
static const QStringList kKnownTags;
static const QStringList kUniqueTags;
diff --git a/src/osd/osdbase.cpp b/src/osd/osdbase.cpp
index 7f5719386b..1e503cff3b 100644
--- a/src/osd/osdbase.cpp
+++ b/src/osd/osdbase.cpp
@@ -34,6 +34,7 @@
#include "core/shared_ptr.h"
#include "core/application.h"
#include "core/logging.h"
+#include "core/settings.h"
#ifdef Q_OS_MACOS
# include "core/macsystemtrayicon.h"
#else
@@ -74,7 +75,7 @@ OSDBase::~OSDBase() {
void OSDBase::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
behaviour_ = static_cast(s.value("Behaviour", static_cast(Behaviour::Native)).toInt());
timeout_msec_ = s.value("Timeout", 5000).toInt();
@@ -200,7 +201,7 @@ void OSDBase::Paused() {
else {
summary = last_song_.PrettyTitle();
if (!last_song_.artist().isEmpty()) {
- summary.prepend(" - ");
+ summary.prepend(QStringLiteral(" - "));
summary.prepend(last_song_.artist());
}
if (behaviour_ == Behaviour::Pretty) {
@@ -245,7 +246,7 @@ void OSDBase::Stopped() {
else {
summary = last_song_.PrettyTitle();
if (!last_song_.artist().isEmpty()) {
- summary.prepend(" - ");
+ summary.prepend(QStringLiteral(" - "));
summary.prepend(last_song_.artist());
}
if (behaviour_ == Behaviour::Pretty) {
diff --git a/src/osd/osddbus.cpp b/src/osd/osddbus.cpp
index de125875cb..842c476846 100644
--- a/src/osd/osddbus.cpp
+++ b/src/osd/osddbus.cpp
@@ -117,7 +117,7 @@ OSDDBus::~OSDDBus() = default;
void OSDDBus::Init() {
- interface_ = make_unique(OrgFreedesktopNotificationsInterface::staticInterfaceName(), "/org/freedesktop/Notifications", QDBusConnection::sessionBus());
+ interface_ = make_unique(QString::fromUtf8(OrgFreedesktopNotificationsInterface::staticInterfaceName()), QStringLiteral("/org/freedesktop/Notifications"), QDBusConnection::sessionBus());
if (!interface_->isValid()) {
qLog(Warning) << "Error connecting to notifications service.";
}
diff --git a/src/osd/osdpretty.cpp b/src/osd/osdpretty.cpp
index 8e8b894cb9..9973bc85bf 100644
--- a/src/osd/osdpretty.cpp
+++ b/src/osd/osdpretty.cpp
@@ -51,6 +51,8 @@
#include
#include
+#include "core/settings.h"
+
#ifdef HAVE_X11EXTRAS
# include
#elif defined(HAVE_X11) && defined(HAVE_QPA_QPLATFORMNATIVEINTERFACE_H)
@@ -232,12 +234,12 @@ bool OSDPretty::IsTransparencyAvailable() {
void OSDPretty::Load() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
foreground_color_ = QColor(s.value("foreground_color", 0).toInt());
background_color_ = QColor(s.value("background_color", kPresetBlue).toInt());
background_opacity_ = s.value("background_opacity", 0.85).toFloat();
- font_.fromString(s.value("font", "Verdana,9,-1,5,50,0,0,0,0,0").toString());
+ font_.fromString(s.value("font", QStringLiteral("Verdana,9,-1,5,50,0,0,0,0,0")).toString());
disable_duration_ = s.value("disable_duration", false).toBool();
#ifdef Q_OS_WIN
fading_enabled_ = s.value("fading", true).toBool();
@@ -245,7 +247,7 @@ void OSDPretty::Load() {
fading_enabled_ = s.value("fading", false).toBool();
#endif
- if (s.contains("popup_screen")) {
+ if (s.contains(QStringLiteral("popup_screen"))) {
popup_screen_name_ = s.value("popup_screen").toString();
if (screens_.contains(popup_screen_name_)) {
popup_screen_ = screens_[popup_screen_name_];
@@ -261,7 +263,7 @@ void OSDPretty::Load() {
if (current_screen()) popup_screen_name_ = current_screen()->name();
}
- if (s.contains("popup_pos")) {
+ if (s.contains(QStringLiteral("popup_pos"))) {
popup_pos_ = s.value("popup_pos").toPoint();
}
else {
diff --git a/src/osd/osdpretty.h b/src/osd/osdpretty.h
index ba1f8f0e35..87a9cac6f0 100644
--- a/src/osd/osdpretty.h
+++ b/src/osd/osdpretty.h
@@ -142,7 +142,7 @@ class OSDPretty : public QWidget {
Mode mode_;
- // Settings loaded from QSettings
+ // Settings loaded from Settings
QColor foreground_color_;
QColor background_color_;
qreal background_opacity_;
diff --git a/src/playlist/playlist.cpp b/src/playlist/playlist.cpp
index 45aba524d3..bea2e91839 100644
--- a/src/playlist/playlist.cpp
+++ b/src/playlist/playlist.cpp
@@ -64,6 +64,7 @@
#include "core/mimedata.h"
#include "core/tagreaderclient.h"
#include "core/song.h"
+#include "core/settings.h"
#include "utilities/timeconstants.h"
#include "collection/collection.h"
#include "collection/collectionbackend.h"
@@ -772,7 +773,7 @@ Qt::ItemFlags Playlist::flags(const QModelIndex &idx) const {
QStringList Playlist::mimeTypes() const {
- return QStringList() << QStringLiteral("text/uri-list") << kRowsMimetype;
+ return QStringList() << QStringLiteral("text/uri-list") << QString::fromUtf8(kRowsMimetype);
}
@@ -800,7 +801,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
if (const SongMimeData *song_data = qobject_cast(data)) {
// Dragged from a collection
// We want to check if these songs are from the actual local file backend, if they are we treat them differently.
- if (song_data->backend && song_data->backend->songs_table() == SCollection::kSongsTable) {
+ if (song_data->backend && song_data->backend->songs_table() == QLatin1String(SCollection::kSongsTable)) {
InsertSongItems(song_data->songs, row, play_now, enqueue_now, enqueue_next_now);
}
else {
@@ -819,7 +820,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
else if (const RadioMimeData *radio_data = qobject_cast(data)) {
InsertRadioItems(radio_data->songs, row, play_now, enqueue_now, enqueue_next_now);
}
- else if (data->hasFormat(kRowsMimetype)) {
+ else if (data->hasFormat(QString::fromUtf8(kRowsMimetype))) {
// Dragged from the playlist
// Rearranging it is tricky...
@@ -829,7 +830,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
qint64 pid = 0;
qint64 own_pid = QCoreApplication::applicationPid();
- QDataStream stream(data->data(kRowsMimetype));
+ QDataStream stream(data->data(QString::fromUtf8(kRowsMimetype)));
stream.readRawData(reinterpret_cast(&source_playlist), sizeof(source_playlist)); // NOLINT(bugprone-sizeof-expression)
stream >> source_rows;
if (!stream.atEnd()) {
@@ -868,7 +869,7 @@ bool Playlist::dropMimeData(const QMimeData *data, Qt::DropAction action, int ro
}
}
}
- else if (data->hasFormat(kCddaMimeType)) {
+ else if (data->hasFormat(QLatin1String(kCddaMimeType))) {
SongLoaderInserter *inserter = new SongLoaderInserter(task_manager_, collection_backend_, backend_->app()->player());
QObject::connect(inserter, &SongLoaderInserter::Error, this, &Playlist::Error);
inserter->LoadAudioCD(this, row, play_now, enqueue_now, enqueue_next_now);
@@ -1291,7 +1292,7 @@ QMimeData *Playlist::mimeData(const QModelIndexList &indexes) const {
buf.close();
mimedata->setUrls(urls);
- mimedata->setData(kRowsMimetype, buf.data());
+ mimedata->setData(QLatin1String(kRowsMimetype), buf.data());
return mimedata;
@@ -1361,8 +1362,8 @@ bool Playlist::ComparePathDepths(const Qt::SortOrder order, PlaylistItemPtr _a,
PlaylistItemPtr a = order == Qt::AscendingOrder ? _a : _b;
PlaylistItemPtr b = order == Qt::AscendingOrder ? _b : _a;
- qint64 a_dir_level = a->Url().path().count('/');
- qint64 b_dir_level = b->Url().path().count('/');
+ qint64 a_dir_level = a->Url().path().count(QLatin1Char('/'));
+ qint64 b_dir_level = b->Url().path().count(QLatin1Char('/'));
return a_dir_level < b_dir_level;
@@ -1615,7 +1616,7 @@ void Playlist::ItemsLoaded() {
emit RestoreFinished();
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
bool greyout = s.value("greyout_songs_startup", true).toBool();
s.endGroup();
diff --git a/src/playlist/playlistbackend.cpp b/src/playlist/playlistbackend.cpp
index 5ecd12ea74..662fe3c16e 100644
--- a/src/playlist/playlistbackend.cpp
+++ b/src/playlist/playlistbackend.cpp
@@ -116,11 +116,11 @@ PlaylistBackend::PlaylistList PlaylistBackend::GetPlaylists(const GetPlaylistsFl
}
QString condition;
if (!condition_list.isEmpty()) {
- condition = " WHERE " + condition_list.join(QStringLiteral(" OR "));
+ condition = QStringLiteral(" WHERE ") + condition_list.join(QStringLiteral(" OR "));
}
SqlQuery q(db);
- q.prepare("SELECT ROWID, name, last_played, special_type, ui_path, is_favorite, dynamic_playlist_type, dynamic_playlist_data, dynamic_playlist_backend FROM playlists " + condition + " ORDER BY ui_order");
+ q.prepare(QStringLiteral("SELECT ROWID, name, last_played, special_type, ui_path, is_favorite, dynamic_playlist_type, dynamic_playlist_data, dynamic_playlist_backend FROM playlists ") + condition + QStringLiteral(" ORDER BY ui_order"));
if (!q.Exec()) {
db_->ReportErrors(q);
return ret;
@@ -184,7 +184,7 @@ PlaylistItemPtrList PlaylistBackend::GetPlaylistItems(const int playlist) {
QMutexLocker l(db_->Mutex());
QSqlDatabase db(db_->Connect());
- QString query = "SELECT songs.ROWID, " + Song::JoinSpec(QStringLiteral("songs")) + ", p.ROWID, " + Song::JoinSpec(QStringLiteral("p")) + ", p.type FROM playlist_items AS p LEFT JOIN songs ON p.collection_id = songs.ROWID WHERE p.playlist = :playlist";
+ QString query = QStringLiteral("SELECT songs.ROWID, ") + Song::JoinSpec(QStringLiteral("songs")) + QStringLiteral(", p.ROWID, ") + Song::JoinSpec(QStringLiteral("p")) + QStringLiteral(", p.type FROM playlist_items AS p LEFT JOIN songs ON p.collection_id = songs.ROWID WHERE p.playlist = :playlist");
SqlQuery q(db);
// Forward iterations only may be faster
q.setForwardOnly(true);
@@ -219,7 +219,7 @@ SongList PlaylistBackend::GetPlaylistSongs(const int playlist) {
QMutexLocker l(db_->Mutex());
QSqlDatabase db(db_->Connect());
- QString query = "SELECT songs.ROWID, " + Song::JoinSpec(QStringLiteral("songs")) + ", p.ROWID, " + Song::JoinSpec(QStringLiteral("p")) + ", p.type FROM playlist_items AS p LEFT JOIN songs ON p.collection_id = songs.ROWID WHERE p.playlist = :playlist";
+ QString query = QStringLiteral("SELECT songs.ROWID, ") + Song::JoinSpec(QStringLiteral("songs")) + QStringLiteral(", p.ROWID, ") + Song::JoinSpec(QStringLiteral("p")) + QStringLiteral(", p.type FROM playlist_items AS p LEFT JOIN songs ON p.collection_id = songs.ROWID WHERE p.playlist = :playlist");
SqlQuery q(db);
// Forward iterations only may be faster
q.setForwardOnly(true);
@@ -296,7 +296,7 @@ PlaylistItemPtr PlaylistBackend::RestoreCueData(PlaylistItemPtr item, SharedPtr<
QFile cue_file(cue_path);
if (!cue_file.open(QIODevice::ReadOnly)) return item;
- song_list = cue_parser.Load(&cue_file, cue_path, QDir(cue_path.section('/', 0, -2)));
+ song_list = cue_parser.Load(&cue_file, cue_path, QDir(cue_path.section(QLatin1Char('/'), 0, -2)));
cue_file.close();
state->cached_cues_[cue_path] = song_list;
}
@@ -348,7 +348,7 @@ void PlaylistBackend::SavePlaylist(int playlist, const PlaylistItemPtrList &item
// Save the new ones
for (PlaylistItemPtr item : items) { // clazy:exclude=range-loop-reference
SqlQuery q(db);
- q.prepare("INSERT INTO playlist_items (playlist, type, collection_id, " + Song::kColumnSpec + ") VALUES (:playlist, :type, :collection_id, " + Song::kBindSpec + ")");
+ q.prepare(QStringLiteral("INSERT INTO playlist_items (playlist, type, collection_id, ") + Song::kColumnSpec + QStringLiteral(") VALUES (:playlist, :type, :collection_id, ") + Song::kBindSpec + QStringLiteral(")"));
q.BindValue(QStringLiteral(":playlist"), playlist);
item->BindToQuery(&q);
diff --git a/src/playlist/playlistcontainer.cpp b/src/playlist/playlistcontainer.cpp
index 8eb217acb0..10a1b36c29 100644
--- a/src/playlist/playlistcontainer.cpp
+++ b/src/playlist/playlistcontainer.cpp
@@ -48,6 +48,7 @@
#include "core/shared_ptr.h"
#include "core/iconloader.h"
+#include "core/settings.h"
#include "playlist.h"
#include "playlisttabbar.h"
#include "playlistview.h"
@@ -135,7 +136,7 @@ PlaylistContainer::PlaylistContainer(QWidget *parent)
QStringLiteral("
") +
tr("Search terms for numerical fields can be prefixed with %1 or %2 to refine the search, e.g.: ")
- .arg(" =, !=, <, >, <=", ">=") +
+ .arg(QStringLiteral(" =, !=, <, >, <="), QStringLiteral(">=")) +
QStringLiteral("") +
tr("rating") +
QStringLiteral("") +
@@ -144,7 +145,7 @@ PlaylistContainer::PlaylistContainer(QWidget *parent)
QStringLiteral("
") +
tr("Multiple search terms can also be combined with \"%1\" (default) and \"%2\", as well as grouped with parentheses. ")
- .arg("AND", "OR") +
+ .arg(QStringLiteral("AND"), QStringLiteral("OR")) +
QStringLiteral("
") +
tr("Available fields") +
@@ -268,7 +269,7 @@ void PlaylistContainer::SetViewModel(Playlist *playlist, const int scroll_positi
void PlaylistContainer::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
int iconsize = s.value(AppearanceSettingsPage::kIconSizePlaylistButtons, 20).toInt();
s.endGroup();
@@ -305,11 +306,11 @@ void PlaylistContainer::FocusSearchField() {
}
void PlaylistContainer::ActivePlaying() {
- UpdateActiveIcon(QIcon(":/pictures/tiny-play.png"));
+ UpdateActiveIcon(QIcon(QStringLiteral(":/pictures/tiny-play.png")));
}
void PlaylistContainer::ActivePaused() {
- UpdateActiveIcon(QIcon(":/pictures/tiny-pause.png"));
+ UpdateActiveIcon(QIcon(QStringLiteral(":/pictures/tiny-pause.png")));
}
void PlaylistContainer::ActiveStopped() { UpdateActiveIcon(QIcon()); }
diff --git a/src/playlist/playlistcontainer.h b/src/playlist/playlistcontainer.h
index 5e4030495d..d993d96091 100644
--- a/src/playlist/playlistcontainer.h
+++ b/src/playlist/playlistcontainer.h
@@ -45,6 +45,7 @@ class PlaylistView;
class Ui_PlaylistContainer;
#include "core/shared_ptr.h"
+#include "core/settings.h"
class PlaylistContainer : public QWidget {
Q_OBJECT
@@ -122,7 +123,7 @@ class PlaylistContainer : public QWidget {
QAction *redo_;
Playlist *playlist_;
- QSettings settings_;
+ Settings settings_;
bool starting_up_;
bool tab_bar_visible_;
diff --git a/src/playlist/playlistdelegates.cpp b/src/playlist/playlistdelegates.cpp
index 633b0b522d..bfeef19a7b 100644
--- a/src/playlist/playlistdelegates.cpp
+++ b/src/playlist/playlistdelegates.cpp
@@ -110,7 +110,7 @@ void QueuedItemDelegate::DrawBox(QPainter *painter, const QRect line_rect, const
smaller.setBold(true);
if (width == -1) {
- width = QFontMetrics(font).horizontalAdvance(text + " ");
+ width = QFontMetrics(font).horizontalAdvance(text + QStringLiteral(" "));
}
QRect rect(line_rect);
@@ -197,7 +197,7 @@ QString PlaylistDelegateBase::displayText(const QVariant &value, const QLocale&)
break;
}
- if (!text.isNull() && !suffix_.isNull()) text += " " + suffix_;
+ if (!text.isNull() && !suffix_.isNull()) text += QStringLiteral(" ") + suffix_;
return text;
}
diff --git a/src/playlist/playlistfilterparser.cpp b/src/playlist/playlistfilterparser.cpp
index b97f5e1d94..95786eda46 100644
--- a/src/playlist/playlistfilterparser.cpp
+++ b/src/playlist/playlistfilterparser.cpp
@@ -358,7 +358,7 @@ FilterTree *FilterParser::parseAndGroup() {
do {
group->add(parseSearchExpression());
advance();
- if (iter_ != end_ && *iter_ == QChar(')')) break;
+ if (iter_ != end_ && *iter_ == QLatin1Char(')')) break;
if (checkOr(false)) {
break;
}
@@ -372,16 +372,16 @@ FilterTree *FilterParser::parseAndGroup() {
bool FilterParser::checkAnd() {
if (iter_ != end_) {
- if (*iter_ == QChar('A')) {
+ if (*iter_ == QLatin1Char('A')) {
buf_ += *iter_;
++iter_;
- if (iter_ != end_ && *iter_ == QChar('N')) {
+ if (iter_ != end_ && *iter_ == QLatin1Char('N')) {
buf_ += *iter_;
++iter_;
- if (iter_ != end_ && *iter_ == QChar('D')) {
+ if (iter_ != end_ && *iter_ == QLatin1Char('D')) {
buf_ += *iter_;
++iter_;
- if (iter_ != end_ && (iter_->isSpace() || *iter_ == QChar('-') || *iter_ == '(')) {
+ if (iter_ != end_ && (iter_->isSpace() || *iter_ == QLatin1Char('-') || *iter_ == QLatin1Char('('))) {
advance();
buf_.clear();
return true;
@@ -397,7 +397,7 @@ bool FilterParser::checkAnd() {
bool FilterParser::checkOr(const bool step_over) {
if (!buf_.isEmpty()) {
- if (buf_ == "OR") {
+ if (buf_ == QLatin1String("OR")) {
if (step_over) {
buf_.clear();
advance();
@@ -407,13 +407,13 @@ bool FilterParser::checkOr(const bool step_over) {
}
else {
if (iter_ != end_) {
- if (*iter_ == 'O') {
+ if (*iter_ == QLatin1Char('O')) {
buf_ += *iter_;
++iter_;
- if (iter_ != end_ && *iter_ == 'R') {
+ if (iter_ != end_ && *iter_ == QLatin1Char('R')) {
buf_ += *iter_;
++iter_;
- if (iter_ != end_ && (iter_->isSpace() || *iter_ == '-' || *iter_ == '(')) {
+ if (iter_ != end_ && (iter_->isSpace() || *iter_ == QLatin1Char('-') || *iter_ == QLatin1Char('('))) {
if (step_over) {
buf_.clear();
advance();
@@ -432,19 +432,19 @@ FilterTree *FilterParser::parseSearchExpression() {
advance();
if (iter_ == end_) return new NopFilter;
- if (*iter_ == '(') {
+ if (*iter_ == QLatin1Char('(')) {
++iter_;
advance();
FilterTree *tree = parseOrGroup();
advance();
if (iter_ != end_) {
- if (*iter_ == ')') {
+ if (*iter_ == QLatin1Char(')')) {
++iter_;
}
}
return tree;
}
- else if (*iter_ == '-') {
+ else if (*iter_ == QLatin1Char('-')) {
++iter_;
FilterTree *tree = parseSearchExpression();
if (tree->type() != FilterTree::FilterType::Nop) return new NotFilter(tree);
@@ -464,7 +464,7 @@ FilterTree *FilterParser::parseSearchTerm() {
bool inQuotes = false;
for (; iter_ != end_; ++iter_) {
if (inQuotes) {
- if (*iter_ == '"') {
+ if (*iter_ == QLatin1Char('"')) {
inQuotes = false;
}
else {
@@ -472,23 +472,23 @@ FilterTree *FilterParser::parseSearchTerm() {
}
}
else {
- if (*iter_ == '"') {
+ if (*iter_ == QLatin1Char('"')) {
inQuotes = true;
}
- else if (col.isEmpty() && *iter_ == ':') {
+ else if (col.isEmpty() && *iter_ == QLatin1Char(':')) {
col = buf_.toLower();
buf_.clear();
prefix.clear(); // prefix isn't allowed here - let's ignore it
}
- else if (iter_->isSpace() || *iter_ == '(' || *iter_ == ')' || *iter_ == '-') {
+ else if (iter_->isSpace() || *iter_ == QLatin1Char('(') || *iter_ == QLatin1Char(')') || *iter_ == QLatin1Char('-')) {
break;
}
else if (buf_.isEmpty()) {
// we don't know whether there is a column part in this search term thus we assume the latter and just try and read a prefix
- if (prefix.isEmpty() && (*iter_ == '>' || *iter_ == '<' || *iter_ == '=' || *iter_ == '!')) {
+ if (prefix.isEmpty() && (*iter_ == QLatin1Char('>') || *iter_ == QLatin1Char('<') || *iter_ == QLatin1Char('=') || *iter_ == QLatin1Char('!'))) {
prefix += *iter_;
}
- else if (prefix != "=" && *iter_ == '=') {
+ else if (prefix != QLatin1String("=") && *iter_ == QLatin1Char('=')) {
prefix += *iter_;
}
else {
@@ -510,7 +510,7 @@ FilterTree *FilterParser::parseSearchTerm() {
FilterTree *FilterParser::createSearchTermTreeNode(const QString &col, const QString &prefix, const QString &search) const {
- if (search.isEmpty() && prefix != "=") {
+ if (search.isEmpty() && prefix != QLatin1String("=")) {
return new NopFilter;
}
// here comes a mess :/
@@ -521,29 +521,29 @@ FilterTree *FilterParser::createSearchTermTreeNode(const QString &col, const QSt
if (columns_[col] == Playlist::Column_Rating) {
float parsed_search = Utilities::ParseSearchRating(search);
- if (prefix == "=") {
+ if (prefix == QStringLiteral("=")) {
cmp = new FloatEqComparator(parsed_search);
}
- else if (prefix == "!=" || prefix == "<>") {
+ else if (prefix == QStringLiteral("!=") || prefix == QStringLiteral("<>")) {
cmp = new FloatNeComparator(parsed_search);
}
- else if (prefix == ">") {
+ else if (prefix == QStringLiteral(">")) {
cmp = new FloatGtComparator(parsed_search);
}
- else if (prefix == ">=") {
+ else if (prefix == QStringLiteral(">=")) {
cmp = new FloatGeComparator(parsed_search);
}
- else if (prefix == "<") {
+ else if (prefix == QStringLiteral("<")) {
cmp = new FloatLtComparator(parsed_search);
}
- else if (prefix == "<=") {
+ else if (prefix == QStringLiteral("<=")) {
cmp = new FloatLeComparator(parsed_search);
}
else {
cmp = new FloatEqComparator(parsed_search);
}
}
- else if (prefix == "!=" || prefix == "<>") {
+ else if (prefix == QStringLiteral("!=") || prefix == QStringLiteral("<>")) {
cmp = new NeComparator(search);
}
else if (!col.isEmpty() && columns_.contains(col) && numerical_columns_.contains(columns_[col])) {
@@ -556,16 +556,16 @@ FilterTree *FilterParser::createSearchTermTreeNode(const QString &col, const QSt
search_value = search.toInt();
}
// alright, back to deciding which comparator we'll use
- if (prefix == ">") {
+ if (prefix == QLatin1String(">")) {
cmp = new GtComparator(search_value);
}
- else if (prefix == ">=") {
+ else if (prefix == QLatin1String(">=")) {
cmp = new GeComparator(search_value);
}
- else if (prefix == "<") {
+ else if (prefix == QLatin1String("<")) {
cmp = new LtComparator(search_value);
}
- else if (prefix == "<=") {
+ else if (prefix == QLatin1String("<=")) {
cmp = new LeComparator(search_value);
}
else {
@@ -574,19 +574,19 @@ FilterTree *FilterParser::createSearchTermTreeNode(const QString &col, const QSt
}
}
else {
- if (prefix == "=") {
+ if (prefix == QStringLiteral("=")) {
cmp = new EqComparator(search);
}
- else if (prefix == ">") {
+ else if (prefix == QStringLiteral(">")) {
cmp = new LexicalGtComparator(search);
}
- else if (prefix == ">=") {
+ else if (prefix == QStringLiteral(">=")) {
cmp = new LexicalGeComparator(search);
}
- else if (prefix == "<") {
+ else if (prefix == QStringLiteral("<")) {
cmp = new LexicalLtComparator(search);
}
- else if (prefix == "<=") {
+ else if (prefix == QStringLiteral("<=")) {
cmp = new LexicalLeComparator(search);
}
else {
diff --git a/src/playlist/playlistheader.cpp b/src/playlist/playlistheader.cpp
index d75f65e0b2..ea7d123088 100644
--- a/src/playlist/playlistheader.cpp
+++ b/src/playlist/playlistheader.cpp
@@ -37,6 +37,7 @@
#include "playlistheader.h"
#include "playlistview.h"
+#include "core/settings.h"
#include "widgets/stretchheaderview.h"
#include "settings/playlistsettingspage.h"
@@ -81,7 +82,7 @@ PlaylistHeader::PlaylistHeader(Qt::Orientation orientation, PlaylistView *view,
QObject::connect(this, &PlaylistHeader::StretchEnabledChanged, action_stretch_, &QAction::setChecked);
- QSettings s;
+ Settings s;
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
action_rating_lock_->setChecked(s.value("rating_locked", false).toBool());
s.endGroup();
diff --git a/src/playlist/playlistlistcontainer.cpp b/src/playlist/playlistlistcontainer.cpp
index cbcf8251b6..533373ae0c 100644
--- a/src/playlist/playlistlistcontainer.cpp
+++ b/src/playlist/playlistlistcontainer.cpp
@@ -49,6 +49,7 @@
#include "core/application.h"
#include "core/iconloader.h"
#include "core/player.h"
+#include "core/settings.h"
#include "playlist.h"
#include "playlistbackend.h"
#include "playlistlistview.h"
@@ -150,7 +151,7 @@ void PlaylistListContainer::SetApplication(Application *app) {
void PlaylistListContainer::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
int iconsize = s.value(AppearanceSettingsPage::kIconSizeLeftPanelButtons, 22).toInt();
s.endGroup();
@@ -213,7 +214,7 @@ void PlaylistListContainer::NewFolderClicked() {
return;
}
- name.replace(QLatin1String("/"), QLatin1String(" "));
+ name.replace(QLatin1Char('/'), QLatin1Char(' '));
model_->invisibleRootItem()->appendRow(model_->NewFolder(name));
@@ -504,7 +505,7 @@ void PlaylistListContainer::ActivePlaying() {
}
void PlaylistListContainer::ActivePaused() {
- UpdateActiveIcon(active_playlist_id_, QIcon(":/pictures/tiny-pause.png"));
+ UpdateActiveIcon(active_playlist_id_, QIcon(QStringLiteral(":/pictures/tiny-pause.png")));
}
void PlaylistListContainer::ActiveStopped() {
diff --git a/src/playlist/playlistlistmodel.cpp b/src/playlist/playlistlistmodel.cpp
index b571cb3546..cab6a8aeb5 100644
--- a/src/playlist/playlistlistmodel.cpp
+++ b/src/playlist/playlistlistmodel.cpp
@@ -159,9 +159,9 @@ QStandardItem *PlaylistListModel::FolderByPath(const QString &path) {
QStandardItem *parent = invisibleRootItem();
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
- const QStringList parts = path.split('/', Qt::SkipEmptyParts);
+ const QStringList parts = path.split(QLatin1Char('/'), Qt::SkipEmptyParts);
#else
- const QStringList parts = path.split('/', QString::SkipEmptyParts);
+ const QStringList parts = path.split(QLatin1Char('/'), QString::SkipEmptyParts);
#endif
for (const QString &part : parts) {
diff --git a/src/playlist/playlistlistview.cpp b/src/playlist/playlistlistview.cpp
index 95eb01c4fa..11cbc49a9f 100644
--- a/src/playlist/playlistlistview.cpp
+++ b/src/playlist/playlistlistview.cpp
@@ -69,7 +69,7 @@ void PlaylistListView::selectionChanged(const QItemSelection&, const QItemSelect
void PlaylistListView::dragEnterEvent(QDragEnterEvent *e) {
- if (e->mimeData()->hasFormat(Playlist::kRowsMimetype)) {
+ if (e->mimeData()->hasFormat(QString::fromUtf8(Playlist::kRowsMimetype))) {
e->acceptProposedAction();
}
else {
@@ -86,7 +86,7 @@ void PlaylistListView::dragMoveEvent(QDragMoveEvent *e) {
QModelIndex drag_hover_tab_ = indexAt(e->pos());
#endif
- if (e->mimeData()->hasFormat(Playlist::kRowsMimetype)) {
+ if (e->mimeData()->hasFormat(QString::fromUtf8(Playlist::kRowsMimetype))) {
if (drag_hover_tab_ != currentIndex()) {
e->setDropAction(Qt::CopyAction);
e->accept(visualRect(drag_hover_tab_));
@@ -124,7 +124,7 @@ void PlaylistListView::timerEvent(QTimerEvent *e) {
void PlaylistListView::dropEvent(QDropEvent *e) {
- if (e->mimeData()->hasFormat(Playlist::kRowsMimetype)) {
+ if (e->mimeData()->hasFormat(QLatin1String(Playlist::kRowsMimetype))) {
if (drag_hover_timer_.isActive()) {
drag_hover_timer_.stop();
}
diff --git a/src/playlist/playlistmanager.cpp b/src/playlist/playlistmanager.cpp
index 9fa8232d69..09f865feef 100644
--- a/src/playlist/playlistmanager.cpp
+++ b/src/playlist/playlistmanager.cpp
@@ -45,6 +45,7 @@
#include "core/shared_ptr.h"
#include "core/application.h"
#include "core/player.h"
+#include "core/settings.h"
#include "utilities/filenameconstants.h"
#include "utilities/timeutils.h"
#include "collection/collectionbackend.h"
@@ -241,7 +242,7 @@ void PlaylistManager::ItemsLoadedForSavePlaylist(const SongList &songs, const QS
void PlaylistManager::SaveWithUI(const int id, const QString &playlist_name) {
- QSettings s;
+ Settings s;
s.beginGroup(Playlist::kSettingsGroup);
QString last_save_filter = s.value("last_save_filter", parser()->default_filter()).toString();
QString last_save_path = s.value("last_save_path", QDir::homePath()).toString();
@@ -249,7 +250,7 @@ void PlaylistManager::SaveWithUI(const int id, const QString &playlist_name) {
s.endGroup();
QString suggested_filename = playlist_name;
- QString filename = last_save_path + "/" + suggested_filename.remove(QRegularExpression(QString(kProblematicCharactersRegex), QRegularExpression::CaseInsensitiveOption)) + "." + last_save_extension;
+ QString filename = last_save_path + QStringLiteral("/") + suggested_filename.remove(QRegularExpression(QLatin1String(kProblematicCharactersRegex), QRegularExpression::CaseInsensitiveOption)) + QStringLiteral(".") + last_save_extension;
QFileInfo fileinfo;
forever {
@@ -441,7 +442,7 @@ void PlaylistManager::UpdateSummaryText() {
QString summary;
if (selected > 1) {
- summary += tr("%1 selected of").arg(selected) + " ";
+ summary += tr("%1 selected of").arg(selected) + QStringLiteral(" ");
}
else {
nanoseconds = current()->GetTotalLength();
@@ -450,7 +451,7 @@ void PlaylistManager::UpdateSummaryText() {
summary += tr("%n track(s)", "", tracks);
if (nanoseconds > 0) {
- summary += " - [ " + Utilities::WordyTimeNanosec(nanoseconds) + " ]";
+ summary += QStringLiteral(" - [ ") + Utilities::WordyTimeNanosec(nanoseconds) + QStringLiteral(" ]");
}
emit SummaryTextChanged(summary);
@@ -565,7 +566,7 @@ QString PlaylistManager::GetNameForNewPlaylist(const SongList &songs) {
if (!various_artists && albums.size() == 1) {
QStringList album_names = albums.values();
- result += " - " + album_names.first();
+ result += QStringLiteral(" - ") + album_names.first();
}
return result;
@@ -633,7 +634,7 @@ void PlaylistManager::SaveAllPlaylists() {
QString extension = dialog.extension();
if (extension.isEmpty()) extension = parser()->default_extension();
- QSettings s;
+ Settings s;
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
PlaylistSettingsPage::PathType path_type = static_cast(s.value("path_type", static_cast(PlaylistSettingsPage::PathType::Automatic)).toInt());
s.endGroup();
@@ -646,7 +647,7 @@ void PlaylistManager::SaveAllPlaylists() {
for (QMap::const_iterator it = playlists_.constBegin(); it != playlists_.constEnd(); ++it) {
const Data &data = *it;
- const QString filepath = path + "/" + data.name + "." + extension;
+ const QString filepath = path + QStringLiteral("/") + data.name + QStringLiteral(".") + extension;
Save(it.key(), filepath, path_type);
}
diff --git a/src/playlist/playlistproxystyle.cpp b/src/playlist/playlistproxystyle.cpp
index fbfc2d6e28..ca041dc32b 100644
--- a/src/playlist/playlistproxystyle.cpp
+++ b/src/playlist/playlistproxystyle.cpp
@@ -41,7 +41,7 @@ void PlaylistProxyStyle::drawControl(ControlElement element, const QStyleOption
const QFontMetrics &font_metrics = header_option->fontMetrics;
// Spaces added to make transition less abrupt
- if (rect.width() < font_metrics.horizontalAdvance(text + " ")) {
+ if (rect.width() < font_metrics.horizontalAdvance(text + QStringLiteral(" "))) {
const Playlist::Column column = static_cast(header_option->section);
QStyleOptionHeader new_option(*header_option);
new_option.text = Playlist::abbreviated_column_name(column);
diff --git a/src/playlist/playlistsaveoptionsdialog.cpp b/src/playlist/playlistsaveoptionsdialog.cpp
index 8e8ebfe122..c38774b018 100644
--- a/src/playlist/playlistsaveoptionsdialog.cpp
+++ b/src/playlist/playlistsaveoptionsdialog.cpp
@@ -27,6 +27,7 @@
#include
#include
+#include "core/settings.h"
#include "settings/playlistsettingspage.h"
#include "playlistsaveoptionsdialog.h"
#include "ui_playlistsaveoptionsdialog.h"
@@ -48,7 +49,7 @@ PlaylistSaveOptionsDialog::~PlaylistSaveOptionsDialog() { delete ui; }
void PlaylistSaveOptionsDialog::accept() {
if (ui->remember_user_choice->isChecked()) {
- QSettings s;
+ Settings s;
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
s.setValue("path_type", ui->filePaths->itemData(ui->filePaths->currentIndex()).toInt());
s.endGroup();
diff --git a/src/playlist/playlisttabbar.cpp b/src/playlist/playlisttabbar.cpp
index 92c836cebb..84462cfe51 100644
--- a/src/playlist/playlisttabbar.cpp
+++ b/src/playlist/playlisttabbar.cpp
@@ -47,6 +47,7 @@
#include "core/shared_ptr.h"
#include "core/iconloader.h"
#include "core/mimedata.h"
+#include "core/settings.h"
#include "widgets/favoritewidget.h"
#include "widgets/renametablineedit.h"
#include "playlist.h"
@@ -217,14 +218,14 @@ void PlaylistTabBar::CloseSlot() {
const int playlist_id = tabData(menu_index_).toInt();
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
const bool ask_for_delete = s.value("warn_close_playlist", true).toBool();
if (ask_for_delete && !manager_->IsPlaylistFavorite(playlist_id) && !manager_->playlist(playlist_id)->GetAllSongs().empty()) {
QMessageBox confirmation_box;
- confirmation_box.setWindowIcon(QIcon(":/icons/64x64/strawberry.png"));
+ confirmation_box.setWindowIcon(QIcon(QStringLiteral(":/icons/64x64/strawberry.png")));
confirmation_box.setWindowTitle(tr("Remove playlist"));
confirmation_box.setIcon(QMessageBox::Question);
confirmation_box.setText(
@@ -345,8 +346,8 @@ void PlaylistTabBar::CurrentIndexChanged(const int index) {
void PlaylistTabBar::InsertTab(const int id, const int index, const QString &text, const bool favorite) {
QString new_text = text;
- if (new_text.contains('&')) {
- new_text = new_text.replace('&', QLatin1String("&&"));
+ if (new_text.contains(QLatin1Char('&'))) {
+ new_text = new_text.replace(QLatin1Char('&'), QLatin1String("&&"));
}
suppress_current_changed_ = true;
@@ -381,7 +382,7 @@ void PlaylistTabBar::TabMoved() {
}
void PlaylistTabBar::dragEnterEvent(QDragEnterEvent *e) {
- if (e->mimeData()->hasUrls() || e->mimeData()->hasFormat(Playlist::kRowsMimetype) || qobject_cast(e->mimeData())) {
+ if (e->mimeData()->hasUrls() || e->mimeData()->hasFormat(QString::fromUtf8(Playlist::kRowsMimetype)) || qobject_cast(e->mimeData())) {
e->acceptProposedAction();
}
}
diff --git a/src/playlist/playlistview.cpp b/src/playlist/playlistview.cpp
index cf432c5f33..004cf0d5c7 100644
--- a/src/playlist/playlistview.cpp
+++ b/src/playlist/playlistview.cpp
@@ -63,6 +63,7 @@
#include "core/player.h"
#include "core/qt_blurimage.h"
#include "core/song.h"
+#include "core/settings.h"
#include "playlistmanager.h"
#include "playlist.h"
#include "playlistdelegates.h"
@@ -291,7 +292,7 @@ void PlaylistView::SetPlaylist(Playlist *playlist) {
void PlaylistView::LoadHeaderState() {
- QSettings s;
+ Settings s;
s.beginGroup(Playlist::kSettingsGroup);
if (s.contains("state")) {
header_state_version_ = s.value("state_version", 0).toInt();
@@ -1171,7 +1172,7 @@ void PlaylistView::PlaylistDestroyed() {
void PlaylistView::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
bars_enabled_ = s.value("show_bars", true).toBool();
@@ -1286,7 +1287,7 @@ void PlaylistView::SaveSettings() {
if (!header_state_loaded_ || read_only_settings_) return;
- QSettings s;
+ Settings s;
s.beginGroup(Playlist::kSettingsGroup);
s.setValue("state_version", header_state_version_);
s.setValue("state", header_->SaveState());
diff --git a/src/playlistparsers/asxiniparser.cpp b/src/playlistparsers/asxiniparser.cpp
index d82d8f2490..6a94adf334 100644
--- a/src/playlistparsers/asxiniparser.cpp
+++ b/src/playlistparsers/asxiniparser.cpp
@@ -54,7 +54,7 @@ SongList AsxIniParser::Load(QIODevice *device, const QString &playlist_path, con
while (!device->atEnd()) {
QString line = QString::fromUtf8(device->readLine()).trimmed();
- qint64 equals = line.indexOf('=');
+ qint64 equals = line.indexOf(QLatin1Char('='));
QString key = line.left(equals).toLower();
QString value = line.mid(equals + 1);
diff --git a/src/playlistparsers/asxparser.cpp b/src/playlistparsers/asxparser.cpp
index acde4214b9..2dc01eb062 100644
--- a/src/playlistparsers/asxparser.cpp
+++ b/src/playlistparsers/asxparser.cpp
@@ -50,7 +50,7 @@ SongList ASXParser::Load(QIODevice *device, const QString &playlist_path, const
// Some playlists have unescaped & characters in URLs :(
QRegularExpression ex(QStringLiteral("(href\\s*=\\s*\")([^\"]+)\""), QRegularExpression::CaseInsensitiveOption);
qint64 index = 0;
- for (QRegularExpressionMatch re_match = ex.match(data, index); re_match.hasMatch(); re_match = ex.match(data, index)) {
+ for (QRegularExpressionMatch re_match = ex.match(QString::fromUtf8(data), index); re_match.hasMatch(); re_match = ex.match(QString::fromUtf8(data), index)) {
index = re_match.capturedStart();
QString url = re_match.captured(2);
url.replace(QRegularExpression(QStringLiteral("&(?!amp;|quot;|apos;|lt;|gt;)")), QStringLiteral("&"));
@@ -92,21 +92,21 @@ Song ASXParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const bool
switch (type) {
case QXmlStreamReader::StartElement: {
- QString name = reader->name().toString().toLower();
- if (name == "ref") {
- ref = reader->attributes().value("href").toString();
+ const QString name = reader->name().toString().toLower();
+ if (name == QStringLiteral("ref")) {
+ ref = reader->attributes().value(QStringLiteral("href")).toString();
}
- else if (name == "title") {
+ else if (name == QStringLiteral("title")) {
title = reader->readElementText();
}
- else if (name == "author") {
+ else if (name == QStringLiteral("author")) {
artist = reader->readElementText();
}
break;
}
case QXmlStreamReader::EndElement: {
- QString name = reader->name().toString().toLower();
- if (name == "entry") {
+ const QString name = reader->name().toString().toLower();
+ if (name == QStringLiteral("entry")) {
goto return_song;
}
break;
@@ -138,16 +138,16 @@ void ASXParser::Save(const SongList &songs, QIODevice *device, const QDir&, cons
writer.writeStartDocument();
{
StreamElement asx(QStringLiteral("asx"), &writer);
- writer.writeAttribute("version", "3.0");
+ writer.writeAttribute(QStringLiteral("version"), QStringLiteral("3.0"));
for (const Song &song : songs) {
StreamElement entry(QStringLiteral("entry"), &writer);
- writer.writeTextElement("title", song.title());
+ writer.writeTextElement(QStringLiteral("title"), song.title());
{
StreamElement ref(QStringLiteral("ref"), &writer);
- writer.writeAttribute("href", song.url().toString());
+ writer.writeAttribute(QStringLiteral("href"), song.url().toString());
}
if (!song.artist().isEmpty()) {
- writer.writeTextElement("author", song.artist());
+ writer.writeTextElement(QStringLiteral("author"), song.artist());
}
}
}
diff --git a/src/playlistparsers/cueparser.cpp b/src/playlistparsers/cueparser.cpp
index 2c71ce3582..5f62721401 100644
--- a/src/playlistparsers/cueparser.cpp
+++ b/src/playlistparsers/cueparser.cpp
@@ -43,22 +43,24 @@
class CollectionBackendInterface;
-const char *CueParser::kFileLineRegExp = "(\\S+)\\s+(?:\"([^\"]+)\"|(\\S+))\\s*(?:\"([^\"]+)\"|(\\S+))?";
-const char *CueParser::kIndexRegExp = "(\\d{1,3}):(\\d{2}):(\\d{2})";
+namespace {
+static constexpr char kFileLineRegExp[] = "(\\S+)\\s+(?:\"([^\"]+)\"|(\\S+))\\s*(?:\"([^\"]+)\"|(\\S+))?";
+static constexpr char kIndexRegExp[] = "(\\d{1,3}):(\\d{2}):(\\d{2})";
-const char *CueParser::kPerformer = "performer";
-const char *CueParser::kTitle = "title";
-const char *CueParser::kSongWriter = "songwriter";
+static constexpr char kPerformer[] = "performer";
+static constexpr char kTitle[] = "title";
+static constexpr char kSongWriter[] = "songwriter";
// composer may be in cue file and is synonym for songwriter
-const char *CueParser::kComposer = "composer";
-const char *CueParser::kFile = "file";
-const char *CueParser::kTrack = "track";
-const char *CueParser::kIndex = "index";
-const char *CueParser::kAudioTrackType = "audio";
-const char *CueParser::kRem = "rem";
-const char *CueParser::kGenre = "genre";
-const char *CueParser::kDate = "date";
-const char *CueParser::kDisc = "discnumber";
+static constexpr char kComposer[] = "composer";
+static constexpr char kFile[] = "file";
+static constexpr char kTrack[] = "track";
+static constexpr char kIndex[] = "index";
+static constexpr char kAudioTrackType[] = "audio";
+static constexpr char kRem[] = "rem";
+static constexpr char kGenre[] = "genre";
+static constexpr char kDate[] = "date";
+static constexpr char kDisc[] = "discnumber";
+}
CueParser::CueParser(SharedPtr collection_backend, QObject *parent)
: ParserBase(collection_backend, parent) {}
@@ -106,40 +108,40 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
const QString &line_name = splitted[0];
const QString &line_value = splitted[1];
- if (line_name.compare(kPerformer, Qt::CaseInsensitive) == 0) {
+ if (line_name.compare(QString::fromUtf8(kPerformer), Qt::CaseInsensitive) == 0) {
album_artist = line_value;
}
- else if (line_name.compare(kTitle, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QString::fromUtf8(kTitle), Qt::CaseInsensitive) == 0) {
album = line_value;
}
- else if (line_name.compare(kSongWriter, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QString::fromUtf8(kSongWriter), Qt::CaseInsensitive) == 0) {
album_composer = line_value;
}
- else if (line_name.compare(kComposer, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QString::fromUtf8(kComposer), Qt::CaseInsensitive) == 0) {
album_composer = line_value;
}
- else if (line_name.compare(kFile, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QString::fromUtf8(kFile), Qt::CaseInsensitive) == 0) {
file = QDir::isAbsolutePath(line_value) ? line_value : dir.absoluteFilePath(line_value);
if (splitted.size() > 2) {
file_type = splitted[2];
}
}
- else if (line_name.compare(kRem, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QString::fromUtf8(kRem), Qt::CaseInsensitive) == 0) {
if (splitted.size() < 3) {
break;
}
- if (line_value.compare(kGenre, Qt::CaseInsensitive) == 0) {
+ if (line_value.compare(QString::fromUtf8(kGenre), Qt::CaseInsensitive) == 0) {
album_genre = splitted[2];
}
- else if (line_value.compare(kDate, Qt::CaseInsensitive) == 0) {
+ else if (line_value.compare(QString::fromUtf8(kDate), Qt::CaseInsensitive) == 0) {
album_date = splitted[2];
}
- else if (line_value.compare(kDisc, Qt::CaseInsensitive) == 0) {
+ else if (line_value.compare(QString::fromUtf8(kDisc), Qt::CaseInsensitive) == 0) {
disc = splitted[2];
}
}
// end of the header -> go into the track mode
- else if (line_name.compare(kTrack, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QString::fromUtf8(kTrack), Qt::CaseInsensitive) == 0) {
files++;
break;
}
@@ -175,11 +177,11 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
const QString &line_value = splitted[1];
QString line_additional = splitted.size() > 2 ? splitted[2].toLower() : QLatin1String("");
- if (line_name.compare(kTrack, Qt::CaseInsensitive) == 0) {
+ if (line_name.compare(QString::fromUtf8(kTrack), Qt::CaseInsensitive) == 0) {
// the beginning of another track's definition - we're saving the current one for later (if it's valid of course)
// please note that the same code is repeated just after this 'do-while' loop
- if (valid_file && !index.isEmpty() && (track_type.isEmpty() || track_type.compare(kAudioTrackType, Qt::CaseInsensitive) == 0)) {
+ if (valid_file && !index.isEmpty() && (track_type.isEmpty() || track_type.compare(QLatin1String(kAudioTrackType), Qt::CaseInsensitive) == 0)) {
entries.append(CueEntry(file, index, title, artist, album_artist, album, composer, album_composer, (genre.isEmpty() ? album_genre : genre), (date.isEmpty() ? album_date : date), disc));
}
@@ -191,43 +193,43 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
}
}
- else if (line_name.compare(kIndex, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QLatin1String(kIndex), Qt::CaseInsensitive) == 0) {
// We need the index's position field
if (!line_additional.isEmpty()) {
// If there's none "01" index, we'll just take the first one also, we'll take the "01" index even if it's the last one
- if (line_value == "01" || index.isEmpty()) {
+ if (line_value == QStringLiteral("01") || index.isEmpty()) {
index = line_additional;
}
}
}
- else if (line_name.compare(kTitle, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QLatin1String(kTitle), Qt::CaseInsensitive) == 0) {
title = line_value;
}
- else if (line_name.compare(kDate, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QLatin1String(kDate), Qt::CaseInsensitive) == 0) {
date = line_value;
}
- else if (line_name.compare(kPerformer, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QLatin1String(kPerformer), Qt::CaseInsensitive) == 0) {
artist = line_value;
}
- else if (line_name.compare(kSongWriter, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QLatin1String(kSongWriter), Qt::CaseInsensitive) == 0) {
composer = line_value;
}
- else if (line_name.compare(kComposer, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QLatin1String(kComposer), Qt::CaseInsensitive) == 0) {
composer = line_value;
}
// End of tracks for the current file -> parse next one
- else if (line_name.compare(kRem, Qt::CaseInsensitive) == 0 && splitted.size() >= 3) {
- if (line_value.compare(kGenre, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QLatin1String(kRem), Qt::CaseInsensitive) == 0 && splitted.size() >= 3) {
+ if (line_value.compare(QLatin1String(kGenre), Qt::CaseInsensitive) == 0) {
genre = splitted[2];
}
- else if (line_value.compare(kDate, Qt::CaseInsensitive) == 0) {
+ else if (line_value.compare(QLatin1String(kDate), Qt::CaseInsensitive) == 0) {
date = splitted[2];
}
}
- else if (line_name.compare(kFile, Qt::CaseInsensitive) == 0) {
+ else if (line_name.compare(QLatin1String(kFile), Qt::CaseInsensitive) == 0) {
break;
}
@@ -235,7 +237,7 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
} while (!(line = text_stream.readLine()).isNull());
// We didn't add the last song yet...
- if (valid_file && !index.isEmpty() && (track_type.isEmpty() || track_type.compare(kAudioTrackType, Qt::CaseInsensitive) == 0)) {
+ if (valid_file && !index.isEmpty() && (track_type.isEmpty() || track_type.compare(QLatin1String(kAudioTrackType), Qt::CaseInsensitive) == 0)) {
entries.append(CueEntry(file, index, title, artist, album_artist, album, composer, album_composer, (genre.isEmpty() ? album_genre : genre), (date.isEmpty() ? album_date : date), disc));
}
}
@@ -285,7 +287,7 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
// line into logical parts and getting rid of all the unnecessary whitespaces and quoting.
QStringList CueParser::SplitCueLine(const QString &line) {
- QRegularExpression line_regexp(kFileLineRegExp);
+ QRegularExpression line_regexp(QString::fromUtf8(kFileLineRegExp));
QRegularExpressionMatch re_match = line_regexp.match(line.trimmed());
if (!re_match.hasMatch()) {
return QStringList();
@@ -356,7 +358,7 @@ bool CueParser::UpdateLastSong(const CueEntry &entry, Song *song) {
qint64 CueParser::IndexToMarker(const QString &index) {
- QRegularExpression index_regexp(kIndexRegExp);
+ QRegularExpression index_regexp(QString::fromUtf8(kIndexRegExp));
QRegularExpressionMatch re_match = index_regexp.match(index);
if (!re_match.hasMatch()) {
return -1;
@@ -382,14 +384,14 @@ void CueParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
// Looks for a track starting with one of the .cue's keywords.
bool CueParser::TryMagic(const QByteArray &data) const {
- QStringList splitted = QString::fromUtf8(data.constData()).split('\n');
+ QStringList splitted = QString::fromUtf8(data.constData()).split(QLatin1Char('\n'));
for (int i = 0; i < splitted.length(); i++) {
QString line = splitted.at(i).trimmed();
- if (line.startsWith(kPerformer, Qt::CaseInsensitive) ||
- line.startsWith(kTitle, Qt::CaseInsensitive) ||
- line.startsWith(kFile, Qt::CaseInsensitive) ||
- line.startsWith(kTrack, Qt::CaseInsensitive)) {
+ if (line.startsWith(QLatin1String(kPerformer), Qt::CaseInsensitive) ||
+ line.startsWith(QLatin1String(kTitle), Qt::CaseInsensitive) ||
+ line.startsWith(QLatin1String(kFile), Qt::CaseInsensitive) ||
+ line.startsWith(QLatin1String(kTrack), Qt::CaseInsensitive)) {
return true;
}
}
@@ -400,8 +402,8 @@ bool CueParser::TryMagic(const QByteArray &data) const {
QString CueParser::FindCueFilename(const QString &filename) {
- QStringList cue_files = QStringList() << filename + ".cue"
- << filename.section('.', 0, -2) + ".cue";
+ QStringList cue_files = QStringList() << filename + QStringLiteral(".cue")
+ << filename.section(QLatin1Char('.'), 0, -2) + QStringLiteral(".cue");
for (const QString &cuefile : cue_files) {
if (QFileInfo::exists(cuefile)) return cuefile;
diff --git a/src/playlistparsers/cueparser.h b/src/playlistparsers/cueparser.h
index eb04d74a82..0b42226637 100644
--- a/src/playlistparsers/cueparser.h
+++ b/src/playlistparsers/cueparser.h
@@ -45,22 +45,6 @@ class CueParser : public ParserBase {
Q_OBJECT
public:
- static const char *kFileLineRegExp;
- static const char *kIndexRegExp;
-
- static const char *kPerformer;
- static const char *kTitle;
- static const char *kSongWriter;
- static const char *kComposer;
- static const char *kFile;
- static const char *kTrack;
- static const char *kIndex;
- static const char *kAudioTrackType;
- static const char *kRem;
- static const char *kGenre;
- static const char *kDate;
- static const char *kDisc;
-
explicit CueParser(SharedPtr collection_backend, QObject *parent = nullptr);
QString name() const override { return QStringLiteral("CUE"); }
diff --git a/src/playlistparsers/m3uparser.cpp b/src/playlistparsers/m3uparser.cpp
index 88c1a00546..7240b9fa20 100644
--- a/src/playlistparsers/m3uparser.cpp
+++ b/src/playlistparsers/m3uparser.cpp
@@ -29,6 +29,7 @@
#include "core/shared_ptr.h"
#include "core/logging.h"
+#include "core/settings.h"
#include "utilities/timeconstants.h"
#include "settings/playlistsettingspage.h"
#include "parserbase.h"
@@ -47,7 +48,7 @@ SongList M3UParser::Load(QIODevice *device, const QString &playlist_path, const
Metadata current_metadata;
QString data = QString::fromUtf8(device->readAll());
- data.replace('\r', '\n');
+ data.replace(QLatin1Char('\r'), QLatin1Char('\n'));
data.replace(QLatin1String("\n\n"), QLatin1String("\n"));
QByteArray bytes = data.toUtf8();
QBuffer buffer(&bytes);
@@ -62,7 +63,7 @@ SongList M3UParser::Load(QIODevice *device, const QString &playlist_path, const
SongList ret;
forever {
- if (line.startsWith('#')) {
+ if (line.startsWith(QLatin1Char('#'))) {
// Extended info or comment.
if (type == M3UType::EXTENDED && line.startsWith(QLatin1String("#EXT"))) {
if (!ParseMetadata(line, ¤t_metadata)) {
@@ -101,8 +102,8 @@ bool M3UParser::ParseMetadata(const QString &line, M3UParser::Metadata *metadata
// Extended info, eg.
// #EXTINF:123,Sample Artist - Sample title
- QString info = line.section(':', 1);
- QString l = info.section(',', 0, 0);
+ QString info = line.section(QLatin1Char(':'), 1);
+ QString l = info.section(QLatin1Char(','), 0, 0);
bool ok = false;
int length = l.toInt(&ok);
if (!ok) {
@@ -110,7 +111,7 @@ bool M3UParser::ParseMetadata(const QString &line, M3UParser::Metadata *metadata
}
metadata->length = length * kNsecPerSec;
- QString track_info = info.section(',', 1);
+ QString track_info = info.section(QLatin1Char(','), 1);
QStringList list = track_info.split(QStringLiteral(" - "));
if (list.size() <= 1) {
metadata->title = track_info;
@@ -126,7 +127,7 @@ void M3UParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
device->write("#EXTM3U\n");
- QSettings s;
+ Settings s;
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
bool write_metadata = s.value("write_metadata", true).toBool();
s.endGroup();
diff --git a/src/playlistparsers/parserbase.cpp b/src/playlistparsers/parserbase.cpp
index ec7cb570b9..1e065a1a7a 100644
--- a/src/playlistparsers/parserbase.cpp
+++ b/src/playlistparsers/parserbase.cpp
@@ -65,7 +65,7 @@ void ParserBase::LoadSong(const QString &filename_or_url, const qint64 beginning
// Strawberry always wants / separators internally.
// Using QDir::fromNativeSeparators() only works on the same platform the playlist was created on/for, using replace() lets playlists work on any platform.
- filename = filename.replace('\\', '/');
+ filename = filename.replace(QLatin1Char('\\'), QLatin1Char('/'));
// Make the path absolute
if (!QDir::isAbsolutePath(filename)) {
diff --git a/src/playlistparsers/playlistparser.cpp b/src/playlistparsers/playlistparser.cpp
index ef5136ac9c..597e9d0733 100644
--- a/src/playlistparsers/playlistparser.cpp
+++ b/src/playlistparsers/playlistparser.cpp
@@ -113,7 +113,7 @@ QString PlaylistParser::FilterForParser(const ParserBase *parser, QStringList *a
QStringList extensions;
extensions.reserve(file_extensions.count());
for (const QString &extension : file_extensions) {
- extensions << "*." + extension;
+ extensions << QStringLiteral("*.") + extension;
}
if (all_extensions) *all_extensions << extensions;
diff --git a/src/playlistparsers/plsparser.cpp b/src/playlistparsers/plsparser.cpp
index 0e8e421b51..591b2f546a 100644
--- a/src/playlistparsers/plsparser.cpp
+++ b/src/playlistparsers/plsparser.cpp
@@ -54,7 +54,7 @@ SongList PLSParser::Load(QIODevice *device, const QString &playlist_path, const
while (!device->atEnd()) {
QString line = QString::fromUtf8(device->readLine()).trimmed();
- qint64 equals = line.indexOf('=');
+ qint64 equals = line.indexOf(QLatin1Char('='));
QString key = line.left(equals).toLower();
QString value = line.mid(equals + 1);
diff --git a/src/playlistparsers/wplparser.cpp b/src/playlistparsers/wplparser.cpp
index 459faf448e..2246769ef2 100644
--- a/src/playlistparsers/wplparser.cpp
+++ b/src/playlistparsers/wplparser.cpp
@@ -68,9 +68,9 @@ void WplParser::ParseSeq(const QDir &dir, QXmlStreamReader *reader, SongList *so
QXmlStreamReader::TokenType type = reader->readNext();
QString name = reader->name().toString();
switch (type) {
- case QXmlStreamReader::StartElement: {
- if (name == "media") {
- QString src = reader->attributes().value("src").toString();
+ case QXmlStreamReader::StartElement:{
+ if (name == QStringLiteral("media")) {
+ QString src = reader->attributes().value(QStringLiteral("src")).toString();
if (!src.isEmpty()) {
Song song = LoadSong(src, 0, 0, dir, collection_search);
if (song.is_valid()) {
@@ -83,8 +83,8 @@ void WplParser::ParseSeq(const QDir &dir, QXmlStreamReader *reader, SongList *so
}
break;
}
- case QXmlStreamReader::EndElement: {
- if (name == "seq") {
+ case QXmlStreamReader::EndElement:{
+ if (name == QStringLiteral("seq")) {
return;
}
break;
@@ -101,13 +101,13 @@ void WplParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
QXmlStreamWriter writer(device);
writer.setAutoFormatting(true);
writer.setAutoFormattingIndent(2);
- writer.writeProcessingInstruction("wpl", "version=\"1.0\"");
+ writer.writeProcessingInstruction(QStringLiteral("wpl"), QStringLiteral("version=\"1.0\""));
StreamElement smil(QStringLiteral("smil"), &writer);
{
StreamElement head(QStringLiteral("head"), &writer);
- WriteMeta(QStringLiteral("Generator"), "Strawberry -- " STRAWBERRY_VERSION_DISPLAY, &writer);
+ WriteMeta(QStringLiteral("Generator"), QStringLiteral("Strawberry -- ") + QLatin1String(STRAWBERRY_VERSION_DISPLAY), &writer);
WriteMeta(QStringLiteral("ItemCount"), QString::number(songs.count()), &writer);
}
@@ -116,8 +116,8 @@ void WplParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
{
StreamElement seq(QStringLiteral("seq"), &writer);
for (const Song &song : songs) {
- writer.writeStartElement("media");
- writer.writeAttribute("src", URLOrFilename(song.url(), dir, path_type));
+ writer.writeStartElement(QStringLiteral("media"));
+ writer.writeAttribute(QStringLiteral("src"), URLOrFilename(song.url(), dir, path_type));
writer.writeEndElement();
}
}
@@ -126,9 +126,9 @@ void WplParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
void WplParser::WriteMeta(const QString &name, const QString &content, QXmlStreamWriter *writer) {
- writer->writeStartElement("meta");
- writer->writeAttribute("name", name);
- writer->writeAttribute("content", content);
+ writer->writeStartElement(QStringLiteral("meta"));
+ writer->writeAttribute(QStringLiteral("name"), name);
+ writer->writeAttribute(QStringLiteral("content"), content);
writer->writeEndElement();
}
diff --git a/src/playlistparsers/xspfparser.cpp b/src/playlistparsers/xspfparser.cpp
index 783bef4586..76aa0ee115 100644
--- a/src/playlistparsers/xspfparser.cpp
+++ b/src/playlistparsers/xspfparser.cpp
@@ -30,6 +30,7 @@
#include
#include "core/shared_ptr.h"
+#include "core/settings.h"
#include "utilities/xmlutils.h"
#include "utilities/timeconstants.h"
#include "settings/playlistsettingspage.h"
@@ -73,22 +74,22 @@ Song XSPFParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const boo
QString name = reader->name().toString();
switch (type) {
case QXmlStreamReader::StartElement: {
- if (name == "location") {
+ if (name == QStringLiteral("location")) {
location = QUrl::fromPercentEncoding(reader->readElementText().toUtf8());
}
- else if (name == "title") {
+ else if (name == QStringLiteral("title")) {
title = reader->readElementText();
}
- else if (name == "creator") {
+ else if (name == QStringLiteral("creator")) {
artist = reader->readElementText();
}
- else if (name == "album") {
+ else if (name == QStringLiteral("album")) {
album = reader->readElementText();
}
- else if (name == "image") {
+ else if (name == QStringLiteral("image")) {
art = QUrl::fromPercentEncoding(reader->readElementText().toUtf8());
}
- else if (name == "duration") { // in milliseconds.
+ else if (name == QStringLiteral("duration")) { // in milliseconds.
const QString duration = reader->readElementText();
bool ok = false;
nanosec = duration.toInt(&ok) * kNsecPerMsec;
@@ -96,7 +97,7 @@ Song XSPFParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const boo
nanosec = -1;
}
}
- else if (name == "trackNum") {
+ else if (name == QStringLiteral("trackNum")) {
const QString track_num_str = reader->readElementText();
bool ok = false;
track_num = track_num_str.toInt(&ok);
@@ -104,13 +105,13 @@ Song XSPFParser::ParseTrack(QXmlStreamReader *reader, const QDir &dir, const boo
track_num = -1;
}
}
- else if (name == "info") {
+ else if (name == QStringLiteral("info")) {
// TODO: Do something with extra info?
}
break;
}
case QXmlStreamReader::EndElement: {
- if (name == "track") {
+ if (name == QStringLiteral("track")) {
goto return_song;
}
}
@@ -143,44 +144,44 @@ void XSPFParser::Save(const SongList &songs, QIODevice *device, const QDir &dir,
writer.setAutoFormattingIndent(2);
writer.writeStartDocument();
StreamElement playlist(QStringLiteral("playlist"), &writer);
- writer.writeAttribute("version", "1");
- writer.writeDefaultNamespace("http://xspf.org/ns/0/");
+ writer.writeAttribute(QStringLiteral("version"), QStringLiteral("1"));
+ writer.writeDefaultNamespace(QStringLiteral("http://xspf.org/ns/0/"));
- QSettings s;
+ Settings s;
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
bool write_metadata = s.value("write_metadata", true).toBool();
s.endGroup();
StreamElement tracklist(QStringLiteral("trackList"), &writer);
for (const Song &song : songs) {
- QString filename_or_url = QUrl::toPercentEncoding(URLOrFilename(song.url(), dir, path_type), "/ ");
+ QString filename_or_url = QString::fromLatin1(QUrl::toPercentEncoding(URLOrFilename(song.url(), dir, path_type), "/ "));
StreamElement track(QStringLiteral("track"), &writer);
- writer.writeTextElement("location", filename_or_url);
+ writer.writeTextElement(QStringLiteral("location"), filename_or_url);
if (write_metadata || (song.is_stream() && !song.is_radio())) {
- writer.writeTextElement("title", song.title());
+ writer.writeTextElement(QStringLiteral("title"), song.title());
if (!song.artist().isEmpty()) {
- writer.writeTextElement("creator", song.artist());
+ writer.writeTextElement(QStringLiteral("creator"), song.artist());
}
if (!song.album().isEmpty()) {
- writer.writeTextElement("album", song.album());
+ writer.writeTextElement(QStringLiteral("album"), song.album());
}
if (song.length_nanosec() != -1) {
- writer.writeTextElement("duration", QString::number(song.length_nanosec() / kNsecPerMsec));
+ writer.writeTextElement(QStringLiteral("duration"), QString::number(song.length_nanosec() / kNsecPerMsec));
}
}
if ((write_metadata || song.has_cue() || (song.is_stream() && !song.is_radio())) && song.track() > 0) {
- writer.writeTextElement("trackNum", QString::number(song.track()));
+ writer.writeTextElement(QStringLiteral("trackNum"), QString::number(song.track()));
}
if (write_metadata || (song.is_stream() && !song.is_radio())) {
const QUrl cover_url = song.art_manual().isEmpty() || !song.art_manual().isValid() ? song.art_automatic() : song.art_manual();
// Ignore images that are in our resource bundle.
if (!cover_url.isEmpty() && cover_url.isValid()) {
- const QString cover_filename = QUrl::toPercentEncoding(URLOrFilename(cover_url, dir, path_type), "/ ");
- writer.writeTextElement("image", cover_filename);
+ const QString cover_filename = QString::fromLatin1(QUrl::toPercentEncoding(URLOrFilename(cover_url, dir, path_type), "/ "));
+ writer.writeTextElement(QStringLiteral("image"), cover_filename);
}
}
}
diff --git a/src/providers/musixmatchprovider.cpp b/src/providers/musixmatchprovider.cpp
index 69a9aac81a..78e4a2f7ed 100644
--- a/src/providers/musixmatchprovider.cpp
+++ b/src/providers/musixmatchprovider.cpp
@@ -27,12 +27,12 @@ const char *MusixmatchProvider::kApiKey = "Y2FhMDRlN2Y4OWE5OTIxYmZlOGMzOWQzOGI3Z
QString MusixmatchProvider::StringFixup(QString text) {
- return text.replace('/', '-')
- .replace('\'', '-')
+ return text.replace(QLatin1Char('/'), QLatin1Char('-'))
+ .replace(QLatin1Char('\''), QLatin1Char('-'))
.remove(QRegularExpression(QStringLiteral("[^\\w0-9\\- ]"), QRegularExpression::UseUnicodePropertiesOption))
.replace(QRegularExpression(QStringLiteral(" {2,}")), QStringLiteral(" "))
.simplified()
- .replace(' ', '-')
+ .replace(QLatin1Char(' '), QLatin1Char('-'))
.replace(QRegularExpression(QStringLiteral("(-)\\1+")), QStringLiteral("-"))
.toLower();
diff --git a/src/qobuz/qobuzbaserequest.cpp b/src/qobuz/qobuzbaserequest.cpp
index b546833979..3004498e14 100644
--- a/src/qobuz/qobuzbaserequest.cpp
+++ b/src/qobuz/qobuzbaserequest.cpp
@@ -52,20 +52,20 @@ QobuzBaseRequest::~QobuzBaseRequest() = default;
QNetworkReply *QobuzBaseRequest::CreateRequest(const QString &ressource_name, const ParamList ¶ms_provided) {
ParamList params = ParamList() << params_provided
- << Param("app_id", app_id());
+ << Param(QStringLiteral("app_id"), app_id());
std::sort(params.begin(), params.end());
QUrlQuery url_query;
for (const Param ¶m : params) {
- url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
+ url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
- QUrl url(QString(QobuzService::kApiUrl) + QStringLiteral("/") + ressource_name);
+ QUrl url(QString::fromLatin1(QobuzService::kApiUrl) + QStringLiteral("/") + ressource_name);
url.setQuery(url_query);
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
- req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
+ req.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
req.setRawHeader("X-App-Id", app_id().toUtf8());
if (authenticated()) req.setRawHeader("X-User-Auth-Token", user_auth_token().toUtf8());
@@ -182,7 +182,7 @@ QString QobuzBaseRequest::ErrorsToHTML(const QStringList &errors) {
QString error_html;
for (const QString &error : errors) {
- error_html += error + "
";
+ error_html += error + QStringLiteral("
");
}
return error_html;
diff --git a/src/qobuz/qobuzfavoriterequest.cpp b/src/qobuz/qobuzfavoriterequest.cpp
index 545c8c4e5f..fc3d02bc25 100644
--- a/src/qobuz/qobuzfavoriterequest.cpp
+++ b/src/qobuz/qobuzfavoriterequest.cpp
@@ -132,13 +132,13 @@ void QobuzFavoriteRequest::AddFavorites(const FavoriteType type, const SongList
void QobuzFavoriteRequest::AddFavoritesRequest(const FavoriteType type, const QStringList &ids_list, const SongList &songs) {
- ParamList params = ParamList() << Param("app_id", app_id())
- << Param("user_auth_token", user_auth_token())
- << Param(FavoriteMethod(type), ids_list.join(','));
+ ParamList params = ParamList() << Param(QStringLiteral("app_id"), app_id())
+ << Param(QStringLiteral("user_auth_token"), user_auth_token())
+ << Param(FavoriteMethod(type), ids_list.join(QLatin1Char(',')));
QUrlQuery url_query;
for (const Param ¶m : params) {
- url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
+ url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
QNetworkReply *reply = CreateRequest(QStringLiteral("favorite/create"), params);
@@ -227,13 +227,13 @@ void QobuzFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongLi
void QobuzFavoriteRequest::RemoveFavoritesRequest(const FavoriteType type, const QStringList &ids_list, const SongList &songs) {
- ParamList params = ParamList() << Param("app_id", app_id())
- << Param("user_auth_token", user_auth_token())
- << Param(FavoriteMethod(type), ids_list.join(','));
+ ParamList params = ParamList() << Param(QStringLiteral("app_id"), app_id())
+ << Param(QStringLiteral("user_auth_token"), user_auth_token())
+ << Param(FavoriteMethod(type), ids_list.join(QLatin1Char(',')));
QUrlQuery url_query;
for (const Param ¶m : params) {
- url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
+ url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
QNetworkReply *reply = CreateRequest(QStringLiteral("favorite/delete"), params);
diff --git a/src/qobuz/qobuzrequest.cpp b/src/qobuz/qobuzrequest.cpp
index d911b42b2c..556c15ee4b 100644
--- a/src/qobuz/qobuzrequest.cpp
+++ b/src/qobuz/qobuzrequest.cpp
@@ -225,12 +225,12 @@ void QobuzRequest::FlushArtistsRequests() {
ParamList params;
if (query_type_ == QueryType::Artists) {
- params << Param("type", "artists");
- params << Param("user_auth_token", user_auth_token());
+ params << Param(QStringLiteral("type"), QStringLiteral("artists"));
+ params << Param(QStringLiteral("user_auth_token"), user_auth_token());
}
- else if (query_type_ == QueryType::SearchArtists) params << Param("query", search_text_);
- if (request.limit > 0) params << Param("limit", QString::number(request.limit));
- if (request.offset > 0) params << Param("offset", QString::number(request.offset));
+ else if (query_type_ == QueryType::SearchArtists) params << Param(QStringLiteral("query"), search_text_);
+ if (request.limit > 0) params << Param(QStringLiteral("limit"), QString::number(request.limit));
+ if (request.offset > 0) params << Param(QStringLiteral("offset"), QString::number(request.offset));
QNetworkReply *reply = nullptr;
if (query_type_ == QueryType::Artists) {
reply = CreateRequest(QStringLiteral("favorite/getUserFavorites"), params);
@@ -277,12 +277,12 @@ void QobuzRequest::FlushAlbumsRequests() {
ParamList params;
if (query_type_ == QueryType::Albums) {
- params << Param("type", "albums");
- params << Param("user_auth_token", user_auth_token());
+ params << Param(QStringLiteral("type"), QStringLiteral("albums"));
+ params << Param(QStringLiteral("user_auth_token"), user_auth_token());
}
- else if (query_type_ == QueryType::SearchAlbums) params << Param("query", search_text_);
- if (request.limit > 0) params << Param("limit", QString::number(request.limit));
- if (request.offset > 0) params << Param("offset", QString::number(request.offset));
+ else if (query_type_ == QueryType::SearchAlbums) params << Param(QStringLiteral("query"), search_text_);
+ if (request.limit > 0) params << Param(QStringLiteral("limit"), QString::number(request.limit));
+ if (request.offset > 0) params << Param(QStringLiteral("offset"), QString::number(request.offset));
QNetworkReply *reply = nullptr;
if (query_type_ == QueryType::Albums) {
reply = CreateRequest(QStringLiteral("favorite/getUserFavorites"), params);
@@ -329,12 +329,12 @@ void QobuzRequest::FlushSongsRequests() {
ParamList params;
if (query_type_ == QueryType::Songs) {
- params << Param("type", "tracks");
- params << Param("user_auth_token", user_auth_token());
+ params << Param(QStringLiteral("type"), QStringLiteral("tracks"));
+ params << Param(QStringLiteral("user_auth_token"), user_auth_token());
}
- else if (query_type_ == QueryType::SearchSongs) params << Param("query", search_text_);
- if (request.limit > 0) params << Param("limit", QString::number(request.limit));
- if (request.offset > 0) params << Param("offset", QString::number(request.offset));
+ else if (query_type_ == QueryType::SearchSongs) params << Param(QStringLiteral("query"), search_text_);
+ if (request.limit > 0) params << Param(QStringLiteral("limit"), QString::number(request.limit));
+ if (request.offset > 0) params << Param(QStringLiteral("offset"), QString::number(request.offset));
QNetworkReply *reply = nullptr;
if (query_type_ == QueryType::Songs) {
reply = CreateRequest(QStringLiteral("favorite/getUserFavorites"), params);
@@ -585,10 +585,10 @@ void QobuzRequest::FlushArtistAlbumsRequests() {
const ArtistAlbumsRequest request = artist_albums_requests_queue_.dequeue();
- ParamList params = ParamList() << Param("artist_id", request.artist.artist_id)
- << Param("extra", "albums");
+ ParamList params = ParamList() << Param(QStringLiteral("artist_id"), request.artist.artist_id)
+ << Param(QStringLiteral("extra"), QStringLiteral("albums"));
- if (request.offset > 0) params << Param("offset", QString::number(request.offset));
+ if (request.offset > 0) params << Param(QStringLiteral("offset"), QString::number(request.offset));
QNetworkReply *reply = CreateRequest(QStringLiteral("artist/get"), params);
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, request]() { ArtistAlbumsReplyReceived(reply, request.artist, request.offset); });
replies_ << reply;
@@ -842,8 +842,8 @@ void QobuzRequest::FlushAlbumSongsRequests() {
while (!album_songs_requests_queue_.isEmpty() && album_songs_requests_active_ < kMaxConcurrentAlbumSongsRequests) {
AlbumSongsRequest request = album_songs_requests_queue_.dequeue();
- ParamList params = ParamList() << Param("album_id", request.album.album_id);
- if (request.offset > 0) params << Param("offset", QString::number(request.offset));
+ ParamList params = ParamList() << Param(QStringLiteral("album_id"), request.album.album_id);
+ if (request.offset > 0) params << Param(QStringLiteral("offset"), QString::number(request.offset));
QNetworkReply *reply = CreateRequest(QStringLiteral("album/get"), params);
replies_ << reply;
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, request]() { AlbumSongsReplyReceived(reply, request.artist, request.album, request.offset); });
@@ -1341,8 +1341,8 @@ void QobuzRequest::AlbumCoverReceived(QNetworkReply *reply, const QUrl &cover_ur
}
QString mimetype = reply->header(QNetworkRequest::ContentTypeHeader).toString();
- if (mimetype.contains(';')) {
- mimetype = mimetype.left(mimetype.indexOf(';'));
+ if (mimetype.contains(QLatin1Char(';'))) {
+ mimetype = mimetype.left(mimetype.indexOf(QLatin1Char(';')));
}
if (!ImageUtils::SupportedImageMimeTypes().contains(mimetype, Qt::CaseInsensitive) && !ImageUtils::SupportedImageFormats().contains(mimetype, Qt::CaseInsensitive)) {
Error(QStringLiteral("Unsupported mimetype for image reader %1 for %2").arg(mimetype, cover_url.toString()));
@@ -1351,7 +1351,7 @@ void QobuzRequest::AlbumCoverReceived(QNetworkReply *reply, const QUrl &cover_ur
return;
}
- QByteArray data = reply->readAll();
+ const QByteArray data = reply->readAll();
if (data.isEmpty()) {
Error(QStringLiteral("Received empty image data for %1").arg(cover_url.toString()));
if (album_covers_requests_sent_.contains(cover_url)) album_covers_requests_sent_.remove(cover_url);
diff --git a/src/qobuz/qobuzservice.cpp b/src/qobuz/qobuzservice.cpp
index 0ab02c588e..a8e4a7fb2c 100644
--- a/src/qobuz/qobuzservice.cpp
+++ b/src/qobuz/qobuzservice.cpp
@@ -45,6 +45,7 @@
#include "core/networkaccessmanager.h"
#include "core/database.h"
#include "core/song.h"
+#include "core/settings.h"
#include "utilities/macaddrutils.h"
#include "internet/internetsearchview.h"
#include "collection/collectionbackend.h"
@@ -62,22 +63,26 @@ using std::make_shared;
const Song::Source QobuzService::kSource = Song::Source::Qobuz;
const char QobuzService::kApiUrl[] = "https://www.qobuz.com/api.json/0.2";
+const int QobuzService::kLoginAttempts = 2;
-constexpr char QobuzService::kAuthUrl[] = "https://www.qobuz.com/api.json/0.2/user/login";
+namespace {
-const int QobuzService::kLoginAttempts = 2;
-constexpr int QobuzService::kTimeResetLoginAttempts = 60000;
+constexpr char kAuthUrl[] = "https://www.qobuz.com/api.json/0.2/user/login";
+
+constexpr int kTimeResetLoginAttempts = 60000;
+
+constexpr char kArtistsSongsTable[] = "qobuz_artists_songs";
+constexpr char kAlbumsSongsTable[] = "qobuz_albums_songs";
+constexpr char kSongsTable[] = "qobuz_songs";
-constexpr char QobuzService::kArtistsSongsTable[] = "qobuz_artists_songs";
-constexpr char QobuzService::kAlbumsSongsTable[] = "qobuz_albums_songs";
-constexpr char QobuzService::kSongsTable[] = "qobuz_songs";
+constexpr char kArtistsSongsFtsTable[] = "qobuz_artists_songs_fts";
+constexpr char kAlbumsSongsFtsTable[] = "qobuz_albums_songs_fts";
+constexpr char kSongsFtsTable[] = "qobuz_songs_fts";
-constexpr char QobuzService::kArtistsSongsFtsTable[] = "qobuz_artists_songs_fts";
-constexpr char QobuzService::kAlbumsSongsFtsTable[] = "qobuz_albums_songs_fts";
-constexpr char QobuzService::kSongsFtsTable[] = "qobuz_songs_fts";
+} // namespace
QobuzService::QobuzService(Application *app, QObject *parent)
- : InternetService(Song::Source::Qobuz, QStringLiteral("Qobuz"), QStringLiteral("qobuz"), QobuzSettingsPage::kSettingsGroup, SettingsDialog::Page::Qobuz, app, parent),
+ : InternetService(Song::Source::Qobuz, QStringLiteral("Qobuz"), QStringLiteral("qobuz"), QLatin1String(QobuzSettingsPage::kSettingsGroup), SettingsDialog::Page::Qobuz, app, parent),
app_(app),
network_(app->network()),
url_handler_(new QobuzUrlHandler(app, this)),
@@ -115,15 +120,15 @@ QobuzService::QobuzService(Application *app, QObject *parent)
artists_collection_backend_ = make_shared();
artists_collection_backend_->moveToThread(app_->database()->thread());
- artists_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Qobuz, kArtistsSongsTable, kArtistsSongsFtsTable);
+ artists_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Qobuz, QLatin1String(kArtistsSongsTable), QLatin1String(kArtistsSongsFtsTable));
albums_collection_backend_ = make_shared();
albums_collection_backend_->moveToThread(app_->database()->thread());
- albums_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Qobuz, kAlbumsSongsTable, kAlbumsSongsFtsTable);
+ albums_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Qobuz, QLatin1String(kAlbumsSongsTable), QLatin1String(kAlbumsSongsFtsTable));
songs_collection_backend_ = make_shared();
songs_collection_backend_->moveToThread(app_->database()->thread());
- songs_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Qobuz, kSongsTable, kSongsFtsTable);
+ songs_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Qobuz, QLatin1String(kSongsTable), QLatin1String(kSongsFtsTable));
artists_collection_model_ = new CollectionModel(artists_collection_backend_, app_, this);
albums_collection_model_ = new CollectionModel(albums_collection_backend_, app_, this);
@@ -229,7 +234,7 @@ void QobuzService::ShowConfig() {
void QobuzService::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(QobuzSettingsPage::kSettingsGroup);
app_id_ = s.value("app_id").toString();
@@ -295,21 +300,21 @@ void QobuzService::SendLoginWithCredentials(const QString &app_id, const QString
timer_login_attempt_->setInterval(kTimeResetLoginAttempts);
timer_login_attempt_->start();
- const ParamList params = ParamList() << Param("app_id", app_id)
- << Param("username", username)
- << Param("password", password)
- << Param("device_manufacturer_id", Utilities::MacAddress());
+ const ParamList params = ParamList() << Param(QStringLiteral("app_id"), app_id)
+ << Param(QStringLiteral("username"), username)
+ << Param(QStringLiteral("password"), password)
+ << Param(QStringLiteral("device_manufacturer_id"), Utilities::MacAddress());
QUrlQuery url_query;
for (const Param ¶m : params) {
- url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
+ url_query.addQueryItem(QString::fromUtf8(QUrl::toPercentEncoding(param.first)), QString::fromUtf8(QUrl::toPercentEncoding(param.second)));
}
- QUrl url(kAuthUrl);
+ QUrl url(QString::fromUtf8(kAuthUrl));
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
- req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
+ req.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8();
QNetworkReply *reply = network_->post(req, query);
@@ -369,7 +374,7 @@ void QobuzService::HandleAuthReply(QNetworkReply *reply) {
login_errors_.clear();
- QByteArray data = reply->readAll();
+ const QByteArray data = reply->readAll();
QJsonParseError json_error;
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
@@ -451,7 +456,7 @@ void QobuzService::HandleAuthReply(QNetworkReply *reply) {
}
credential_id_ = obj_credential[QStringLiteral("id")].toInt();
- QSettings s;
+ Settings s;
s.beginGroup(QobuzSettingsPage::kSettingsGroup);
s.setValue("user_auth_token", user_auth_token_);
s.setValue("user_id", user_id_);
@@ -476,7 +481,7 @@ void QobuzService::Logout() {
user_id_ = -1;
credential_id_ = -1;
- QSettings s;
+ Settings s;
s.beginGroup(QobuzSettingsPage::kSettingsGroup);
s.remove("user_id");
s.remove("credential_id");
@@ -784,7 +789,7 @@ void QobuzService::LoginError(const QString &error, const QVariant &debug) {
QString error_html;
for (const QString &e : login_errors_) {
qLog(Error) << "Qobuz:" << e;
- error_html += e + "
";
+ error_html += e + QStringLiteral("
");
}
if (debug.isValid()) qLog(Debug) << debug;
diff --git a/src/qobuz/qobuzservice.h b/src/qobuz/qobuzservice.h
index edfb76e200..5fffc62880 100644
--- a/src/qobuz/qobuzservice.h
+++ b/src/qobuz/qobuzservice.h
@@ -63,6 +63,7 @@ class QobuzService : public InternetService {
static const Song::Source kSource;
static const char kApiUrl[];
+ static const int kLoginAttempts;
void Exit() override;
void ReloadSettings() override;
@@ -147,19 +148,6 @@ class QobuzService : public InternetService {
void SendSearch();
void LoginError(const QString &error = QString(), const QVariant &debug = QVariant());
- static const char kAuthUrl[];
-
- static const int kLoginAttempts;
- static const int kTimeResetLoginAttempts;
-
- static const char kArtistsSongsTable[];
- static const char kAlbumsSongsTable[];
- static const char kSongsTable[];
-
- static const char kArtistsSongsFtsTable[];
- static const char kAlbumsSongsFtsTable[];
- static const char kSongsFtsTable[];
-
Application *app_;
SharedPtr network_;
QobuzUrlHandler *url_handler_;
diff --git a/src/qobuz/qobuzstreamurlrequest.cpp b/src/qobuz/qobuzstreamurlrequest.cpp
index dd410dc633..8a6284900f 100644
--- a/src/qobuz/qobuzstreamurlrequest.cpp
+++ b/src/qobuz/qobuzstreamurlrequest.cpp
@@ -115,26 +115,26 @@ void QobuzStreamURLRequest::GetStreamURL() {
quint64 timestamp = QDateTime::currentDateTime().toSecsSinceEpoch();
- ParamList params_to_sign = ParamList() << Param("format_id", QString::number(format()))
- << Param("track_id", QString::number(song_id_));
+ ParamList params_to_sign = ParamList() << Param(QStringLiteral("format_id"), QString::number(format()))
+ << Param(QStringLiteral("track_id"), QString::number(song_id_));
std::sort(params_to_sign.begin(), params_to_sign.end());
QString data_to_sign;
- data_to_sign += QLatin1String("trackgetFileUrl");
+ data_to_sign += QStringLiteral("trackgetFileUrl");
for (const Param ¶m : params_to_sign) {
data_to_sign += param.first + param.second;
}
data_to_sign += QString::number(timestamp);
- data_to_sign += app_secret().toUtf8();
+ data_to_sign += app_secret();
QByteArray const digest = QCryptographicHash::hash(data_to_sign.toUtf8(), QCryptographicHash::Md5);
- QString signature = QString::fromLatin1(digest.toHex()).rightJustified(32, '0').toLower();
+ const QString signature = QString::fromLatin1(digest.toHex()).rightJustified(32, QLatin1Char('0')).toLower();
ParamList params = params_to_sign;
- params << Param("request_ts", QString::number(timestamp));
- params << Param("request_sig", signature);
- params << Param("user_auth_token", user_auth_token());
+ params << Param(QStringLiteral("request_ts"), QString::number(timestamp));
+ params << Param(QStringLiteral("request_sig"), signature);
+ params << Param(QStringLiteral("user_auth_token"), user_auth_token());
std::sort(params.begin(), params.end());
@@ -192,7 +192,7 @@ void QobuzStreamURLRequest::StreamURLReceived() {
Song::FileType filetype(Song::FileType::Unknown);
QMimeDatabase mimedb;
- QStringList suffixes = mimedb.mimeTypeForName(mimetype.toUtf8()).suffixes();
+ QStringList suffixes = mimedb.mimeTypeForName(mimetype).suffixes();
for (const QString &suffix : suffixes) {
filetype = Song::FiletypeByExtension(suffix);
if (filetype != Song::FileType::Unknown) break;
diff --git a/src/queue/queue.cpp b/src/queue/queue.cpp
index 5f93f2813a..fc931a44c9 100644
--- a/src/queue/queue.cpp
+++ b/src/queue/queue.cpp
@@ -39,7 +39,9 @@
#include "playlist/playlist.h"
#include "queue.h"
-const char *Queue::kRowsMimetype = "application/x-strawberry-queue-rows";
+namespace {
+static constexpr char kRowsMimetype[] = "application/x-strawberry-queue-rows";
+}
Queue::Queue(Playlist *playlist, QObject *parent) : QAbstractProxyModel(parent), playlist_(playlist), total_length_ns_(0) {
@@ -252,7 +254,7 @@ void Queue::UpdateSummaryText() {
summary += tr("%n track(s)", "", tracks);
if (nanoseconds > 0) {
- summary += " - [ " + Utilities::WordyTimeNanosec(nanoseconds) + " ]";
+ summary += QStringLiteral(" - [ ") + Utilities::WordyTimeNanosec(nanoseconds) + QStringLiteral(" ]");
}
emit SummaryTextChanged(summary);
@@ -320,7 +322,7 @@ void Queue::MoveDown(int row) {
}
QStringList Queue::mimeTypes() const {
- return QStringList() << kRowsMimetype << Playlist::kRowsMimetype;
+ return QStringList() << QLatin1String(kRowsMimetype) << QLatin1String(Playlist::kRowsMimetype);
}
Qt::DropActions Queue::supportedDropActions() const {
@@ -343,7 +345,7 @@ QMimeData *Queue::mimeData(const QModelIndexList &indexes) const {
QDataStream stream(&buf);
stream << rows;
buf.close();
- data->setData(kRowsMimetype, buf.data());
+ data->setData(QLatin1String(kRowsMimetype), buf.data());
}
return data;
@@ -355,11 +357,11 @@ bool Queue::dropMimeData(const QMimeData *data, Qt::DropAction action, int row,
if (action == Qt::IgnoreAction)
return false;
- if (data->hasFormat(kRowsMimetype)) {
+ if (data->hasFormat(QLatin1String(kRowsMimetype))) {
// Dragged from the queue
QList proxy_rows;
- QDataStream stream(data->data(kRowsMimetype));
+ QDataStream stream(data->data(QLatin1String(kRowsMimetype)));
stream >> proxy_rows;
// Make sure we take them in order
@@ -367,12 +369,12 @@ bool Queue::dropMimeData(const QMimeData *data, Qt::DropAction action, int row,
Move(proxy_rows, row);
}
- else if (data->hasFormat(Playlist::kRowsMimetype)) {
+ else if (data->hasFormat(QLatin1String(Playlist::kRowsMimetype))) {
// Dragged from the playlist
Playlist *playlist = nullptr;
QList source_rows;
- QDataStream stream(data->data(Playlist::kRowsMimetype));
+ QDataStream stream(data->data(QLatin1String(Playlist::kRowsMimetype)));
stream.readRawData(reinterpret_cast(&playlist), sizeof(Playlist));
stream >> source_rows;
diff --git a/src/queue/queue.h b/src/queue/queue.h
index 4a4321b15b..e96ae9afe6 100644
--- a/src/queue/queue.h
+++ b/src/queue/queue.h
@@ -41,8 +41,6 @@ class Queue : public QAbstractProxyModel {
public:
explicit Queue(Playlist *playlist, QObject *parent = nullptr);
- static const char *kRowsMimetype;
-
// Query the queue
bool is_empty() const;
int PositionOf(const QModelIndex &source_index) const;
diff --git a/src/queue/queueview.cpp b/src/queue/queueview.cpp
index d5ec1c07ba..95b3849233 100644
--- a/src/queue/queueview.cpp
+++ b/src/queue/queueview.cpp
@@ -35,6 +35,7 @@
#include "core/shared_ptr.h"
#include "core/iconloader.h"
+#include "core/settings.h"
#include "playlist/playlist.h"
#include "playlist/playlistdelegates.h"
#include "playlist/playlistmanager.h"
@@ -86,7 +87,7 @@ void QueueView::SetPlaylistManager(SharedPtr playlist_manager)
void QueueView::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
int iconsize = s.value(AppearanceSettingsPage::kIconSizeLeftPanelButtons, 22).toInt();
s.endGroup();
diff --git a/src/radios/radiochannel.cpp b/src/radios/radiochannel.cpp
index 98dce5d9d6..a0ab582dc3 100644
--- a/src/radios/radiochannel.cpp
+++ b/src/radios/radiochannel.cpp
@@ -28,7 +28,7 @@ Song RadioChannel::ToSong() const {
Song song(source);
song.set_valid(true);
song.set_filetype(Song::FileType::Stream);
- song.set_title(Song::DescriptionForSource(source) + " " + name);
+ song.set_title(Song::DescriptionForSource(source) + QStringLiteral(" ") + name);
song.set_url(url);
return song;
diff --git a/src/radios/radiomodel.cpp b/src/radios/radiomodel.cpp
index 16b4195608..fa15e626c7 100644
--- a/src/radios/radiomodel.cpp
+++ b/src/radios/radiomodel.cpp
@@ -181,7 +181,7 @@ void RadioModel::AddChannels(const RadioChannelList &channels) {
RadioItem *item = new RadioItem(RadioItem::Type_Channel, container);
item->source = channel.source;
item->display_text = channel.name;
- item->sort_text = SortText(Song::TextForSource(channel.source) + " - " + channel.name);
+ item->sort_text = SortText(Song::TextForSource(channel.source) + QStringLiteral(" - ") + channel.name);
item->channel = channel;
item->lazy_loaded = true;
items_ << item;
@@ -258,7 +258,7 @@ QString RadioModel::ChannelIconPixmapCacheKey(const QModelIndex &idx) const {
idx_copy = idx_copy.parent();
}
- return path.join('/');
+ return path.join(QLatin1Char('/'));
}
diff --git a/src/radios/radioparadiseservice.cpp b/src/radios/radioparadiseservice.cpp
index 2afa717425..71c9c880a9 100644
--- a/src/radios/radioparadiseservice.cpp
+++ b/src/radios/radioparadiseservice.cpp
@@ -32,7 +32,9 @@
#include "radioparadiseservice.h"
#include "radiochannel.h"
-const char *RadioParadiseService::kApiChannelsUrl = "https://api.radioparadise.com/api/list_streams";
+namespace {
+constexpr char kApiChannelsUrl[] = "https://api.radioparadise.com/api/list_streams";
+}
RadioParadiseService::RadioParadiseService(Application *app, SharedPtr network, QObject *parent)
: RadioService(Song::Source::RadioParadise, QStringLiteral("Radio Paradise"), IconLoader::Load(QStringLiteral("radioparadise")), app, network, parent) {}
@@ -57,7 +59,7 @@ void RadioParadiseService::GetChannels() {
Abort();
- QUrl url(kApiChannelsUrl);
+ QUrl url(QString::fromLatin1(kApiChannelsUrl));
QNetworkRequest req(url);
QNetworkReply *reply = network_->get(req);
replies_ << reply;
@@ -108,11 +110,11 @@ void RadioParadiseService::GetChannelsReply(QNetworkReply *reply, const int task
QString label = obj_stream[QStringLiteral("label")].toString();
QString url = obj_stream[QStringLiteral("url")].toString();
if (!url.contains(QRegularExpression(QStringLiteral("^[0-9a-zA-Z]*:\\/\\/"), QRegularExpression::CaseInsensitiveOption))) {
- url.prepend("https://");
+ url.prepend(QStringLiteral("https://"));
}
RadioChannel channel;
channel.source = source_;
- channel.name = name + " - " + label;
+ channel.name = name + QStringLiteral(" - ") + label;
channel.url.setUrl(url);
channels << channel;
}
diff --git a/src/radios/radioparadiseservice.h b/src/radios/radioparadiseservice.h
index 2341ad826a..ec51533da4 100644
--- a/src/radios/radioparadiseservice.h
+++ b/src/radios/radioparadiseservice.h
@@ -48,7 +48,6 @@ class RadioParadiseService : public RadioService {
void GetChannelsReply(QNetworkReply *reply, const int task_id);
private:
- static const char *kApiChannelsUrl;
QList replies_;
RadioChannelList channels_;
};
diff --git a/src/radios/radioviewcontainer.cpp b/src/radios/radioviewcontainer.cpp
index f721530935..db41b6ded3 100644
--- a/src/radios/radioviewcontainer.cpp
+++ b/src/radios/radioviewcontainer.cpp
@@ -22,6 +22,7 @@
#include
#include "core/iconloader.h"
+#include "core/settings.h"
#include "settings/appearancesettingspage.h"
#include "radioviewcontainer.h"
#include "ui_radioviewcontainer.h"
@@ -44,7 +45,7 @@ RadioViewContainer::~RadioViewContainer() { delete ui_; }
void RadioViewContainer::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
int iconsize = s.value(AppearanceSettingsPage::kIconSizeLeftPanelButtons, 22).toInt();
s.endGroup();
diff --git a/src/radios/somafmservice.cpp b/src/radios/somafmservice.cpp
index e29f495a11..d676c70389 100644
--- a/src/radios/somafmservice.cpp
+++ b/src/radios/somafmservice.cpp
@@ -34,7 +34,9 @@
#include "somafmservice.h"
#include "radiochannel.h"
-const char *SomaFMService::kApiChannelsUrl = "https://somafm.com/channels.json";
+namespace {
+constexpr char kApiChannelsUrl[] = "https://somafm.com/channels.json";
+}
SomaFMService::SomaFMService(Application *app, SharedPtr network, QObject *parent)
: RadioService(Song::Source::SomaFM, QStringLiteral("SomaFM"), IconLoader::Load(QStringLiteral("somafm")), app, network, parent) {}
@@ -63,7 +65,7 @@ void SomaFMService::GetChannels() {
Abort();
- QUrl url(kApiChannelsUrl);
+ QUrl url(QString::fromUtf8(kApiChannelsUrl));
QNetworkRequest req(url);
QNetworkReply *reply = network_->get(req);
replies_ << reply;
@@ -110,13 +112,13 @@ void SomaFMService::GetChannelsReply(QNetworkReply *reply, const int task_id) {
}
RadioChannel channel;
QString quality = obj_playlist[QStringLiteral("quality")].toString();
- if (quality != "highest") continue;
+ if (quality != QStringLiteral("highest")) continue;
channel.source = source_;
channel.name = name;
channel.url.setUrl(obj_playlist[QStringLiteral("url")].toString());
channel.thumbnail_url.setUrl(image);
if (obj_playlist.contains(QStringLiteral("format"))) {
- channel.name.append(" " + obj_playlist[QStringLiteral("format")].toString().toUpper());
+ channel.name.append(QLatin1Char(' ') + obj_playlist[QStringLiteral("format")].toString().toUpper());
}
channels << channel;
}
diff --git a/src/radios/somafmservice.h b/src/radios/somafmservice.h
index da8e649200..df23a7b31c 100644
--- a/src/radios/somafmservice.h
+++ b/src/radios/somafmservice.h
@@ -53,7 +53,6 @@ class SomaFMService : public RadioService {
void GetStreamUrlsReply(QNetworkReply *reply, const int task_id, RadioChannel channel);
private:
- static const char *kApiChannelsUrl;
QList replies_;
RadioChannelList channels_;
};
diff --git a/src/scrobbler/audioscrobbler.h b/src/scrobbler/audioscrobbler.h
index 4e853b3c24..3e5de2e609 100644
--- a/src/scrobbler/audioscrobbler.h
+++ b/src/scrobbler/audioscrobbler.h
@@ -55,7 +55,7 @@ class AudioScrobbler : public QObject {
SharedPtr ServiceByName(const QString &name);
template
SharedPtr Service() {
- return std::static_pointer_cast(ServiceByName(T::kName));
+ return std::static_pointer_cast(ServiceByName(QLatin1String(T::kName)));
}
void ReloadSettings();
diff --git a/src/scrobbler/lastfmimport.cpp b/src/scrobbler/lastfmimport.cpp
index 264efa5f38..f939a57905 100644
--- a/src/scrobbler/lastfmimport.cpp
+++ b/src/scrobbler/lastfmimport.cpp
@@ -41,6 +41,7 @@
#include "core/logging.h"
#include "core/shared_ptr.h"
#include "core/networkaccessmanager.h"
+#include "core/settings.h"
#include "lastfmimport.h"
@@ -94,7 +95,7 @@ void LastFMImport::AbortAll() {
void LastFMImport::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(LastFMScrobbler::kSettingsGroup);
username_ = s.value("username").toString();
s.endGroup();
@@ -104,24 +105,24 @@ void LastFMImport::ReloadSettings() {
QNetworkReply *LastFMImport::CreateRequest(const ParamList &request_params) {
ParamList params = ParamList()
- << Param("api_key", ScrobblingAPI20::kApiKey)
- << Param("user", username_)
- << Param("lang", QLocale().name().left(2).toLower())
- << Param("format", "json")
+ << Param(QStringLiteral("api_key"), QLatin1String(ScrobblingAPI20::kApiKey))
+ << Param(QStringLiteral("user"), username_)
+ << Param(QStringLiteral("lang"), QLocale().name().left(2).toLower())
+ << Param(QStringLiteral("format"), QStringLiteral("json"))
<< request_params;
std::sort(params.begin(), params.end());
QUrlQuery url_query;
for (const Param ¶m : params) {
- url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
+ url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
- QUrl url(LastFMScrobbler::kApiUrl);
+ QUrl url(QLatin1String(LastFMScrobbler::kApiUrl));
url.setQuery(url_query);
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
- req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
+ req.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
QNetworkReply *reply = network_->get(req);
replies_ << reply;
@@ -251,15 +252,15 @@ void LastFMImport::AddGetRecentTracksRequest(const int page) {
void LastFMImport::SendGetRecentTracksRequest(GetRecentTracksRequest request) {
- ParamList params = ParamList() << Param("method", "user.getRecentTracks");
+ ParamList params = ParamList() << Param(QStringLiteral("method"), QStringLiteral("user.getRecentTracks"));
if (request.page == 0) {
- params << Param("page", "1");
- params << Param("limit", "1");
+ params << Param(QStringLiteral("page"), QStringLiteral("1"));
+ params << Param(QStringLiteral("limit"), QStringLiteral("1"));
}
else {
- params << Param("page", QString::number(request.page));
- params << Param("limit", "500");
+ params << Param(QStringLiteral("page"), QString::number(request.page));
+ params << Param(QStringLiteral("limit"), QStringLiteral("500"));
}
QNetworkReply *reply = CreateRequest(params);
@@ -414,15 +415,15 @@ void LastFMImport::AddGetTopTracksRequest(const int page) {
void LastFMImport::SendGetTopTracksRequest(GetTopTracksRequest request) {
- ParamList params = ParamList() << Param("method", "user.getTopTracks");
+ ParamList params = ParamList() << Param(QStringLiteral("method"), QStringLiteral("user.getTopTracks"));
if (request.page == 0) {
- params << Param("page", "1");
- params << Param("limit", "1");
+ params << Param(QStringLiteral("page"), QStringLiteral("1"));
+ params << Param(QStringLiteral("limit"), QStringLiteral("1"));
}
else {
- params << Param("page", QString::number(request.page));
- params << Param("limit", "500");
+ params << Param(QStringLiteral("page"), QString::number(request.page));
+ params << Param(QStringLiteral("limit"), QStringLiteral("500"));
}
QNetworkReply *reply = CreateRequest(params);
diff --git a/src/scrobbler/lastfmscrobbler.cpp b/src/scrobbler/lastfmscrobbler.cpp
index a8de1b8d35..44ae692734 100644
--- a/src/scrobbler/lastfmscrobbler.cpp
+++ b/src/scrobbler/lastfmscrobbler.cpp
@@ -34,4 +34,4 @@ const char *LastFMScrobbler::kApiUrl = "https://ws.audioscrobbler.com/2.0/";
const char *LastFMScrobbler::kCacheFile = "lastfmscrobbler.cache";
LastFMScrobbler::LastFMScrobbler(SharedPtr settings, SharedPtr network, QObject *parent)
- : ScrobblingAPI20(kName, kSettingsGroup, kAuthUrl, kApiUrl, true, kCacheFile, settings, network, parent) {}
+ : ScrobblingAPI20(QLatin1String(kName), QLatin1String(kSettingsGroup), QLatin1String(kAuthUrl), QLatin1String(kApiUrl), true, QLatin1String(kCacheFile), settings, network, parent) {}
diff --git a/src/scrobbler/librefmscrobbler.cpp b/src/scrobbler/librefmscrobbler.cpp
index 1d8a11b2df..08cdbc1234 100644
--- a/src/scrobbler/librefmscrobbler.cpp
+++ b/src/scrobbler/librefmscrobbler.cpp
@@ -35,4 +35,4 @@ const char *LibreFMScrobbler::kApiUrl = "https://libre.fm/2.0/";
const char *LibreFMScrobbler::kCacheFile = "librefmscrobbler.cache";
LibreFMScrobbler::LibreFMScrobbler(SharedPtr settings, SharedPtr network, QObject *parent)
- : ScrobblingAPI20(kName, kSettingsGroup, kAuthUrl, kApiUrl, false, kCacheFile, settings, network, parent) {}
+ : ScrobblingAPI20(QLatin1String(kName), QLatin1String(kSettingsGroup), QLatin1String(kAuthUrl), QLatin1String(kApiUrl), false, QLatin1String(kCacheFile), settings, network, parent) {}
diff --git a/src/scrobbler/listenbrainzscrobbler.cpp b/src/scrobbler/listenbrainzscrobbler.cpp
index 19110cfcb4..8dbc7a349e 100644
--- a/src/scrobbler/listenbrainzscrobbler.cpp
+++ b/src/scrobbler/listenbrainzscrobbler.cpp
@@ -44,6 +44,7 @@
#include "core/networkaccessmanager.h"
#include "core/song.h"
#include "core/logging.h"
+#include "core/settings.h"
#include "utilities/timeconstants.h"
#include "internet/localredirectserver.h"
#include "settings/scrobblersettingspage.h"
@@ -57,19 +58,22 @@
const char *ListenBrainzScrobbler::kName = "ListenBrainz";
const char *ListenBrainzScrobbler::kSettingsGroup = "ListenBrainz";
-const char *ListenBrainzScrobbler::kOAuthAuthorizeUrl = "https://musicbrainz.org/oauth2/authorize";
-const char *ListenBrainzScrobbler::kOAuthAccessTokenUrl = "https://musicbrainz.org/oauth2/token";
-const char *ListenBrainzScrobbler::kOAuthRedirectUrl = "http://localhost";
-const char *ListenBrainzScrobbler::kApiUrl = "https://api.listenbrainz.org";
-const char *ListenBrainzScrobbler::kClientIDB64 = "b2VBVU53cVNRZXIwZXIwOUZpcWkwUQ==";
-const char *ListenBrainzScrobbler::kClientSecretB64 = "Uk9GZ2hrZVEzRjNvUHlFaHFpeVdQQQ==";
-const char *ListenBrainzScrobbler::kCacheFile = "listenbrainzscrobbler.cache";
-const int ListenBrainzScrobbler::kScrobblesPerRequest = 10;
+
+namespace {
+constexpr char kOAuthAuthorizeUrl[] = "https://musicbrainz.org/oauth2/authorize";
+constexpr char kOAuthAccessTokenUrl[] = "https://musicbrainz.org/oauth2/token";
+constexpr char kOAuthRedirectUrl[] = "http://localhost";
+constexpr char kApiUrl[] = "https://api.listenbrainz.org";
+constexpr char kClientIDB64[] = "b2VBVU53cVNRZXIwZXIwOUZpcWkwUQ==";
+constexpr char kClientSecretB64[] = "Uk9GZ2hrZVEzRjNvUHlFaHFpeVdQQQ==";
+constexpr char kCacheFile[] = "listenbrainzscrobbler.cache";
+constexpr int kScrobblesPerRequest = 10;
+} // namespace
ListenBrainzScrobbler::ListenBrainzScrobbler(SharedPtr settings, SharedPtr network, QObject *parent)
- : ScrobblerService(kName, settings, parent),
+ : ScrobblerService(QLatin1String(kName), settings, parent),
network_(network),
- cache_(new ScrobblerCache(kCacheFile, this)),
+ cache_(new ScrobblerCache(QLatin1String(kCacheFile), this)),
server_(nullptr),
enabled_(false),
expires_in_(-1),
@@ -110,7 +114,7 @@ ListenBrainzScrobbler::~ListenBrainzScrobbler() {
void ListenBrainzScrobbler::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
enabled_ = s.value("enabled", false).toBool();
user_token_ = s.value("user_token").toString();
@@ -124,7 +128,7 @@ void ListenBrainzScrobbler::ReloadSettings() {
void ListenBrainzScrobbler::LoadSession() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
access_token_ = s.value("access_token").toString();
expires_in_ = s.value("expires_in", -1).toInt();
@@ -150,13 +154,13 @@ void ListenBrainzScrobbler::Logout() {
expires_in_ = -1;
login_time_ = 0;
- QSettings settings;
- settings.beginGroup(kSettingsGroup);
- settings.remove("access_token");
- settings.remove("expires_in");
- settings.remove("token_type");
- settings.remove("refresh_token");
- settings.endGroup();
+ Settings s;
+ s.beginGroup(kSettingsGroup);
+ s.remove("access_token");
+ s.remove("expires_in");
+ s.remove("token_type");
+ s.remove("refresh_token");
+ s.endGroup();
}
@@ -173,15 +177,15 @@ void ListenBrainzScrobbler::Authenticate() {
QObject::connect(server_, &LocalRedirectServer::Finished, this, &ListenBrainzScrobbler::RedirectArrived);
}
- QUrl redirect_url(kOAuthRedirectUrl);
+ QUrl redirect_url(QString::fromLatin1(kOAuthRedirectUrl));
redirect_url.setPort(server_->url().port());
QUrlQuery url_query;
url_query.addQueryItem(QStringLiteral("response_type"), QStringLiteral("code"));
- url_query.addQueryItem(QStringLiteral("client_id"), QByteArray::fromBase64(kClientIDB64));
+ url_query.addQueryItem(QStringLiteral("client_id"), QString::fromLatin1(QByteArray::fromBase64(kClientIDB64)));
url_query.addQueryItem(QStringLiteral("redirect_uri"), redirect_url.toString());
url_query.addQueryItem(QStringLiteral("scope"), QStringLiteral("profile;email;tag;rating;collection;submit_isrc;submit_barcode"));
- QUrl url(kOAuthAuthorizeUrl);
+ QUrl url(QString::fromLatin1(kOAuthAuthorizeUrl));
url.setQuery(url_query);
bool result = QDesktopServices::openUrl(url);
@@ -268,17 +272,17 @@ void ListenBrainzScrobbler::RequestAccessToken(const QUrl &redirect_url, const Q
refresh_login_timer_.stop();
- ParamList params = ParamList() << Param("client_id", QByteArray::fromBase64(kClientIDB64))
- << Param("client_secret", QByteArray::fromBase64(kClientSecretB64));
+ ParamList params = ParamList() << Param(QStringLiteral("client_id"), QString::fromLatin1(QByteArray::fromBase64(kClientIDB64)))
+ << Param(QStringLiteral("client_secret"), QString::fromLatin1(QByteArray::fromBase64(kClientSecretB64)));
if (!code.isEmpty() && !redirect_url.isEmpty()) {
- params << Param("grant_type", "authorization_code");
- params << Param("code", code);
- params << Param("redirect_uri", redirect_url.toString());
+ params << Param(QStringLiteral("grant_type"), QStringLiteral("authorization_code"));
+ params << Param(QStringLiteral("code"), code);
+ params << Param(QStringLiteral("redirect_uri"), redirect_url.toString());
}
else if (!refresh_token_.isEmpty() && enabled_) {
- params << Param("grant_type", "refresh_token");
- params << Param("refresh_token", refresh_token_);
+ params << Param(QStringLiteral("grant_type"), QStringLiteral("refresh_token"));
+ params << Param(QStringLiteral("refresh_token"), refresh_token_);
}
else {
return;
@@ -286,14 +290,14 @@ void ListenBrainzScrobbler::RequestAccessToken(const QUrl &redirect_url, const Q
QUrlQuery url_query;
for (const Param ¶m : params) {
- url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
+ url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
- QUrl session_url(kOAuthAccessTokenUrl);
+ QUrl session_url(QString::fromLatin1(kOAuthAccessTokenUrl));
QNetworkRequest req(session_url);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
- req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
+ req.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8();
QNetworkReply *reply = network_->post(req, query);
replies_ << reply;
@@ -328,7 +332,7 @@ void ListenBrainzScrobbler::AuthenticateReplyFinished(QNetworkReply *reply) {
}
login_time_ = QDateTime::currentDateTime().toSecsSinceEpoch();
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("access_token", access_token_);
s.setValue("expires_in", expires_in_);
@@ -354,7 +358,7 @@ QNetworkReply *ListenBrainzScrobbler::CreateRequest(const QUrl &url, const QJson
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
- req.setHeader(QNetworkRequest::ContentTypeHeader, "application/json");
+ req.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/json"));
req.setRawHeader("Authorization", QStringLiteral("Token %1").arg(user_token_).toUtf8());
QNetworkReply *reply = network_->post(req, json_doc.toJson());
replies_ << reply;
@@ -398,13 +402,13 @@ QJsonObject ListenBrainzScrobbler::JsonTrackMetadata(const ScrobbleMetadata &met
QStringList artist_mbids_list;
if (!metadata.musicbrainz_album_artist_id.isEmpty()) {
- artist_mbids_list << metadata.musicbrainz_album_artist_id.split('/');
+ artist_mbids_list << metadata.musicbrainz_album_artist_id.split(QLatin1Char('/'));
}
if (!metadata.musicbrainz_artist_id.isEmpty()) {
- artist_mbids_list << metadata.musicbrainz_artist_id.split('/');
+ artist_mbids_list << metadata.musicbrainz_artist_id.split(QLatin1Char('/'));
}
if (!metadata.musicbrainz_original_artist_id.isEmpty()) {
- artist_mbids_list << metadata.musicbrainz_original_artist_id.split('/');
+ artist_mbids_list << metadata.musicbrainz_original_artist_id.split(QLatin1Char('/'));
}
if (!artist_mbids_list.isEmpty()) {
QJsonArray artist_mbids_array;
@@ -456,11 +460,11 @@ void ListenBrainzScrobbler::UpdateNowPlaying(const Song &song) {
QJsonArray array_payload;
array_payload.append(object_listen);
QJsonObject object;
- object.insert(QStringLiteral("listen_type"), "playing_now");
+ object.insert(QStringLiteral("listen_type"), QStringLiteral("playing_now"));
object.insert(QStringLiteral("payload"), array_payload);
QJsonDocument doc(object);
- QUrl url(QStringLiteral("%1/1/submit-listens").arg(kApiUrl));
+ QUrl url(QStringLiteral("%1/1/submit-listens").arg(QLatin1String(kApiUrl)));
QNetworkReply *reply = CreateRequest(url, doc);
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply]() { UpdateNowPlayingRequestFinished(reply); });
@@ -559,11 +563,11 @@ void ListenBrainzScrobbler::Submit() {
submitted_ = true;
QJsonObject object;
- object.insert(QStringLiteral("listen_type"), "import");
+ object.insert(QStringLiteral("listen_type"), QStringLiteral("import"));
object.insert(QStringLiteral("payload"), array);
QJsonDocument doc(object);
- QUrl url(QStringLiteral("%1/1/submit-listens").arg(kApiUrl));
+ QUrl url(QStringLiteral("%1/1/submit-listens").arg(QLatin1String(kApiUrl)));
QNetworkReply *reply = CreateRequest(url, doc);
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, cache_items_sent]() { ScrobbleRequestFinished(reply, cache_items_sent); });
@@ -633,7 +637,7 @@ void ListenBrainzScrobbler::Love() {
object.insert(QStringLiteral("recording_mbid"), song_playing_.musicbrainz_recording_id());
object.insert(QStringLiteral("score"), 1);
- QUrl url(QStringLiteral("%1/1/feedback/recording-feedback").arg(kApiUrl));
+ QUrl url(QStringLiteral("%1/1/feedback/recording-feedback").arg(QLatin1String(kApiUrl)));
QNetworkReply *reply = CreateRequest(url, QJsonDocument(object));
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply]() { LoveRequestFinished(reply); });
diff --git a/src/scrobbler/listenbrainzscrobbler.h b/src/scrobbler/listenbrainzscrobbler.h
index 476e0175d3..12773075e0 100644
--- a/src/scrobbler/listenbrainzscrobbler.h
+++ b/src/scrobbler/listenbrainzscrobbler.h
@@ -101,15 +101,6 @@ class ListenBrainzScrobbler : public ScrobblerService {
void StartSubmit(const bool initial = false) override;
void CheckScrobblePrevSong();
- static const char *kOAuthAuthorizeUrl;
- static const char *kOAuthAccessTokenUrl;
- static const char *kOAuthRedirectUrl;
- static const char *kApiUrl;
- static const char *kClientIDB64;
- static const char *kClientSecretB64;
- static const char *kCacheFile;
- static const int kScrobblesPerRequest;
-
SharedPtr network_;
ScrobblerCache *cache_;
LocalRedirectServer *server_;
diff --git a/src/scrobbler/scrobblercache.cpp b/src/scrobbler/scrobblercache.cpp
index f66d64e937..6057328c81 100644
--- a/src/scrobbler/scrobblercache.cpp
+++ b/src/scrobbler/scrobblercache.cpp
@@ -47,7 +47,7 @@ using namespace std::chrono_literals;
ScrobblerCache::ScrobblerCache(const QString &filename, QObject *parent)
: QObject(parent),
timer_flush_(new QTimer(this)),
- filename_(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/" + filename),
+ filename_(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/") + filename),
loaded_(false) {
ReadCache();
diff --git a/src/scrobbler/scrobblersettings.cpp b/src/scrobbler/scrobblersettings.cpp
index 835fbf62b4..5a373a4a43 100644
--- a/src/scrobbler/scrobblersettings.cpp
+++ b/src/scrobbler/scrobblersettings.cpp
@@ -25,6 +25,7 @@
#include "core/application.h"
#include "core/song.h"
+#include "core/settings.h"
#include "settings/settingsdialog.h"
#include "settings/scrobblersettingspage.h"
#include "scrobblersettings.h"
@@ -47,7 +48,7 @@ ScrobblerSettings::ScrobblerSettings(Application *app, QObject *parent)
void ScrobblerSettings::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(ScrobblerSettingsPage::kSettingsGroup);
enabled_ = s.value("enabled", false).toBool();
offline_ = s.value("offline", false).toBool();
@@ -92,7 +93,7 @@ void ScrobblerSettings::ToggleScrobbling() {
bool enabled_old_ = enabled_;
enabled_ = !enabled_;
- QSettings s;
+ Settings s;
s.beginGroup(ScrobblerSettingsPage::kSettingsGroup);
s.setValue("enabled", enabled_);
s.endGroup();
@@ -106,7 +107,7 @@ void ScrobblerSettings::ToggleOffline() {
bool offline_old_ = offline_;
offline_ = !offline_;
- QSettings s;
+ Settings s;
s.beginGroup(ScrobblerSettingsPage::kSettingsGroup);
s.setValue("offline", offline_);
s.endGroup();
diff --git a/src/scrobbler/scrobblingapi20.cpp b/src/scrobbler/scrobblingapi20.cpp
index ba959221fe..2c6af2dcd2 100644
--- a/src/scrobbler/scrobblingapi20.cpp
+++ b/src/scrobbler/scrobblingapi20.cpp
@@ -48,6 +48,7 @@
#include "core/networkaccessmanager.h"
#include "core/song.h"
#include "core/logging.h"
+#include "core/settings.h"
#include "utilities/timeconstants.h"
#include "internet/localredirectserver.h"
#include "settings/scrobblersettingspage.h"
@@ -60,8 +61,10 @@
#include "scrobblemetadata.h"
const char *ScrobblingAPI20::kApiKey = "211990b4c96782c05d1536e7219eb56e";
-const char *ScrobblingAPI20::kSecret = "80fd738f49596e9709b1bf9319c444a8";
-const int ScrobblingAPI20::kScrobblesPerRequest = 50;
+namespace {
+constexpr char kSecret[] = "80fd738f49596e9709b1bf9319c444a8";
+constexpr int kScrobblesPerRequest = 50;
+}
ScrobblingAPI20::ScrobblingAPI20(const QString &name, const QString &settings_group, const QString &auth_url, const QString &api_url, const bool batch, const QString &cache_file, SharedPtr settings, SharedPtr network, QObject *parent)
: ScrobblerService(name, settings, parent),
@@ -108,7 +111,7 @@ ScrobblingAPI20::~ScrobblingAPI20() {
void ScrobblingAPI20::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(settings_group_);
enabled_ = s.value("enabled", false).toBool();
@@ -122,7 +125,7 @@ void ScrobblingAPI20::ReloadSettings() {
void ScrobblingAPI20::LoadSession() {
- QSettings s;
+ Settings s;
s.beginGroup(settings_group_);
subscriber_ = s.value("subscriber", false).toBool();
username_ = s.value("username").toString();
@@ -137,7 +140,7 @@ void ScrobblingAPI20::Logout() {
username_.clear();
session_key_.clear();
- QSettings settings;
+ Settings settings;
settings.beginGroup(settings_group_);
settings.remove("subscriber");
settings.remove("username");
@@ -202,7 +205,7 @@ void ScrobblingAPI20::Authenticate() {
}
QUrlQuery url_query;
- url_query.addQueryItem(QStringLiteral("api_key"), kApiKey);
+ url_query.addQueryItem(QStringLiteral("api_key"), QLatin1String(kApiKey));
url_query.addQueryItem(QStringLiteral("cb"), server_->url().toString());
QUrl url(auth_url_);
url.setQuery(url_query);
@@ -246,7 +249,7 @@ void ScrobblingAPI20::RedirectArrived() {
if (url.isValid()) {
QUrlQuery url_query(url);
if (url_query.hasQueryItem(QStringLiteral("token"))) {
- QString token = url_query.queryItemValue(QStringLiteral("token")).toUtf8();
+ QString token = url_query.queryItemValue(QStringLiteral("token"));
RequestSession(token);
}
else {
@@ -271,18 +274,18 @@ void ScrobblingAPI20::RequestSession(const QString &token) {
QUrl session_url(api_url_);
QUrlQuery session_url_query;
- session_url_query.addQueryItem(QStringLiteral("api_key"), kApiKey);
+ session_url_query.addQueryItem(QStringLiteral("api_key"), QLatin1String(kApiKey));
session_url_query.addQueryItem(QStringLiteral("method"), QStringLiteral("auth.getSession"));
session_url_query.addQueryItem(QStringLiteral("token"), token);
QString data_to_sign;
for (const Param ¶m : session_url_query.queryItems()) {
data_to_sign += param.first + param.second;
}
- data_to_sign += kSecret;
+ data_to_sign += QString::fromUtf8(kSecret);
QByteArray const digest = QCryptographicHash::hash(data_to_sign.toUtf8(), QCryptographicHash::Md5);
- QString signature = QString::fromLatin1(digest.toHex()).rightJustified(32, '0').toLower();
+ const QString signature = QString::fromLatin1(digest.toHex()).rightJustified(32, QLatin1Char('0')).toLower();
session_url_query.addQueryItem(QStringLiteral("api_sig"), signature);
- session_url_query.addQueryItem(QUrl::toPercentEncoding(QStringLiteral("format")), QUrl::toPercentEncoding(QStringLiteral("json")));
+ session_url_query.addQueryItem(QString::fromUtf8(QUrl::toPercentEncoding(QStringLiteral("format"))), QString::fromUtf8(QUrl::toPercentEncoding(QStringLiteral("json"))));
session_url.setQuery(session_url_query);
QNetworkRequest req(session_url);
@@ -331,7 +334,7 @@ void ScrobblingAPI20::AuthenticateReplyFinished(QNetworkReply *reply) {
username_ = json_obj[QStringLiteral("name")].toString();
session_key_ = json_obj[QStringLiteral("key")].toString();
- QSettings s;
+ Settings s;
s.beginGroup(settings_group_);
s.setValue("subscriber", subscriber_);
s.setValue("username", username_);
@@ -347,9 +350,9 @@ void ScrobblingAPI20::AuthenticateReplyFinished(QNetworkReply *reply) {
QNetworkReply *ScrobblingAPI20::CreateRequest(const ParamList &request_params) {
ParamList params = ParamList()
- << Param("api_key", kApiKey)
- << Param("sk", session_key_)
- << Param("lang", QLocale().name().left(2).toLower())
+ << Param(QStringLiteral("api_key"), QLatin1String(kApiKey))
+ << Param(QStringLiteral("sk"), session_key_)
+ << Param(QStringLiteral("lang"), QLocale().name().left(2).toLower())
<< request_params;
std::sort(params.begin(), params.end());
@@ -358,21 +361,21 @@ QNetworkReply *ScrobblingAPI20::CreateRequest(const ParamList &request_params) {
QString data_to_sign;
for (const Param ¶m : params) {
EncodedParam encoded_param(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
- url_query.addQueryItem(encoded_param.first, encoded_param.second);
+ url_query.addQueryItem(QString::fromUtf8(encoded_param.first), QString::fromUtf8(encoded_param.second));
data_to_sign += param.first + param.second;
}
- data_to_sign += kSecret;
+ data_to_sign += QString::fromUtf8(kSecret);
QByteArray const digest = QCryptographicHash::hash(data_to_sign.toUtf8(), QCryptographicHash::Md5);
- QString signature = QString::fromLatin1(digest.toHex()).rightJustified(32, '0').toLower();
+ const QString signature = QString::fromLatin1(digest.toHex()).rightJustified(32, QLatin1Char('0')).toLower();
- url_query.addQueryItem(QStringLiteral("api_sig"), QUrl::toPercentEncoding(signature));
- url_query.addQueryItem(QStringLiteral("format"), QUrl::toPercentEncoding(QStringLiteral("json")));
+ url_query.addQueryItem(QStringLiteral("api_sig"), QString::fromUtf8(QUrl::toPercentEncoding(signature)));
+ url_query.addQueryItem(QStringLiteral("format"), QStringLiteral("json"));
QUrl url(api_url_);
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
- req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
+ req.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8();
QNetworkReply *reply = network_->post(req, query);
replies_ << reply;
@@ -394,16 +397,16 @@ void ScrobblingAPI20::UpdateNowPlaying(const Song &song) {
if (!authenticated() || !song.is_metadata_good() || settings_->offline()) return;
ParamList params = ParamList()
- << Param("method", "track.updateNowPlaying")
- << Param("artist", prefer_albumartist_ ? song.effective_albumartist() : song.artist())
- << Param("track", StripTitle(song.title()));
+ << Param(QStringLiteral("method"), QStringLiteral("track.updateNowPlaying"))
+ << Param(QStringLiteral("artist"), prefer_albumartist_ ? song.effective_albumartist() : song.artist())
+ << Param(QStringLiteral("track"), StripTitle(song.title()));
if (!song.album().isEmpty()) {
- params << Param("album", StripAlbum(song.album()));
+ params << Param(QStringLiteral("album"), StripAlbum(song.album()));
}
if (!prefer_albumartist_ && !song.albumartist().isEmpty()) {
- params << Param("albumArtist", song.albumartist());
+ params << Param(QStringLiteral("albumArtist"), song.albumartist());
}
QNetworkReply *reply = CreateRequest(params);
@@ -486,7 +489,7 @@ void ScrobblingAPI20::Submit() {
qLog(Debug) << name_ << "Submitting scrobbles.";
- ParamList params = ParamList() << Param("method", "track.scrobble");
+ ParamList params = ParamList() << Param(QStringLiteral("method"), QStringLiteral("track.scrobble"));
int i = 0;
ScrobblerCacheItemPtrList all_cache_items = cache_->List();
@@ -688,20 +691,20 @@ void ScrobblingAPI20::ScrobbleRequestFinished(QNetworkReply *reply, ScrobblerCac
void ScrobblingAPI20::SendSingleScrobble(ScrobblerCacheItemPtr item) {
ParamList params = ParamList()
- << Param("method", "track.scrobble")
- << Param("artist", prefer_albumartist_ ? item->metadata.effective_albumartist() : item->metadata.artist)
- << Param("track", StripTitle(item->metadata.title))
- << Param("timestamp", QString::number(item->timestamp))
- << Param("duration", QString::number(item->metadata.length_nanosec / kNsecPerSec));
+ << Param(QStringLiteral("method"), QStringLiteral("track.scrobble"))
+ << Param(QStringLiteral("artist"), prefer_albumartist_ ? item->metadata.effective_albumartist() : item->metadata.artist)
+ << Param(QStringLiteral("track"), StripTitle(item->metadata.title))
+ << Param(QStringLiteral("timestamp"), QString::number(item->timestamp))
+ << Param(QStringLiteral("duration"), QString::number(item->metadata.length_nanosec / kNsecPerSec));
if (!item->metadata.album.isEmpty()) {
- params << Param("album", StripAlbum(item->metadata.album));
+ params << Param(QStringLiteral("album"), StripAlbum(item->metadata.album));
}
if (!prefer_albumartist_ && !item->metadata.albumartist.isEmpty()) {
- params << Param("albumArtist", item->metadata.albumartist);
+ params << Param(QStringLiteral("albumArtist"), item->metadata.albumartist);
}
if (item->metadata.track > 0) {
- params << Param("trackNumber", QString::number(item->metadata.track));
+ params << Param(QStringLiteral("trackNumber"), QString::number(item->metadata.track));
}
QNetworkReply *reply = CreateRequest(params);
@@ -825,16 +828,16 @@ void ScrobblingAPI20::Love() {
qLog(Debug) << name_ << "Sending love for song" << song_playing_.artist() << song_playing_.album() << song_playing_.title();
ParamList params = ParamList()
- << Param("method", "track.love")
- << Param("artist", prefer_albumartist_ ? song_playing_.effective_albumartist() : song_playing_.artist())
- << Param("track", song_playing_.title());
+ << Param(QStringLiteral("method"), QStringLiteral("track.love"))
+ << Param(QStringLiteral("artist"), prefer_albumartist_ ? song_playing_.effective_albumartist() : song_playing_.artist())
+ << Param(QStringLiteral("track"), song_playing_.title());
if (!song_playing_.album().isEmpty()) {
- params << Param("album", song_playing_.album());
+ params << Param(QStringLiteral("album"), song_playing_.album());
}
if (!prefer_albumartist_ && !song_playing_.albumartist().isEmpty()) {
- params << Param("albumArtist", song_playing_.albumartist());
+ params << Param(QStringLiteral("albumArtist"), song_playing_.albumartist());
}
QNetworkReply *reply = CreateRequest(params);
diff --git a/src/scrobbler/scrobblingapi20.h b/src/scrobbler/scrobblingapi20.h
index a09d85f7e8..a993c82f2e 100644
--- a/src/scrobbler/scrobblingapi20.h
+++ b/src/scrobbler/scrobblingapi20.h
@@ -120,9 +120,6 @@ class ScrobblingAPI20 : public ScrobblerService {
RateLimitExceeded = 29,
};
- static const char *kSecret;
- static const int kScrobblesPerRequest;
-
QNetworkReply *CreateRequest(const ParamList &request_params);
ReplyResult GetJsonObject(QNetworkReply *reply, QJsonObject &json_obj, QString &error_description);
diff --git a/src/scrobbler/subsonicscrobbler.cpp b/src/scrobbler/subsonicscrobbler.cpp
index 89b5218d6d..cca5b3f1f9 100644
--- a/src/scrobbler/subsonicscrobbler.cpp
+++ b/src/scrobbler/subsonicscrobbler.cpp
@@ -43,7 +43,7 @@
const char *SubsonicScrobbler::kName = "Subsonic";
SubsonicScrobbler::SubsonicScrobbler(SharedPtr settings, Application *app, QObject *parent)
- : ScrobblerService(kName, settings, parent),
+ : ScrobblerService(QLatin1String(kName), settings, parent),
app_(app),
service_(nullptr),
enabled_(false),
@@ -58,7 +58,7 @@ SubsonicScrobbler::SubsonicScrobbler(SharedPtr settings, Appl
void SubsonicScrobbler::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(SubsonicSettingsPage::kSettingsGroup);
enabled_ = s.value("serversidescrobbling", false).toBool();
s.endGroup();
diff --git a/src/settings/appearancesettingspage.cpp b/src/settings/appearancesettingspage.cpp
index 960c3af0d4..156645b84d 100644
--- a/src/settings/appearancesettingspage.cpp
+++ b/src/settings/appearancesettingspage.cpp
@@ -44,6 +44,7 @@
#include "utilities/colorutils.h"
#include "core/iconloader.h"
#include "core/stylehelper.h"
+#include "core/settings.h"
#include "covermanager/albumcoverchoicecontroller.h"
#include "settingspage.h"
#include "settingsdialog.h"
@@ -89,7 +90,7 @@ AppearanceSettingsPage::AppearanceSettingsPage(SettingsDialog *dialog, QWidget *
ui_->setupUi(this);
setWindowIcon(IconLoader::Load(QStringLiteral("view-media-visualization"), true, 0, 32));
- ui_->combobox_style->addItem(QStringLiteral("default"), "default");
+ ui_->combobox_style->addItem(QStringLiteral("default"), QStringLiteral("default"));
for (const QString &style : QStyleFactory::keys()) {
ui_->combobox_style->addItem(style, style);
}
@@ -139,10 +140,10 @@ AppearanceSettingsPage::~AppearanceSettingsPage() {
void AppearanceSettingsPage::Load() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
- ComboBoxLoadFromSettings(s, ui_->combobox_style, kStyle, QStringLiteral("default"));
+ ComboBoxLoadFromSettings(s, ui_->combobox_style, QLatin1String(kStyle), QStringLiteral("default"));
#if !defined(Q_OS_MACOS) && !defined(Q_OS_WIN)
ui_->checkbox_system_icons->setChecked(s.value(kSystemThemeIcons, false).toBool());
@@ -215,13 +216,13 @@ void AppearanceSettingsPage::Load() {
Init(ui_->layout_appearancesettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
void AppearanceSettingsPage::Save() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("style", ui_->combobox_style->currentText());
@@ -297,7 +298,7 @@ void AppearanceSettingsPage::UpdateColorSelectorColor(QWidget *color_selector, c
void AppearanceSettingsPage::SelectBackgroundImage() {
- QString selected_filename = QFileDialog::getOpenFileName(this, tr("Select background image"), background_image_filename_, tr(AlbumCoverChoiceController::kLoadImageFileFilter) + ";;" + tr(AlbumCoverChoiceController::kAllFilesFilter));
+ QString selected_filename = QFileDialog::getOpenFileName(this, tr("Select background image"), background_image_filename_, tr(AlbumCoverChoiceController::kLoadImageFileFilter) + QStringLiteral(";;") + tr(AlbumCoverChoiceController::kAllFilesFilter));
if (selected_filename.isEmpty()) return;
background_image_filename_ = selected_filename;
ui_->background_image_filename->setText(background_image_filename_);
diff --git a/src/settings/backendsettingspage.cpp b/src/settings/backendsettingspage.cpp
index 3197fff7ac..f113443134 100644
--- a/src/settings/backendsettingspage.cpp
+++ b/src/settings/backendsettingspage.cpp
@@ -43,6 +43,7 @@
#include "core/iconloader.h"
#include "core/player.h"
#include "core/logging.h"
+#include "core/settings.h"
#include "engine/enginebase.h"
#include "engine/enginedevice.h"
#include "engine/devicefinders.h"
@@ -55,12 +56,15 @@
#include "ui_backendsettingspage.h"
const char *BackendSettingsPage::kSettingsGroup = "Backend";
-const char *BackendSettingsPage::kOutputAutomaticallySelect = "Automatically select";
-const char *BackendSettingsPage::kOutputCustom = "Custom";
const qint64 BackendSettingsPage::kDefaultBufferDuration = 4000;
const double BackendSettingsPage::kDefaultBufferLowWatermark = 0.33;
const double BackendSettingsPage::kDefaultBufferHighWatermark = 0.99;
+namespace {
+static constexpr char kOutputAutomaticallySelect[] = "Automatically select";
+static constexpr char kOutputCustom[] = "Custom";
+} // namespace
+
BackendSettingsPage::BackendSettingsPage(SettingsDialog *dialog, QWidget *parent)
: SettingsPage(dialog, parent),
ui_(new Ui_BackendSettingsPage),
@@ -115,7 +119,7 @@ void BackendSettingsPage::Load() {
configloaded_ = false;
engineloaded_ = false;
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
EngineBase::Type enginetype = EngineBase::TypeFromName(s.value("engine", EngineBase::Name(EngineBase::Type::None)).toString());
@@ -226,7 +230,7 @@ void BackendSettingsPage::Load() {
#endif
Init(ui_->layout_backendsettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
// Check if engine, output or device is set to a different setting than the configured to force saving settings.
@@ -241,7 +245,7 @@ void BackendSettingsPage::Load() {
}
QVariant device_value;
if (ui_->combobox_device->currentText().isEmpty()) device_value = QVariant();
- else if (ui_->combobox_device->currentText() == kOutputCustom) device_value = ui_->lineedit_device->text();
+ else if (ui_->combobox_device->currentText() == QLatin1String(kOutputCustom)) device_value = ui_->lineedit_device->text();
else device_value = ui_->combobox_device->itemData(ui_->combobox_device->currentIndex()).value();
if (enginetype_current_ != enginetype || output_name != output_current_ || device_value != device_current_) {
@@ -364,7 +368,7 @@ void BackendSettingsPage::Load_Device(const QString &output, const QVariant &dev
#ifdef Q_OS_WIN
if (engine()->type() != EngineBase::Type::GStreamer)
#endif
- ui_->combobox_device->addItem(IconLoader::Load(QStringLiteral("soundcard")), kOutputAutomaticallySelect, QVariant());
+ ui_->combobox_device->addItem(IconLoader::Load(QStringLiteral("soundcard")), QLatin1String(kOutputAutomaticallySelect), QVariant());
for (DeviceFinder *f : dialog()->app()->device_finders()->ListFinders()) {
if (!f->outputs().contains(output)) continue;
@@ -376,7 +380,7 @@ void BackendSettingsPage::Load_Device(const QString &output, const QVariant &dev
}
if (engine()->CustomDeviceSupport(output)) {
- ui_->combobox_device->addItem(IconLoader::Load(QStringLiteral("soundcard")), kOutputCustom, QVariant());
+ ui_->combobox_device->addItem(IconLoader::Load(QStringLiteral("soundcard")), QLatin1String(kOutputCustom), QVariant());
ui_->lineedit_device->setEnabled(true);
}
else {
@@ -446,8 +450,8 @@ void BackendSettingsPage::Load_Device(const QString &output, const QVariant &dev
ui_->lineedit_device->setText(device.toString());
if (!found) {
for (int i = 0; i < ui_->combobox_device->count(); ++i) {
- if (ui_->combobox_device->itemText(i) == kOutputCustom) {
- if (ui_->combobox_device->currentText() != kOutputCustom) ui_->combobox_device->setCurrentIndex(i);
+ if (ui_->combobox_device->itemText(i) == QLatin1String(kOutputCustom)) {
+ if (ui_->combobox_device->currentText() != QLatin1String(kOutputCustom)) ui_->combobox_device->setCurrentIndex(i);
break;
}
}
@@ -478,10 +482,10 @@ void BackendSettingsPage::Save() {
}
if (ui_->combobox_device->currentText().isEmpty()) device_value = QVariant();
- else if (ui_->combobox_device->currentText() == kOutputCustom) device_value = ui_->lineedit_device->text();
+ else if (ui_->combobox_device->currentText() == QLatin1String(kOutputCustom)) device_value = ui_->lineedit_device->text();
else device_value = ui_->combobox_device->itemData(ui_->combobox_device->currentIndex()).value();
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("engine", EngineBase::Name(enginetype));
@@ -586,7 +590,7 @@ void BackendSettingsPage::DeviceSelectionChanged(int index) {
if (engine()->CustomDeviceSupport(output.name)) {
ui_->lineedit_device->setEnabled(true);
- if (ui_->combobox_device->currentText() != kOutputCustom) {
+ if (ui_->combobox_device->currentText() != QLatin1String(kOutputCustom)) {
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
if (device.metaType().id() == QMetaType::QString)
#else
@@ -638,7 +642,7 @@ void BackendSettingsPage::DeviceStringChanged() {
#endif
QString device_str = device.toString();
if (device_str.isEmpty()) continue;
- if (ui_->combobox_device->itemText(i) == kOutputCustom) continue;
+ if (ui_->combobox_device->itemText(i) == QLatin1String(kOutputCustom)) continue;
if (device_str == ui_->lineedit_device->text()) {
if (ui_->combobox_device->currentIndex() != i) ui_->combobox_device->setCurrentIndex(i);
found = true;
@@ -647,15 +651,15 @@ void BackendSettingsPage::DeviceStringChanged() {
if (engine()->CustomDeviceSupport(output.name)) {
ui_->lineedit_device->setEnabled(true);
- if ((!found) && (ui_->combobox_device->currentText() != kOutputCustom)) {
+ if ((!found) && (ui_->combobox_device->currentText() != QLatin1String(kOutputCustom))) {
for (int i = 0; i < ui_->combobox_device->count(); ++i) {
- if (ui_->combobox_device->itemText(i) == kOutputCustom) {
+ if (ui_->combobox_device->itemText(i) == QLatin1String(kOutputCustom)) {
ui_->combobox_device->setCurrentIndex(i);
break;
}
}
}
- if (ui_->combobox_device->currentText() == kOutputCustom) {
+ if (ui_->combobox_device->currentText() == QLatin1String(kOutputCustom)) {
if ((ui_->lineedit_device->text().isEmpty()) && (ui_->combobox_device->count() > 0) && (ui_->combobox_device->currentIndex() != 0)) ui_->combobox_device->setCurrentIndex(0);
}
}
@@ -806,7 +810,7 @@ void BackendSettingsPage::SelectDevice(const QString &device_new) {
if (device_new.isEmpty()) {
for (int i = 0; i < ui_->combobox_device->count(); ++i) {
- if (ui_->combobox_device->itemText(i) == kOutputAutomaticallySelect && ui_->combobox_device->currentIndex() != i) {
+ if (ui_->combobox_device->itemText(i) == QLatin1String(kOutputAutomaticallySelect) && ui_->combobox_device->currentIndex() != i) {
ui_->combobox_device->setCurrentIndex(i);
break;
}
@@ -833,7 +837,7 @@ void BackendSettingsPage::SelectDevice(const QString &device_new) {
if (!found) {
ui_->lineedit_device->setText(device_new);
for (int i = 0; i < ui_->combobox_device->count(); ++i) {
- if (ui_->combobox_device->itemText(i) == kOutputCustom && ui_->combobox_device->currentIndex() != i) {
+ if (ui_->combobox_device->itemText(i) == QLatin1String(kOutputCustom) && ui_->combobox_device->currentIndex() != i) {
ui_->combobox_device->setCurrentIndex(i);
break;
}
diff --git a/src/settings/backendsettingspage.h b/src/settings/backendsettingspage.h
index a04580f99a..12ff152c4a 100644
--- a/src/settings/backendsettingspage.h
+++ b/src/settings/backendsettingspage.h
@@ -91,9 +91,6 @@ class BackendSettingsPage : public SettingsPage {
void SelectDevice(const QString &device_new);
private:
- static const char *kOutputAutomaticallySelect;
- static const char *kOutputCustom;
-
Ui_BackendSettingsPage *ui_;
bool configloaded_;
bool engineloaded_;
diff --git a/src/settings/behavioursettingspage.cpp b/src/settings/behavioursettingspage.cpp
index 8256adcb5e..dc56e2a867 100644
--- a/src/settings/behavioursettingspage.cpp
+++ b/src/settings/behavioursettingspage.cpp
@@ -40,6 +40,7 @@
#include "core/iconloader.h"
#include "core/mainwindow.h"
+#include "core/settings.h"
#include "settings/settingspage.h"
#include "behavioursettingspage.h"
#include "ui_behavioursettingspage.h"
@@ -77,13 +78,13 @@ BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog, QWidget *pa
#ifdef HAVE_TRANSLATIONS
// Populate the language combo box. We do this by looking at all the compiled in translations.
- QDir dir1(":/translations/");
- QDir dir2(TRANSLATIONS_DIR);
- QStringList codes(dir1.entryList(QStringList() << "*.qm"));
+ QDir dir1(QStringLiteral(":/translations/"));
+ QDir dir2(QStringLiteral(TRANSLATIONS_DIR));
+ QStringList codes(dir1.entryList(QStringList() << QStringLiteral("*.qm")));
if (dir2.exists()) {
- codes << dir2.entryList(QStringList() << "*.qm");
+ codes << dir2.entryList(QStringList() << QStringLiteral("*.qm"));
}
- QRegularExpression lang_re("^strawberry_(.*).qm$");
+ QRegularExpression lang_re(QStringLiteral("^strawberry_(.*).qm$"));
for (const QString &filename : codes) {
QRegularExpressionMatch re_match = lang_re.match(filename);
@@ -93,21 +94,21 @@ BehaviourSettingsPage::BehaviourSettingsPage(SettingsDialog *dialog, QWidget *pa
QString code = re_match.captured(1);
QString lookup_code = QString(code)
- .replace("@latin", "_Latn")
- .replace("_CN", "_Hans_CN")
- .replace("_TW", "_Hant_TW");
+ .replace(QStringLiteral("@latin"), QStringLiteral("_Latn"))
+ .replace(QStringLiteral("_CN"), QStringLiteral("_Hans_CN"))
+ .replace(QStringLiteral("_TW"), QStringLiteral("_Hant_TW"));
QString language_name = QLocale::languageToString(QLocale(lookup_code).language());
QString native_name = QLocale(lookup_code).nativeLanguageName();
if (!native_name.isEmpty()) {
language_name = native_name;
}
- QString name = QString("%1 (%2)").arg(language_name, code);
+ QString name = QStringLiteral("%1 (%2)").arg(language_name, code);
language_map_[name] = code;
}
- language_map_["English (en)"] = "en";
+ language_map_[QStringLiteral("English (en)")] = QStringLiteral("en");
// Sort the names and show them in the UI
QStringList names = language_map_.keys();
@@ -145,7 +146,7 @@ BehaviourSettingsPage::~BehaviourSettingsPage() {
void BehaviourSettingsPage::Load() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
#ifdef Q_OS_MACOS
@@ -217,13 +218,13 @@ void BehaviourSettingsPage::Load() {
Init(ui_->layout_behavioursettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
void BehaviourSettingsPage::Save() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("showtrayicon", ui_->checkbox_showtrayicon->isChecked());
diff --git a/src/settings/collectionsettingspage.cpp b/src/settings/collectionsettingspage.cpp
index 24bfca50e1..42ce7dcc9b 100644
--- a/src/settings/collectionsettingspage.cpp
+++ b/src/settings/collectionsettingspage.cpp
@@ -43,6 +43,7 @@
#include "core/application.h"
#include "core/iconloader.h"
+#include "core/settings.h"
#include "utilities/strutils.h"
#include "utilities/timeutils.h"
#include "collection/collection.h"
@@ -112,7 +113,7 @@ CollectionSettingsPage::~CollectionSettingsPage() { delete ui_; }
void CollectionSettingsPage::Add() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
QString path(s.value("last_path", QStandardPaths::writableLocation(QStandardPaths::MusicLocation)).toString());
@@ -173,7 +174,7 @@ void CollectionSettingsPage::Load() {
QObject::connect(ui_->list->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &CollectionSettingsPage::CurrentRowChanged);
}
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
ui_->auto_open->setChecked(s.value("auto_open", true).toBool());
@@ -215,13 +216,13 @@ void CollectionSettingsPage::Load() {
ui_->disk_cache_in_use->setText((dialog()->app()->collection_model()->icon_cache_disk_size() == 0 ? QStringLiteral("empty") : Utilities::PrettySize(dialog()->app()->collection_model()->icon_cache_disk_size())));
Init(ui_->layout_collectionsettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
void CollectionSettingsPage::Save() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("auto_open", ui_->auto_open->isChecked());
@@ -238,9 +239,9 @@ void CollectionSettingsPage::Save() {
QString filter_text = ui_->cover_art_patterns->text();
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
- QStringList filters = filter_text.split(',', Qt::SkipEmptyParts);
+ QStringList filters = filter_text.split(QLatin1Char(','), Qt::SkipEmptyParts);
#else
- QStringList filters = filter_text.split(',', QString::SkipEmptyParts);
+ QStringList filters = filter_text.split(QLatin1Char(','), QString::SkipEmptyParts);
#endif
s.setValue("cover_art_patterns", filters);
diff --git a/src/settings/contextsettingspage.cpp b/src/settings/contextsettingspage.cpp
index 35156eca9f..622426144f 100644
--- a/src/settings/contextsettingspage.cpp
+++ b/src/settings/contextsettingspage.cpp
@@ -38,6 +38,7 @@
#include "core/iconloader.h"
#include "core/mainwindow.h"
+#include "core/settings.h"
#include "settingspage.h"
#include "settingsdialog.h"
#include "contextsettingspage.h"
@@ -113,7 +114,7 @@ ContextSettingsPage::ContextSettingsPage(SettingsDialog *dialog, QWidget *parent
QFile file(QStringLiteral(":/text/ghosts.txt"));
if (file.open(QIODevice::ReadOnly)) {
- QString text = file.readAll();
+ QString text = QString::fromUtf8(file.readAll());
ui_->preview_headline->setText(text);
ui_->preview_normal->setText(text);
file.close();
@@ -128,11 +129,11 @@ ContextSettingsPage::~ContextSettingsPage() { delete ui_; }
void ContextSettingsPage::Load() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
- ui_->context_custom_text1->setText(s.value(kSettingsTitleFmt, "%title% - %artist%").toString());
- ui_->context_custom_text2->setText(s.value(kSettingsSummaryFmt, "%album%").toString());
+ ui_->context_custom_text1->setText(s.value(kSettingsTitleFmt, QStringLiteral("%title% - %artist%")).toString());
+ ui_->context_custom_text2->setText(s.value(kSettingsSummaryFmt, QStringLiteral("%album%")).toString());
for (int i = 0; i < static_cast(ContextSettingsOrder::NELEMS); ++i) {
checkboxes_[i]->setChecked(s.value(kSettingsGroupEnable[i], checkboxes_[i]->isChecked()).toBool());
@@ -140,9 +141,9 @@ void ContextSettingsPage::Load() {
// Fonts
QString default_font;
- int i = ui_->font_headline->findText(kDefaultFontFamily);
+ int i = ui_->font_headline->findText(QLatin1String(kDefaultFontFamily));
if (i >= 0) {
- default_font = kDefaultFontFamily;
+ default_font = QLatin1String(kDefaultFontFamily);
}
else {
default_font = font().family();
@@ -160,13 +161,13 @@ void ContextSettingsPage::Load() {
Init(ui_->layout_contextsettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
void ContextSettingsPage::Save() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue(kSettingsTitleFmt, ui_->context_custom_text1->text());
diff --git a/src/settings/coverssettingspage.cpp b/src/settings/coverssettingspage.cpp
index ab4442c92d..ae68a4c256 100644
--- a/src/settings/coverssettingspage.cpp
+++ b/src/settings/coverssettingspage.cpp
@@ -39,6 +39,7 @@
#include "ui_coverssettingspage.h"
#include "core/application.h"
#include "core/iconloader.h"
+#include "core/settings.h"
#include "utilities/coveroptions.h"
#include "covermanager/coverproviders.h"
#include "covermanager/coverprovider.h"
@@ -107,7 +108,7 @@ void CoversSettingsPage::Load() {
item->setForeground(provider->is_enabled() ? palette().color(QPalette::Active, QPalette::Text) : palette().color(QPalette::Disabled, QPalette::Text));
}
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
const QStringList all_types = QStringList() << QStringLiteral("art_unset")
@@ -160,13 +161,13 @@ void CoversSettingsPage::Load() {
Init(ui_->layout_coverssettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
void CoversSettingsPage::Save() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
QStringList providers;
@@ -220,11 +221,11 @@ void CoversSettingsPage::ProvidersCurrentItemChanged(QListWidgetItem *item_curre
CoverProvider *provider = dialog()->app()->cover_providers()->ProviderByName(item_current->text());
if (provider) {
if (provider->AuthenticationRequired()) {
- if (provider->name() == "Tidal" && !provider->IsAuthenticated()) {
+ if (provider->name() == QStringLiteral("Tidal") && !provider->IsAuthenticated()) {
DisableAuthentication();
ui_->label_auth_info->setText(tr("Use Tidal settings to authenticate."));
}
- else if (provider->name() == "Qobuz" && !provider->IsAuthenticated()) {
+ else if (provider->name() == QStringLiteral("Qobuz") && !provider->IsAuthenticated()) {
DisableAuthentication();
ui_->label_auth_info->setText(tr("Use Qobuz settings to authenticate."));
}
@@ -333,11 +334,11 @@ void CoversSettingsPage::LogoutClicked() {
if (!provider) return;
provider->Deauthenticate();
- if (provider->name() == "Tidal") {
+ if (provider->name() == QStringLiteral("Tidal")) {
DisableAuthentication();
ui_->label_auth_info->setText(tr("Use Tidal settings to authenticate."));
}
- else if (provider->name() == "Qobuz") {
+ else if (provider->name() == QStringLiteral("Qobuz")) {
DisableAuthentication();
ui_->label_auth_info->setText(tr("Use Qobuz settings to authenticate."));
}
@@ -419,16 +420,16 @@ void CoversSettingsPage::AddAlbumCoverArtType(const QString &name, const QString
QString CoversSettingsPage::AlbumCoverArtTypeDescription(const QString &type) const {
- if (type == "art_unset") {
+ if (type == QStringLiteral("art_unset")) {
return tr("Manually unset (%1)").arg(type);
}
- if (type == "art_manual") {
+ if (type == QStringLiteral("art_manual")) {
return tr("Set through album cover search (%1)").arg(type);
}
- if (type == "art_automatic") {
+ if (type == QStringLiteral("art_automatic")) {
return tr("Automatically picked up from album directory (%1)").arg(type);
}
- if (type == "art_embedded") {
+ if (type == QStringLiteral("art_embedded")) {
return tr("Embedded album cover art (%1)").arg(type);
}
diff --git a/src/settings/globalshortcutssettingspage.cpp b/src/settings/globalshortcutssettingspage.cpp
index e660b57516..a5a12eb16e 100644
--- a/src/settings/globalshortcutssettingspage.cpp
+++ b/src/settings/globalshortcutssettingspage.cpp
@@ -40,6 +40,7 @@
#include "core/iconloader.h"
#include "core/logging.h"
+#include "core/settings.h"
#include "utilities/envutils.h"
#include "globalshortcuts/globalshortcutgrabber.h"
#include "globalshortcuts/globalshortcutsmanager.h"
@@ -95,7 +96,7 @@ GlobalShortcutsSettingsPage::~GlobalShortcutsSettingsPage() { delete ui_; }
void GlobalShortcutsSettingsPage::Load() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
GlobalShortcutsManager *manager = dialog()->global_shortcuts_manager();
@@ -205,13 +206,13 @@ void GlobalShortcutsSettingsPage::Load() {
Init(ui_->layout_globalshortcutssettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
void GlobalShortcutsSettingsPage::Save() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
QList shortcuts = shortcuts_.values();
@@ -344,18 +345,18 @@ void GlobalShortcutsSettingsPage::ChangeClicked() {
void GlobalShortcutsSettingsPage::X11Warning() {
QString de = de_.toLower();
- if (de == "kde" || de == "gnome" || de == "x-cinnamon" || de == "mate") {
+ if (de == QStringLiteral("kde") || de == QStringLiteral("gnome") || de == QStringLiteral("x-cinnamon") || de == QStringLiteral("mate")) {
QString text(tr("Using X11 shortcuts on %1 is not recommended and can cause keyboard to become unresponsive!").arg(de_));
- if (de == "kde") {
+ if (de == QStringLiteral("kde")) {
text += tr(" Shortcuts on %1 are usually used through MPRIS and KGlobalAccel.").arg(de_);
}
- else if (de == "gnome") {
+ else if (de == QStringLiteral("gnome")) {
text += tr(" Shortcuts on %1 are usually used through Gnome Settings Daemon and should be configured in gnome-settings-daemon instead.").arg(de_);
}
- else if (de == "x-cinnamon") {
+ else if (de == QStringLiteral("x-cinnamon")) {
text += tr(" Shortcuts on %1 are usually used through Gnome Settings Daemon and should be configured in cinnamon-settings-daemon instead.").arg(de_);
}
- else if (de == "mate") {
+ else if (de == QStringLiteral("mate")) {
text += tr(" Shortcuts on %1 are usually used through MATE Settings Daemon and should be configured there instead.").arg(de_);
}
ui_->label_warn_text->setText(text);
diff --git a/src/settings/globalshortcutssettingspage.h b/src/settings/globalshortcutssettingspage.h
index 749efcfb36..620ae22525 100644
--- a/src/settings/globalshortcutssettingspage.h
+++ b/src/settings/globalshortcutssettingspage.h
@@ -25,7 +25,6 @@
#include "config.h"
#include
-#include
#include
#include
#include
diff --git a/src/settings/lyricssettingspage.cpp b/src/settings/lyricssettingspage.cpp
index 78dfc2a2b8..b19669bdc4 100644
--- a/src/settings/lyricssettingspage.cpp
+++ b/src/settings/lyricssettingspage.cpp
@@ -39,6 +39,7 @@
#include "ui_lyricssettingspage.h"
#include "core/application.h"
#include "core/iconloader.h"
+#include "core/settings.h"
#include "lyrics/lyricsproviders.h"
#include "lyrics/lyricsprovider.h"
#include "widgets/loginstatewidget.h"
@@ -89,7 +90,7 @@ void LyricsSettingsPage::Load() {
Init(ui_->layout_lyricssettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
@@ -101,7 +102,7 @@ void LyricsSettingsPage::Save() {
if (item->checkState() == Qt::Checked) providers << item->text(); // clazy:exclude=reserve-candidates
}
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("providers", providers);
s.endGroup();
diff --git a/src/settings/moodbarsettingspage.cpp b/src/settings/moodbarsettingspage.cpp
index ad7f275ea4..3712e00919 100644
--- a/src/settings/moodbarsettingspage.cpp
+++ b/src/settings/moodbarsettingspage.cpp
@@ -33,6 +33,7 @@
#include "core/iconloader.h"
#include "core/logging.h"
+#include "core/settings.h"
#include "settingsdialog.h"
#include "settingspage.h"
@@ -64,7 +65,7 @@ MoodbarSettingsPage::~MoodbarSettingsPage() { delete ui_; }
void MoodbarSettingsPage::Load() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
ui_->moodbar_enabled->setChecked(s.value("enabled", false).toBool());
ui_->moodbar_show->setChecked(s.value("show", false).toBool());
@@ -76,13 +77,13 @@ void MoodbarSettingsPage::Load() {
Init(ui_->layout_moodbarsettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
void MoodbarSettingsPage::Save() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("enabled", ui_->moodbar_enabled->isChecked());
s.setValue("show", ui_->moodbar_show->isChecked());
diff --git a/src/settings/networkproxysettingspage.cpp b/src/settings/networkproxysettingspage.cpp
index b0e32b79e9..a648732dad 100644
--- a/src/settings/networkproxysettingspage.cpp
+++ b/src/settings/networkproxysettingspage.cpp
@@ -32,6 +32,7 @@
#include "core/iconloader.h"
#include "core/networkproxyfactory.h"
+#include "core/settings.h"
#include "networkproxysettingspage.h"
#include "settings/settingspage.h"
#include "ui_networkproxysettingspage.h"
@@ -53,7 +54,7 @@ NetworkProxySettingsPage::~NetworkProxySettingsPage() { delete ui_; }
void NetworkProxySettingsPage::Load() {
- QSettings s;
+ Settings s;
s.beginGroup(NetworkProxyFactory::kSettingsGroup);
const NetworkProxyFactory::Mode mode = static_cast(s.value("mode", static_cast(NetworkProxyFactory::Mode::System)).toInt());
@@ -82,13 +83,13 @@ void NetworkProxySettingsPage::Load() {
Init(ui_->layout_networkproxysettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
void NetworkProxySettingsPage::Save() {
- QSettings s;
+ Settings s;
NetworkProxyFactory::Mode mode = NetworkProxyFactory::Mode::System;
if (ui_->proxy_direct->isChecked()) mode = NetworkProxyFactory::Mode::Direct;
diff --git a/src/settings/notificationssettingspage.cpp b/src/settings/notificationssettingspage.cpp
index 6762f617d3..0ef9dd3bf0 100644
--- a/src/settings/notificationssettingspage.cpp
+++ b/src/settings/notificationssettingspage.cpp
@@ -46,6 +46,7 @@
#include
#include "core/iconloader.h"
+#include "core/settings.h"
#include "osd/osdbase.h"
#include "osd/osdpretty.h"
#include "settingspage.h"
@@ -151,7 +152,7 @@ void NotificationsSettingsPage::hideEvent(QHideEvent*) {
void NotificationsSettingsPage::Load() {
- QSettings s;
+ Settings s;
s.beginGroup(OSDBase::kSettingsGroup);
const OSDBase::Behaviour osd_behaviour = static_cast(s.value("Behaviour", static_cast(OSDBase::Behaviour::Native)).toInt());
@@ -221,13 +222,13 @@ void NotificationsSettingsPage::Load() {
Init(ui_->layout_notificationssettingspage->parentWidget());
- if (!QSettings().childGroups().contains(OSDBase::kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(OSDBase::kSettingsGroup))) set_changed();
}
void NotificationsSettingsPage::Save() {
- QSettings s;
+ Settings s;
OSDBase::Behaviour osd_behaviour = OSDBase::Behaviour::Disabled;
if (ui_->notifications_none->isChecked()) osd_behaviour = OSDBase::Behaviour::Disabled;
diff --git a/src/settings/playlistsettingspage.cpp b/src/settings/playlistsettingspage.cpp
index df8389d457..80c27dc814 100644
--- a/src/settings/playlistsettingspage.cpp
+++ b/src/settings/playlistsettingspage.cpp
@@ -27,6 +27,7 @@
#include
#include "core/iconloader.h"
+#include "core/settings.h"
#include "playlist/playlist.h"
#include "settingspage.h"
#include "playlistsettingspage.h"
@@ -51,7 +52,7 @@ PlaylistSettingsPage::~PlaylistSettingsPage() {
void PlaylistSettingsPage::Load() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
ui_->checkbox_alternating_row_colors->setChecked(s.value("alternating_row_colors", true).toBool());
@@ -105,7 +106,7 @@ void PlaylistSettingsPage::Load() {
Init(ui_->layout_playlistsettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
@@ -125,7 +126,7 @@ void PlaylistSettingsPage::Save() {
path_type = PathType::Ask_User;
}
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("alternating_row_colors", ui_->checkbox_alternating_row_colors->isChecked());
s.setValue("show_bars", ui_->checkbox_barscurrenttrack->isChecked());
diff --git a/src/settings/qobuzsettingspage.cpp b/src/settings/qobuzsettingspage.cpp
index 060c7235a3..5a712f8886 100644
--- a/src/settings/qobuzsettingspage.cpp
+++ b/src/settings/qobuzsettingspage.cpp
@@ -36,6 +36,7 @@
#include "ui_qobuzsettingspage.h"
#include "core/application.h"
#include "core/iconloader.h"
+#include "core/settings.h"
#include "widgets/loginstatewidget.h"
#include "internet/internetservices.h"
#include "qobuz/qobuzservice.h"
@@ -71,7 +72,7 @@ QobuzSettingsPage::~QobuzSettingsPage() { delete ui_; }
void QobuzSettingsPage::Load() {
- QSettings s;
+ Settings s;
if (!s.contains(kSettingsGroup)) set_changed();
s.beginGroup(kSettingsGroup);
@@ -98,13 +99,13 @@ void QobuzSettingsPage::Load() {
Init(ui_->layout_qobuzsettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
void QobuzSettingsPage::Save() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("enabled", ui_->enable->isChecked());
s.setValue("app_id", ui_->app_id->text());
diff --git a/src/settings/scrobblersettingspage.cpp b/src/settings/scrobblersettingspage.cpp
index af15d8ac27..d882936654 100644
--- a/src/settings/scrobblersettingspage.cpp
+++ b/src/settings/scrobblersettingspage.cpp
@@ -34,6 +34,7 @@
#include "core/application.h"
#include "core/iconloader.h"
#include "core/song.h"
+#include "core/settings.h"
#include "widgets/loginstatewidget.h"
#include "scrobbler/audioscrobbler.h"
@@ -78,7 +79,7 @@ ScrobblerSettingsPage::ScrobblerSettingsPage(SettingsDialog *dialog, QWidget *pa
QObject::connect(ui_->widget_listenbrainz_login_state, &LoginStateWidget::LogoutClicked, this, &ScrobblerSettingsPage::ListenBrainz_Logout);
ui_->widget_listenbrainz_login_state->AddCredentialGroup(ui_->widget_listenbrainz_login);
- ui_->label_listenbrainz_token->setText("" + tr("Enter your user token from") + " " + "https://listenbrainz.org/profile/
");
+ ui_->label_listenbrainz_token->setText(QStringLiteral("") + tr("Enter your user token from") + QStringLiteral(" ") + QStringLiteral("https://listenbrainz.org/profile/
"));
resize(sizeHint());
@@ -88,7 +89,7 @@ ScrobblerSettingsPage::~ScrobblerSettingsPage() { delete ui_; }
void ScrobblerSettingsPage::Load() {
- QSettings s;
+ Settings s;
if (!s.contains(kSettingsGroup)) set_changed();
ui_->checkbox_enable->setChecked(scrobbler_->enabled());
@@ -124,13 +125,13 @@ void ScrobblerSettingsPage::Load() {
Init(ui_->layout_scrobblersettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
void ScrobblerSettingsPage::Save() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("enabled", ui_->checkbox_enable->isChecked());
diff --git a/src/settings/settingsdialog.cpp b/src/settings/settingsdialog.cpp
index b87a88fb36..165106d3cc 100644
--- a/src/settings/settingsdialog.cpp
+++ b/src/settings/settingsdialog.cpp
@@ -49,6 +49,7 @@
#include "core/application.h"
#include "core/player.h"
+#include "core/settings.h"
#include "utilities/screenutils.h"
#include "widgets/groupediconview.h"
#include "collection/collectionmodel.h"
@@ -237,8 +238,8 @@ void SettingsDialog::reject() {
void SettingsDialog::LoadGeometry() {
- QSettings s;
- s.beginGroup(kSettingsGroup);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup));
if (s.contains("geometry")) {
restoreGeometry(s.value("geometry").toByteArray());
}
@@ -251,8 +252,8 @@ void SettingsDialog::LoadGeometry() {
void SettingsDialog::SaveGeometry() {
- QSettings s;
- s.beginGroup(kSettingsGroup);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup));
s.setValue("geometry", saveGeometry());
s.endGroup();
@@ -353,7 +354,7 @@ void SettingsDialog::CurrentItemChanged(QTreeWidgetItem *item) {
}
// Set the title
- ui_->title->setText("" + item->text(0) + "");
+ ui_->title->setText(QStringLiteral("") + item->text(0) + QStringLiteral(""));
// Display the right page
QList pages = pages_.values();
diff --git a/src/settings/settingsdialog.h b/src/settings/settingsdialog.h
index 013890dd52..cbdb23e4c7 100644
--- a/src/settings/settingsdialog.h
+++ b/src/settings/settingsdialog.h
@@ -32,7 +32,6 @@
#include
#include
#include
-#include
#include "core/shared_ptr.h"
#include "engine/enginebase.h"
diff --git a/src/settings/settingspage.cpp b/src/settings/settingspage.cpp
index e1bf5b3ea9..69b463d71c 100644
--- a/src/settings/settingspage.cpp
+++ b/src/settings/settingspage.cpp
@@ -31,6 +31,7 @@
#include
#include "core/logging.h"
+#include "core/settings.h"
#include "settingsdialog.h"
#include "settingspage.h"
@@ -151,7 +152,7 @@ void SettingsPage::Apply() {
}
-void SettingsPage::ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const QString &default_value) {
+void SettingsPage::ComboBoxLoadFromSettings(const Settings &s, QComboBox *combobox, const QString &setting, const QString &default_value) {
QString value = s.value(setting, default_value).toString();
int i = combobox->findData(value);
@@ -160,7 +161,7 @@ void SettingsPage::ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combo
}
-void SettingsPage::ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const int default_value) {
+void SettingsPage::ComboBoxLoadFromSettings(const Settings &s, QComboBox *combobox, const QString &setting, const int default_value) {
int value = s.value(setting, default_value).toInt();
int i = combobox->findData(value);
@@ -169,7 +170,7 @@ void SettingsPage::ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combo
}
-void SettingsPage::ComboBoxLoadFromSettingsByIndex(const QSettings &s, QComboBox *combobox, const QString &setting, const int default_value) {
+void SettingsPage::ComboBoxLoadFromSettingsByIndex(const Settings &s, QComboBox *combobox, const QString &setting, const int default_value) {
if (combobox->count() == 0) return;
int i = s.value(setting, default_value).toInt();
diff --git a/src/settings/settingspage.h b/src/settings/settingspage.h
index 98b7d73489..88fd081b48 100644
--- a/src/settings/settingspage.h
+++ b/src/settings/settingspage.h
@@ -34,6 +34,7 @@
#include "osd/osdbase.h"
#include "core/logging.h"
+#include "core/settings.h"
class QCheckBox;
class QComboBox;
@@ -68,9 +69,9 @@ class SettingsPage : public QWidget {
void set_changed() { changed_ = true; }
- static void ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const QString &default_value);
- static void ComboBoxLoadFromSettings(const QSettings &s, QComboBox *combobox, const QString &setting, const int default_value);
- static void ComboBoxLoadFromSettingsByIndex(const QSettings &s, QComboBox *combobox, const QString &setting, const int default_value);
+ static void ComboBoxLoadFromSettings(const Settings &s, QComboBox *combobox, const QString &setting, const QString &default_value);
+ static void ComboBoxLoadFromSettings(const Settings &s, QComboBox *combobox, const QString &setting, const int default_value);
+ static void ComboBoxLoadFromSettingsByIndex(const Settings &s, QComboBox *combobox, const QString &setting, const int default_value);
private:
virtual void Save() = 0;
diff --git a/src/settings/subsonicsettingspage.cpp b/src/settings/subsonicsettingspage.cpp
index bac7a7ffdd..d0634f3f88 100644
--- a/src/settings/subsonicsettingspage.cpp
+++ b/src/settings/subsonicsettingspage.cpp
@@ -36,6 +36,7 @@
#include "ui_subsonicsettingspage.h"
#include "core/application.h"
#include "core/iconloader.h"
+#include "core/settings.h"
#include "internet/internetservices.h"
#include "subsonic/subsonicservice.h"
@@ -71,7 +72,7 @@ SubsonicSettingsPage::~SubsonicSettingsPage() { delete ui_; }
void SubsonicSettingsPage::Load() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
ui_->enable->setChecked(s.value("enabled", false).toBool());
ui_->server_url->setText(s.value("url").toString());
@@ -98,13 +99,13 @@ void SubsonicSettingsPage::Load() {
Init(ui_->layout_subsonicsettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
void SubsonicSettingsPage::Save() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("enabled", ui_->enable->isChecked());
s.setValue("url", QUrl(ui_->server_url->text()));
diff --git a/src/settings/tidalsettingspage.cpp b/src/settings/tidalsettingspage.cpp
index 66428c2ecc..45e0683676 100644
--- a/src/settings/tidalsettingspage.cpp
+++ b/src/settings/tidalsettingspage.cpp
@@ -36,6 +36,7 @@
#include "ui_tidalsettingspage.h"
#include "core/application.h"
#include "core/iconloader.h"
+#include "core/settings.h"
#include "internet/internetservices.h"
#include "tidal/tidalservice.h"
#include "widgets/loginstatewidget.h"
@@ -62,16 +63,16 @@ TidalSettingsPage::TidalSettingsPage(SettingsDialog *dialog, QWidget *parent)
dialog->installEventFilter(this);
- ui_->quality->addItem(QStringLiteral("Low"), "LOW");
- ui_->quality->addItem(QStringLiteral("High"), "HIGH");
- ui_->quality->addItem(QStringLiteral("Lossless"), "LOSSLESS");
- ui_->quality->addItem(QStringLiteral("Hi resolution"), "HI_RES");
+ ui_->quality->addItem(QStringLiteral("Low"), QStringLiteral("LOW"));
+ ui_->quality->addItem(QStringLiteral("High"), QStringLiteral("HIGH"));
+ ui_->quality->addItem(QStringLiteral("Lossless"), QStringLiteral("LOSSLESS"));
+ ui_->quality->addItem(QStringLiteral("Hi resolution"), QStringLiteral("HI_RES"));
- ui_->coversize->addItem(QStringLiteral("160x160"), "160x160");
- ui_->coversize->addItem(QStringLiteral("320x320"), "320x320");
- ui_->coversize->addItem(QStringLiteral("640x640"), "640x640");
- ui_->coversize->addItem(QStringLiteral("750x750"), "750x750");
- ui_->coversize->addItem(QStringLiteral("1280x1280"), "1280x1280");
+ ui_->coversize->addItem(QStringLiteral("160x160"), QStringLiteral("160x160"));
+ ui_->coversize->addItem(QStringLiteral("320x320"), QStringLiteral("320x320"));
+ ui_->coversize->addItem(QStringLiteral("640x640"), QStringLiteral("640x640"));
+ ui_->coversize->addItem(QStringLiteral("750x750"), QStringLiteral("750x750"));
+ ui_->coversize->addItem(QStringLiteral("1280x1280"), QStringLiteral("1280x1280"));
ui_->streamurl->addItem(QStringLiteral("streamurl"), static_cast(StreamUrlMethod::StreamUrl));
ui_->streamurl->addItem(QStringLiteral("urlpostpaywall"), static_cast(StreamUrlMethod::UrlPostPaywall));
@@ -83,7 +84,7 @@ TidalSettingsPage::~TidalSettingsPage() { delete ui_; }
void TidalSettingsPage::Load() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
ui_->enable->setChecked(s.value("enabled", false).toBool());
ui_->oauth->setChecked(s.value("oauth", true).toBool());
@@ -114,13 +115,13 @@ void TidalSettingsPage::Load() {
Init(ui_->layout_tidalsettingspage->parentWidget());
- if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
+ if (!Settings().childGroups().contains(QLatin1String(kSettingsGroup))) set_changed();
}
void TidalSettingsPage::Save() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("enabled", ui_->enable->isChecked());
s.setValue("oauth", ui_->oauth->isChecked());
diff --git a/src/smartplaylists/smartplaylistsearch.cpp b/src/smartplaylists/smartplaylistsearch.cpp
index 37dd999804..fe6bf14aa6 100644
--- a/src/smartplaylists/smartplaylistsearch.cpp
+++ b/src/smartplaylists/smartplaylistsearch.cpp
@@ -51,7 +51,7 @@ void SmartPlaylistSearch::Reset() {
QString SmartPlaylistSearch::ToSql(const QString &songs_table) const {
- QString sql = "SELECT ROWID," + Song::kColumnSpec + " FROM " + songs_table;
+ QString sql = QStringLiteral("SELECT ROWID,") + Song::kColumnSpec + QStringLiteral(" FROM ") + songs_table;
// Add search terms
QStringList where_clauses;
@@ -63,16 +63,16 @@ QString SmartPlaylistSearch::ToSql(const QString &songs_table) const {
if (!terms_.isEmpty() && search_type_ != SearchType::All) {
QString boolean_op = search_type_ == SearchType::And ? QStringLiteral(" AND ") : QStringLiteral(" OR ");
- where_clauses << "(" + term_where_clauses.join(boolean_op) + ")";
+ where_clauses << QStringLiteral("(") + term_where_clauses.join(boolean_op) + QStringLiteral(")");
}
// Restrict the IDs of songs if we're making a dynamic playlist
if (!id_not_in_.isEmpty()) {
QString numbers;
for (int id : id_not_in_) {
- numbers += (numbers.isEmpty() ? "" : ",") + QString::number(id);
+ numbers += (numbers.isEmpty() ? QLatin1String("") : QStringLiteral(",")) + QString::number(id);
}
- where_clauses << "(ROWID NOT IN (" + numbers + "))";
+ where_clauses << QStringLiteral("(ROWID NOT IN (") + numbers + QStringLiteral("))");
}
// We never want to include songs that have been deleted,
@@ -80,7 +80,7 @@ QString SmartPlaylistSearch::ToSql(const QString &songs_table) const {
where_clauses << QStringLiteral("unavailable = 0");
if (!where_clauses.isEmpty()) {
- sql += " WHERE " + where_clauses.join(QStringLiteral(" AND "));
+ sql += QStringLiteral(" WHERE ") + where_clauses.join(QStringLiteral(" AND "));
}
// Add sort by
@@ -88,7 +88,7 @@ QString SmartPlaylistSearch::ToSql(const QString &songs_table) const {
sql += QLatin1String(" ORDER BY random()");
}
else {
- sql += " ORDER BY " + SmartPlaylistSearchTerm::FieldColumnName(sort_field_) + (sort_type_ == SortType::FieldAsc ? " ASC" : " DESC");
+ sql += QStringLiteral(" ORDER BY ") + SmartPlaylistSearchTerm::FieldColumnName(sort_field_) + (sort_type_ == SortType::FieldAsc ? QStringLiteral(" ASC") : QStringLiteral(" DESC"));
}
// Add limit
@@ -96,7 +96,7 @@ QString SmartPlaylistSearch::ToSql(const QString &songs_table) const {
sql += QStringLiteral(" LIMIT %1 OFFSET %2").arg(limit_).arg(first_item_);
}
else if (limit_ != -1) {
- sql += " LIMIT " + QString::number(limit_);
+ sql += QStringLiteral(" LIMIT ") + QString::number(limit_);
}
//qLog(Debug) << sql;
diff --git a/src/smartplaylists/smartplaylistsearchterm.cpp b/src/smartplaylists/smartplaylistsearchterm.cpp
index 27f539ea5f..e17feadb6e 100644
--- a/src/smartplaylists/smartplaylistsearchterm.cpp
+++ b/src/smartplaylists/smartplaylistsearchterm.cpp
@@ -39,7 +39,7 @@ QString SmartPlaylistSearchTerm::ToSql() const {
QString col = FieldColumnName(field_);
QString date = DateName(datetype_, true);
QString value = value_.toString();
- value.replace('\'', QLatin1String("''"));
+ value.replace(QLatin1Char('\''), QLatin1String("''"));
if (field_ == Field::Filetype) {
Song::FileType filetype = Song::FiletypeByExtension(value);
@@ -62,10 +62,10 @@ QString SmartPlaylistSearchTerm::ToSql() const {
if (TypeOf(field_) == Type::Date) {
if (special_date_query) {
// We have a numeric date, consider also the time for more precision
- col = "DATETIME(" + col + ", 'unixepoch', 'localtime')";
+ col = QStringLiteral("DATETIME(") + col + QStringLiteral(", 'unixepoch', 'localtime')");
second_value = second_value_.toString();
- second_value.replace('\'', QLatin1String("''"));
- if (date == "weeks") {
+ second_value.replace(QLatin1Char('\''), QLatin1String("''"));
+ if (date == QStringLiteral("weeks")) {
// Sqlite doesn't know weeks, transform them to days
date = QStringLiteral("days");
value = QString::number(value_.toInt() * 7);
@@ -76,80 +76,80 @@ QString SmartPlaylistSearchTerm::ToSql() const {
// We have the exact date
// The calendar widget specifies no time so ditch the possible time part
// from integers representing the dates.
- col = "DATE(" + col + ", 'unixepoch', 'localtime')";
- value = "DATE(" + value + ", 'unixepoch', 'localtime')";
+ col = QStringLiteral("DATE(") + col + QStringLiteral(", 'unixepoch', 'localtime')");
+ value = QStringLiteral("DATE(") + value + QStringLiteral(", 'unixepoch', 'localtime')");
}
}
else if (TypeOf(field_) == Type::Time) {
// Convert seconds to nanoseconds
- value = "CAST (" + value + " *1000000000 AS INTEGER)";
+ value = QStringLiteral("CAST (") + value + QStringLiteral(" *1000000000 AS INTEGER)");
}
// File paths need some extra processing since they are stored as encoded urls in the database.
if (field_ == Field::Filepath) {
if (operator_ == Operator::StartsWith || operator_ == Operator::Equals) {
- value = QUrl::fromLocalFile(value).toEncoded();
+ value = QString::fromUtf8(QUrl::fromLocalFile(value).toEncoded());
}
else {
- value = QUrl(value).toEncoded();
+ value = QString::fromUtf8(QUrl(value).toEncoded());
}
}
else if (TypeOf(field_) == Type::Rating) {
- col = "CAST ((replace(" + col + ", -1, 0) + 0.05) * 10 AS INTEGER)";
- value = "CAST ((" + value + " + 0.05) * 10 AS INTEGER)";
+ col = QStringLiteral("CAST ((replace(") + col + QStringLiteral(", -1, 0) + 0.05) * 10 AS INTEGER)");
+ value = QStringLiteral("CAST ((") + value + QStringLiteral(" + 0.05) * 10 AS INTEGER)");
}
switch (operator_) {
case Operator::Contains:
- return col + " LIKE '%" + value + "%'";
+ return col + QStringLiteral(" LIKE '%") + value + QStringLiteral("%'");
case Operator::NotContains:
- return col + " NOT LIKE '%" + value + "%'";
+ return col + QStringLiteral(" NOT LIKE '%") + value + QStringLiteral("%'");
case Operator::StartsWith:
- return col + " LIKE '" + value + "%'";
+ return col + QStringLiteral(" LIKE '") + value + QStringLiteral("%'");
case Operator::EndsWith:
- return col + " LIKE '%" + value + "'";
+ return col + QStringLiteral(" LIKE '%") + value + QStringLiteral("'");
case Operator::Equals:
if (TypeOf(field_) == Type::Text) {
- return col + " LIKE '" + value + "'";
+ return col + QStringLiteral(" LIKE '") + value + QStringLiteral("'");
}
else if (TypeOf(field_) == Type::Date || TypeOf(field_) == Type::Time || TypeOf(field_) == Type::Rating) {
- return col + " = " + value;
+ return col + QStringLiteral(" = ") + value;
}
else {
- return col + " = '" + value + "'";
+ return col + QStringLiteral(" = '") + value + QStringLiteral("'");
}
case Operator::GreaterThan:
if (TypeOf(field_) == Type::Date || TypeOf(field_) == Type::Time || TypeOf(field_) == Type::Rating) {
- return col + " > " + value;
+ return col + QStringLiteral(" > ") + value;
}
else {
- return col + " > '" + value + "'";
+ return col + QStringLiteral(" > '") + value + QLatin1Char('\'');
}
case Operator::LessThan:
if (TypeOf(field_) == Type::Date || TypeOf(field_) == Type::Time || TypeOf(field_) == Type::Rating) {
- return col + " < " + value;
+ return col + QStringLiteral(" < ") + value;
}
else {
- return col + " < '" + value + "'";
+ return col + QStringLiteral(" < '") + value + QStringLiteral("'");
}
case Operator::NumericDate:
- return col + " > " + "DATETIME('now', '-" + value + " " + date + "', 'localtime')";
+ return col + QStringLiteral(" > ") + QStringLiteral("DATETIME('now', '-") + value + QStringLiteral(" ") + date + QStringLiteral("', 'localtime')");
case Operator::NumericDateNot:
- return col + " < " + "DATETIME('now', '-" + value + " " + date + "', 'localtime')";
+ return col + QStringLiteral(" < ") + QStringLiteral("DATETIME('now', '-") + value + QStringLiteral(" ") + date + QStringLiteral("', 'localtime')");
case Operator::RelativeDate:
// Consider the time range before the first date but after the second one
- return "(" + col + " < " + "DATETIME('now', '-" + value + " " + date + "', 'localtime') AND " + col + " > " + "DATETIME('now', '-" + second_value + " " + date + "', 'localtime'))";
+ return QStringLiteral("(") + col + QStringLiteral(" < ") + QStringLiteral("DATETIME('now', '-") + value + QStringLiteral(" ") + date + QStringLiteral("', 'localtime') AND ") + col + QStringLiteral(" > ") + QStringLiteral("DATETIME('now', '-") + second_value + QStringLiteral(" ") + date + QStringLiteral("', 'localtime'))");
case Operator::NotEquals:
if (TypeOf(field_) == Type::Text) {
- return col + " <> '" + value + "'";
+ return col + QStringLiteral(" <> '") + value + QStringLiteral("'");
}
else {
- return col + " <> " + value;
+ return col + QStringLiteral(" <> ") + value;
}
case Operator::Empty:
- return col + " = ''";
+ return col + QStringLiteral(" = ''");
case Operator::NotEmpty:
- return col + " <> ''";
+ return col + QStringLiteral(" <> ''");
}
return QString();
diff --git a/src/smartplaylists/smartplaylistsearchtermwidget.cpp b/src/smartplaylists/smartplaylistsearchtermwidget.cpp
index 7fe847e31b..730cbfaebd 100644
--- a/src/smartplaylists/smartplaylistsearchtermwidget.cpp
+++ b/src/smartplaylists/smartplaylistsearchtermwidget.cpp
@@ -381,7 +381,7 @@ SmartPlaylistSearchTerm SmartPlaylistSearchTermWidget::Term() const {
ret.value_ = ui_->value_text->text();
}
else if (value_page == ui_->page_empty) {
- ret.value_ = "";
+ ret.value_ = QLatin1String("");
}
else if (value_page == ui_->page_number) {
ret.value_ = ui_->value_number->value();
diff --git a/src/smartplaylists/smartplaylistsmodel.cpp b/src/smartplaylists/smartplaylistsmodel.cpp
index 089b5c51e9..d0ad5d4e6b 100644
--- a/src/smartplaylists/smartplaylistsmodel.cpp
+++ b/src/smartplaylists/smartplaylistsmodel.cpp
@@ -32,6 +32,7 @@
#include "core/application.h"
#include "core/iconloader.h"
#include "core/simpletreemodel.h"
+#include "core/settings.h"
#include "collection/collectionbackend.h"
#include "smartplaylistsitem.h"
@@ -63,62 +64,62 @@ void SmartPlaylistsModel::Init() {
<< (SmartPlaylistsModel::GeneratorList()
<< PlaylistGeneratorPtr(
new PlaylistQueryGenerator(
- QT_TRANSLATE_NOOP("SmartPlaylists", "Newest tracks"),
+ QT_TRANSLATE_NOOP(QStringLiteral("SmartPlaylists"), QStringLiteral("Newest tracks")),
SmartPlaylistSearch(SmartPlaylistSearch::SearchType::All, SmartPlaylistSearch::TermList(),
SmartPlaylistSearch::SortType::FieldDesc,
SmartPlaylistSearchTerm::Field::DateCreated)
)
)
<< PlaylistGeneratorPtr(new PlaylistQueryGenerator(
- QT_TRANSLATE_NOOP("SmartPlaylists", "50 random tracks"),
+ QT_TRANSLATE_NOOP(QStringLiteral("SmartPlaylists"), QStringLiteral("50 random tracks")),
SmartPlaylistSearch(SmartPlaylistSearch::SearchType::All, SmartPlaylistSearch::TermList(), SmartPlaylistSearch::SortType::Random, SmartPlaylistSearchTerm::Field::Title, 50)
)
)
<< PlaylistGeneratorPtr(
new PlaylistQueryGenerator(
- QT_TRANSLATE_NOOP("SmartPlaylists", "Ever played"),
+ QT_TRANSLATE_NOOP(QStringLiteral("SmartPlaylists"), QStringLiteral("Ever played")),
SmartPlaylistSearch(SmartPlaylistSearch::SearchType::And, SmartPlaylistSearch::TermList() << SmartPlaylistSearchTerm( SmartPlaylistSearchTerm::Field::PlayCount, SmartPlaylistSearchTerm::Operator::GreaterThan, 0), SmartPlaylistSearch::SortType::Random, SmartPlaylistSearchTerm::Field::Title)
)
)
<< PlaylistGeneratorPtr(
new PlaylistQueryGenerator(
- QT_TRANSLATE_NOOP("SmartPlaylists", "Never played"),
+ QT_TRANSLATE_NOOP(QStringLiteral("SmartPlaylists"), QStringLiteral("Never played")),
SmartPlaylistSearch(SmartPlaylistSearch::SearchType::And, SmartPlaylistSearch::TermList() << SmartPlaylistSearchTerm(SmartPlaylistSearchTerm::Field::PlayCount, SmartPlaylistSearchTerm::Operator::Equals, 0), SmartPlaylistSearch::SortType::Random, SmartPlaylistSearchTerm::Field::Title)
)
)
<< PlaylistGeneratorPtr(
new PlaylistQueryGenerator(
- QT_TRANSLATE_NOOP("SmartPlaylists", "Last played"),
+ QT_TRANSLATE_NOOP(QStringLiteral("SmartPlaylists"), QStringLiteral("Last played")),
SmartPlaylistSearch(SmartPlaylistSearch::SearchType::All, SmartPlaylistSearch::TermList(), SmartPlaylistSearch::SortType::FieldDesc, SmartPlaylistSearchTerm::Field::LastPlayed)
)
)
<< PlaylistGeneratorPtr(
new PlaylistQueryGenerator(
- QT_TRANSLATE_NOOP("SmartPlaylists", "Most played"),
+ QT_TRANSLATE_NOOP(QStringLiteral("SmartPlaylists"), QStringLiteral("Most played")),
SmartPlaylistSearch(SmartPlaylistSearch::SearchType::All, SmartPlaylistSearch::TermList(), SmartPlaylistSearch::SortType::FieldDesc, SmartPlaylistSearchTerm::Field::PlayCount)
)
)
<< PlaylistGeneratorPtr(
new PlaylistQueryGenerator(
- QT_TRANSLATE_NOOP("SmartPlaylists", "Favourite tracks"),
+ QT_TRANSLATE_NOOP(QStringLiteral("SmartPlaylists"), QStringLiteral("Favourite tracks")),
SmartPlaylistSearch(SmartPlaylistSearch::SearchType::All, SmartPlaylistSearch::TermList(), SmartPlaylistSearch::SortType::FieldDesc, SmartPlaylistSearchTerm::Field::Rating)
)
)
<< PlaylistGeneratorPtr(
new PlaylistQueryGenerator(
- QT_TRANSLATE_NOOP("Library", "Least favourite tracks"),
+ QT_TRANSLATE_NOOP(QStringLiteral("Library"), QStringLiteral("Least favourite tracks")),
SmartPlaylistSearch(SmartPlaylistSearch::SearchType::Or, SmartPlaylistSearch::TermList()
<< SmartPlaylistSearchTerm(SmartPlaylistSearchTerm::Field::Rating, SmartPlaylistSearchTerm::Operator::LessThan, 0.5)
<< SmartPlaylistSearchTerm(SmartPlaylistSearchTerm::Field::SkipCount, SmartPlaylistSearchTerm::Operator::GreaterThan, 4), SmartPlaylistSearch::SortType::FieldDesc, SmartPlaylistSearchTerm::Field::SkipCount)
)
)
)
- << (SmartPlaylistsModel::GeneratorList() << PlaylistGeneratorPtr(new PlaylistQueryGenerator(QT_TRANSLATE_NOOP("SmartPlaylists", "All tracks"), SmartPlaylistSearch(SmartPlaylistSearch::SearchType::All, SmartPlaylistSearch::TermList(), SmartPlaylistSearch::SortType::FieldAsc, SmartPlaylistSearchTerm::Field::Artist, -1))))
- << (SmartPlaylistsModel::GeneratorList() << PlaylistGeneratorPtr(new PlaylistQueryGenerator( QT_TRANSLATE_NOOP("SmartPlaylists", "Dynamic random mix"), SmartPlaylistSearch(SmartPlaylistSearch::SearchType::All, SmartPlaylistSearch::TermList(), SmartPlaylistSearch::SortType::Random, SmartPlaylistSearchTerm::Field::Title), true)));
+ << (SmartPlaylistsModel::GeneratorList() << PlaylistGeneratorPtr(new PlaylistQueryGenerator(QT_TRANSLATE_NOOP(QStringLiteral("SmartPlaylists"), QStringLiteral("All tracks")), SmartPlaylistSearch(SmartPlaylistSearch::SearchType::All, SmartPlaylistSearch::TermList(), SmartPlaylistSearch::SortType::FieldAsc, SmartPlaylistSearchTerm::Field::Artist, -1))))
+ << (SmartPlaylistsModel::GeneratorList() << PlaylistGeneratorPtr(new PlaylistQueryGenerator( QT_TRANSLATE_NOOP(QStringLiteral("SmartPlaylists"), QStringLiteral("Dynamic random mix")), SmartPlaylistSearch(SmartPlaylistSearch::SearchType::All, SmartPlaylistSearch::TermList(), SmartPlaylistSearch::SortType::Random, SmartPlaylistSearchTerm::Field::Title), true)));
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
- int version = s.value(collection_backend_->songs_table() + "_version", 0).toInt();
+ int version = s.value(collection_backend_->songs_table() + QStringLiteral("_version"), 0).toInt();
// How many defaults do we have to write?
int unwritten_defaults = 0;
@@ -142,7 +143,7 @@ void SmartPlaylistsModel::Init() {
s.endArray();
}
- s.setValue(collection_backend_->songs_table() + "_version", version);
+ s.setValue(collection_backend_->songs_table() + QStringLiteral("_version"), version);
const int count = s.beginReadArray(collection_backend_->songs_table());
for (int i = 0; i < count; ++i) {
@@ -154,7 +155,7 @@ void SmartPlaylistsModel::Init() {
}
-void SmartPlaylistsModel::ItemFromSmartPlaylist(const QSettings &s, const bool notify) {
+void SmartPlaylistsModel::ItemFromSmartPlaylist(const Settings &s, const bool notify) {
SmartPlaylistsItem *item = new SmartPlaylistsItem(SmartPlaylistsItem::Type_SmartPlaylist, notify ? nullptr : root_);
item->display_text = tr(qPrintable(s.value("name").toString()));
@@ -169,7 +170,7 @@ void SmartPlaylistsModel::ItemFromSmartPlaylist(const QSettings &s, const bool n
void SmartPlaylistsModel::AddGenerator(PlaylistGeneratorPtr gen) {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
// Count the existing items
@@ -195,7 +196,7 @@ void SmartPlaylistsModel::UpdateGenerator(const QModelIndex &idx, PlaylistGenera
if (!item) return;
// Update the config
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
// Count the existing items
@@ -224,7 +225,7 @@ void SmartPlaylistsModel::DeleteGenerator(const QModelIndex &idx) {
// Remove the item from the tree
root_->DeleteNotify(idx.row());
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
// Rewrite all the items to the settings
@@ -241,7 +242,7 @@ void SmartPlaylistsModel::DeleteGenerator(const QModelIndex &idx) {
}
-void SmartPlaylistsModel::SaveGenerator(QSettings *s, const int i, PlaylistGeneratorPtr generator) {
+void SmartPlaylistsModel::SaveGenerator(Settings *s, const int i, PlaylistGeneratorPtr generator) {
s->setArrayIndex(i);
s->setValue("name", generator->name());
@@ -300,7 +301,7 @@ QMimeData *SmartPlaylistsModel::mimeData(const QModelIndexList &indexes) const {
if (!generator) return nullptr;
PlaylistGeneratorMimeData *mimedata = new PlaylistGeneratorMimeData(generator);
- mimedata->setData(kSmartPlaylistsMimeType, QByteArray());
+ mimedata->setData(QLatin1String(kSmartPlaylistsMimeType), QByteArray());
mimedata->name_for_new_playlist_ = data(indexes.first()).toString();
return mimedata;
diff --git a/src/smartplaylists/smartplaylistsmodel.h b/src/smartplaylists/smartplaylistsmodel.h
index 898426a1fd..98cddfd555 100644
--- a/src/smartplaylists/smartplaylistsmodel.h
+++ b/src/smartplaylists/smartplaylistsmodel.h
@@ -33,6 +33,7 @@
#include "core/shared_ptr.h"
#include "core/simpletreemodel.h"
+#include "core/settings.h"
#include "smartplaylistsitem.h"
#include "playlistgenerator_fwd.h"
@@ -77,8 +78,8 @@ class SmartPlaylistsModel : public SimpleTreeModel {
static const char *kSmartPlaylistsMimeType;
static const int kSmartPlaylistsVersion;
- static void SaveGenerator(QSettings *s, const int i, PlaylistGeneratorPtr generator);
- void ItemFromSmartPlaylist(const QSettings &s, const bool notify);
+ static void SaveGenerator(Settings *s, const int i, PlaylistGeneratorPtr generator);
+ void ItemFromSmartPlaylist(const Settings &s, const bool notify);
private:
SharedPtr collection_backend_;
diff --git a/src/smartplaylists/smartplaylistsviewcontainer.cpp b/src/smartplaylists/smartplaylistsviewcontainer.cpp
index abd42f31fc..f4634b4a15 100644
--- a/src/smartplaylists/smartplaylistsviewcontainer.cpp
+++ b/src/smartplaylists/smartplaylistsviewcontainer.cpp
@@ -27,6 +27,7 @@
#include "core/application.h"
#include "core/iconloader.h"
#include "core/mimedata.h"
+#include "core/settings.h"
#include "collection/collectionbackend.h"
#include "settings/appearancesettingspage.h"
@@ -109,7 +110,7 @@ void SmartPlaylistsViewContainer::showEvent(QShowEvent *e) {
void SmartPlaylistsViewContainer::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
int iconsize = s.value(AppearanceSettingsPage::kIconSizeLeftPanelButtons, 22).toInt();
s.endGroup();
diff --git a/src/smartplaylists/smartplaylistwizard.cpp b/src/smartplaylists/smartplaylistwizard.cpp
index a66d624037..bc70df1e24 100644
--- a/src/smartplaylists/smartplaylistwizard.cpp
+++ b/src/smartplaylists/smartplaylistwizard.cpp
@@ -124,7 +124,7 @@ void SmartPlaylistWizard::SetGenerator(PlaylistGeneratorPtr gen) {
// Set the name
if (!gen->name().isEmpty()) {
- setWindowTitle(windowTitle() + " - " + gen->name());
+ setWindowTitle(windowTitle() + QStringLiteral(" - ") + gen->name());
}
finish_page_->ui_->name->setText(gen->name());
finish_page_->ui_->dynamic->setChecked(gen->is_dynamic());
diff --git a/src/subsonic/subsonicbaserequest.cpp b/src/subsonic/subsonicbaserequest.cpp
index bcfa9d2290..c9e0d99204 100644
--- a/src/subsonic/subsonicbaserequest.cpp
+++ b/src/subsonic/subsonicbaserequest.cpp
@@ -55,31 +55,31 @@ SubsonicBaseRequest::SubsonicBaseRequest(SubsonicService *service, QObject *pare
QUrl SubsonicBaseRequest::CreateUrl(const QUrl &server_url, const SubsonicSettingsPage::AuthMethod auth_method, const QString &username, const QString &password, const QString &ressource_name, const ParamList ¶ms_provided) {
ParamList params = ParamList() << params_provided
- << Param("c", SubsonicService::kClientName)
- << Param("v", SubsonicService::kApiVersion)
- << Param("f", "json")
- << Param("u", username);
+ << Param(QStringLiteral("c"), QLatin1String(SubsonicService::kClientName))
+ << Param(QStringLiteral("v"), QLatin1String(SubsonicService::kApiVersion))
+ << Param(QStringLiteral("f"), QStringLiteral("json"))
+ << Param(QStringLiteral("u"), username);
if (auth_method == SubsonicSettingsPage::AuthMethod::Hex) {
- params << Param("p", QString("enc:" + password.toUtf8().toHex()));
+ params << Param(QStringLiteral("p"), QStringLiteral("enc:") + QString::fromUtf8(password.toUtf8().toHex()));
}
else {
const QString salt = Utilities::CryptographicRandomString(20);
QCryptographicHash md5(QCryptographicHash::Md5);
md5.addData(password.toUtf8());
md5.addData(salt.toUtf8());
- params << Param("s", salt);
- params << Param("t", md5.result().toHex());
+ params << Param(QStringLiteral("s"), salt);
+ params << Param(QStringLiteral("t"), QString::fromUtf8(md5.result().toHex()));
}
QUrlQuery url_query;
for (const Param ¶m : params) {
- url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
+ url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
QUrl url(server_url);
- if (!url.path().isEmpty() && url.path().right(1) == "/") {
+ if (!url.path().isEmpty() && url.path().right(1) == QStringLiteral("/")) {
url.setPath(url.path() + QStringLiteral("rest/") + ressource_name + QStringLiteral(".view"));
}
else {
@@ -97,13 +97,13 @@ QNetworkReply *SubsonicBaseRequest::CreateGetRequest(const QString &ressource_na
QUrl url = CreateUrl(server_url(), auth_method(), username(), password(), ressource_name, params_provided);
QNetworkRequest req(url);
- if (url.scheme() == "https" && !verify_certificate()) {
+ if (url.scheme() == QStringLiteral("https") && !verify_certificate()) {
QSslConfiguration sslconfig = QSslConfiguration::defaultConfiguration();
sslconfig.setPeerVerifyMode(QSslSocket::VerifyNone);
req.setSslConfiguration(sslconfig);
}
- req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
+ req.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
@@ -222,7 +222,7 @@ QString SubsonicBaseRequest::ErrorsToHTML(const QStringList &errors) {
QString error_html;
for (const QString &error : errors) {
- error_html += error + "
";
+ error_html += error + QStringLiteral("
");
}
return error_html;
diff --git a/src/subsonic/subsonicrequest.cpp b/src/subsonic/subsonicrequest.cpp
index bed47beb57..2217db89d1 100644
--- a/src/subsonic/subsonicrequest.cpp
+++ b/src/subsonic/subsonicrequest.cpp
@@ -145,9 +145,9 @@ void SubsonicRequest::FlushAlbumsRequests() {
Request request = albums_requests_queue_.dequeue();
++albums_requests_active_;
- ParamList params = ParamList() << Param("type", "alphabeticalByName");
- if (request.size > 0) params << Param("size", QString::number(request.size));
- if (request.offset > 0) params << Param("offset", QString::number(request.offset));
+ ParamList params = ParamList() << Param(QStringLiteral("type"), QStringLiteral("alphabeticalByName"));
+ if (request.size > 0) params << Param(QStringLiteral("size"), QString::number(request.size));
+ if (request.offset > 0) params << Param(QStringLiteral("offset"), QString::number(request.offset));
QNetworkReply *reply = CreateGetRequest(QStringLiteral("getAlbumList2"), params);
replies_ << reply;
@@ -341,7 +341,7 @@ void SubsonicRequest::FlushAlbumSongsRequests() {
Request request = album_songs_requests_queue_.dequeue();
++album_songs_requests_active_;
- QNetworkReply *reply = CreateGetRequest(QStringLiteral("getAlbum"), ParamList() << Param("id", request.album_id));
+ QNetworkReply *reply = CreateGetRequest(QStringLiteral("getAlbum"), ParamList() << Param(QStringLiteral("id"), request.album_id));
replies_ << reply;
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, request]() { AlbumSongsReplyReceived(reply, request.artist_id, request.album_id, request.album_artist); });
timeouts_->AddReply(reply);
@@ -631,7 +631,7 @@ QString SubsonicRequest::ParseSong(Song &song, const QJsonObject &json_obj, cons
cover_url = cover_urls_[cover_id];
}
else {
- cover_url = CreateUrl(server_url(), auth_method(), username(), password(), QStringLiteral("getCoverArt"), ParamList() << Param("id", cover_id));
+ cover_url = CreateUrl(server_url(), auth_method(), username(), password(), QStringLiteral("getCoverArt"), ParamList() << Param(QStringLiteral("id"), cover_id));
cover_urls_.insert(cover_id, cover_url);
}
}
@@ -639,7 +639,7 @@ QString SubsonicRequest::ParseSong(Song &song, const QJsonObject &json_obj, cons
Song::FileType filetype(Song::FileType::Stream);
if (!mimetype.isEmpty()) {
QMimeDatabase mimedb;
- QStringList suffixes = mimedb.mimeTypeForName(mimetype.toUtf8()).suffixes();
+ QStringList suffixes = mimedb.mimeTypeForName(mimetype).suffixes();
for (const QString &suffix : suffixes) {
filetype = Song::FiletypeByExtension(suffix);
if (filetype != Song::FileType::Unknown) break;
@@ -721,7 +721,7 @@ void SubsonicRequest::AddAlbumCoverRequest(const Song &song) {
request.album_id = song.album_id();
request.cover_id = cover_id;
request.url = cover_url;
- request.filename = cover_path + "/" + cover_id + ".jpg";
+ request.filename = cover_path + QLatin1Char('/') + cover_id + QStringLiteral(".jpg");
if (request.filename.isEmpty()) return;
album_covers_requests_sent_.insert(cover_id, song.song_id());
@@ -799,8 +799,8 @@ void SubsonicRequest::AlbumCoverReceived(QNetworkReply *reply, const AlbumCoverR
}
QString mimetype = reply->header(QNetworkRequest::ContentTypeHeader).toString();
- if (mimetype.contains(';')) {
- mimetype = mimetype.left(mimetype.indexOf(';'));
+ if (mimetype.contains(QLatin1Char(';'))) {
+ mimetype = mimetype.left(mimetype.indexOf(QLatin1Char(';')));
}
if (!ImageUtils::SupportedImageMimeTypes().contains(mimetype, Qt::CaseInsensitive) && !ImageUtils::SupportedImageFormats().contains(mimetype, Qt::CaseInsensitive)) {
Error(QStringLiteral("Unsupported mimetype for image reader %1 for %2").arg(mimetype, request.url.toString()));
diff --git a/src/subsonic/subsonicscrobblerequest.cpp b/src/subsonic/subsonicscrobblerequest.cpp
index 1c65a8aeb2..314b24a3a1 100644
--- a/src/subsonic/subsonicscrobblerequest.cpp
+++ b/src/subsonic/subsonicscrobblerequest.cpp
@@ -73,9 +73,9 @@ void SubsonicScrobbleRequest::FlushScrobbleRequests() {
Request request = scrobble_requests_queue_.dequeue();
++scrobble_requests_active_;
- ParamList params = ParamList() << Param("id", request.song_id)
- << Param("submission", QVariant(request.submission).toString())
- << Param("time", QVariant(request.time_ms).toString());
+ ParamList params = ParamList() << Param(QStringLiteral("id"), request.song_id)
+ << Param(QStringLiteral("submission"), QVariant(request.submission).toString())
+ << Param(QStringLiteral("time"), QVariant(request.time_ms).toString());
QNetworkReply *reply = CreateGetRequest(QStringLiteral("scrobble"), params);
replies_ << reply;
diff --git a/src/subsonic/subsonicservice.cpp b/src/subsonic/subsonicservice.cpp
index 71f643f871..0c52d41c04 100644
--- a/src/subsonic/subsonicservice.cpp
+++ b/src/subsonic/subsonicservice.cpp
@@ -48,6 +48,7 @@
#include "core/player.h"
#include "core/database.h"
#include "core/song.h"
+#include "core/settings.h"
#include "utilities/randutils.h"
#include "collection/collectionbackend.h"
#include "collection/collectionmodel.h"
@@ -64,12 +65,15 @@ using std::make_shared;
const Song::Source SubsonicService::kSource = Song::Source::Subsonic;
const char *SubsonicService::kClientName = "Strawberry";
const char *SubsonicService::kApiVersion = "1.11.0";
-const char *SubsonicService::kSongsTable = "subsonic_songs";
-const char *SubsonicService::kSongsFtsTable = "subsonic_songs_fts";
-const int SubsonicService::kMaxRedirects = 3;
+
+namespace {
+constexpr char kSongsTable[] = "subsonic_songs";
+constexpr char kSongsFtsTable[] = "subsonic_songs_fts";
+constexpr int kMaxRedirects = 3;
+} // namespace
SubsonicService::SubsonicService(Application *app, QObject *parent)
- : InternetService(Song::Source::Subsonic, QStringLiteral("Subsonic"), QStringLiteral("subsonic"), SubsonicSettingsPage::kSettingsGroup, SettingsDialog::Page::Subsonic, app, parent),
+ : InternetService(Song::Source::Subsonic, QStringLiteral("Subsonic"), QStringLiteral("subsonic"), QLatin1String(SubsonicSettingsPage::kSettingsGroup), SettingsDialog::Page::Subsonic, app, parent),
app_(app),
url_handler_(new SubsonicUrlHandler(app, this)),
collection_backend_(nullptr),
@@ -85,9 +89,10 @@ SubsonicService::SubsonicService(Application *app, QObject *parent)
// Backend
+
collection_backend_ = make_shared();
collection_backend_->moveToThread(app_->database()->thread());
- collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Subsonic, kSongsTable, kSongsFtsTable);
+ collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Subsonic, QLatin1String(kSongsTable), QLatin1String(kSongsFtsTable));
// Model
@@ -126,7 +131,7 @@ void SubsonicService::ShowConfig() {
void SubsonicService::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(SubsonicSettingsPage::kSettingsGroup);
server_url_ = s.value("url").toUrl();
@@ -159,30 +164,30 @@ void SubsonicService::SendPingWithCredentials(QUrl url, const QString &username,
using Param = QPair;
using ParamList = QList;
- ParamList params = ParamList() << Param("c", kClientName)
- << Param("v", kApiVersion)
- << Param("f", "json")
- << Param("u", username);
+ ParamList params = ParamList() << Param(QStringLiteral("c"), QLatin1String(kClientName))
+ << Param(QStringLiteral("v"), QLatin1String(kApiVersion))
+ << Param(QStringLiteral("f"), QStringLiteral("json"))
+ << Param(QStringLiteral("u"), username);
if (auth_method == SubsonicSettingsPage::AuthMethod::Hex) {
- params << Param("p", QString("enc:" + password.toUtf8().toHex()));
+ params << Param(QStringLiteral("p"), QStringLiteral("enc:") + QString::fromLatin1(password.toUtf8().toHex()));
}
else {
const QString salt = Utilities::CryptographicRandomString(20);
QCryptographicHash md5(QCryptographicHash::Md5);
md5.addData(password.toUtf8());
md5.addData(salt.toUtf8());
- params << Param("s", salt);
- params << Param("t", md5.result().toHex());
+ params << Param(QStringLiteral("s"), salt);
+ params << Param(QStringLiteral("t"), QString::fromLatin1(md5.result().toHex()));
}
QUrlQuery url_query(url.query());
for (const Param ¶m : params) {
- url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
+ url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
if (!redirect) {
- if (!url.path().isEmpty() && url.path().right(1) == "/") {
+ if (!url.path().isEmpty() && url.path().right(1) == QStringLiteral("/")) {
url.setPath(url.path() + QStringLiteral("rest/ping.view"));
}
else {
@@ -194,14 +199,14 @@ void SubsonicService::SendPingWithCredentials(QUrl url, const QString &username,
QNetworkRequest req(url);
- if (url.scheme() == "https" && !verify_certificate_) {
+ if (url.scheme() == QStringLiteral("https") && !verify_certificate_) {
QSslConfiguration sslconfig = QSslConfiguration::defaultConfiguration();
sslconfig.setPeerVerifyMode(QSslSocket::VerifyNone);
req.setSslConfiguration(sslconfig);
}
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
- req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
+ req.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
req.setAttribute(QNetworkRequest::Http2AllowedAttribute, http2_);
@@ -263,7 +268,7 @@ void SubsonicService::HandlePingReply(QNetworkReply *reply, const QUrl &url, con
}
// See if there is Json data containing "error" - then use that instead.
- QByteArray data = reply->readAll();
+ const QByteArray data = reply->readAll();
QJsonParseError parse_error;
QJsonDocument json_doc = QJsonDocument::fromJson(data, &parse_error);
if (parse_error.error == QJsonParseError::NoError && !json_doc.isEmpty() && json_doc.isObject()) {
@@ -358,12 +363,12 @@ void SubsonicService::HandlePingReply(QNetworkReply *reply, const QUrl &url, con
QString status = obj_response[QStringLiteral("status")].toString().toLower();
QString message = obj_response[QStringLiteral("message")].toString();
- if (status == "failed") {
+ if (status == QStringLiteral("failed")) {
emit TestComplete(false, message);
emit TestFailure(message);
return;
}
- else if (status == "ok") {
+ else if (status == QStringLiteral("ok")) {
emit TestComplete(true);
emit TestSuccess();
return;
@@ -461,7 +466,7 @@ void SubsonicService::PingError(const QString &error, const QVariant &debug) {
QString error_html;
for (const QString &e : errors_) {
qLog(Error) << "Subsonic:" << e;
- error_html += e + "
";
+ error_html += e + QStringLiteral("
");
}
if (debug.isValid()) qLog(Debug) << debug;
diff --git a/src/subsonic/subsonicservice.h b/src/subsonic/subsonicservice.h
index 42ebb21a5b..4128105760 100644
--- a/src/subsonic/subsonicservice.h
+++ b/src/subsonic/subsonicservice.h
@@ -103,10 +103,6 @@ class SubsonicService : public InternetService {
private:
void PingError(const QString &error = QString(), const QVariant &debug = QVariant());
- static const char *kSongsTable;
- static const char *kSongsFtsTable;
- static const int kMaxRedirects;
-
Application *app_;
ScopedPtr network_;
SubsonicUrlHandler *url_handler_;
diff --git a/src/subsonic/subsonicurlhandler.cpp b/src/subsonic/subsonicurlhandler.cpp
index a68548260e..8c18ea11eb 100644
--- a/src/subsonic/subsonicurlhandler.cpp
+++ b/src/subsonic/subsonicurlhandler.cpp
@@ -45,7 +45,7 @@ UrlHandler::LoadResult SubsonicUrlHandler::StartLoading(const QUrl &url) {
using Param = QPair;
using ParamList = QList;
- const QUrl stream_url = SubsonicBaseRequest::CreateUrl(server_url(), auth_method(), username(), password(), QStringLiteral("stream"), ParamList() << Param("id", url.path()));
+ const QUrl stream_url = SubsonicBaseRequest::CreateUrl(server_url(), auth_method(), username(), password(), QStringLiteral("stream"), ParamList() << Param(QStringLiteral("id"), url.path()));
return LoadResult(url, LoadResult::Type::TrackAvailable, stream_url);
diff --git a/src/tidal/tidalbaserequest.cpp b/src/tidal/tidalbaserequest.cpp
index fd25774832..81076b0f29 100644
--- a/src/tidal/tidalbaserequest.cpp
+++ b/src/tidal/tidalbaserequest.cpp
@@ -48,18 +48,18 @@ TidalBaseRequest::TidalBaseRequest(TidalService *service, SharedPtr";
+ error_html += error + QStringLiteral("
");
}
return error_html;
diff --git a/src/tidal/tidalfavoriterequest.cpp b/src/tidal/tidalfavoriterequest.cpp
index fd6b20fd89..66ec0de3a1 100644
--- a/src/tidal/tidalfavoriterequest.cpp
+++ b/src/tidal/tidalfavoriterequest.cpp
@@ -134,18 +134,18 @@ void TidalFavoriteRequest::AddFavorites(const FavoriteType type, const SongList
void TidalFavoriteRequest::AddFavoritesRequest(const FavoriteType type, const QStringList &id_list, const SongList &songs) {
- ParamList params = ParamList() << Param("countryCode", country_code())
- << Param(FavoriteMethod(type), id_list.join(','));
+ ParamList params = ParamList() << Param(QStringLiteral("countryCode"), country_code())
+ << Param(FavoriteMethod(type), id_list.join(QLatin1Char(',')));
QUrlQuery url_query;
for (const Param ¶m : params) {
- url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
+ url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
- QUrl url(QString(TidalService::kApiUrl) + QStringLiteral("/") + "users/" + QString::number(service_->user_id()) + "/favorites/" + FavoriteText(type));
+ QUrl url(QString::fromLatin1(TidalService::kApiUrl) + QStringLiteral("/") + QStringLiteral("users/") + QString::number(service_->user_id()) + QStringLiteral("/favorites/") + FavoriteText(type));
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
- req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
+ req.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
if (oauth() && !access_token().isEmpty()) req.setRawHeader("authorization", "Bearer " + access_token().toUtf8());
else if (!session_id().isEmpty()) req.setRawHeader("X-Tidal-SessionId", session_id().toUtf8());
QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8();
@@ -244,18 +244,18 @@ void TidalFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongLi
void TidalFavoriteRequest::RemoveFavoritesRequest(const FavoriteType type, const QString &id, const SongList &songs) {
- ParamList params = ParamList() << Param("countryCode", country_code());
+ ParamList params = ParamList() << Param(QStringLiteral("countryCode"), country_code());
QUrlQuery url_query;
for (const Param ¶m : params) {
- url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
+ url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
- QUrl url(QString(TidalService::kApiUrl) + QStringLiteral("/") + "users/" + QString::number(service_->user_id()) + "/favorites/" + FavoriteText(type) + QStringLiteral("/") + id);
+ QUrl url(QString::fromLatin1(TidalService::kApiUrl) + QStringLiteral("/users/") + QString::number(service_->user_id()) + QStringLiteral("/favorites/") + FavoriteText(type) + QStringLiteral("/") + id);
url.setQuery(url_query);
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
- req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
+ req.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
if (oauth() && !access_token().isEmpty()) req.setRawHeader("authorization", "Bearer " + access_token().toUtf8());
else if (!session_id().isEmpty()) req.setRawHeader("X-Tidal-SessionId", session_id().toUtf8());
QNetworkReply *reply = network_->deleteResource(req);
diff --git a/src/tidal/tidalrequest.cpp b/src/tidal/tidalrequest.cpp
index cbb13b66fa..f242e2cdbf 100644
--- a/src/tidal/tidalrequest.cpp
+++ b/src/tidal/tidalrequest.cpp
@@ -248,9 +248,9 @@ void TidalRequest::FlushArtistsRequests() {
Request request = artists_requests_queue_.dequeue();
ParamList parameters;
- if (query_type_ == QueryType::SearchArtists) parameters << Param("query", search_text_);
- if (request.limit > 0) parameters << Param("limit", QString::number(request.limit));
- if (request.offset > 0) parameters << Param("offset", QString::number(request.offset));
+ if (query_type_ == QueryType::SearchArtists) parameters << Param(QStringLiteral("query"), search_text_);
+ if (request.limit > 0) parameters << Param(QStringLiteral("limit"), QString::number(request.limit));
+ if (request.offset > 0) parameters << Param(QStringLiteral("offset"), QString::number(request.offset));
QNetworkReply *reply = nullptr;
if (query_type_ == QueryType::Artists) {
reply = CreateRequest(QStringLiteral("users/%1/favorites/artists").arg(service_->user_id()), parameters);
@@ -296,9 +296,9 @@ void TidalRequest::FlushAlbumsRequests() {
Request request = albums_requests_queue_.dequeue();
ParamList parameters;
- if (query_type_ == QueryType::SearchAlbums) parameters << Param("query", search_text_);
- if (request.limit > 0) parameters << Param("limit", QString::number(request.limit));
- if (request.offset > 0) parameters << Param("offset", QString::number(request.offset));
+ if (query_type_ == QueryType::SearchAlbums) parameters << Param(QStringLiteral("query"), search_text_);
+ if (request.limit > 0) parameters << Param(QStringLiteral("limit"), QString::number(request.limit));
+ if (request.offset > 0) parameters << Param(QStringLiteral("offset"), QString::number(request.offset));
QNetworkReply *reply = nullptr;
if (query_type_ == QueryType::Albums) {
reply = CreateRequest(QStringLiteral("users/%1/favorites/albums").arg(service_->user_id()), parameters);
@@ -344,9 +344,9 @@ void TidalRequest::FlushSongsRequests() {
Request request = songs_requests_queue_.dequeue();
ParamList parameters;
- if (query_type_ == QueryType::SearchSongs) parameters << Param("query", search_text_);
- if (request.limit > 0) parameters << Param("limit", QString::number(request.limit));
- if (request.offset > 0) parameters << Param("offset", QString::number(request.offset));
+ if (query_type_ == QueryType::SearchSongs) parameters << Param(QStringLiteral("query"), search_text_);
+ if (request.limit > 0) parameters << Param(QStringLiteral("limit"), QString::number(request.limit));
+ if (request.offset > 0) parameters << Param(QStringLiteral("offset"), QString::number(request.offset));
QNetworkReply *reply = nullptr;
if (query_type_ == QueryType::Songs) {
reply = CreateRequest(QStringLiteral("users/%1/favorites/tracks").arg(service_->user_id()), parameters);
@@ -584,7 +584,7 @@ void TidalRequest::FlushArtistAlbumsRequests() {
const ArtistAlbumsRequest request = artist_albums_requests_queue_.dequeue();
ParamList parameters;
- if (request.offset > 0) parameters << Param("offset", QString::number(request.offset));
+ if (request.offset > 0) parameters << Param(QStringLiteral("offset"), QString::number(request.offset));
QNetworkReply *reply = CreateRequest(QStringLiteral("artists/%1/albums").arg(request.artist.artist_id), parameters);
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, request]() { ArtistAlbumsReplyReceived(reply, request.artist, request.offset); });
replies_ << reply;
@@ -692,7 +692,7 @@ void TidalRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_req
if (service_->album_explicit() && obj_item.contains(QStringLiteral("explicit"))) {
album.album_explicit = obj_item[QStringLiteral("explicit")].toVariant().toBool();
if (album.album_explicit && !album.album.isEmpty()) {
- album.album.append(" (Explicit)");
+ album.album.append(QStringLiteral(" (Explicit)"));
}
}
}
@@ -717,7 +717,7 @@ void TidalRequest::AlbumsReceived(QNetworkReply *reply, const Artist &artist_req
if (service_->album_explicit() && obj_album.contains(QStringLiteral("explicit"))) {
album.album_explicit = obj_album[QStringLiteral("explicit")].toVariant().toBool();
if (album.album_explicit && !album.album.isEmpty()) {
- album.album.append(" (Explicit)");
+ album.album.append(QStringLiteral(" (Explicit)"));
}
}
}
@@ -859,7 +859,7 @@ void TidalRequest::FlushAlbumSongsRequests() {
AlbumSongsRequest request = album_songs_requests_queue_.dequeue();
ParamList parameters;
- if (request.offset > 0) parameters << Param("offset", QString::number(request.offset));
+ if (request.offset > 0) parameters << Param(QStringLiteral("offset"), QString::number(request.offset));
QNetworkReply *reply = CreateRequest(QStringLiteral("albums/%1/tracks").arg(request.album.album_id), parameters);
replies_ << reply;
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, request]() { AlbumSongsReplyReceived(reply, request.artist, request.album, request.offset); });
@@ -1095,7 +1095,7 @@ void TidalRequest::ParseSong(Song &song, const QJsonObject &json_obj, const Arti
return;
}
QString album_title = obj_album[QStringLiteral("title")].toString();
- if (album.album_explicit) album_title.append(" (Explicit)");
+ if (album.album_explicit) album_title.append(QStringLiteral(" (Explicit)"));
if (!allow_streaming) {
Warn(QStringLiteral("Song %1 %2 %3 is not allowStreaming").arg(artist, album_title, title));
@@ -1125,7 +1125,7 @@ void TidalRequest::ParseSong(Song &song, const QJsonObject &json_obj, const Arti
if (obj_album.contains(QStringLiteral("cover"))) {
const QString cover = obj_album[QStringLiteral("cover")].toString().replace(QLatin1String("-"), QLatin1String("/"));
if (!cover.isEmpty()) {
- cover_url.setUrl(QStringLiteral("%1/images/%2/%3.jpg").arg(kResourcesUrl, cover, coversize_));
+ cover_url.setUrl(QStringLiteral("%1/images/%2/%3.jpg").arg(QLatin1String(kResourcesUrl), cover, coversize_));
}
}
@@ -1277,8 +1277,8 @@ void TidalRequest::AlbumCoverReceived(QNetworkReply *reply, const QString &album
}
QString mimetype = reply->header(QNetworkRequest::ContentTypeHeader).toString();
- if (mimetype.contains(';')) {
- mimetype = mimetype.left(mimetype.indexOf(';'));
+ if (mimetype.contains(QLatin1Char(';'))) {
+ mimetype = mimetype.left(mimetype.indexOf(QLatin1Char(';')));
}
if (!ImageUtils::SupportedImageMimeTypes().contains(mimetype, Qt::CaseInsensitive) && !ImageUtils::SupportedImageFormats().contains(mimetype, Qt::CaseInsensitive)) {
Error(QStringLiteral("Unsupported mimetype for image reader %1 for %2").arg(mimetype, url.toString()));
@@ -1287,7 +1287,7 @@ void TidalRequest::AlbumCoverReceived(QNetworkReply *reply, const QString &album
return;
}
- QByteArray data = reply->readAll();
+ const QByteArray data = reply->readAll();
if (data.isEmpty()) {
Error(QStringLiteral("Received empty image data for %1").arg(url.toString()));
if (album_covers_requests_sent_.contains(album_id)) album_covers_requests_sent_.remove(album_id);
diff --git a/src/tidal/tidalservice.cpp b/src/tidal/tidalservice.cpp
index f0218c15f1..9a9d6281a7 100644
--- a/src/tidal/tidalservice.cpp
+++ b/src/tidal/tidalservice.cpp
@@ -48,6 +48,7 @@
#include "core/networkaccessmanager.h"
#include "core/database.h"
#include "core/song.h"
+#include "core/settings.h"
#include "utilities/randutils.h"
#include "utilities/timeconstants.h"
#include "internet/internetsearchview.h"
@@ -69,25 +70,29 @@ const Song::Source TidalService::kSource = Song::Source::Tidal;
const char TidalService::kApiUrl[] = "https://api.tidalhifi.com/v1";
const char TidalService::kResourcesUrl[] = "https://resources.tidal.com";
+const int TidalService::kLoginAttempts = 2;
-constexpr char TidalService::kOAuthUrl[] = "https://login.tidal.com/authorize";
-constexpr char TidalService::kOAuthAccessTokenUrl[] = "https://login.tidal.com/oauth2/token";
-constexpr char TidalService::kOAuthRedirectUrl[] = "tidal://login/auth";
-constexpr char TidalService::kAuthUrl[] = "https://api.tidalhifi.com/v1/login/username";
+namespace {
-const int TidalService::kLoginAttempts = 2;
-constexpr int TidalService::kTimeResetLoginAttempts = 60000;
+constexpr char kOAuthUrl[] = "https://login.tidal.com/authorize";
+constexpr char kOAuthAccessTokenUrl[] = "https://login.tidal.com/oauth2/token";
+constexpr char kOAuthRedirectUrl[] = "tidal://login/auth";
+constexpr char kAuthUrl[] = "https://api.tidalhifi.com/v1/login/username";
+
+constexpr int kTimeResetLoginAttempts = 60000;
-constexpr char TidalService::kArtistsSongsTable[] = "tidal_artists_songs";
-constexpr char TidalService::kAlbumsSongsTable[] = "tidal_albums_songs";
-constexpr char TidalService::kSongsTable[] = "tidal_songs";
+constexpr char kArtistsSongsTable[] = "tidal_artists_songs";
+constexpr char kAlbumsSongsTable[] = "tidal_albums_songs";
+constexpr char kSongsTable[] = "tidal_songs";
-constexpr char TidalService::kArtistsSongsFtsTable[] = "tidal_artists_songs_fts";
-constexpr char TidalService::kAlbumsSongsFtsTable[] = "tidal_albums_songs_fts";
-constexpr char TidalService::kSongsFtsTable[] = "tidal_songs_fts";
+constexpr char kArtistsSongsFtsTable[] = "tidal_artists_songs_fts";
+constexpr char kAlbumsSongsFtsTable[] = "tidal_albums_songs_fts";
+constexpr char kSongsFtsTable[] = "tidal_songs_fts";
+
+} // namespace
TidalService::TidalService(Application *app, QObject *parent)
- : InternetService(Song::Source::Tidal, QStringLiteral("Tidal"), QStringLiteral("tidal"), TidalSettingsPage::kSettingsGroup, SettingsDialog::Page::Tidal, app, parent),
+ : InternetService(Song::Source::Tidal, QStringLiteral("Tidal"), QStringLiteral("tidal"), QLatin1String(TidalSettingsPage::kSettingsGroup), SettingsDialog::Page::Tidal, app, parent),
app_(app),
network_(app->network()),
url_handler_(new TidalUrlHandler(app, this)),
@@ -130,15 +135,15 @@ TidalService::TidalService(Application *app, QObject *parent)
artists_collection_backend_ = make_shared();
artists_collection_backend_->moveToThread(app_->database()->thread());
- artists_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Tidal, kArtistsSongsTable, kArtistsSongsFtsTable);
+ artists_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Tidal, QLatin1String(kArtistsSongsTable), QLatin1String(kArtistsSongsFtsTable));
albums_collection_backend_ = make_shared();
albums_collection_backend_->moveToThread(app_->database()->thread());
- albums_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Tidal, kAlbumsSongsTable, kAlbumsSongsFtsTable);
+ albums_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Tidal, QLatin1String(kAlbumsSongsTable), QLatin1String(kAlbumsSongsFtsTable));
songs_collection_backend_ = make_shared();
songs_collection_backend_->moveToThread(app_->database()->thread());
- songs_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Tidal, kSongsTable, kSongsFtsTable);
+ songs_collection_backend_->Init(app_->database(), app->task_manager(), Song::Source::Tidal, QLatin1String(kSongsTable), QLatin1String(kSongsFtsTable));
artists_collection_model_ = new CollectionModel(artists_collection_backend_, app_, this);
albums_collection_model_ = new CollectionModel(albums_collection_backend_, app_, this);
@@ -247,10 +252,10 @@ void TidalService::ShowConfig() {
void TidalService::LoadSession() {
- QSettings s;
+ Settings s;
s.beginGroup(TidalSettingsPage::kSettingsGroup);
user_id_ = s.value("user_id").toInt();
- country_code_ = s.value("country_code", "US").toString();
+ country_code_ = s.value("country_code", QStringLiteral("US")).toString();
access_token_ = s.value("access_token").toString();
refresh_token_ = s.value("refresh_token").toString();
session_id_ = s.value("session_id").toString();
@@ -273,7 +278,7 @@ void TidalService::LoadSession() {
void TidalService::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(TidalSettingsPage::kSettingsGroup);
enabled_ = s.value("enabled", false).toBool();
@@ -286,13 +291,13 @@ void TidalService::ReloadSettings() {
if (password.isEmpty()) password_.clear();
else password_ = QString::fromUtf8(QByteArray::fromBase64(password));
- quality_ = s.value("quality", "LOSSLESS").toString();
+ quality_ = s.value("quality", QStringLiteral("LOSSLESS")).toString();
quint64 search_delay = s.value("searchdelay", 1500).toInt();
artistssearchlimit_ = s.value("artistssearchlimit", 4).toInt();
albumssearchlimit_ = s.value("albumssearchlimit", 10).toInt();
songssearchlimit_ = s.value("songssearchlimit", 10).toInt();
fetchalbums_ = s.value("fetchalbums", false).toBool();
- coversize_ = s.value("coversize", "640x640").toString();
+ coversize_ = s.value("coversize", QStringLiteral("640x640")).toString();
download_album_covers_ = s.value("downloadalbumcovers", true).toBool();
stream_url_method_ = static_cast(s.value("streamurl", static_cast(TidalSettingsPage::StreamUrlMethod::StreamUrl)).toInt());
album_explicit_ = s.value("album_explicit").toBool();
@@ -307,25 +312,25 @@ void TidalService::StartAuthorization(const QString &client_id) {
client_id_ = client_id;
code_verifier_ = Utilities::CryptographicRandomString(44);
- code_challenge_ = QString(QCryptographicHash::hash(code_verifier_.toUtf8(), QCryptographicHash::Sha256).toBase64(QByteArray::Base64UrlEncoding));
+ code_challenge_ = QString::fromUtf8(QCryptographicHash::hash(code_verifier_.toUtf8(), QCryptographicHash::Sha256).toBase64(QByteArray::Base64UrlEncoding));
- if (code_challenge_.lastIndexOf(QChar('=')) == code_challenge_.length() - 1) {
+ if (code_challenge_.lastIndexOf(QLatin1Char('=')) == code_challenge_.length() - 1) {
code_challenge_.chop(1);
}
- const ParamList params = ParamList() << Param("response_type", "code")
- << Param("code_challenge", code_challenge_)
- << Param("code_challenge_method", "S256")
- << Param("redirect_uri", kOAuthRedirectUrl)
- << Param("client_id", client_id_)
- << Param("scope", "r_usr w_usr");
+ const ParamList params = ParamList() << Param(QStringLiteral("response_type"), QStringLiteral("code"))
+ << Param(QStringLiteral("code_challenge"), code_challenge_)
+ << Param(QStringLiteral("code_challenge_method"), QStringLiteral("S256"))
+ << Param(QStringLiteral("redirect_uri"), QLatin1String(kOAuthRedirectUrl))
+ << Param(QStringLiteral("client_id"), client_id_)
+ << Param(QStringLiteral("scope"), QStringLiteral("r_usr w_usr"));
QUrlQuery url_query;
for (const Param ¶m : params) {
- url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
+ url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
- QUrl url = QUrl(kOAuthUrl);
+ QUrl url = QUrl(QString::fromLatin1(kOAuthUrl));
url.setQuery(url_query);
QDesktopServices::openUrl(url);
@@ -339,15 +344,15 @@ void TidalService::AuthorizationUrlReceived(const QUrl &url) {
if (url_query.hasQueryItem(QStringLiteral("token_type")) && url_query.hasQueryItem(QStringLiteral("expires_in")) && url_query.hasQueryItem(QStringLiteral("access_token"))) {
- access_token_ = url_query.queryItemValue(QStringLiteral("access_token")).toUtf8();
+ access_token_ = url_query.queryItemValue(QStringLiteral("access_token"));
if (url_query.hasQueryItem(QStringLiteral("refresh_token"))) {
- refresh_token_ = url_query.queryItemValue(QStringLiteral("refresh_token")).toUtf8();
+ refresh_token_ = url_query.queryItemValue(QStringLiteral("refresh_token"));
}
expires_in_ = url_query.queryItemValue(QStringLiteral("expires_in")).toInt();
login_time_ = QDateTime::currentDateTime().toSecsSinceEpoch();
session_id_.clear();
- QSettings s;
+ Settings s;
s.beginGroup(TidalSettingsPage::kSettingsGroup);
s.setValue("access_token", access_token_);
s.setValue("refresh_token", refresh_token_);
@@ -379,18 +384,18 @@ void TidalService::RequestAccessToken(const QString &code) {
timer_refresh_login_->stop();
- ParamList params = ParamList() << Param("client_id", client_id_);
+ ParamList params = ParamList() << Param(QStringLiteral("client_id"), client_id_);
if (!code.isEmpty()) {
- params << Param("grant_type", "authorization_code");
- params << Param("code", code);
- params << Param("code_verifier", code_verifier_);
- params << Param("redirect_uri", kOAuthRedirectUrl);
- params << Param("scope", "r_usr w_usr");
+ params << Param(QStringLiteral("grant_type"), QStringLiteral("authorization_code"));
+ params << Param(QStringLiteral("code"), code);
+ params << Param(QStringLiteral("code_verifier"), code_verifier_);
+ params << Param(QStringLiteral("redirect_uri"), QLatin1String(kOAuthRedirectUrl));
+ params << Param(QStringLiteral("scope"), QStringLiteral("r_usr w_usr"));
}
else if (!refresh_token_.isEmpty() && enabled_ && oauth_) {
- params << Param("grant_type", "refresh_token");
- params << Param("refresh_token", refresh_token_);
+ params << Param(QStringLiteral("grant_type"), QStringLiteral("refresh_token"));
+ params << Param(QStringLiteral("refresh_token"), refresh_token_);
}
else {
return;
@@ -398,13 +403,13 @@ void TidalService::RequestAccessToken(const QString &code) {
QUrlQuery url_query;
for (const Param ¶m : params) {
- url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
+ url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
- QUrl url(kOAuthAccessTokenUrl);
+ QUrl url(QString::fromLatin1(kOAuthAccessTokenUrl));
QNetworkRequest req(url);
req.setAttribute(QNetworkRequest::RedirectPolicyAttribute, QNetworkRequest::NoLessSafeRedirectPolicy);
- QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8();
+ const QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8();
login_errors_.clear();
QNetworkReply *reply = network_->post(req, query);
@@ -462,7 +467,7 @@ void TidalService::AccessTokenRequestFinished(QNetworkReply *reply) {
}
}
- QByteArray data(reply->readAll());
+ const QByteArray data = reply->readAll();
QJsonParseError json_error;
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
@@ -509,7 +514,7 @@ void TidalService::AccessTokenRequestFinished(QNetworkReply *reply) {
session_id_.clear();
- QSettings s;
+ Settings s;
s.beginGroup(TidalSettingsPage::kSettingsGroup);
s.setValue("access_token", access_token_);
s.setValue("refresh_token", refresh_token_);
@@ -543,20 +548,20 @@ void TidalService::SendLoginWithCredentials(const QString &api_token, const QStr
timer_login_attempt_->start();
timer_refresh_login_->stop();
- const ParamList params = ParamList() << Param("token", (api_token.isEmpty() ? api_token_ : api_token))
- << Param("username", username)
- << Param("password", password)
- << Param("clientVersion", "2.2.1--7");
+ const ParamList params = ParamList() << Param(QStringLiteral("token"), (api_token.isEmpty() ? api_token_ : api_token))
+ << Param(QStringLiteral("username"), username)
+ << Param(QStringLiteral("password"), password)
+ << Param(QStringLiteral("clientVersion"), QStringLiteral("2.2.1--7"));
QUrlQuery url_query;
for (const Param ¶m : params) {
- url_query.addQueryItem(QUrl::toPercentEncoding(param.first), QUrl::toPercentEncoding(param.second));
+ url_query.addQueryItem(QString::fromLatin1(QUrl::toPercentEncoding(param.first)), QString::fromLatin1(QUrl::toPercentEncoding(param.second)));
}
- QUrl url(kAuthUrl);
+ QUrl url(QString::fromLatin1(kAuthUrl));
QNetworkRequest req(url);
- req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
+ req.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
req.setRawHeader("X-Tidal-Token", (api_token.isEmpty() ? api_token_.toUtf8() : api_token.toUtf8()));
QByteArray query = url_query.toString(QUrl::FullyEncoded).toUtf8();
@@ -615,7 +620,7 @@ void TidalService::HandleAuthReply(QNetworkReply *reply) {
login_errors_.clear();
- QByteArray data(reply->readAll());
+ const QByteArray data = reply->readAll();
QJsonParseError json_error;
QJsonDocument json_doc = QJsonDocument::fromJson(data, &json_error);
@@ -651,7 +656,7 @@ void TidalService::HandleAuthReply(QNetworkReply *reply) {
access_token_.clear();
refresh_token_.clear();
- QSettings s;
+ Settings s;
s.beginGroup(TidalSettingsPage::kSettingsGroup);
s.remove("access_token");
s.remove("refresh_token");
@@ -681,7 +686,7 @@ void TidalService::Logout() {
expires_in_ = 0;
login_time_ = 0;
- QSettings s;
+ Settings s;
s.beginGroup(TidalSettingsPage::kSettingsGroup);
s.remove("user_id");
s.remove("country_code");
@@ -1026,7 +1031,7 @@ void TidalService::LoginError(const QString &error, const QVariant &debug) {
QString error_html;
for (const QString &e : login_errors_) {
qLog(Error) << "Tidal:" << e;
- error_html += e + "
";
+ error_html += e + QStringLiteral("
");
}
if (debug.isValid()) qLog(Debug) << debug;
diff --git a/src/tidal/tidalservice.h b/src/tidal/tidalservice.h
index bd02302e4e..11210086fd 100644
--- a/src/tidal/tidalservice.h
+++ b/src/tidal/tidalservice.h
@@ -65,6 +65,7 @@ class TidalService : public InternetService {
static const Song::Source kSource;
static const char kApiUrl[];
static const char kResourcesUrl[];
+ static const int kLoginAttempts;
void Exit() override;
void ReloadSettings() override;
@@ -159,22 +160,6 @@ class TidalService : public InternetService {
void SendSearch();
void LoginError(const QString &error = QString(), const QVariant &debug = QVariant());
- static const char kOAuthUrl[];
- static const char kOAuthAccessTokenUrl[];
- static const char kOAuthRedirectUrl[];
- static const char kAuthUrl[];
-
- static const int kLoginAttempts;
- static const int kTimeResetLoginAttempts;
-
- static const char kArtistsSongsTable[];
- static const char kAlbumsSongsTable[];
- static const char kSongsTable[];
-
- static const char kArtistsSongsFtsTable[];
- static const char kAlbumsSongsFtsTable[];
- static const char kSongsFtsTable[];
-
Application *app_;
SharedPtr network_;
TidalUrlHandler *url_handler_;
diff --git a/src/tidal/tidalstreamurlrequest.cpp b/src/tidal/tidalstreamurlrequest.cpp
index 9dd53a579e..e2c1bc3b02 100644
--- a/src/tidal/tidalstreamurlrequest.cpp
+++ b/src/tidal/tidalstreamurlrequest.cpp
@@ -121,22 +121,22 @@ void TidalStreamURLRequest::GetStreamURL() {
switch (stream_url_method()) {
case TidalSettingsPage::StreamUrlMethod::StreamUrl:
- params << Param("soundQuality", quality());
+ params << Param(QStringLiteral("soundQuality"), quality());
reply_ = CreateRequest(QStringLiteral("tracks/%1/streamUrl").arg(song_id_), params);
QObject::connect(reply_, &QNetworkReply::finished, this, &TidalStreamURLRequest::StreamURLReceived);
break;
case TidalSettingsPage::StreamUrlMethod::UrlPostPaywall:
- params << Param("audioquality", quality());
- params << Param("playbackmode", "STREAM");
- params << Param("assetpresentation", "FULL");
- params << Param("urlusagemode", "STREAM");
+ params << Param(QStringLiteral("audioquality"), quality());
+ params << Param(QStringLiteral("playbackmode"), QStringLiteral("STREAM"));
+ params << Param(QStringLiteral("assetpresentation"), QStringLiteral("FULL"));
+ params << Param(QStringLiteral("urlusagemode"), QStringLiteral("STREAM"));
reply_ = CreateRequest(QStringLiteral("tracks/%1/urlpostpaywall").arg(song_id_), params);
QObject::connect(reply_, &QNetworkReply::finished, this, &TidalStreamURLRequest::StreamURLReceived);
break;
case TidalSettingsPage::StreamUrlMethod::PlaybackInfoPostPaywall:
- params << Param("audioquality", quality());
- params << Param("playbackmode", "STREAM");
- params << Param("assetpresentation", "FULL");
+ params << Param(QStringLiteral("audioquality"), quality());
+ params << Param(QStringLiteral("playbackmode"), QStringLiteral("STREAM"));
+ params << Param(QStringLiteral("assetpresentation"), QStringLiteral("FULL"));
reply_ = CreateRequest(QStringLiteral("tracks/%1/playbackinfopostpaywall").arg(song_id_), params);
QObject::connect(reply_, &QNetworkReply::finished, this, &TidalStreamURLRequest::StreamURLReceived);
break;
@@ -233,7 +233,7 @@ void TidalStreamURLRequest::StreamURLReceived() {
QString mimetype = json_obj[QStringLiteral("mimeType")].toString();
QMimeDatabase mimedb;
- QStringList suffixes = mimedb.mimeTypeForName(mimetype.toUtf8()).suffixes();
+ QStringList suffixes = mimedb.mimeTypeForName(mimetype).suffixes();
for (const QString &suffix : suffixes) {
filetype = Song::FiletypeByExtension(suffix);
if (filetype != Song::FileType::Unknown) break;
diff --git a/src/transcoder/transcodedialog.cpp b/src/transcoder/transcodedialog.cpp
index be20554ac7..914c6f821d 100644
--- a/src/transcoder/transcodedialog.cpp
+++ b/src/transcoder/transcodedialog.cpp
@@ -57,6 +57,7 @@
#include "core/iconloader.h"
#include "core/mainwindow.h"
+#include "core/settings.h"
#include "utilities/screenutils.h"
#include "widgets/fileview.h"
#include "transcodedialog.h"
@@ -71,8 +72,11 @@
#endif
const char *TranscodeDialog::kSettingsGroup = "Transcoder";
-const int TranscodeDialog::kProgressInterval = 500;
-const int TranscodeDialog::kMaxDestinationItems = 10;
+
+namespace {
+constexpr int kProgressInterval = 500;
+constexpr int kMaxDestinationItems = 10;
+}
static bool ComparePresetsByName(const TranscoderPreset &left, const TranscoderPreset &right) {
return left.name_ < right.name_;
@@ -107,11 +111,11 @@ TranscodeDialog::TranscodeDialog(QMainWindow *mainwindow, QWidget *parent)
}
// Load settings
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
last_add_dir_ = s.value("last_add_dir", QDir::homePath()).toString();
last_import_dir_ = s.value("last_import_dir", QDir::homePath()).toString();
- QString last_output_format = s.value("last_output_format", "audio/x-vorbis").toString();
+ QString last_output_format = s.value("last_output_format", QStringLiteral("audio/x-vorbis")).toString();
s.endGroup();
for (int i = 0; i < ui_->format->count(); ++i) {
@@ -186,7 +190,7 @@ void TranscodeDialog::reject() {
void TranscodeDialog::LoadGeometry() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
if (s.contains("geometry")) {
restoreGeometry(s.value("geometry").toByteArray());
@@ -200,7 +204,7 @@ void TranscodeDialog::LoadGeometry() {
void TranscodeDialog::SaveGeometry() {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("geometry", saveGeometry());
s.endGroup();
@@ -253,7 +257,7 @@ void TranscodeDialog::Start() {
transcoder_->Start();
// Save the last output format
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("last_output_format", preset.codec_mimetype_);
s.endGroup();
@@ -299,15 +303,15 @@ void TranscodeDialog::UpdateStatusText() {
QStringList sections;
if (queued_) {
- sections << "" + tr("%n remaining", "", queued_) + "";
+ sections << QStringLiteral("") + tr("%n remaining", "", queued_) + QStringLiteral("");
}
if (finished_success_) {
- sections << "" + tr("%n finished", "", finished_success_) + "";
+ sections << QStringLiteral("") + tr("%n finished", "", finished_success_) + QStringLiteral("");
}
if (finished_failed_) {
- sections << "" + tr("%n failed", "", finished_failed_) + "";
+ sections << QStringLiteral("") + tr("%n failed", "", finished_failed_) + QStringLiteral("");
}
ui_->progress_text->setText(sections.join(QStringLiteral(", ")));
@@ -322,14 +326,14 @@ void TranscodeDialog::Add() {
QStringList filenames = QFileDialog::getOpenFileNames(
this, tr("Add files to transcode"), last_add_dir_,
- QStringLiteral("%1 (%2);;%3").arg(tr("Music"), FileView::kFileFilter, tr(MainWindow::kAllFilesFilterSpec)));
+ QStringLiteral("%1 (%2);;%3").arg(tr("Music"), QLatin1String(FileView::kFileFilter), tr(MainWindow::kAllFilesFilterSpec)));
if (filenames.isEmpty()) return;
SetFilenames(filenames);
last_add_dir_ = filenames[0];
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("last_add_dir", last_add_dir_);
s.endGroup();
@@ -345,9 +349,9 @@ void TranscodeDialog::Import() {
QStringList filenames;
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
- QStringList audioTypes = QString(FileView::kFileFilter).split(QStringLiteral(" "), Qt::SkipEmptyParts);
+ QStringList audioTypes = QString::fromLatin1(FileView::kFileFilter).split(QLatin1Char(' '), Qt::SkipEmptyParts);
#else
- QStringList audioTypes = QString(FileView::kFileFilter).split(" ", QString::SkipEmptyParts);
+ QStringList audioTypes = QString::fromLatin1(FileView::kFileFilter).split(QLatin1Char(' '), QString::SkipEmptyParts);
#endif
QDirIterator files(path, audioTypes, QDir::Files | QDir::Readable, QDirIterator::Subdirectories);
@@ -359,7 +363,7 @@ void TranscodeDialog::Import() {
SetFilenames(filenames);
last_import_dir_ = path;
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("last_import_dir", last_import_dir_);
s.endGroup();
@@ -369,8 +373,8 @@ void TranscodeDialog::Import() {
void TranscodeDialog::SetFilenames(const QStringList &filenames) {
for (const QString &filename : filenames) {
- QString name = filename.section('/', -1, -1);
- QString path = filename.section('/', 0, -2);
+ QString name = filename.section(QLatin1Char('/'), -1, -1);
+ QString path = filename.section(QLatin1Char('/'), 0, -2);
QTreeWidgetItem *item = new QTreeWidgetItem(ui_->files, QStringList() << name << path);
item->setData(0, Qt::UserRole, filename);
@@ -438,7 +442,7 @@ void TranscodeDialog::AddDestination() {
// Returns the rightmost non-empty part of 'path'.
QString TranscodeDialog::TrimPath(const QString &path) {
- return path.section('/', -1, -1, QString::SectionSkipEmpty);
+ return path.section(QLatin1Char('/'), -1, -1, QString::SectionSkipEmpty);
}
QString TranscodeDialog::GetOutputFileName(const QString &input_filepath, const TranscoderPreset &preset) const {
@@ -447,12 +451,12 @@ QString TranscodeDialog::GetOutputFileName(const QString &input_filepath, const
QString output_filepath;
if (destination_path.isEmpty()) {
// Keep the original path.
- output_filepath = input_filepath.section('.', 0, -2) + '.' + preset.extension_;
+ output_filepath = input_filepath.section(QLatin1Char('.'), 0, -2) + QLatin1Char('.') + preset.extension_;
}
else {
QString filename = TrimPath(input_filepath);
- filename = filename.section('.', 0, -2);
- output_filepath = destination_path + '/' + filename + '.' + preset.extension_;
+ filename = filename.section(QLatin1Char('.'), 0, -2);
+ output_filepath = destination_path + QLatin1Char('/') + filename + QLatin1Char('.') + preset.extension_;
}
if (output_filepath.isEmpty()) return QString();
diff --git a/src/transcoder/transcodedialog.h b/src/transcoder/transcodedialog.h
index 0eee9eec87..ff7f2f6e98 100644
--- a/src/transcoder/transcodedialog.h
+++ b/src/transcoder/transcodedialog.h
@@ -49,8 +49,6 @@ class TranscodeDialog : public QDialog {
~TranscodeDialog() override;
static const char *kSettingsGroup;
- static const int kProgressInterval;
- static const int kMaxDestinationItems;
void SetFilenames(const QStringList &filenames);
diff --git a/src/transcoder/transcoder.cpp b/src/transcoder/transcoder.cpp
index 3eac9b9277..cbc213034e 100644
--- a/src/transcoder/transcoder.cpp
+++ b/src/transcoder/transcoder.cpp
@@ -45,6 +45,7 @@
#include "core/logging.h"
#include "core/shared_ptr.h"
#include "core/signalchecker.h"
+#include "core/settings.h"
#include "transcoder.h"
using std::make_shared;
@@ -94,7 +95,7 @@ GstElement *Transcoder::CreateElementForMimeType(const QString &element_type, co
if (mime_type.isEmpty()) return nullptr;
// HACK: Force mp4mux because it doesn't set any useful src caps
- if (mime_type == "audio/mp4") {
+ if (mime_type == QStringLiteral("audio/mp4")) {
emit LogLine(QStringLiteral("Using '%1' (rank %2)").arg(QStringLiteral("mp4mux")).arg(-1));
return CreateElement(QStringLiteral("mp4mux"), bin);
}
@@ -127,7 +128,7 @@ GstElement *Transcoder::CreateElementForMimeType(const QString &element_type, co
if (intersection) {
if (!gst_caps_is_empty(intersection)) {
int rank = static_cast(gst_plugin_feature_get_rank(GST_PLUGIN_FEATURE(factory)));
- QString name = GST_OBJECT_NAME(factory);
+ const QString name = QString::fromUtf8(GST_OBJECT_NAME(factory));
if (name.startsWith(QLatin1String("ffmux")) || name.startsWith(QLatin1String("ffenc"))) {
rank = -1; // ffmpeg usually sucks
@@ -152,7 +153,7 @@ GstElement *Transcoder::CreateElementForMimeType(const QString &element_type, co
emit LogLine(QStringLiteral("Using '%1' (rank %2)").arg(best.name_).arg(best.rank_));
- if (best.name_ == "lamemp3enc") {
+ if (best.name_ == QStringLiteral("lamemp3enc")) {
// Special case: we need to add xingmux and id3v2mux to the pipeline when using lamemp3enc because it doesn't write the VBR or ID3v2 headers itself.
emit LogLine(QStringLiteral("Adding xingmux and id3v2mux to the pipeline"));
@@ -212,8 +213,8 @@ Transcoder::Transcoder(QObject *parent, const QString &settings_postfix)
JobFinishedEvent::sEventType = QEvent::registerEventType();
// Initialize some settings for the lamemp3enc element.
- QSettings s;
- s.beginGroup("Transcoder/lamemp3enc" + settings_postfix_);
+ Settings s;
+ s.beginGroup(QStringLiteral("Transcoder/lamemp3enc") + settings_postfix_);
if (s.value("target").isNull()) {
s.setValue("target", 1); // 1 == bitrate
@@ -301,10 +302,10 @@ QString Transcoder::GetFile(const QString &input, const TranscoderPreset &preset
if (!fileinfo_output.isFile() || fileinfo_output.filePath().isEmpty() || fileinfo_output.path().isEmpty() || fileinfo_output.fileName().isEmpty() || fileinfo_output.suffix().isEmpty()) {
QFileInfo fileinfo_input(input);
- QString temp_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/transcoder";
+ QString temp_dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/transcoder");
if (!QDir(temp_dir).exists()) QDir().mkpath(temp_dir);
- QString filename = fileinfo_input.completeBaseName() + "." + preset.extension_;
- fileinfo_output.setFile(temp_dir + "/" + filename);
+ QString filename = fileinfo_input.completeBaseName() + QLatin1Char('.') + preset.extension_;
+ fileinfo_output.setFile(temp_dir + QLatin1Char('/') + filename);
}
// Never overwrite existing files
@@ -571,8 +572,8 @@ QMap Transcoder::GetProgress() const {
void Transcoder::SetElementProperties(const QString &name, GObject *object) {
- QSettings s;
- s.beginGroup("Transcoder/" + name + settings_postfix_);
+ Settings s;
+ s.beginGroup(QStringLiteral("Transcoder/") + name + settings_postfix_);
guint properties_count = 0;
GParamSpec **properties = g_object_class_list_properties(G_OBJECT_GET_CLASS(object), &properties_count);
@@ -580,16 +581,16 @@ void Transcoder::SetElementProperties(const QString &name, GObject *object) {
for (uint i = 0; i < properties_count; ++i) {
GParamSpec *property = properties[i];
- if (!s.contains(property->name)) {
+ if (!s.contains(QString::fromUtf8(property->name))) {
continue;
}
- const QVariant value = s.value(property->name);
+ const QVariant value = s.value(QString::fromUtf8(property->name));
if (value.isNull()) {
continue;
}
- emit LogLine(QStringLiteral("Setting %1 property: %2 = %3").arg(name, property->name, value.toString()));
+ emit LogLine(QStringLiteral("Setting %1 property: %2 = %3").arg(name, QString::fromUtf8(property->name), value.toString()));
switch (property->value_type) {
case G_TYPE_FLOAT:{
diff --git a/src/transcoder/transcoderoptionsaac.cpp b/src/transcoder/transcoderoptionsaac.cpp
index a2646f3c4d..85fd4c06be 100644
--- a/src/transcoder/transcoderoptionsaac.cpp
+++ b/src/transcoder/transcoderoptionsaac.cpp
@@ -30,7 +30,11 @@
#include "transcoderoptionsaac.h"
#include "ui_transcoderoptionsaac.h"
-const char *TranscoderOptionsAAC::kSettingsGroup = "Transcoder/faac";
+#include "core/settings.h"
+
+namespace {
+constexpr char kSettingsGroup[] = "Transcoder/faac";
+}
TranscoderOptionsAAC::TranscoderOptionsAAC(QWidget *parent) : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsAAC) {
ui_->setupUi(this);
@@ -42,8 +46,8 @@ TranscoderOptionsAAC::~TranscoderOptionsAAC() {
void TranscoderOptionsAAC::Load() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
ui_->bitrate_slider->setValue(s.value("bitrate", 320000).toInt() / 1000);
ui_->profile->setCurrentIndex(s.value("profile", 2).toInt() - 1);
ui_->tns->setChecked(s.value("tns", false).toBool());
@@ -55,8 +59,8 @@ void TranscoderOptionsAAC::Load() {
void TranscoderOptionsAAC::Save() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
s.setValue("bitrate", ui_->bitrate_slider->value() * 1000);
s.setValue("profile", ui_->profile->currentIndex() + 1);
s.setValue("tns", ui_->tns->isChecked());
diff --git a/src/transcoder/transcoderoptionsaac.h b/src/transcoder/transcoderoptionsaac.h
index e880166194..e367fee0c7 100644
--- a/src/transcoder/transcoderoptionsaac.h
+++ b/src/transcoder/transcoderoptionsaac.h
@@ -40,8 +40,6 @@ class TranscoderOptionsAAC : public TranscoderOptionsInterface {
void Save() override;
private:
- static const char *kSettingsGroup;
-
Ui_TranscoderOptionsAAC *ui_;
};
diff --git a/src/transcoder/transcoderoptionsasf.cpp b/src/transcoder/transcoderoptionsasf.cpp
index 51a5fd4f6d..bd7b014089 100644
--- a/src/transcoder/transcoderoptionsasf.cpp
+++ b/src/transcoder/transcoderoptionsasf.cpp
@@ -25,11 +25,15 @@
#include
#include
-#include "transcoder/transcoderoptionsinterface.h"
+#include "transcoderoptionsinterface.h"
#include "transcoderoptionsasf.h"
#include "ui_transcoderoptionsasf.h"
-const char *TranscoderOptionsASF::kSettingsGroup = "Transcoder/ffenc_wmav2";
+#include "core/settings.h"
+
+namespace {
+constexpr char kSettingsGroup[] = "Transcoder/ffenc_wmav2";
+}
TranscoderOptionsASF::TranscoderOptionsASF(QWidget *parent) : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsASF) {
ui_->setupUi(this);
@@ -41,8 +45,8 @@ TranscoderOptionsASF::~TranscoderOptionsASF() {
void TranscoderOptionsASF::Load() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
ui_->bitrate_slider->setValue(s.value("bitrate", 320000).toInt() / 1000);
s.endGroup();
@@ -50,8 +54,8 @@ void TranscoderOptionsASF::Load() {
void TranscoderOptionsASF::Save() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
s.setValue("bitrate", ui_->bitrate_slider->value() * 1000);
s.endGroup();
diff --git a/src/transcoder/transcoderoptionsasf.h b/src/transcoder/transcoderoptionsasf.h
index 4e297ba9bf..4a1e0a7111 100644
--- a/src/transcoder/transcoderoptionsasf.h
+++ b/src/transcoder/transcoderoptionsasf.h
@@ -40,8 +40,6 @@ class TranscoderOptionsASF : public TranscoderOptionsInterface {
void Save() override;
private:
- static const char *kSettingsGroup;
-
Ui_TranscoderOptionsASF *ui_;
};
diff --git a/src/transcoder/transcoderoptionsdialog.cpp b/src/transcoder/transcoderoptionsdialog.cpp
index ebbb59c39f..b9691e766b 100644
--- a/src/transcoder/transcoderoptionsdialog.cpp
+++ b/src/transcoder/transcoderoptionsdialog.cpp
@@ -61,7 +61,7 @@ TranscoderOptionsDialog::TranscoderOptionsDialog(Song::FileType type, QWidget *p
}
if (options_) {
- setWindowTitle(windowTitle() + " - " + Song::TextForFiletype(type));
+ setWindowTitle(windowTitle() + QStringLiteral(" - ") + Song::TextForFiletype(type));
options_->layout()->setContentsMargins(0, 0, 0, 0);
ui_->verticalLayout->insertWidget(0, options_);
resize(width(), minimumHeight());
diff --git a/src/transcoder/transcoderoptionsflac.cpp b/src/transcoder/transcoderoptionsflac.cpp
index 5c6e5f2b70..fc6293f61f 100644
--- a/src/transcoder/transcoderoptionsflac.cpp
+++ b/src/transcoder/transcoderoptionsflac.cpp
@@ -29,7 +29,11 @@
#include "transcoderoptionsflac.h"
#include "ui_transcoderoptionsflac.h"
-const char *TranscoderOptionsFLAC::kSettingsGroup = "Transcoder/flacenc";
+#include "core/settings.h"
+
+namespace {
+constexpr char kSettingsGroup[] = "Transcoder/flacenc";
+}
TranscoderOptionsFLAC::TranscoderOptionsFLAC(QWidget *parent) : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsFLAC) {
ui_->setupUi(this);
@@ -41,8 +45,8 @@ TranscoderOptionsFLAC::~TranscoderOptionsFLAC() {
void TranscoderOptionsFLAC::Load() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
ui_->quality->setValue(s.value("quality", 5).toInt());
s.endGroup();
@@ -50,8 +54,8 @@ void TranscoderOptionsFLAC::Load() {
void TranscoderOptionsFLAC::Save() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
s.setValue("quality", ui_->quality->value());
s.endGroup();
diff --git a/src/transcoder/transcoderoptionsflac.h b/src/transcoder/transcoderoptionsflac.h
index 3f77ec65c3..98f1097581 100644
--- a/src/transcoder/transcoderoptionsflac.h
+++ b/src/transcoder/transcoderoptionsflac.h
@@ -40,8 +40,6 @@ class TranscoderOptionsFLAC : public TranscoderOptionsInterface {
void Save() override;
private:
- static const char *kSettingsGroup;
-
Ui_TranscoderOptionsFLAC *ui_;
};
diff --git a/src/transcoder/transcoderoptionsmp3.cpp b/src/transcoder/transcoderoptionsmp3.cpp
index 4cee0893f9..398d6e6503 100644
--- a/src/transcoder/transcoderoptionsmp3.cpp
+++ b/src/transcoder/transcoderoptionsmp3.cpp
@@ -33,7 +33,11 @@
#include "transcoderoptionsmp3.h"
#include "ui_transcoderoptionsmp3.h"
-const char *TranscoderOptionsMP3::kSettingsGroup = "Transcoder/lamemp3enc";
+#include "core/settings.h"
+
+namespace {
+constexpr char kSettingsGroup[] = "Transcoder/lamemp3enc";
+}
TranscoderOptionsMP3::TranscoderOptionsMP3(QWidget *parent) : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsMP3) {
@@ -50,8 +54,8 @@ TranscoderOptionsMP3::~TranscoderOptionsMP3() {
void TranscoderOptionsMP3::Load() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
if (s.value("target", 1).toInt() == 0) {
ui_->target_quality->setChecked(true);
@@ -72,8 +76,8 @@ void TranscoderOptionsMP3::Load() {
void TranscoderOptionsMP3::Save() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
s.setValue("target", ui_->target_quality->isChecked() ? 0 : 1);
s.setValue("quality", ui_->quality_spinbox->value());
diff --git a/src/transcoder/transcoderoptionsmp3.h b/src/transcoder/transcoderoptionsmp3.h
index b36604372e..be233f4bac 100644
--- a/src/transcoder/transcoderoptionsmp3.h
+++ b/src/transcoder/transcoderoptionsmp3.h
@@ -46,8 +46,6 @@ class TranscoderOptionsMP3 : public TranscoderOptionsInterface {
void QualitySpinboxChanged(const double value);
private:
- static const char *kSettingsGroup;
-
Ui_TranscoderOptionsMP3 *ui_;
};
diff --git a/src/transcoder/transcoderoptionsopus.cpp b/src/transcoder/transcoderoptionsopus.cpp
index ae9c397351..4e35ad59cd 100644
--- a/src/transcoder/transcoderoptionsopus.cpp
+++ b/src/transcoder/transcoderoptionsopus.cpp
@@ -29,9 +29,13 @@
#include "transcoderoptionsopus.h"
#include "ui_transcoderoptionsopus.h"
+#include "core/settings.h"
+
// TODO: Add more options than only bitrate as soon as gst doesn't crash anymore while using the cbr parameter (like cbr=false)
-const char *TranscoderOptionsOpus::kSettingsGroup = "Transcoder/opusenc";
+namespace {
+constexpr char kSettingsGroup[] = "Transcoder/opusenc";
+}
TranscoderOptionsOpus::TranscoderOptionsOpus(QWidget *parent) : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsOpus) {
ui_->setupUi(this);
@@ -43,8 +47,8 @@ TranscoderOptionsOpus::~TranscoderOptionsOpus() {
void TranscoderOptionsOpus::Load() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
ui_->bitrate_slider->setValue(s.value("bitrate", 320000).toInt() / 1000);
s.endGroup();
@@ -52,8 +56,8 @@ void TranscoderOptionsOpus::Load() {
void TranscoderOptionsOpus::Save() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
s.setValue("bitrate", ui_->bitrate_slider->value() * 1000);
s.endGroup();
diff --git a/src/transcoder/transcoderoptionsopus.h b/src/transcoder/transcoderoptionsopus.h
index b85137eefc..3f9ab3761a 100644
--- a/src/transcoder/transcoderoptionsopus.h
+++ b/src/transcoder/transcoderoptionsopus.h
@@ -40,8 +40,6 @@ class TranscoderOptionsOpus : public TranscoderOptionsInterface {
void Save() override;
private:
- static const char *kSettingsGroup;
-
Ui_TranscoderOptionsOpus *ui_;
};
diff --git a/src/transcoder/transcoderoptionsspeex.cpp b/src/transcoder/transcoderoptionsspeex.cpp
index 2c15fbb85f..2aee551010 100644
--- a/src/transcoder/transcoderoptionsspeex.cpp
+++ b/src/transcoder/transcoderoptionsspeex.cpp
@@ -32,7 +32,11 @@
#include "transcoderoptionsspeex.h"
#include "ui_transcoderoptionsspeex.h"
-const char *TranscoderOptionsSpeex::kSettingsGroup = "Transcoder/speexenc";
+#include "core/settings.h"
+
+namespace {
+constexpr char kSettingsGroup[] = "Transcoder/speexenc";
+}
TranscoderOptionsSpeex::TranscoderOptionsSpeex(QWidget *parent) : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsSpeex) {
ui_->setupUi(this);
@@ -44,8 +48,8 @@ TranscoderOptionsSpeex::~TranscoderOptionsSpeex() {
void TranscoderOptionsSpeex::Load() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
ui_->quality_slider->setValue(s.value("quality", 10).toInt());
ui_->bitrate_slider->setValue(s.value("bitrate", 0).toInt() / 1000);
@@ -63,8 +67,8 @@ void TranscoderOptionsSpeex::Load() {
void TranscoderOptionsSpeex::Save() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
s.setValue("quality", ui_->quality_slider->value());
s.setValue("bitrate", ui_->bitrate_slider->value() * 1000);
diff --git a/src/transcoder/transcoderoptionsspeex.h b/src/transcoder/transcoderoptionsspeex.h
index 3e2bd907e3..64ccf0bf34 100644
--- a/src/transcoder/transcoderoptionsspeex.h
+++ b/src/transcoder/transcoderoptionsspeex.h
@@ -40,8 +40,6 @@ class TranscoderOptionsSpeex : public TranscoderOptionsInterface {
void Save() override;
private:
- static const char *kSettingsGroup;
-
Ui_TranscoderOptionsSpeex *ui_;
};
diff --git a/src/transcoder/transcoderoptionsvorbis.cpp b/src/transcoder/transcoderoptionsvorbis.cpp
index 0c7e0d7505..5f081d42b6 100644
--- a/src/transcoder/transcoderoptionsvorbis.cpp
+++ b/src/transcoder/transcoderoptionsvorbis.cpp
@@ -30,7 +30,11 @@
#include "transcoderoptionsvorbis.h"
#include "ui_transcoderoptionsvorbis.h"
-const char *TranscoderOptionsVorbis::kSettingsGroup = "Transcoder/vorbisenc";
+#include "core/settings.h"
+
+namespace {
+constexpr char kSettingsGroup[] = "Transcoder/vorbisenc";
+}
TranscoderOptionsVorbis::TranscoderOptionsVorbis(QWidget *parent) : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsVorbis) {
ui_->setupUi(this);
@@ -42,8 +46,8 @@ TranscoderOptionsVorbis::~TranscoderOptionsVorbis() {
void TranscoderOptionsVorbis::Load() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
int bitrate = s.value("bitrate", -1).toInt();
bitrate = bitrate == -1 ? 0 : bitrate / 1000;
@@ -66,8 +70,8 @@ void TranscoderOptionsVorbis::Load() {
void TranscoderOptionsVorbis::Save() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
int bitrate = ui_->bitrate_slider->value();
bitrate = bitrate == 0 ? -1 : bitrate * 1000;
diff --git a/src/transcoder/transcoderoptionsvorbis.h b/src/transcoder/transcoderoptionsvorbis.h
index 44a436a8f9..c4bacc6130 100644
--- a/src/transcoder/transcoderoptionsvorbis.h
+++ b/src/transcoder/transcoderoptionsvorbis.h
@@ -40,8 +40,6 @@ class TranscoderOptionsVorbis : public TranscoderOptionsInterface {
void Save() override;
private:
- static const char *kSettingsGroup;
-
Ui_TranscoderOptionsVorbis *ui_;
};
diff --git a/src/transcoder/transcoderoptionswavpack.cpp b/src/transcoder/transcoderoptionswavpack.cpp
index 00a882979b..c3c4d25eb7 100644
--- a/src/transcoder/transcoderoptionswavpack.cpp
+++ b/src/transcoder/transcoderoptionswavpack.cpp
@@ -27,7 +27,11 @@
#include "transcoderoptionswavpack.h"
#include "ui_transcoderoptionswavpack.h"
-const char *TranscoderOptionsWavPack::kSettingsGroup = "Transcoder/wavpackenc";
+#include "core/settings.h"
+
+namespace {
+constexpr char kSettingsGroup[] = "Transcoder/wavpackenc";
+}
TranscoderOptionsWavPack::TranscoderOptionsWavPack(QWidget *parent) : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsWavPack) {
ui_->setupUi(this);
@@ -39,16 +43,16 @@ TranscoderOptionsWavPack::~TranscoderOptionsWavPack() {
void TranscoderOptionsWavPack::Load() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
s.endGroup();
}
void TranscoderOptionsWavPack::Save() {
- QSettings s;
- s.beginGroup(kSettingsGroup + settings_postfix_);
+ Settings s;
+ s.beginGroup(QLatin1String(kSettingsGroup) + settings_postfix_);
s.endGroup();
}
diff --git a/src/transcoder/transcoderoptionswavpack.h b/src/transcoder/transcoderoptionswavpack.h
index d361a23fea..75eaedc4fe 100644
--- a/src/transcoder/transcoderoptionswavpack.h
+++ b/src/transcoder/transcoderoptionswavpack.h
@@ -39,8 +39,6 @@ class TranscoderOptionsWavPack : public TranscoderOptionsInterface {
void Save() override;
private:
- static const char *kSettingsGroup;
-
Ui_TranscoderOptionsWavPack *ui_;
};
diff --git a/src/utilities/coverutils.cpp b/src/utilities/coverutils.cpp
index 5b1bffa6cb..1ce21e48f3 100644
--- a/src/utilities/coverutils.cpp
+++ b/src/utilities/coverutils.cpp
@@ -43,18 +43,18 @@ QByteArray CoverUtils::Sha1CoverHash(const QString &artist, const QString &album
QString CoverUtils::AlbumCoverFilename(QString artist, QString album, const QString &extension) {
- artist.remove('/').remove('\\');
- album.remove('/').remove('\\');
+ artist.remove(QLatin1Char('/')).remove(QLatin1Char('\\'));
+ album.remove(QLatin1Char('/')).remove(QLatin1Char('\\'));
- QString filename = artist + "-" + album;
+ QString filename = artist + QStringLiteral("-") + album;
filename = Utilities::Transliterate(filename.toLower());
- filename = filename.replace(' ', '-')
+ filename = filename.replace(QLatin1Char(' '), QLatin1Char('-'))
.replace(QLatin1String("--"), QLatin1String("-"))
- .remove(QRegularExpression(QString(kInvalidFatCharactersRegex), QRegularExpression::CaseInsensitiveOption))
+ .remove(QRegularExpression(QLatin1String(kInvalidFatCharactersRegex), QRegularExpression::CaseInsensitiveOption))
.simplified();
if (!extension.isEmpty()) {
- filename.append('.');
+ filename.append(QLatin1Char('.'));
filename.append(extension);
}
@@ -76,7 +76,7 @@ QString CoverUtils::CoverFilePath(const CoverOptions &options, const Song::Sourc
path = Song::ImageCacheDir(source);
}
- if (path.right(1) == QDir::separator() || path.right(1) == "/") {
+ if (path.right(1) == QDir::separator() || path.right(1) == QLatin1String("/")) {
path.chop(1);
}
@@ -92,11 +92,11 @@ QString CoverUtils::CoverFilePath(const CoverOptions &options, const Song::Sourc
options.cover_filename == CoverOptions::CoverFilename::Pattern &&
!options.cover_pattern.isEmpty()) {
filename = CoverFilenameFromVariable(options, artist, album);
- filename.remove(QRegularExpression(QString(kInvalidFatCharactersRegex), QRegularExpression::CaseInsensitiveOption)).remove('/').remove('\\');
+ filename.remove(QRegularExpression(QLatin1String(kInvalidFatCharactersRegex), QRegularExpression::CaseInsensitiveOption)).remove(QLatin1Char('/')).remove(QLatin1Char('\\'));
if (options.cover_lowercase) filename = filename.toLower();
if (options.cover_replace_spaces) filename.replace(QRegularExpression(QStringLiteral("\\s")), QStringLiteral("-"));
if (!extension.isEmpty()) {
- filename.append('.');
+ filename.append(QLatin1Char('.'));
filename.append(extension);
}
}
@@ -105,7 +105,7 @@ QString CoverUtils::CoverFilePath(const CoverOptions &options, const Song::Sourc
filename = CoverFilenameFromSource(source, cover_url, artist, album, album_id, extension);
}
- QString filepath(path + "/" + filename);
+ QString filepath(path + QStringLiteral("/") + filename);
return filepath;
@@ -118,7 +118,7 @@ QString CoverUtils::CoverFilenameFromSource(const Song::Source source, const QUr
switch (source) {
case Song::Source::Tidal:
if (!album_id.isEmpty()) {
- filename = album_id + "-" + cover_url.fileName();
+ filename = album_id + QStringLiteral("-") + cover_url.fileName();
break;
}
[[fallthrough]];
@@ -137,12 +137,12 @@ QString CoverUtils::CoverFilenameFromSource(const Song::Source source, const QUr
case Song::Source::SomaFM:
case Song::Source::RadioParadise:
case Song::Source::Unknown:
- filename = Sha1CoverHash(artist, album).toHex();
+ filename = QString::fromUtf8(Sha1CoverHash(artist, album).toHex());
break;
}
if (!extension.isEmpty()) {
- filename.append('.');
+ filename.append(QLatin1Char('.'));
filename.append(extension);
}
@@ -159,7 +159,7 @@ QString CoverUtils::CoverFilenameFromVariable(const CoverOptions &options, const
filename.replace(QLatin1String("%artist"), artist);
filename.replace(QLatin1String("%album"), album);
if (!extension.isEmpty()) {
- filename.append('.');
+ filename.append(QLatin1Char('.'));
filename.append(extension);
}
return filename;
diff --git a/src/utilities/envutils.cpp b/src/utilities/envutils.cpp
index f93173cf06..3f84075bc1 100644
--- a/src/utilities/envutils.cpp
+++ b/src/utilities/envutils.cpp
@@ -52,19 +52,19 @@ QString DesktopEnvironment() {
if (!qEnvironmentVariableIsEmpty("GNOME_DESKTOP_SESSION_ID")) return QStringLiteral("Gnome");
QString session = GetEnv(QStringLiteral("DESKTOP_SESSION"));
- qint64 slash = session.lastIndexOf('/');
+ qint64 slash = session.lastIndexOf(QLatin1Char('/'));
if (slash != -1) {
QSettings desktop_file(QStringLiteral("%1.desktop").arg(session), QSettings::IniFormat);
- desktop_file.beginGroup("Desktop Entry");
- QString name = desktop_file.value("DesktopNames").toString();
+ desktop_file.beginGroup(QStringLiteral("Desktop Entry"));
+ QString name = desktop_file.value(QStringLiteral("DesktopNames")).toString();
desktop_file.endGroup();
if (!name.isEmpty()) return name;
session = session.mid(slash + 1);
}
- if (session == "kde") return QStringLiteral("KDE");
- else if (session == "gnome") return QStringLiteral("Gnome");
- else if (session == "xfce") return QStringLiteral("XFCE");
+ if (session == QStringLiteral("kde")) return QStringLiteral("KDE");
+ else if (session == QStringLiteral("gnome")) return QStringLiteral("Gnome");
+ else if (session == QStringLiteral("xfce")) return QStringLiteral("XFCE");
return QStringLiteral("Unknown");
diff --git a/src/utilities/filemanagerutils.cpp b/src/utilities/filemanagerutils.cpp
index 2ea60ab9b9..679a8a92a0 100644
--- a/src/utilities/filemanagerutils.cpp
+++ b/src/utilities/filemanagerutils.cpp
@@ -46,11 +46,11 @@ void OpenInFileManager(const QString &path, const QUrl &url) {
#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
proc.startCommand(QStringLiteral("xdg-mime query default inode/directory"));
#else
- proc.start("xdg-mime", QStringList() << "query" << "default" << "inode/directory");
+ proc.start(QStringLiteral("xdg-mime"), QStringList() << QStringLiteral("query") << QStringLiteral("default") << QStringLiteral("inode/directory"));
#endif
proc.waitForFinished();
- QString desktop_file = proc.readLine().simplified();
- QString xdg_data_dirs = QString(qgetenv("XDG_DATA_DIRS"));
+ QString desktop_file = QString::fromUtf8(proc.readLine()).simplified();
+ QString xdg_data_dirs = QString::fromUtf8(qgetenv("XDG_DATA_DIRS"));
if (xdg_data_dirs.isEmpty()) {
xdg_data_dirs = QStringLiteral("/usr/local/share/:/usr/share/");
}
@@ -62,15 +62,15 @@ void OpenInFileManager(const QString &path, const QUrl &url) {
QString desktop_file_path = QStringLiteral("%1/applications/%2").arg(data_dir, desktop_file);
if (!QFile::exists(desktop_file_path)) continue;
QSettings setting(desktop_file_path, QSettings::IniFormat);
- setting.beginGroup("Desktop Entry");
- if (setting.contains("Exec")) {
- QString cmd = setting.value("Exec").toString();
+ setting.beginGroup(QStringLiteral("Desktop Entry"));
+ if (setting.contains(QStringLiteral("Exec"))) {
+ QString cmd = setting.value(QStringLiteral("Exec")).toString();
if (cmd.isEmpty()) break;
cmd = cmd.remove(QRegularExpression(QStringLiteral("[%][a-zA-Z]*( |$)"), QRegularExpression::CaseInsensitiveOption));
# if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
- command_params = cmd.split(' ', Qt::SkipEmptyParts);
+ command_params = cmd.split(QLatin1Char(' '), Qt::SkipEmptyParts);
# else
- command_params = cmd.split(' ', QString::SkipEmptyParts);
+ command_params = cmd.split(QLatin1Char(' '), QString::SkipEmptyParts);
# endif
command = command_params.first();
command_params.removeFirst();
@@ -83,7 +83,7 @@ void OpenInFileManager(const QString &path, const QUrl &url) {
command = command.split(QStringLiteral("/")).last();
}
- if (command.isEmpty() || command == "exo-open") {
+ if (command.isEmpty() || command == QStringLiteral("exo-open")) {
QDesktopServices::openUrl(QUrl::fromLocalFile(path));
}
else if (command.startsWith(QLatin1String("nautilus"))) {
diff --git a/src/utilities/fileutils.cpp b/src/utilities/fileutils.cpp
index af044be0c0..a159210ec5 100644
--- a/src/utilities/fileutils.cpp
+++ b/src/utilities/fileutils.cpp
@@ -86,21 +86,21 @@ bool Copy(QIODevice *source, QIODevice *destination) {
bool CopyRecursive(const QString &source, const QString &destination) {
// Make the destination directory
- QString dir_name = source.section('/', -1, -1);
- QString dest_path = destination + "/" + dir_name;
+ QString dir_name = source.section(QLatin1Char('/'), -1, -1);
+ QString dest_path = destination + QLatin1Char('/') + dir_name;
QDir().mkpath(dest_path);
QDir dir(source);
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs)) {
- if (!CopyRecursive(source + "/" + child, dest_path)) {
- qLog(Warning) << "Failed to copy dir" << source + "/" + child << "to" << dest_path;
+ if (!CopyRecursive(source + QLatin1Char('/') + child, dest_path)) {
+ qLog(Warning) << "Failed to copy dir" << source + QLatin1Char('/') + child << "to" << dest_path;
return false;
}
}
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Files)) {
- if (!QFile::copy(source + "/" + child, dest_path + "/" + child)) {
- qLog(Warning) << "Failed to copy file" << source + "/" + child << "to" << dest_path;
+ if (!QFile::copy(source + QLatin1Char('/') + child, dest_path + QLatin1Char('/') + child)) {
+ qLog(Warning) << "Failed to copy file" << source + QLatin1Char('/') + child << "to" << dest_path;
return false;
}
}
@@ -112,13 +112,13 @@ bool RemoveRecursive(const QString &path) {
QDir dir(path);
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Dirs | QDir::Hidden)) {
- if (!RemoveRecursive(path + "/" + child)) {
+ if (!RemoveRecursive(path + QLatin1Char('/') + child)) {
return false;
}
}
for (const QString &child : dir.entryList(QDir::NoDotAndDotDot | QDir::Files | QDir::Hidden)) {
- if (!QFile::remove(path + "/" + child)) {
+ if (!QFile::remove(path + QLatin1Char('/') + child)) {
return false;
}
}
diff --git a/src/utilities/imageutils.cpp b/src/utilities/imageutils.cpp
index 7763a40cf6..992dbdb4e2 100644
--- a/src/utilities/imageutils.cpp
+++ b/src/utilities/imageutils.cpp
@@ -38,7 +38,7 @@ QStringList ImageUtils::SupportedImageMimeTypes() {
if (kSupportedImageMimeTypes.isEmpty()) {
for (const QByteArray &mimetype : QImageReader::supportedMimeTypes()) {
- kSupportedImageMimeTypes << mimetype;
+ kSupportedImageMimeTypes << QString::fromUtf8(mimetype);
}
}
@@ -50,7 +50,7 @@ QStringList ImageUtils::SupportedImageFormats() {
if (kSupportedImageFormats.isEmpty()) {
for (const QByteArray &filetype : QImageReader::supportedImageFormats()) {
- kSupportedImageFormats << filetype;
+ kSupportedImageFormats << QString::fromUtf8(filetype);
}
}
@@ -78,7 +78,7 @@ QByteArray ImageUtils::FileToJpegData(const QString &filename) {
if (filename.isEmpty()) return QByteArray();
QByteArray image_data = Utilities::ReadDataFromFile(filename);
- if (Utilities::MimeTypeFromData(image_data) == "image/jpeg") return image_data;
+ if (Utilities::MimeTypeFromData(image_data) == QStringLiteral("image/jpeg")) return image_data;
else {
QImage image;
if (image.loadFromData(image_data)) {
diff --git a/src/utilities/macaddrutils.cpp b/src/utilities/macaddrutils.cpp
index 4f380614a4..e19dde3932 100644
--- a/src/utilities/macaddrutils.cpp
+++ b/src/utilities/macaddrutils.cpp
@@ -31,7 +31,7 @@ QString MacAddress() {
for (QNetworkInterface &netif : QNetworkInterface::allInterfaces()) {
if (
- (netif.hardwareAddress() == "00:00:00:00:00:00") ||
+ (netif.hardwareAddress() == QStringLiteral("00:00:00:00:00:00")) ||
(netif.flags() & QNetworkInterface::IsLoopBack) ||
!(netif.flags() & QNetworkInterface::IsUp) ||
!(netif.flags() & QNetworkInterface::IsRunning)
diff --git a/src/utilities/searchparserutils.cpp b/src/utilities/searchparserutils.cpp
index 1380ac9a47..813f7cc9d0 100644
--- a/src/utilities/searchparserutils.cpp
+++ b/src/utilities/searchparserutils.cpp
@@ -49,7 +49,7 @@ int ParseSearchTime(const QString &time_str) {
if (c.isDigit()) {
accum = accum * 10 + c.digitValue();
}
- else if (c == ':') {
+ else if (c == QLatin1Char(':')) {
seconds = seconds * 60 + accum;
accum = 0;
++colon_count;
@@ -89,7 +89,7 @@ float ParseSearchRating(const QString &rating_str) {
}
// check if the search is a float
- else if (rating_str.at(0) == 'f') {
+ else if (rating_str.at(0) == QLatin1Char('f')) {
QString rating_float = rating_str;
rating_float = rating_float.remove(0, 1);
diff --git a/src/utilities/strutils.cpp b/src/utilities/strutils.cpp
index 9d03a6c920..6bdc774398 100644
--- a/src/utilities/strutils.cpp
+++ b/src/utilities/strutils.cpp
@@ -35,7 +35,7 @@ QString PrettySize(const quint64 bytes) {
if (bytes > 0) {
if (bytes <= 1000) {
- ret = QString::number(bytes) + " bytes";
+ ret = QString::number(bytes) + QStringLiteral(" bytes");
}
else if (bytes <= 1000 * 1000) {
ret = QString::asprintf("%.1f KB", static_cast(bytes) / 1000.0F);
@@ -52,16 +52,16 @@ QString PrettySize(const quint64 bytes) {
}
QString PrettySize(const QSize size) {
- return QString::number(size.width()) + "x" + QString::number(size.height());
+ return QString::number(size.width()) + QLatin1Char('x') + QString::number(size.height());
}
QString PathWithoutFilenameExtension(const QString &filename) {
- if (filename.section('/', -1, -1).contains('.')) return filename.section('.', 0, -2);
+ if (filename.section(QLatin1Char('/'), -1, -1).contains(QLatin1Char('.'))) return filename.section(QLatin1Char('.'), 0, -2);
return filename;
}
QString FiddleFileExtension(const QString &filename, const QString &new_extension) {
- return PathWithoutFilenameExtension(filename) + "." + new_extension;
+ return PathWithoutFilenameExtension(filename) + QLatin1Char('.') + new_extension;
}
const char *EnumToString(const QMetaObject &meta, const char *name, const int value) {
@@ -86,7 +86,7 @@ QStringList Prepend(const QString &text, const QStringList &list) {
QStringList Updateify(const QStringList &list) {
QStringList ret(list);
- for (int i = 0; i < ret.count(); ++i) ret[i].prepend(ret[i] + " = :");
+ for (int i = 0; i < ret.count(); ++i) ret[i].prepend(ret[i] + QStringLiteral(" = :"));
return ret;
}
@@ -136,61 +136,61 @@ QString ReplaceVariable(const QString &variable, const Song &song, const QString
QString value = variable;
- if (variable == "%title%") {
+ if (variable == QStringLiteral("%title%")) {
value = song.PrettyTitle();
}
- else if (variable == "%album%") {
+ else if (variable == QStringLiteral("%album%")) {
value = song.album();
}
- else if (variable == "%artist%") {
+ else if (variable == QStringLiteral("%artist%")) {
value = song.artist();
}
- else if (variable == "%albumartist%") {
+ else if (variable == QStringLiteral("%albumartist%")) {
value = song.effective_albumartist();
}
- else if (variable == "%track%") {
+ else if (variable == QStringLiteral("%track%")) {
value.setNum(song.track());
}
- else if (variable == "%disc%") {
+ else if (variable == QStringLiteral("%disc%")) {
value.setNum(song.disc());
}
- else if (variable == "%year%") {
+ else if (variable == QStringLiteral("%year%")) {
value = song.PrettyYear();
}
- else if (variable == "%originalyear%") {
+ else if (variable == QStringLiteral("%originalyear%")) {
value = song.PrettyOriginalYear();
}
- else if (variable == "%genre%") {
+ else if (variable == QStringLiteral("%genre%")) {
value = song.genre();
}
- else if (variable == "%composer%") {
+ else if (variable == QStringLiteral("%composer%")) {
value = song.composer();
}
- else if (variable == "%performer%") {
+ else if (variable == QStringLiteral("%performer%")) {
value = song.performer();
}
- else if (variable == "%grouping%") {
+ else if (variable == QStringLiteral("%grouping%")) {
value = song.grouping();
}
- else if (variable == "%length%") {
+ else if (variable == QStringLiteral("%length%")) {
value = song.PrettyLength();
}
- else if (variable == "%filename%") {
+ else if (variable == QStringLiteral("%filename%")) {
value = song.basefilename();
}
- else if (variable == "%url%") {
+ else if (variable == QStringLiteral("%url%")) {
value = song.url().toString();
}
- else if (variable == "%playcount%") {
+ else if (variable == QStringLiteral("%playcount%")) {
value.setNum(song.playcount());
}
- else if (variable == "%skipcount%") {
+ else if (variable == QStringLiteral("%skipcount%")) {
value.setNum(song.skipcount());
}
- else if (variable == "%rating%") {
+ else if (variable == QStringLiteral("%rating%")) {
value = song.PrettyRating();
}
- else if (variable == "%newline%") {
+ else if (variable == QStringLiteral("%newline%")) {
return QString(newline); // No HTML escaping, return immediately.
}
diff --git a/src/utilities/timeutils.cpp b/src/utilities/timeutils.cpp
index 16d8403bd3..44ec84bb02 100644
--- a/src/utilities/timeutils.cpp
+++ b/src/utilities/timeutils.cpp
@@ -50,7 +50,7 @@ QString PrettyTime(int seconds) {
}
QString PrettyTimeDelta(const int seconds) {
- return (seconds >= 0 ? "+" : "-") + PrettyTime(seconds);
+ return (seconds >= 0 ? QStringLiteral("+") : QStringLiteral("-")) + PrettyTime(seconds);
}
QString PrettyTimeNanosec(const qint64 nanoseconds) {
@@ -67,7 +67,7 @@ QString WordyTime(const quint64 seconds) {
if (days > 0) parts << (days == 1 ? QObject::tr("1 day") : QObject::tr("%1 days").arg(days));
parts << PrettyTime(static_cast(seconds - days * 60 * 60 * 24));
- return parts.join(QStringLiteral(" "));
+ return parts.join(QLatin1Char(' '));
}
@@ -82,8 +82,8 @@ QString Ago(const qint64 seconds_since_epoch, const QLocale &locale) {
const qint64 days_ago = then.date().daysTo(now.date());
const QString time = then.time().toString(locale.timeFormat(QLocale::ShortFormat));
- if (days_ago == 0) return QObject::tr("Today") + " " + time;
- if (days_ago == 1) return QObject::tr("Yesterday") + " " + time;
+ if (days_ago == 0) return QObject::tr("Today") + QLatin1Char(' ') + time;
+ if (days_ago == 1) return QObject::tr("Yesterday") + QLatin1Char(' ') + time;
if (days_ago <= 7) return QObject::tr("%1 days ago").arg(days_ago);
return then.date().toString(locale.dateFormat(QLocale::ShortFormat));
diff --git a/src/widgets/fancytabwidget.cpp b/src/widgets/fancytabwidget.cpp
index 70c9fc19ba..373bfaf0fe 100644
--- a/src/widgets/fancytabwidget.cpp
+++ b/src/widgets/fancytabwidget.cpp
@@ -61,6 +61,7 @@
#include "fancytabwidget.h"
#include "core/stylehelper.h"
+#include "core/settings.h"
#include "settings/appearancesettingspage.h"
using namespace std::chrono_literals;
@@ -480,11 +481,11 @@ FancyTabWidget::~FancyTabWidget() {
void FancyTabWidget::Load(const QString &kSettingsGroup) {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
QMultiMap tabs;
for (TabData *tab : std::as_const(tabs_)) {
- int idx = s.value("tab_" + tab->name(), tab->index()).toInt();
+ int idx = s.value(QStringLiteral("tab_") + tab->name(), tab->index()).toInt();
while (tabs.contains(idx)) { ++idx; }
tabs.insert(idx, tab);
}
@@ -505,14 +506,14 @@ int FancyTabWidget::insertTab(const int idx, QWidget *page, const QIcon &icon, c
void FancyTabWidget::SaveSettings(const QString &kSettingsGroup) {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("tab_mode", static_cast(mode_));
s.setValue("current_tab", currentIndex());
for (TabData *tab : std::as_const(tabs_)) {
- QString k = "tab_" + tab->name();
+ QString k = QStringLiteral("tab_") + tab->name();
int idx = QTabWidget::indexOf(tab->page());
if (idx < 0) {
if (s.contains(k)) s.remove(k);
@@ -528,7 +529,7 @@ void FancyTabWidget::SaveSettings(const QString &kSettingsGroup) {
void FancyTabWidget::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
bg_color_system_ = s.value(AppearanceSettingsPage::kTabBarSystemColor, false).toBool();
bg_gradient_ = s.value(AppearanceSettingsPage::kTabBarGradient, true).toBool();
diff --git a/src/widgets/fileview.cpp b/src/widgets/fileview.cpp
index 5e80a9e410..624b64e3ec 100644
--- a/src/widgets/fileview.cpp
+++ b/src/widgets/fileview.cpp
@@ -41,6 +41,7 @@
#include "core/filesystemmusicstorage.h"
#include "core/iconloader.h"
#include "core/mimedata.h"
+#include "core/settings.h"
#include "dialogs/deleteconfirmationdialog.h"
#include "fileview.h"
#include "fileviewlist.h"
@@ -93,7 +94,7 @@ FileView::FileView(QWidget *parent)
QObject::connect(ui_->list, &FileViewList::Delete, this, &FileView::Delete);
QObject::connect(ui_->list, &FileViewList::EditTags, this, &FileView::EditTags);
- QString filter(FileView::kFileFilter);
+ QString filter(QLatin1String(FileView::kFileFilter));
filter_list_ << filter.split(QStringLiteral(" "));
ReloadSettings();
@@ -106,7 +107,7 @@ FileView::~FileView() {
void FileView::ReloadSettings() {
- QSettings s;
+ Settings s;
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
int iconsize = s.value(AppearanceSettingsPage::kIconSizeLeftPanelButtons, 22).toInt();
s.endGroup();
diff --git a/src/widgets/freespacebar.cpp b/src/widgets/freespacebar.cpp
index 1cf0137b19..10168a51f9 100644
--- a/src/widgets/freespacebar.cpp
+++ b/src/widgets/freespacebar.cpp
@@ -229,7 +229,7 @@ QString FreeSpaceBar::TextForSize(const QString &prefix, const quint64 size) {
ret = QStringLiteral("0 MB");
}
- if (!prefix.isEmpty()) ret.prepend(prefix + " ");
+ if (!prefix.isEmpty()) ret.prepend(prefix + QStringLiteral(" "));
return ret;
diff --git a/src/widgets/lineedit.h b/src/widgets/lineedit.h
index 056cc34ab1..12751164f0 100644
--- a/src/widgets/lineedit.h
+++ b/src/widgets/lineedit.h
@@ -188,7 +188,7 @@ class SpinBox : public QSpinBox, public ExtendedEditor {
QVariant value() const override { return QSpinBox::value(); }
void set_value(const QVariant &value) override { QSpinBox::setValue(value.toInt()); }
- bool is_empty() const override { return text().isEmpty() || text() == "0"; }
+ bool is_empty() const override { return text().isEmpty() || text() == QStringLiteral("0"); }
public slots:
void set_focus() override { QSpinBox::setFocus(); }
@@ -214,7 +214,7 @@ class CheckBox : public QCheckBox, public ExtendedEditor {
// ExtendedEditor
void set_enabled(bool enabled) override { QCheckBox::setEnabled(enabled); }
- bool is_empty() const override { return text().isEmpty() || text() == "0"; }
+ bool is_empty() const override { return text().isEmpty() || text() == QStringLiteral("0"); }
QVariant value() const override { return QCheckBox::isChecked(); }
void set_value(const QVariant &value) override { QCheckBox::setCheckState(value.toBool() ? Qt::Checked : Qt::Unchecked); }
void set_partially() override { QCheckBox::setCheckState(Qt::PartiallyChecked); }
diff --git a/src/widgets/loginstatewidget.cpp b/src/widgets/loginstatewidget.cpp
index f17f624d2b..31e9ec6769 100644
--- a/src/widgets/loginstatewidget.cpp
+++ b/src/widgets/loginstatewidget.cpp
@@ -79,8 +79,8 @@ void LoginStateWidget::SetLoggedIn(const State state, const QString &account_nam
ui_->signed_out->setVisible(state != State::LoggedIn);
ui_->busy->setVisible(state == State::LoginInProgress);
- if (account_name.isEmpty()) ui_->signed_in_label->setText("" + tr("You are signed in.") + "");
- else ui_->signed_in_label->setText(tr("You are signed in as %1.").arg("" + account_name + ""));
+ if (account_name.isEmpty()) ui_->signed_in_label->setText(QStringLiteral("") + tr("You are signed in.") + QStringLiteral(""));
+ else ui_->signed_in_label->setText(tr("You are signed in as %1.").arg(QStringLiteral("") + account_name + QStringLiteral("")));
for (QWidget *widget : credential_groups_) {
widget->setVisible(state != State::LoggedIn);
@@ -151,7 +151,7 @@ void LoginStateWidget::SetExpires(const QDate expires) {
if (expires.isValid()) {
const QString expires_text = QLocale().toString(expires, QLocale::LongFormat);
- ui_->expires_label->setText(tr("Expires on %1").arg("" + expires_text + ""));
+ ui_->expires_label->setText(tr("Expires on %1").arg(QStringLiteral("") + expires_text + QStringLiteral("")));
}
}
diff --git a/src/widgets/playingwidget.cpp b/src/widgets/playingwidget.cpp
index 599149eff8..70c2f31b9a 100644
--- a/src/widgets/playingwidget.cpp
+++ b/src/widgets/playingwidget.cpp
@@ -40,6 +40,7 @@
#include
#include "core/application.h"
+#include "core/settings.h"
#include "utilities/imageutils.h"
#include "covermanager/albumcoverchoicecontroller.h"
#include "playingwidget.h"
@@ -87,7 +88,7 @@ PlayingWidget::PlayingWidget(QWidget *parent)
SetHeight(0);
// Load settings
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
mode_ = static_cast(s.value("mode", static_cast(Mode::LargeSongDetails)).toInt());
fit_width_ = s.value("fit_cover_width", false).toBool();
@@ -139,7 +140,7 @@ void PlayingWidget::Init(Application *app, AlbumCoverChoiceController *album_cov
above_statusbar_action_ = menu_->addAction(tr("Show above status bar"));
above_statusbar_action_->setCheckable(true);
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
above_statusbar_action_->setChecked(s.value("above_status_bar", false).toBool());
s.endGroup();
@@ -229,7 +230,7 @@ void PlayingWidget::SetMode(const Mode mode) {
UpdateDetailsText();
update();
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("mode", static_cast(mode_));
s.endGroup();
@@ -242,7 +243,7 @@ void PlayingWidget::FitCoverWidth(const bool fit) {
UpdateHeight();
update();
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("fit_cover_width", fit_width_);
s.endGroup();
@@ -251,7 +252,7 @@ void PlayingWidget::FitCoverWidth(const bool fit) {
void PlayingWidget::ShowAboveStatusBar(const bool above) {
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("above_status_bar", above);
s.endGroup();
@@ -547,7 +548,7 @@ void PlayingWidget::SearchCoverInProgress() {
downloading_covers_ = true;
// Show a spinner animation
- spinner_animation_ = make_unique(":/pictures/spinner.gif", QByteArray(), this);
+ spinner_animation_ = make_unique(QStringLiteral(":/pictures/spinner.gif"), QByteArray(), this);
QObject::connect(&*spinner_animation_, &QMovie::updated, this, &PlayingWidget::Update);
spinner_animation_->start();
update();
diff --git a/src/widgets/ratingwidget.cpp b/src/widgets/ratingwidget.cpp
index ac26fc2f7d..fde714628e 100644
--- a/src/widgets/ratingwidget.cpp
+++ b/src/widgets/ratingwidget.cpp
@@ -29,16 +29,13 @@
#include
#include
-const int RatingPainter::kStarCount;
-const int RatingPainter::kStarSize;
-
RatingPainter::RatingPainter() {
// Load the base pixmaps
- QIcon star_on(":/pictures/star-on.png");
+ QIcon star_on(QStringLiteral(":/pictures/star-on.png"));
QList star_on_sizes = star_on.availableSizes();
QPixmap on(star_on.pixmap(star_on_sizes.last()));
- QIcon star_off(":/pictures/star-off.png");
+ QIcon star_off(QStringLiteral(":/pictures/star-off.png"));
QList star_off_sizes = star_off.availableSizes();
QPixmap off(star_off.pixmap(star_off_sizes.last()));
diff --git a/src/widgets/ratingwidget.h b/src/widgets/ratingwidget.h
index e63bcb9a19..0a8bb7a3eb 100644
--- a/src/widgets/ratingwidget.h
+++ b/src/widgets/ratingwidget.h
@@ -30,8 +30,9 @@ class RatingPainter {
public:
RatingPainter();
- static const int kStarCount = 5;
- static const int kStarSize = 16;
+ static constexpr int kStarCount = 5;
+ static constexpr int kStarSize = 16;
+
static QRect Contents(const QRect rect);
static float RatingForPos(const QPoint pos, const QRect rect);
diff --git a/src/widgets/trackslider.cpp b/src/widgets/trackslider.cpp
index b4991b1028..e03ec63753 100644
--- a/src/widgets/trackslider.cpp
+++ b/src/widgets/trackslider.cpp
@@ -29,6 +29,7 @@
#include
#include
+#include "core/settings.h"
#include "utilities/timeutils.h"
#include "utilities/timeconstants.h"
#include "trackslider.h"
@@ -57,7 +58,7 @@ TrackSlider::TrackSlider(QWidget *parent)
UpdateLabelWidth();
// Load settings
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
show_remaining_time_ = s.value("show_remaining_time").toBool();
s.endGroup();
@@ -142,7 +143,7 @@ void TrackSlider::UpdateTimes(const int elapsed) {
ui_->elapsed->setText(Utilities::PrettyTime(elapsed));
// Update normally if showing remaining time
if (show_remaining_time_) {
- ui_->remaining->setText("-" + Utilities::PrettyTime(static_cast(ui_->slider->maximum() / kMsecPerSec) - elapsed));
+ ui_->remaining->setText(QLatin1Char('-') + Utilities::PrettyTime(static_cast(ui_->slider->maximum() / kMsecPerSec) - elapsed));
}
else {
// Check if slider maximum value is changed before updating
@@ -214,7 +215,7 @@ void TrackSlider::ToggleTimeDisplay() {
UpdateTimes(static_cast(ui_->slider->value() / kMsecPerSec));
// Save this setting
- QSettings s;
+ Settings s;
s.beginGroup(kSettingsGroup);
s.setValue("show_remaining_time", show_remaining_time_);
diff --git a/src/widgets/volumeslider.cpp b/src/widgets/volumeslider.cpp
index 201768d1a9..d1e464046b 100644
--- a/src/widgets/volumeslider.cpp
+++ b/src/widgets/volumeslider.cpp
@@ -109,7 +109,7 @@ void VolumeSlider::paintEvent(QPaintEvent*) {
vol_font.setPixelSize(9);
p.setFont(vol_font);
const QRect rect(0, 0, 34, 15);
- p.drawText(rect, Qt::AlignRight | Qt::AlignVCenter, QString::number(value()) + '%');
+ p.drawText(rect, Qt::AlignRight | Qt::AlignVCenter, QString::number(value()) + QLatin1Char('%'));
}