Disable automatic conversions from 8-bit strings
This commit is contained in:
@@ -100,7 +100,7 @@ CommandlineOptions::CommandlineOptions(int argc, char **argv)
|
||||
play_track_at_(-1),
|
||||
show_osd_(false),
|
||||
toggle_pretty_osd_(false),
|
||||
log_levels_(logging::kDefaultLogLevels) {
|
||||
log_levels_(QLatin1String(logging::kDefaultLogLevels)) {
|
||||
|
||||
#ifdef Q_OS_WIN32
|
||||
Q_UNUSED(argv);
|
||||
@@ -108,7 +108,7 @@ CommandlineOptions::CommandlineOptions(int argc, char **argv)
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
// Remove -psn_xxx option that Mac passes when opened from Finder.
|
||||
RemoveArg("-psn", 1);
|
||||
RemoveArg(QStringLiteral("-psn"), 1);
|
||||
#endif
|
||||
|
||||
// Remove the -session option that KDE passes
|
||||
@@ -212,9 +212,9 @@ bool CommandlineOptions::Parse() {
|
||||
if (c == -1) break;
|
||||
|
||||
switch (c) {
|
||||
case 'h': {
|
||||
case 'h':{
|
||||
QString translated_help_text =
|
||||
QString(kHelpText)
|
||||
QString::fromUtf8(kHelpText)
|
||||
.arg(QObject::tr("Usage"), QObject::tr("options"), QObject::tr("URL(s)"),
|
||||
QObject::tr("Player options"),
|
||||
QObject::tr("Start the playlist currently playing"),
|
||||
@@ -309,7 +309,7 @@ bool CommandlineOptions::Parse() {
|
||||
case LongOptions::LogLevels:
|
||||
log_levels_ = OptArgToString(optarg);
|
||||
break;
|
||||
case LongOptions::Version: {
|
||||
case LongOptions::Version:{
|
||||
QString version_text = QString::fromUtf8(kVersionText).arg(QStringLiteral(STRAWBERRY_VERSION_DISPLAY));
|
||||
std::cout << version_text.toLocal8Bit().constData() << std::endl;
|
||||
std::exit(0);
|
||||
@@ -429,7 +429,7 @@ QString CommandlineOptions::DecodeName(wchar_t *opt) {
|
||||
#else
|
||||
QString CommandlineOptions::OptArgToString(char *opt) {
|
||||
|
||||
return QString(opt);
|
||||
return QString::fromUtf8(opt);
|
||||
}
|
||||
|
||||
QString CommandlineOptions::DecodeName(char *opt) {
|
||||
|
||||
@@ -47,10 +47,13 @@
|
||||
#include "sqlquery.h"
|
||||
#include "scopedtransaction.h"
|
||||
|
||||
const char *Database::kDatabaseFilename = "strawberry.db";
|
||||
const int Database::kSchemaVersion = 18;
|
||||
const int Database::kMinSupportedSchemaVersion = 10;
|
||||
const char *Database::kMagicAllSongsTables = "%allsongstables";
|
||||
|
||||
namespace {
|
||||
constexpr char kDatabaseFilename[] = "strawberry.db";
|
||||
constexpr int kMinSupportedSchemaVersion = 10;
|
||||
constexpr char kMagicAllSongsTables[] = "%allsongstables";
|
||||
} // namespace
|
||||
|
||||
int Database::sNextConnectionId = 1;
|
||||
QMutex Database::sNextConnectionIdMutex;
|
||||
@@ -131,14 +134,14 @@ QSqlDatabase Database::Connect() {
|
||||
//qLog(Debug) << "Opened database with connection id" << connection_id;
|
||||
|
||||
if (injected_database_name_.isNull()) {
|
||||
db.setDatabaseName(directory_ + "/" + kDatabaseFilename);
|
||||
db.setDatabaseName(directory_ + QLatin1Char('/') + QLatin1String(kDatabaseFilename));
|
||||
}
|
||||
else {
|
||||
db.setDatabaseName(injected_database_name_);
|
||||
}
|
||||
|
||||
if (!db.open()) {
|
||||
app_->AddError("Database: " + db.lastError().text());
|
||||
app_->AddError(QStringLiteral("Database: ") + db.lastError().text());
|
||||
return db;
|
||||
}
|
||||
|
||||
@@ -405,16 +408,16 @@ void Database::ExecSongTablesCommands(QSqlDatabase &db, const QStringList &song_
|
||||
for (const QString &command : commands) {
|
||||
// There are now lots of "songs" tables that need to have the same schema: songs and device_*_songs.
|
||||
// We allow a magic value in the schema files to update all songs tables at once.
|
||||
if (command.contains(kMagicAllSongsTables)) {
|
||||
if (command.contains(QLatin1String(kMagicAllSongsTables))) {
|
||||
for (const QString &table : song_tables) {
|
||||
// Another horrible hack: device songs tables don't have matching _fts tables, so if this command tries to touch one, ignore it.
|
||||
if (table.startsWith(QLatin1String("device_")) && command.contains(QString(kMagicAllSongsTables) + "_fts")) {
|
||||
if (table.startsWith(QLatin1String("device_")) && command.contains(QLatin1String(kMagicAllSongsTables) + QStringLiteral("_fts"))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
qLog(Info) << "Updating" << table << "for" << kMagicAllSongsTables;
|
||||
QString new_command(command);
|
||||
new_command.replace(kMagicAllSongsTables, table);
|
||||
new_command.replace(QLatin1String(kMagicAllSongsTables), table);
|
||||
SqlQuery query(db);
|
||||
query.prepare(new_command);
|
||||
if (!query.Exec()) {
|
||||
@@ -443,7 +446,7 @@ QStringList Database::SongsTables(QSqlDatabase &db, const int schema_version) {
|
||||
|
||||
// look for the tables in the main db
|
||||
for (const QString &table : db.tables()) {
|
||||
if (table == "songs" || table.endsWith(QLatin1String("_songs"))) ret << table;
|
||||
if (table == QStringLiteral("songs") || table.endsWith(QLatin1String("_songs"))) ret << table;
|
||||
}
|
||||
|
||||
// look for the tables in attached dbs
|
||||
@@ -453,7 +456,7 @@ QStringList Database::SongsTables(QSqlDatabase &db, const int schema_version) {
|
||||
q.prepare(QStringLiteral("SELECT NAME FROM %1.sqlite_master WHERE type='table' AND name='songs' OR name LIKE '%songs'").arg(key));
|
||||
if (q.Exec()) {
|
||||
while (q.next()) {
|
||||
QString tab_name = key + "." + q.value(0).toString();
|
||||
QString tab_name = key + QStringLiteral(".") + q.value(0).toString();
|
||||
ret << tab_name;
|
||||
}
|
||||
}
|
||||
@@ -495,13 +498,13 @@ bool Database::IntegrityCheck(const QSqlDatabase &db) {
|
||||
QString message = q.value(0).toString();
|
||||
|
||||
// If no errors are found, a single row with the value "ok" is returned
|
||||
if (message == "ok") {
|
||||
if (message == QStringLiteral("ok")) {
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
if (!error_reported) { app_->AddError(tr("Database corruption detected.")); }
|
||||
app_->AddError("Database: " + message);
|
||||
app_->AddError(QStringLiteral("Database: ") + message);
|
||||
error_reported = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ class Database : public QObject {
|
||||
explicit Database(Application *app, QObject *parent = nullptr, const QString &database_name = QString());
|
||||
~Database() override;
|
||||
|
||||
static const int kSchemaVersion;
|
||||
|
||||
struct AttachedDatabase {
|
||||
AttachedDatabase() {}
|
||||
AttachedDatabase(const QString &filename, const QString &schema, bool is_temporary)
|
||||
@@ -60,11 +62,6 @@ class Database : public QObject {
|
||||
bool is_temporary_;
|
||||
};
|
||||
|
||||
static const int kSchemaVersion;
|
||||
static const int kMinSupportedSchemaVersion;
|
||||
static const char *kDatabaseFilename;
|
||||
static const char *kMagicAllSongsTables;
|
||||
|
||||
void ExitAsync();
|
||||
QSqlDatabase Connect();
|
||||
void Close();
|
||||
|
||||
@@ -39,13 +39,13 @@ FilesystemMusicStorage::FilesystemMusicStorage(const Song::Source source, const
|
||||
bool FilesystemMusicStorage::CopyToStorage(const CopyJob &job, QString &error_text) {
|
||||
|
||||
const QFileInfo src = QFileInfo(job.source_);
|
||||
const QFileInfo dest = QFileInfo(root_ + "/" + job.destination_);
|
||||
const QFileInfo dest = QFileInfo(root_ + QLatin1Char('/') + job.destination_);
|
||||
|
||||
QFileInfo cover_src;
|
||||
QFileInfo cover_dest;
|
||||
if (job.albumcover_ && !job.cover_source_.isEmpty() && !job.cover_dest_.isEmpty()) {
|
||||
cover_src = QFileInfo(job.cover_source_);
|
||||
cover_dest = QFileInfo(root_ + "/" + job.cover_dest_);
|
||||
cover_dest = QFileInfo(root_ + QLatin1Char('/') + job.cover_dest_);
|
||||
}
|
||||
|
||||
// Don't do anything if the destination is the same as the source
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "settings.h"
|
||||
#include "iconmapper.h"
|
||||
#include "settings/appearancesettingspage.h"
|
||||
#include "iconloader.h"
|
||||
@@ -39,14 +40,14 @@ bool IconLoader::custom_icons_ = false;
|
||||
void IconLoader::Init() {
|
||||
|
||||
#if !defined(Q_OS_MACOS) && !defined(Q_OS_WIN)
|
||||
QSettings s;
|
||||
Settings s;
|
||||
s.beginGroup(AppearanceSettingsPage::kSettingsGroup);
|
||||
system_icons_ = s.value("system_icons", false).toBool();
|
||||
s.endGroup();
|
||||
#endif
|
||||
|
||||
QDir dir;
|
||||
if (dir.exists(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/icons")) {
|
||||
if (dir.exists(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/icons"))) {
|
||||
custom_icons_ = true;
|
||||
}
|
||||
|
||||
@@ -118,7 +119,7 @@ QIcon IconLoader::Load(const QString &name, const bool system_icon, const int fi
|
||||
}
|
||||
|
||||
if (custom_icons_) {
|
||||
QString custom_icon_path = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/icons/%1x%2/%3.png";
|
||||
QString custom_icon_path = QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/icons/%1x%2/%3.png");
|
||||
for (int s : sizes) {
|
||||
QString filename(custom_icon_path.arg(s).arg(s).arg(name));
|
||||
if (QFile::exists(filename)) ret.addFile(filename, QSize(s, s));
|
||||
|
||||
@@ -38,100 +38,100 @@ struct IconProperties {
|
||||
|
||||
static const QMap<QString, IconProperties> iconmapper_ = { // clazy:exclude=non-pod-global-static
|
||||
|
||||
{ "albums", { {"media-optical"}} },
|
||||
{ "alsa", { {}} },
|
||||
{ "application-exit", { {}} },
|
||||
{ "applications-internet", { {}} },
|
||||
{ "bluetooth", { {"preferences-system-bluetooth", "bluetooth-active"}} },
|
||||
{ "cdcase", { {"cdcover", "media-optical"}} },
|
||||
{ "media-optical", { {"cd"}} },
|
||||
{ "configure", { {}} },
|
||||
{ "device-ipod-nano", { {}} },
|
||||
{ "device-ipod", { {}} },
|
||||
{ "device-phone", { {}} },
|
||||
{ "device", { {"drive-removable-media-usb-pendrive"}} },
|
||||
{ "device-usb-drive", { {}} },
|
||||
{ "device-usb-flash", { {}} },
|
||||
{ "dialog-error", { {}} },
|
||||
{ "dialog-information", { {}} },
|
||||
{ "dialog-ok-apply", { {}} },
|
||||
{ "dialog-password", { {}} },
|
||||
{ "dialog-warning", { {}} },
|
||||
{ "document-download", { {"download"}} },
|
||||
{ "document-new", { {}} },
|
||||
{ "document-open-folder", { {}} },
|
||||
{ "document-open", { {}} },
|
||||
{ "document-save", { {}} },
|
||||
{ "document-search", { {}} },
|
||||
{ "document-open-remote", { {}} },
|
||||
{ "download", { {"applications-internet", "network-workgroup"}} },
|
||||
{ "edit-clear-list", { {"edit-clear-list","edit-clear-all"}} },
|
||||
{ "edit-clear-locationbar-ltr", { {"edit-clear-locationbar-ltr"}} },
|
||||
{ "edit-copy", { {}} },
|
||||
{ "edit-delete", { {}} },
|
||||
{ "edit-find", { {}} },
|
||||
{ "edit-redo", { {}} },
|
||||
{ "edit-rename", { {}} },
|
||||
{ "edit-undo", { {}} },
|
||||
{ "electrocompaniet", { {}} },
|
||||
{ "equalizer", { {"view-media-equalizer"}} },
|
||||
{ "folder-new", { {}} },
|
||||
{ "folder", { {}} },
|
||||
{ "folder-sound", { {"folder-music"}} },
|
||||
{ "footsteps", { {"go-jump"}} },
|
||||
{ "go-down", { {}} },
|
||||
{ "go-home", { {}} },
|
||||
{ "go-jump", { {}} },
|
||||
{ "go-next", { {}} },
|
||||
{ "go-previous", { {}} },
|
||||
{ "go-up", { {}} },
|
||||
{ "gstreamer", { {"phonon-gstreamer"}} },
|
||||
{ "headset", { {"audio-headset"}} },
|
||||
{ "help-hint", { {}} },
|
||||
{ "intel", { {}} },
|
||||
{ "jack", { {"audio-input-line"}} },
|
||||
{ "keyboard", { {"input-keyboard"}} },
|
||||
{ "list-add", { {}} },
|
||||
{ "list-remove", { {}} },
|
||||
{ "love", { {"heart", "emblem-favorite"}} },
|
||||
{ "mcintosh-player", { {}} },
|
||||
{ "mcintosh", { {}} },
|
||||
{ "mcintosh-text", { {}} },
|
||||
{ "media-eject", { {}} },
|
||||
{ "media-playback-pause", { {"media-pause"}} },
|
||||
{ "media-playlist-repeat", { {}} },
|
||||
{ "media-playlist-shuffle", { {""}} },
|
||||
{ "media-playback-start", { {"media-play", "media-playback-playing"}} },
|
||||
{ "media-seek-backward", { {}} },
|
||||
{ "media-seek-forward", { {}} },
|
||||
{ "media-skip-backward", { {}} },
|
||||
{ "media-skip-forward", { {}} },
|
||||
{ "media-playback-stop", { {"media-stop"}} },
|
||||
{ "moodbar", { {"preferences-desktop-icons"}} },
|
||||
{ "nvidia", { {}} },
|
||||
{ "pulseaudio", { {}} },
|
||||
{ "realtek", { {}} },
|
||||
{ "scrobble-disabled", { {}} },
|
||||
{ "scrobble", { {"love"}} },
|
||||
{ "search", { {}} },
|
||||
{ "soundcard", { {"audiocard", "audio-card"}} },
|
||||
{ "speaker", { {}} },
|
||||
{ "star-grey", { {}} },
|
||||
{ "star", { {}} },
|
||||
{ "strawberry", { {}} },
|
||||
{ "subsonic", { {}} },
|
||||
{ "tidal", { {}} },
|
||||
{ "tools-wizard", { {}} },
|
||||
{ "view-choose", { {}} },
|
||||
{ "view-fullscreen", { {}} },
|
||||
{ "view-media-lyrics", { {}} },
|
||||
{ "view-media-playlist", { {}} },
|
||||
{ "view-media-visualization", { {"preferences-desktop-theme"}} },
|
||||
{ "view-refresh", { {}} },
|
||||
{ "library-music", { {"vinyl"}} },
|
||||
{ "vlc", { {}} },
|
||||
{ "zoom-in", { {}} },
|
||||
{ "zoom-out", { {}, 0, 0 } }
|
||||
{ QStringLiteral("albums"), { {QStringLiteral("media-optical")}} },
|
||||
{ QStringLiteral("alsa"), { {}} },
|
||||
{ QStringLiteral("application-exit"), { {}} },
|
||||
{ QStringLiteral("applications-internet"), { {}} },
|
||||
{ QStringLiteral("bluetooth"), { {QStringLiteral("preferences-system-bluetooth"), QStringLiteral("bluetooth-active")}} },
|
||||
{ QStringLiteral("cdcase"), { {QStringLiteral("cdcover"), QStringLiteral("media-optical")}} },
|
||||
{ QStringLiteral("media-optical"), { {QStringLiteral("cd")}} },
|
||||
{ QStringLiteral("configure"), { {}} },
|
||||
{ QStringLiteral("device-ipod-nano"), { {}} },
|
||||
{ QStringLiteral("device-ipod"), { {}} },
|
||||
{ QStringLiteral("device-phone"), { {}} },
|
||||
{ QStringLiteral("device"), { {QStringLiteral("drive-removable-media-usb-pendrive")}} },
|
||||
{ QStringLiteral("device-usb-drive"), { {}} },
|
||||
{ QStringLiteral("device-usb-flash"), { {}} },
|
||||
{ QStringLiteral("dialog-error"), { {}} },
|
||||
{ QStringLiteral("dialog-information"), { {}} },
|
||||
{ QStringLiteral("dialog-ok-apply"), { {}} },
|
||||
{ QStringLiteral("dialog-password"), { {}} },
|
||||
{ QStringLiteral("dialog-warning"), { {}} },
|
||||
{ QStringLiteral("document-download"), { {QStringLiteral("download")}} },
|
||||
{ QStringLiteral("document-new"), { {}} },
|
||||
{ QStringLiteral("document-open-folder"), { {}} },
|
||||
{ QStringLiteral("document-open"), { {}} },
|
||||
{ QStringLiteral("document-save"), { {}} },
|
||||
{ QStringLiteral("document-search"), { {}} },
|
||||
{ QStringLiteral("document-open-remote"), { {}} },
|
||||
{ QStringLiteral("download"), { {QStringLiteral("applications-internet"), QStringLiteral("network-workgroup")}} },
|
||||
{ QStringLiteral("edit-clear-list"), { {QStringLiteral("edit-clear-list"), QStringLiteral("edit-clear-all")}} },
|
||||
{ QStringLiteral("edit-clear-locationbar-ltr"), { {QStringLiteral("edit-clear-locationbar-ltr")}} },
|
||||
{ QStringLiteral("edit-copy"), { {}} },
|
||||
{ QStringLiteral("edit-delete"), { {}} },
|
||||
{ QStringLiteral("edit-find"), { {}} },
|
||||
{ QStringLiteral("edit-redo"), { {}} },
|
||||
{ QStringLiteral("edit-rename"), { {}} },
|
||||
{ QStringLiteral("edit-undo"), { {}} },
|
||||
{ QStringLiteral("electrocompaniet"), { {}} },
|
||||
{ QStringLiteral("equalizer"), { {QStringLiteral("view-media-equalizer")}} },
|
||||
{ QStringLiteral("folder-new"), { {}} },
|
||||
{ QStringLiteral("folder"), { {}} },
|
||||
{ QStringLiteral("folder-sound"), { {QStringLiteral("folder-music")}} },
|
||||
{ QStringLiteral("footsteps"), { {QStringLiteral("go-jump")}} },
|
||||
{ QStringLiteral("go-down"), { {}} },
|
||||
{ QStringLiteral("go-home"), { {}} },
|
||||
{ QStringLiteral("go-jump"), { {}} },
|
||||
{ QStringLiteral("go-next"), { {}} },
|
||||
{ QStringLiteral("go-previous"), { {}} },
|
||||
{ QStringLiteral("go-up"), { {}} },
|
||||
{ QStringLiteral("gstreamer"), { {QStringLiteral("phonon-gstreamer")}} },
|
||||
{ QStringLiteral("headset"), { {QStringLiteral("audio-headset")}} },
|
||||
{ QStringLiteral("help-hint"), { {}} },
|
||||
{ QStringLiteral("intel"), { {}} },
|
||||
{ QStringLiteral("jack"), { {QStringLiteral("audio-input-line")}} },
|
||||
{ QStringLiteral("keyboard"), { {QStringLiteral("input-keyboard")}} },
|
||||
{ QStringLiteral("list-add"), { {}} },
|
||||
{ QStringLiteral("list-remove"), { {}} },
|
||||
{ QStringLiteral("love"), { {QStringLiteral("heart"), QStringLiteral("emblem-favorite")}} },
|
||||
{ QStringLiteral("mcintosh-player"), { {}} },
|
||||
{ QStringLiteral("mcintosh"), { {}} },
|
||||
{ QStringLiteral("mcintosh-text"), { {}} },
|
||||
{ QStringLiteral("media-eject"), { {}} },
|
||||
{ QStringLiteral("media-playback-pause"), { {QStringLiteral("media-pause")}} },
|
||||
{ QStringLiteral("media-playlist-repeat"), { {}} },
|
||||
{ QStringLiteral("media-playlist-shuffle"), { {QLatin1String("")}} },
|
||||
{ QStringLiteral("media-playback-start"), { {QStringLiteral("media-play"), QStringLiteral("media-playback-playing")}} },
|
||||
{ QStringLiteral("media-seek-backward"), { {}} },
|
||||
{ QStringLiteral("media-seek-forward"), { {}} },
|
||||
{ QStringLiteral("media-skip-backward"), { {}} },
|
||||
{ QStringLiteral("media-skip-forward"), { {}} },
|
||||
{ QStringLiteral("media-playback-stop"), { {QStringLiteral("media-stop")}} },
|
||||
{ QStringLiteral("moodbar"), { {QStringLiteral("preferences-desktop-icons")}} },
|
||||
{ QStringLiteral("nvidia"), { {}} },
|
||||
{ QStringLiteral("pulseaudio"), { {}} },
|
||||
{ QStringLiteral("realtek"), { {}} },
|
||||
{ QStringLiteral("scrobble-disabled"), { {}} },
|
||||
{ QStringLiteral("scrobble"), { {QStringLiteral("love")}} },
|
||||
{ QStringLiteral("search"), { {}} },
|
||||
{ QStringLiteral("soundcard"), { {QStringLiteral("audiocard"), QStringLiteral("audio-card")}} },
|
||||
{ QStringLiteral("speaker"), { {}} },
|
||||
{ QStringLiteral("star-grey"), { {}} },
|
||||
{ QStringLiteral("star"), { {}} },
|
||||
{ QStringLiteral("strawberry"), { {}} },
|
||||
{ QStringLiteral("subsonic"), { {}} },
|
||||
{ QStringLiteral("tidal"), { {}} },
|
||||
{ QStringLiteral("tools-wizard"), { {}} },
|
||||
{ QStringLiteral("view-choose"), { {}} },
|
||||
{ QStringLiteral("view-fullscreen"), { {}} },
|
||||
{ QStringLiteral("view-media-lyrics"), { {}} },
|
||||
{ QStringLiteral("view-media-playlist"), { {}} },
|
||||
{ QStringLiteral("view-media-visualization"), { {QStringLiteral("preferences-desktop-theme")}} },
|
||||
{ QStringLiteral("view-refresh"), { {}} },
|
||||
{ QStringLiteral("library-music"), { {QStringLiteral("vinyl")}} },
|
||||
{ QStringLiteral("vlc"), { {}} },
|
||||
{ QStringLiteral("zoom-in"), { {}} },
|
||||
{ QStringLiteral("zoom-out"), { {}, 0, 0 } }
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -60,13 +60,12 @@
|
||||
#include <QDir>
|
||||
#include <QEvent>
|
||||
#include <QFile>
|
||||
#include <QSettings>
|
||||
|
||||
#include <QtDebug>
|
||||
|
||||
QDebug operator<<(QDebug dbg, NSObject *object) {
|
||||
|
||||
QString ns_format = [[NSString stringWithFormat:@"%@", object] UTF8String];
|
||||
const QString ns_format = QString::fromUtf8([[NSString stringWithFormat:@"%@", object] UTF8String]);
|
||||
dbg.nospace() << ns_format;
|
||||
return dbg.space();
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ void MacFSListener::EventStreamCallback(ConstFSEventStreamRef stream, void *user
|
||||
for (size_t i = 0; i < num_events; ++i) {
|
||||
QString path = QString::fromUtf8(paths[i]);
|
||||
qLog(Debug) << "Something changed at:" << path;
|
||||
while (path.endsWith('/')) {
|
||||
while (path.endsWith(QLatin1Char('/'))) {
|
||||
path.chop(1);
|
||||
}
|
||||
emit me->PathChanged(path);
|
||||
|
||||
@@ -70,7 +70,7 @@ class MacSystemTrayIconPrivate {
|
||||
MacSystemTrayIconPrivate() {
|
||||
dock_menu_ = [[NSMenu alloc] initWithTitle:@"DockMenu"];
|
||||
|
||||
QString title = QT_TR_NOOP("Now Playing");
|
||||
QString title = QT_TR_NOOP(QStringLiteral("Now Playing"));
|
||||
NSString *t = [[NSString alloc] initWithUTF8String:title.toUtf8().constData()];
|
||||
now_playing_ = [[NSMenuItem alloc] initWithTitle:t action:nullptr keyEquivalent:@""];
|
||||
now_playing_artist_ = [[NSMenuItem alloc] initWithTitle:@"Nothing to see here" action:nullptr keyEquivalent:@""];
|
||||
@@ -89,7 +89,7 @@ class MacSystemTrayIconPrivate {
|
||||
|
||||
void AddMenuItem(QAction *action) {
|
||||
// Strip accelarators from name.
|
||||
QString text = action->text().remove("&");
|
||||
QString text = action->text().remove(QLatin1Char('&'));
|
||||
NSString *title = [[NSString alloc] initWithUTF8String: text.toUtf8().constData()];
|
||||
// Create an object that can receive user clicks and pass them on to the QAction.
|
||||
Target *target = [[Target alloc] initWithQAction:action];
|
||||
@@ -152,10 +152,10 @@ class MacSystemTrayIconPrivate {
|
||||
|
||||
SystemTrayIcon::SystemTrayIcon(QObject *parent)
|
||||
: QObject(parent),
|
||||
normal_icon_(QPixmap(":/pictures/strawberry.png").scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation)),
|
||||
grey_icon_(QPixmap(":/pictures/strawberry-grey.png").scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation)),
|
||||
playing_icon_(":/pictures/tiny-play.png"),
|
||||
paused_icon_(":/pictures/tiny-pause.png"),
|
||||
normal_icon_(QPixmap(QStringLiteral(":/pictures/strawberry.png")).scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation)),
|
||||
grey_icon_(QPixmap(QStringLiteral(":/pictures/strawberry-grey.png")).scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation)),
|
||||
playing_icon_(QStringLiteral(":/pictures/tiny-play.png")),
|
||||
paused_icon_(QStringLiteral(":/pictures/tiny-pause.png")),
|
||||
trayicon_progress_(false),
|
||||
song_progress_(0) {
|
||||
|
||||
|
||||
@@ -104,6 +104,7 @@
|
||||
# include "qtsystemtrayicon.h"
|
||||
#endif
|
||||
#include "networkaccessmanager.h"
|
||||
#include "settings.h"
|
||||
#include "utilities/envutils.h"
|
||||
#include "utilities/filemanagerutils.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
@@ -301,13 +302,13 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
|
||||
}),
|
||||
smartplaylists_view_(new SmartPlaylistsViewContainer(app, this)),
|
||||
#ifdef HAVE_SUBSONIC
|
||||
subsonic_view_(new InternetSongsView(app_, app->internet_services()->ServiceBySource(Song::Source::Subsonic), SubsonicSettingsPage::kSettingsGroup, SettingsDialog::Page::Subsonic, this)),
|
||||
subsonic_view_(new InternetSongsView(app_, app->internet_services()->ServiceBySource(Song::Source::Subsonic), QLatin1String(SubsonicSettingsPage::kSettingsGroup), SettingsDialog::Page::Subsonic, this)),
|
||||
#endif
|
||||
#ifdef HAVE_TIDAL
|
||||
tidal_view_(new InternetTabsView(app_, app->internet_services()->ServiceBySource(Song::Source::Tidal), TidalSettingsPage::kSettingsGroup, SettingsDialog::Page::Tidal, this)),
|
||||
tidal_view_(new InternetTabsView(app_, app->internet_services()->ServiceBySource(Song::Source::Tidal), QLatin1String(TidalSettingsPage::kSettingsGroup), SettingsDialog::Page::Tidal, this)),
|
||||
#endif
|
||||
#ifdef HAVE_QOBUZ
|
||||
qobuz_view_(new InternetTabsView(app_, app->internet_services()->ServiceBySource(Song::Source::Qobuz), QobuzSettingsPage::kSettingsGroup, SettingsDialog::Page::Qobuz, this)),
|
||||
qobuz_view_(new InternetTabsView(app_, app->internet_services()->ServiceBySource(Song::Source::Qobuz), QLatin1String(QobuzSettingsPage::kSettingsGroup), SettingsDialog::Page::Qobuz, this)),
|
||||
#endif
|
||||
radio_view_(new RadioViewContainer(this)),
|
||||
lastfm_import_dialog_(new LastFMImportDialog(app_->lastfm_import(), this)),
|
||||
@@ -398,7 +399,7 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
|
||||
// Add the playing widget to the fancy tab widget
|
||||
ui_->tabs->addBottomWidget(ui_->widget_playing);
|
||||
//ui_->tabs->SetBackgroundPixmap(QPixmap(":/pictures/strawberry-background.png"));
|
||||
ui_->tabs->Load(kSettingsGroup);
|
||||
ui_->tabs->Load(QLatin1String(kSettingsGroup));
|
||||
|
||||
track_position_timer_->setInterval(kTrackPositionUpdateTimeMs);
|
||||
QObject::connect(track_position_timer_, &QTimer::timeout, this, &MainWindow::UpdateTrackPosition);
|
||||
@@ -448,7 +449,7 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
|
||||
// Help menu
|
||||
|
||||
ui_->action_about_strawberry->setIcon(IconLoader::Load(QStringLiteral("strawberry")));
|
||||
ui_->action_about_qt->setIcon(QIcon(":/qt-project.org/qmessagebox/images/qtlogo-64.png"));
|
||||
ui_->action_about_qt->setIcon(QIcon(QStringLiteral(":/qt-project.org/qmessagebox/images/qtlogo-64.png")));
|
||||
|
||||
// Music menu
|
||||
|
||||
@@ -690,7 +691,7 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
|
||||
|
||||
QAction *collection_config_action = new QAction(IconLoader::Load(QStringLiteral("configure")), tr("Configure collection..."), this);
|
||||
QObject::connect(collection_config_action, &QAction::triggered, this, &MainWindow::ShowCollectionConfig);
|
||||
collection_view_->filter_widget()->SetSettingsGroup(CollectionSettingsPage::kSettingsGroup);
|
||||
collection_view_->filter_widget()->SetSettingsGroup(QLatin1String(CollectionSettingsPage::kSettingsGroup));
|
||||
collection_view_->filter_widget()->Init(app_->collection()->model());
|
||||
|
||||
QAction *separator = new QAction(this);
|
||||
@@ -952,7 +953,7 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
|
||||
#else
|
||||
BehaviourSettingsPage::StartupBehaviour startupbehaviour = BehaviourSettingsPage::StartupBehaviour::Remember;
|
||||
{
|
||||
QSettings s;
|
||||
Settings s;
|
||||
s.beginGroup(BehaviourSettingsPage::kSettingsGroup);
|
||||
startupbehaviour = static_cast<BehaviourSettingsPage::StartupBehaviour>(s.value("startupbehaviour", static_cast<int>(BehaviourSettingsPage::StartupBehaviour::Remember)).toInt());
|
||||
s.endGroup();
|
||||
@@ -975,7 +976,7 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
|
||||
}
|
||||
[[fallthrough]];
|
||||
case BehaviourSettingsPage::StartupBehaviour::Remember:
|
||||
default: {
|
||||
default:{
|
||||
|
||||
was_maximized_ = settings_.value("maximized", true).toBool();
|
||||
if (was_maximized_) setWindowState(windowState() | Qt::WindowMaximized);
|
||||
@@ -1024,18 +1025,18 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
|
||||
}
|
||||
|
||||
#ifdef HAVE_QTSPARKLE
|
||||
QUrl sparkle_url(QTSPARKLE_URL);
|
||||
QUrl sparkle_url(QString::fromLatin1(QTSPARKLE_URL));
|
||||
if (!sparkle_url.isEmpty()) {
|
||||
qLog(Debug) << "Creating Qt Sparkle updater";
|
||||
qtsparkle::Updater *updater = new qtsparkle::Updater(sparkle_url, this);
|
||||
updater->SetVersion(STRAWBERRY_VERSION_PACKAGE);
|
||||
updater->SetVersion(QStringLiteral(STRAWBERRY_VERSION_PACKAGE));
|
||||
QObject::connect(check_updates, &QAction::triggered, updater, &qtsparkle::Updater::CheckNow);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
if (!Utilities::GetEnv(QStringLiteral("SNAP")).isEmpty() && !Utilities::GetEnv(QStringLiteral("SNAP_NAME")).isEmpty()) {
|
||||
QSettings s;
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
const bool ignore_snap = s.value("ignore_snap", false).toBool();
|
||||
s.endGroup();
|
||||
@@ -1049,30 +1050,30 @@ MainWindow::MainWindow(Application *app, SharedPtr<SystemTrayIcon> tray_icon, OS
|
||||
|
||||
#if defined(Q_OS_MACOS)
|
||||
if (Utilities::ProcessTranslated()) {
|
||||
QSettings s;
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
const bool ignore_rosetta = s.value("ignore_rosetta", false).toBool();
|
||||
s.endGroup();
|
||||
if (!ignore_rosetta) {
|
||||
MessageDialog *rosetta_message = new MessageDialog(this);
|
||||
rosetta_message->set_settings_group(kSettingsGroup);
|
||||
rosetta_message->set_do_not_show_message_again("ignore_rosetta");
|
||||
rosetta_message->set_settings_group(QLatin1String(kSettingsGroup));
|
||||
rosetta_message->set_do_not_show_message_again(QStringLiteral("ignore_rosetta"));
|
||||
rosetta_message->setAttribute(Qt::WA_DeleteOnClose);
|
||||
rosetta_message->ShowMessage(tr("Strawberry running under Rosetta"), tr("You are running Strawberry under Rosetta. Running Strawberry under Rosetta is unsupported and known to have issues. You should download Strawberry for the correct CPU architecture from %1").arg("<a href=\"https://downloads.strawberrymusicplayer.org/\">downloads.strawberrymusicplayer.org</a>"), IconLoader::Load("dialog-warning"));
|
||||
rosetta_message->ShowMessage(tr("Strawberry running under Rosetta"), tr("You are running Strawberry under Rosetta. Running Strawberry under Rosetta is unsupported and known to have issues. You should download Strawberry for the correct CPU architecture from %1").arg(QStringLiteral("<a href=\"https://downloads.strawberrymusicplayer.org/\">downloads.strawberrymusicplayer.org</a>")), IconLoader::Load(QStringLiteral("dialog-warning")));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
{
|
||||
QSettings s;
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
const QString do_not_show_sponsor_message_key = QStringLiteral("do_not_show_sponsor_message");
|
||||
constexpr char do_not_show_sponsor_message_key[] = "do_not_show_sponsor_message";
|
||||
const bool do_not_show_sponsor_message = s.value(do_not_show_sponsor_message_key, false).toBool();
|
||||
s.endGroup();
|
||||
if (!do_not_show_sponsor_message) {
|
||||
MessageDialog *sponsor_message = new MessageDialog(this);
|
||||
sponsor_message->set_settings_group(kSettingsGroup);
|
||||
sponsor_message->set_do_not_show_message_again(do_not_show_sponsor_message_key);
|
||||
sponsor_message->set_settings_group(QLatin1String(kSettingsGroup));
|
||||
sponsor_message->set_do_not_show_message_again(QLatin1String(do_not_show_sponsor_message_key));
|
||||
sponsor_message->setAttribute(Qt::WA_DeleteOnClose);
|
||||
sponsor_message->ShowMessage(tr("Sponsoring Strawberry"), tr("Strawberry is free and open source software. If you like Strawberry, please consider sponsoring the project. For more information about sponsorship see our website %1").arg(QStringLiteral("<a href= \"https://www.strawberrymusicplayer.org/\">www.strawberrymusicplayer.org</a>")), IconLoader::Load(QStringLiteral("dialog-information")));
|
||||
}
|
||||
@@ -1089,7 +1090,7 @@ MainWindow::~MainWindow() {
|
||||
|
||||
void MainWindow::ReloadSettings() {
|
||||
|
||||
QSettings s;
|
||||
Settings s;
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
constexpr bool keeprunning_available = true;
|
||||
@@ -1252,7 +1253,7 @@ void MainWindow::SaveSettings() {
|
||||
SaveGeometry();
|
||||
SavePlaybackStatus();
|
||||
app_->player()->SaveVolume();
|
||||
ui_->tabs->SaveSettings(kSettingsGroup);
|
||||
ui_->tabs->SaveSettings(QLatin1String(kSettingsGroup));
|
||||
ui_->playlist->view()->SaveSettings();
|
||||
app_->scrobbler()->WriteCache();
|
||||
|
||||
@@ -1507,7 +1508,7 @@ void MainWindow::SaveGeometry() {
|
||||
|
||||
void MainWindow::SavePlaybackStatus() {
|
||||
|
||||
QSettings s;
|
||||
Settings s;
|
||||
|
||||
s.beginGroup(Player::kSettingsGroup);
|
||||
s.setValue("playback_state", static_cast<int>(app_->player()->GetState()));
|
||||
@@ -1526,7 +1527,7 @@ void MainWindow::SavePlaybackStatus() {
|
||||
|
||||
void MainWindow::LoadPlaybackStatus() {
|
||||
|
||||
QSettings s;
|
||||
Settings s;
|
||||
|
||||
s.beginGroup(BehaviourSettingsPage::kSettingsGroup);
|
||||
const bool resume_playback = s.value("resumeplayback", false).toBool();
|
||||
@@ -1550,7 +1551,7 @@ void MainWindow::ResumePlayback() {
|
||||
|
||||
qLog(Debug) << "Resuming playback";
|
||||
|
||||
QSettings s;
|
||||
Settings s;
|
||||
s.beginGroup(Player::kSettingsGroup);
|
||||
const EngineBase::State playback_state = static_cast<EngineBase::State>(s.value("playback_state", static_cast<int>(EngineBase::State::Empty)).toInt());
|
||||
int playback_playlist = s.value("playback_playlist", -1).toInt();
|
||||
@@ -2054,7 +2055,7 @@ void MainWindow::PlaylistRightClick(const QPoint global_pos, const QModelIndex &
|
||||
|
||||
QString column_name = Playlist::column_name(column);
|
||||
QString column_value = app_->playlist_manager()->current()->data(source_index).toString();
|
||||
if (column_value.length() > 25) column_value = column_value.left(25) + "...";
|
||||
if (column_value.length() > 25) column_value = column_value.left(25) + QStringLiteral("...");
|
||||
|
||||
ui_->action_selection_set_value->setText(tr("Set %1 to \"%2\"...").arg(column_name.toLower(), column_value));
|
||||
ui_->action_edit_value->setText(tr("Edit tag \"%1\"...").arg(column_name));
|
||||
@@ -2297,7 +2298,7 @@ void MainWindow::AddFile() {
|
||||
PlaylistParser parser(app_->collection_backend());
|
||||
|
||||
// Show dialog
|
||||
QStringList file_names = QFileDialog::getOpenFileNames(this, tr("Add file"), directory, QStringLiteral("%1 (%2);;%3;;%4").arg(tr("Music"), FileView::kFileFilter, parser.filters(PlaylistParser::Type::Load), tr(kAllFilesFilterSpec)));
|
||||
QStringList file_names = QFileDialog::getOpenFileNames(this, tr("Add file"), directory, QStringLiteral("%1 (%2);;%3;;%4").arg(tr("Music"), QLatin1String(FileView::kFileFilter), parser.filters(PlaylistParser::Type::Load), tr(kAllFilesFilterSpec)));
|
||||
|
||||
if (file_names.isEmpty()) return;
|
||||
|
||||
@@ -2341,7 +2342,7 @@ void MainWindow::AddCDTracks() {
|
||||
MimeData *mimedata = new MimeData;
|
||||
// We are putting empty data, but we specify cdda mimetype to indicate that we want to load audio cd tracks
|
||||
mimedata->open_in_new_playlist_ = true;
|
||||
mimedata->setData(Playlist::kCddaMimeType, QByteArray());
|
||||
mimedata->setData(QLatin1String(Playlist::kCddaMimeType), QByteArray());
|
||||
AddToPlaylist(mimedata);
|
||||
|
||||
}
|
||||
@@ -2375,7 +2376,7 @@ void MainWindow::ShowInCollection() {
|
||||
}
|
||||
QString search;
|
||||
if (!songs.isEmpty()) {
|
||||
search = "artist:" + songs.first().artist() + " album:" + songs.first().album();
|
||||
search = QStringLiteral("artist:") + songs.first().artist() + QStringLiteral(" album:") + songs.first().album();
|
||||
}
|
||||
collection_view_->filter_widget()->ShowInCollection(search);
|
||||
|
||||
@@ -2468,9 +2469,9 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
break;
|
||||
|
||||
case CommandlineOptions::PlayerAction::ResizeWindow:{
|
||||
if (options.window_size().contains('x') && options.window_size().length() >= 4) {
|
||||
QString str_w = options.window_size().left(options.window_size().indexOf('x'));
|
||||
QString str_h = options.window_size().right(options.window_size().length() - options.window_size().indexOf('x') - 1);
|
||||
if (options.window_size().contains(QLatin1Char('x')) && options.window_size().length() >= 4) {
|
||||
QString str_w = options.window_size().left(options.window_size().indexOf(QLatin1Char('x')));
|
||||
QString str_h = options.window_size().right(options.window_size().length() - options.window_size().indexOf(QLatin1Char('x')) - 1);
|
||||
bool w_ok = false;
|
||||
bool h_ok = false;
|
||||
int w = str_w.toInt(&w_ok);
|
||||
@@ -2509,7 +2510,7 @@ void MainWindow::CommandlineOptionsReceived(const CommandlineOptions &options) {
|
||||
|
||||
#ifdef HAVE_TIDAL
|
||||
for (const QUrl &url : options.urls()) {
|
||||
if (url.scheme() == "tidal" && url.host() == "login") {
|
||||
if (url.scheme() == QStringLiteral("tidal") && url.host() == QStringLiteral("login")) {
|
||||
emit AuthorizationUrlReceived(url);
|
||||
return;
|
||||
}
|
||||
@@ -2951,11 +2952,11 @@ void MainWindow::CheckFullRescanRevisions() {
|
||||
|
||||
// if we have any...
|
||||
if (!reasons.isEmpty()) {
|
||||
QString message = tr("The version of Strawberry you've just updated to requires a full collection rescan because of the new features listed below:") + "<ul>";
|
||||
QString message = tr("The version of Strawberry you've just updated to requires a full collection rescan because of the new features listed below:") + QStringLiteral("<ul>");
|
||||
for (const QString &reason : reasons) {
|
||||
message += ("<li>" + reason + "</li>");
|
||||
message += QStringLiteral("<li>") + reason + QStringLiteral("</li>");
|
||||
}
|
||||
message += "</ul>" + tr("Would you like to run a full rescan right now?");
|
||||
message += QStringLiteral("</ul>") + tr("Would you like to run a full rescan right now?");
|
||||
if (QMessageBox::question(this, tr("Collection rescan notice"), message, QMessageBox::Yes, QMessageBox::No) == QMessageBox::Yes) {
|
||||
app_->collection()->FullScan();
|
||||
}
|
||||
@@ -3262,7 +3263,7 @@ void MainWindow::PlaylistDelete() {
|
||||
app_->player()->Next();
|
||||
}
|
||||
|
||||
SharedPtr<MusicStorage> storage = make_shared<FilesystemMusicStorage>(Song::Source::LocalFile, "/");
|
||||
SharedPtr<MusicStorage> storage = make_shared<FilesystemMusicStorage>(Song::Source::LocalFile, QStringLiteral("/"));
|
||||
DeleteFiles *delete_files = new DeleteFiles(app_->task_manager(), storage, true);
|
||||
QObject::connect(delete_files, &DeleteFiles::Finished, this, &MainWindow::DeleteFilesFinished);
|
||||
delete_files->Start(selected_songs);
|
||||
|
||||
@@ -52,6 +52,7 @@
|
||||
#include "platforminterface.h"
|
||||
#include "song.h"
|
||||
#include "tagreaderclient.h"
|
||||
#include "settings.h"
|
||||
#include "engine/enginebase.h"
|
||||
#include "osd/osdbase.h"
|
||||
#include "playlist/playlist.h"
|
||||
@@ -379,7 +380,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||
|
||||
QTimer *track_position_timer_;
|
||||
QTimer *track_slider_timer_;
|
||||
QSettings settings_;
|
||||
Settings settings_;
|
||||
|
||||
bool keep_running_;
|
||||
bool playing_widget_;
|
||||
|
||||
@@ -94,9 +94,9 @@ const QDBusArgument &operator>>(const QDBusArgument &arg, MaybePlaylist &playlis
|
||||
|
||||
namespace mpris {
|
||||
|
||||
const char *Mpris2::kMprisObjectPath = "/org/mpris/MediaPlayer2";
|
||||
const char *Mpris2::kServiceName = "org.mpris.MediaPlayer2.strawberry";
|
||||
const char *Mpris2::kFreedesktopPath = "org.freedesktop.DBus.Properties";
|
||||
constexpr char kMprisObjectPath[] = "/org/mpris/MediaPlayer2";
|
||||
constexpr char kServiceName[] = "org.mpris.MediaPlayer2.strawberry";
|
||||
constexpr char kFreedesktopPath[] = "org.freedesktop.DBus.Properties";
|
||||
|
||||
Mpris2::Mpris2(Application *app, QObject *parent)
|
||||
: QObject(parent),
|
||||
@@ -108,13 +108,13 @@ Mpris2::Mpris2(Application *app, QObject *parent)
|
||||
new Mpris2Player(this);
|
||||
new Mpris2Playlists(this);
|
||||
|
||||
if (!QDBusConnection::sessionBus().registerService(kServiceName)) {
|
||||
qLog(Warning) << "Failed to register" << QString(kServiceName) << "on the session bus";
|
||||
if (!QDBusConnection::sessionBus().registerService(QLatin1String(kServiceName))) {
|
||||
qLog(Warning) << "Failed to register" << kServiceName << "on the session bus";
|
||||
return;
|
||||
}
|
||||
|
||||
if (!QDBusConnection::sessionBus().registerObject(kMprisObjectPath, this)) {
|
||||
qLog(Warning) << "Failed to register" << QString(kMprisObjectPath) << "on the session bus";
|
||||
if (!QDBusConnection::sessionBus().registerObject(QLatin1String(kMprisObjectPath), this)) {
|
||||
qLog(Warning) << "Failed to register" << kMprisObjectPath << "on the session bus";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -131,13 +131,13 @@ Mpris2::Mpris2(Application *app, QObject *parent)
|
||||
|
||||
app_name_[0] = app_name_[0].toUpper();
|
||||
|
||||
QStringList data_dirs = QString(qgetenv("XDG_DATA_DIRS")).split(QStringLiteral(":"));
|
||||
QStringList data_dirs = QString::fromUtf8(qgetenv("XDG_DATA_DIRS")).split(QLatin1Char(':'));
|
||||
|
||||
if (!data_dirs.contains("/usr/local/share")) {
|
||||
if (!data_dirs.contains(QStringLiteral("/usr/local/share"))) {
|
||||
data_dirs.append(QStringLiteral("/usr/local/share"));
|
||||
}
|
||||
|
||||
if (!data_dirs.contains("/usr/share")) {
|
||||
if (!data_dirs.contains(QStringLiteral("/usr/share"))) {
|
||||
data_dirs.append(QStringLiteral("/usr/share"));
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ Mpris2::Mpris2(Application *app, QObject *parent)
|
||||
}
|
||||
|
||||
if (desktopfilepath_.isEmpty()) {
|
||||
desktopfilepath_ = QGuiApplication::desktopFileName() + ".desktop";
|
||||
desktopfilepath_ = QGuiApplication::desktopFileName() + QStringLiteral(".desktop");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -195,7 +195,7 @@ void Mpris2::EmitNotification(const QString &name, const QVariant &value) {
|
||||
|
||||
void Mpris2::EmitNotification(const QString &name, const QVariant &value, const QString &mprisEntity) {
|
||||
|
||||
QDBusMessage msg = QDBusMessage::createSignal(kMprisObjectPath, kFreedesktopPath, QStringLiteral("PropertiesChanged"));
|
||||
QDBusMessage msg = QDBusMessage::createSignal(QLatin1String(kMprisObjectPath), QLatin1String(kFreedesktopPath), QStringLiteral("PropertiesChanged"));
|
||||
QVariantMap map;
|
||||
map.insert(name, value);
|
||||
QVariantList args = QVariantList() << mprisEntity << map << QStringList();
|
||||
@@ -207,18 +207,18 @@ void Mpris2::EmitNotification(const QString &name, const QVariant &value, const
|
||||
void Mpris2::EmitNotification(const QString &name) {
|
||||
|
||||
QVariant value;
|
||||
if (name == "PlaybackStatus") value = PlaybackStatus();
|
||||
else if (name == "LoopStatus") value = LoopStatus();
|
||||
else if (name == "Shuffle") value = Shuffle();
|
||||
else if (name == "Metadata") value = Metadata();
|
||||
else if (name == "Rating") value = Rating();
|
||||
else if (name == "Volume") value = Volume();
|
||||
else if (name == "Position") value = Position();
|
||||
else if (name == "CanPlay") value = CanPlay();
|
||||
else if (name == "CanPause") value = CanPause();
|
||||
else if (name == "CanSeek") value = CanSeek();
|
||||
else if (name == "CanGoNext") value = CanGoNext();
|
||||
else if (name == "CanGoPrevious") value = CanGoPrevious();
|
||||
if (name == QStringLiteral("PlaybackStatus")) value = PlaybackStatus();
|
||||
else if (name == QStringLiteral("LoopStatus")) value = LoopStatus();
|
||||
else if (name == QStringLiteral("Shuffle")) value = Shuffle();
|
||||
else if (name == QStringLiteral("Metadata")) value = Metadata();
|
||||
else if (name == QStringLiteral("Rating")) value = Rating();
|
||||
else if (name == QStringLiteral("Volume")) value = Volume();
|
||||
else if (name == QStringLiteral("Position")) value = Position();
|
||||
else if (name == QStringLiteral("CanPlay")) value = CanPlay();
|
||||
else if (name == QStringLiteral("CanPause")) value = CanPause();
|
||||
else if (name == QStringLiteral("CanSeek")) value = CanSeek();
|
||||
else if (name == QStringLiteral("CanGoNext")) value = CanGoNext();
|
||||
else if (name == QStringLiteral("CanGoPrevious")) value = CanGoPrevious();
|
||||
|
||||
if (value.isValid()) EmitNotification(name, value);
|
||||
|
||||
@@ -240,7 +240,7 @@ QString Mpris2::DesktopEntryAbsolutePath() const {
|
||||
|
||||
}
|
||||
|
||||
QString Mpris2::DesktopEntry() const { return QGuiApplication::desktopFileName() + ".desktop"; }
|
||||
QString Mpris2::DesktopEntry() const { return QGuiApplication::desktopFileName() + QStringLiteral(".desktop"); }
|
||||
|
||||
QStringList Mpris2::SupportedUriSchemes() const {
|
||||
|
||||
@@ -325,13 +325,13 @@ void Mpris2::SetLoopStatus(const QString &value) {
|
||||
|
||||
PlaylistSequence::RepeatMode mode = PlaylistSequence::RepeatMode::Off;
|
||||
|
||||
if (value == "None") {
|
||||
if (value == QStringLiteral("None")) {
|
||||
mode = PlaylistSequence::RepeatMode::Off;
|
||||
}
|
||||
else if (value == "Track") {
|
||||
else if (value == QStringLiteral("Track")) {
|
||||
mode = PlaylistSequence::RepeatMode::Track;
|
||||
}
|
||||
else if (value == "Playlist") {
|
||||
else if (value == QStringLiteral("Playlist")) {
|
||||
mode = PlaylistSequence::RepeatMode::Playlist;
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ bool Mpris2::CanPlay() const {
|
||||
|
||||
// This one's a bit different than MPRIS 1 - we want this to be true even when the song is already paused or stopped.
|
||||
bool Mpris2::CanPause() const {
|
||||
return (app_->player()->GetCurrentItem() && app_->player()->GetState() == EngineBase::State::Playing && !(app_->player()->GetCurrentItem()->options() & PlaylistItem::Option::PauseDisabled)) || PlaybackStatus() == "Paused" || PlaybackStatus() == "Stopped";
|
||||
return (app_->player()->GetCurrentItem() && app_->player()->GetState() == EngineBase::State::Playing && !(app_->player()->GetCurrentItem()->options() & PlaylistItem::Option::PauseDisabled)) || PlaybackStatus() == QStringLiteral("Paused") || PlaybackStatus() == QStringLiteral("Stopped");
|
||||
}
|
||||
|
||||
bool Mpris2::CanSeek() const { return CanSeek(app_->player()->GetState()); }
|
||||
@@ -594,7 +594,7 @@ MaybePlaylist Mpris2::ActivePlaylist() const {
|
||||
|
||||
void Mpris2::ActivatePlaylist(const QDBusObjectPath &playlist_id) {
|
||||
|
||||
QStringList split_path = playlist_id.path().split('/');
|
||||
QStringList split_path = playlist_id.path().split(QLatin1Char('/'));
|
||||
qLog(Debug) << Q_FUNC_INFO << playlist_id.path() << split_path;
|
||||
if (split_path.isEmpty()) {
|
||||
return;
|
||||
@@ -648,7 +648,7 @@ void Mpris2::PlaylistChangedSlot(Playlist *playlist) {
|
||||
|
||||
void Mpris2::PlaylistCollectionChanged(Playlist *playlist) {
|
||||
Q_UNUSED(playlist);
|
||||
EmitNotification(QStringLiteral("PlaylistCount"), "", QStringLiteral("org.mpris.MediaPlayer2.Playlists"));
|
||||
EmitNotification(QStringLiteral("PlaylistCount"), QLatin1String(""), QStringLiteral("org.mpris.MediaPlayer2.Playlists"));
|
||||
}
|
||||
|
||||
} // namespace mpris
|
||||
|
||||
@@ -232,10 +232,6 @@ class Mpris2 : public QObject {
|
||||
QString DesktopEntryAbsolutePath() const;
|
||||
|
||||
private:
|
||||
static const char *kMprisObjectPath;
|
||||
static const char *kServiceName;
|
||||
static const char *kFreedesktopPath;
|
||||
|
||||
Application *app_;
|
||||
|
||||
QString app_name_;
|
||||
|
||||
@@ -57,7 +57,7 @@ QNetworkReply *NetworkAccessManager::createRequest(Operation op, const QNetworkR
|
||||
new_request.setHeader(QNetworkRequest::UserAgentHeader, user_agent);
|
||||
|
||||
if (op == QNetworkAccessManager::PostOperation && !new_request.header(QNetworkRequest::ContentTypeHeader).isValid()) {
|
||||
new_request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||
new_request.setHeader(QNetworkRequest::ContentTypeHeader, QStringLiteral("application/x-www-form-urlencoded"));
|
||||
}
|
||||
|
||||
// Prefer the cache unless the caller has changed the setting already
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/settings.h"
|
||||
#include "networkproxyfactory.h"
|
||||
|
||||
NetworkProxyFactory *NetworkProxyFactory::sInstance = nullptr;
|
||||
@@ -78,7 +79,7 @@ void NetworkProxyFactory::ReloadSettings() {
|
||||
|
||||
QMutexLocker l(&mutex_);
|
||||
|
||||
QSettings s;
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
|
||||
mode_ = static_cast<Mode>(s.value("mode", static_cast<int>(Mode::System)).toInt());
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include <QSettings>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/settings.h"
|
||||
#include "utilities/timeconstants.h"
|
||||
|
||||
#include "scoped_ptr.h"
|
||||
@@ -94,7 +95,7 @@ Player::Player(Application *app, QObject *parent)
|
||||
seek_step_sec_(10),
|
||||
play_offset_nanosec_(0) {
|
||||
|
||||
QSettings s;
|
||||
Settings s;
|
||||
s.beginGroup(BackendSettingsPage::kSettingsGroup);
|
||||
EngineBase::Type enginetype = EngineBase::TypeFromName(s.value("engine", EngineBase::Name(EngineBase::Type::GStreamer)).toString().toLower());
|
||||
s.endGroup();
|
||||
@@ -139,7 +140,7 @@ EngineBase::Type Player::CreateEngine(EngineBase::Type enginetype) {
|
||||
}
|
||||
|
||||
if (use_enginetype != enginetype) { // Engine was set to something else. Reset output and device.
|
||||
QSettings s;
|
||||
Settings s;
|
||||
s.beginGroup(BackendSettingsPage::kSettingsGroup);
|
||||
s.setValue("engine", EngineBase::Name(use_enginetype));
|
||||
s.setValue("output", engine_->DefaultOutput());
|
||||
@@ -159,7 +160,7 @@ EngineBase::Type Player::CreateEngine(EngineBase::Type enginetype) {
|
||||
|
||||
void Player::Init() {
|
||||
|
||||
QSettings s;
|
||||
Settings s;
|
||||
|
||||
if (!engine_) {
|
||||
s.beginGroup(BackendSettingsPage::kSettingsGroup);
|
||||
@@ -203,7 +204,7 @@ void Player::Init() {
|
||||
|
||||
void Player::ReloadSettings() {
|
||||
|
||||
QSettings s;
|
||||
Settings s;
|
||||
|
||||
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
|
||||
continue_on_error_ = s.value("continue_on_error", false).toBool();
|
||||
@@ -221,7 +222,7 @@ void Player::ReloadSettings() {
|
||||
|
||||
void Player::LoadVolume() {
|
||||
|
||||
QSettings s;
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
const uint volume = s.value("volume", 100).toInt();
|
||||
s.endGroup();
|
||||
@@ -232,7 +233,7 @@ void Player::LoadVolume() {
|
||||
|
||||
void Player::SaveVolume() {
|
||||
|
||||
QSettings s;
|
||||
Settings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("volume", volume_);
|
||||
s.endGroup();
|
||||
@@ -283,7 +284,7 @@ void Player::HandleLoadResult(const UrlHandler::LoadResult &result) {
|
||||
if (is_current) NextItem(stream_change_type_, autoscroll_);
|
||||
break;
|
||||
|
||||
case UrlHandler::LoadResult::Type::TrackAvailable: {
|
||||
case UrlHandler::LoadResult::Type::TrackAvailable:{
|
||||
|
||||
qLog(Debug) << "URL handler for" << result.media_url_ << "returned" << result.stream_url_;
|
||||
|
||||
@@ -497,7 +498,7 @@ void Player::PlayPause(const quint64 offset_nanosec, const Playlist::AutoScroll
|
||||
emit Resumed();
|
||||
break;
|
||||
|
||||
case EngineBase::State::Playing: {
|
||||
case EngineBase::State::Playing:{
|
||||
if (current_item_->options() & PlaylistItem::Option::PauseDisabled) {
|
||||
Stop();
|
||||
}
|
||||
@@ -511,7 +512,7 @@ void Player::PlayPause(const quint64 offset_nanosec, const Playlist::AutoScroll
|
||||
|
||||
case EngineBase::State::Empty:
|
||||
case EngineBase::State::Error:
|
||||
case EngineBase::State::Idle: {
|
||||
case EngineBase::State::Idle:{
|
||||
pause_time_ = QDateTime();
|
||||
play_offset_nanosec_ = offset_nanosec;
|
||||
app_->playlist_manager()->SetActivePlaylist(app_->playlist_manager()->current_id());
|
||||
|
||||
120
src/core/settings.cpp
Normal file
120
src/core/settings.cpp
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QSettings>
|
||||
#include <QVariant>
|
||||
#include <QString>
|
||||
|
||||
#include "settings.h"
|
||||
|
||||
Settings::Settings(QObject *parent)
|
||||
: QSettings(parent) {}
|
||||
|
||||
Settings::Settings(const QString &filename, const Format format, QObject *parent)
|
||||
: QSettings(filename, format, parent) {}
|
||||
|
||||
// Compatibility with older Qt versions
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0)
|
||||
|
||||
void Settings::beginGroup(const char *prefix) {
|
||||
|
||||
QSettings::beginGroup(QLatin1String(prefix));
|
||||
|
||||
}
|
||||
|
||||
void Settings::beginGroup(const QString &prefix) {
|
||||
|
||||
QSettings::beginGroup(prefix);
|
||||
|
||||
}
|
||||
|
||||
bool Settings::contains(const char *key) const {
|
||||
|
||||
return QSettings::contains(QLatin1String(key));
|
||||
|
||||
}
|
||||
|
||||
bool Settings::contains(const QString &key) const {
|
||||
|
||||
return QSettings::contains(key);
|
||||
|
||||
}
|
||||
|
||||
QVariant Settings::value(const char *key, const QVariant &default_value) const {
|
||||
|
||||
return QSettings::value(QLatin1String(key), default_value);
|
||||
|
||||
}
|
||||
|
||||
QVariant Settings::value(const QString &key, const QVariant &default_value) const {
|
||||
|
||||
return QSettings::value(key, default_value);
|
||||
|
||||
}
|
||||
|
||||
void Settings::setValue(const char *key, const QVariant &value) {
|
||||
|
||||
QSettings::setValue(QLatin1String(key), value);
|
||||
|
||||
}
|
||||
|
||||
void Settings::setValue(const QString &key, const QVariant &value) {
|
||||
|
||||
QSettings::setValue(key, value);
|
||||
|
||||
}
|
||||
|
||||
int Settings::beginReadArray(const char *prefix) {
|
||||
|
||||
return QSettings::beginReadArray(QLatin1String(prefix));
|
||||
|
||||
}
|
||||
|
||||
int Settings::beginReadArray(const QString &prefix) {
|
||||
|
||||
return QSettings::beginReadArray(prefix);
|
||||
|
||||
}
|
||||
|
||||
void Settings::beginWriteArray(const char *prefix, int size) {
|
||||
|
||||
QSettings::beginWriteArray(QLatin1String(prefix), size);
|
||||
|
||||
}
|
||||
|
||||
void Settings::beginWriteArray(const QString &prefix, int size) {
|
||||
|
||||
QSettings::beginWriteArray(prefix, size);
|
||||
|
||||
}
|
||||
|
||||
void Settings::remove(const char *key) {
|
||||
|
||||
QSettings::remove(QLatin1String(key));
|
||||
|
||||
}
|
||||
|
||||
void Settings::remove(const QString &key) {
|
||||
|
||||
QSettings::remove(key);
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
51
src/core/settings.h
Normal file
51
src/core/settings.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2024, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* Strawberry is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Strawberry is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
#include <QSettings>
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
class Settings : public QSettings {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Settings(QObject *parent = nullptr);
|
||||
explicit Settings(const QString &filename, const Format format, QObject *parent = nullptr);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) // Compatibility with older Qt versions
|
||||
void beginGroup(const char *prefix);
|
||||
void beginGroup(const QString &prefix);
|
||||
bool contains(const char *key) const;
|
||||
bool contains(const QString &key) const;
|
||||
QVariant value(const char *key, const QVariant &default_value = QVariant()) const;
|
||||
QVariant value(const QString &key, const QVariant &default_value = QVariant()) const;
|
||||
void setValue(const char *key, const QVariant &value);
|
||||
void setValue(const QString &key, const QVariant &value);
|
||||
int beginReadArray(const char *prefix);
|
||||
int beginReadArray(const QString &prefix);
|
||||
void beginWriteArray(const char *prefix, int size = -1);
|
||||
void beginWriteArray(const QString &prefix, int size = -1);
|
||||
void remove(const char *key);
|
||||
void remove(const QString &key);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // SETTINGS_H
|
||||
@@ -30,7 +30,7 @@ DefaultSettingsProvider::DefaultSettingsProvider() = default;
|
||||
void DefaultSettingsProvider::set_group(const char *group) {
|
||||
while (!backend_.group().isEmpty()) backend_.endGroup();
|
||||
|
||||
backend_.beginGroup(group);
|
||||
backend_.beginGroup(QLatin1String(group));
|
||||
}
|
||||
|
||||
QVariant DefaultSettingsProvider::value(const QString &key, const QVariant &default_value) const {
|
||||
|
||||
@@ -659,7 +659,7 @@ QString Song::sortable(const QString &v) {
|
||||
for (const auto &i : kArticles) {
|
||||
if (copy.startsWith(i)) {
|
||||
qint64 ilen = i.length();
|
||||
return copy.right(copy.length() - ilen) + ", " + copy.left(ilen - 1);
|
||||
return copy.right(copy.length() - ilen) + QStringLiteral(", ") + copy.left(ilen - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -668,7 +668,7 @@ QString Song::sortable(const QString &v) {
|
||||
}
|
||||
|
||||
QString Song::JoinSpec(const QString &table) {
|
||||
return Utilities::Prepend(table + ".", kColumns).join(QStringLiteral(", "));
|
||||
return Utilities::Prepend(table + QLatin1Char('.'), kColumns).join(QStringLiteral(", "));
|
||||
}
|
||||
|
||||
QString Song::PrettyTitle() const {
|
||||
@@ -686,7 +686,7 @@ QString Song::PrettyTitleWithArtist() const {
|
||||
|
||||
QString title(PrettyTitle());
|
||||
|
||||
if (!d->artist_.isEmpty()) title = d->artist_ + " - " + title;
|
||||
if (!d->artist_.isEmpty()) title = d->artist_ + QStringLiteral(" - ") + title;
|
||||
|
||||
return title;
|
||||
|
||||
@@ -722,7 +722,7 @@ QString Song::TitleWithCompilationArtist() const {
|
||||
|
||||
if (title.isEmpty()) title = d->basefilename_;
|
||||
|
||||
if (is_compilation() && !d->artist_.isEmpty() && !d->artist_.contains(QLatin1String("various"), Qt::CaseInsensitive)) title = d->artist_ + " - " + title;
|
||||
if (is_compilation() && !d->artist_.isEmpty() && !d->artist_.contains(QLatin1String("various"), Qt::CaseInsensitive)) title = d->artist_ + QStringLiteral(" - ") + title;
|
||||
|
||||
return title;
|
||||
|
||||
@@ -894,11 +894,11 @@ bool Song::IsSimilar(const Song &other) const {
|
||||
Song::Source Song::SourceFromURL(const QUrl &url) {
|
||||
|
||||
if (url.isLocalFile()) return Source::LocalFile;
|
||||
else if (url.scheme() == "cdda") return Source::CDDA;
|
||||
else if (url.scheme() == "tidal") return Source::Tidal;
|
||||
else if (url.scheme() == "subsonic") return Source::Subsonic;
|
||||
else if (url.scheme() == "qobuz") return Source::Qobuz;
|
||||
else if (url.scheme() == "http" || url.scheme() == "https" || url.scheme() == "rtsp") {
|
||||
else if (url.scheme() == QStringLiteral("cdda")) return Source::CDDA;
|
||||
else if (url.scheme() == QStringLiteral("tidal")) return Source::Tidal;
|
||||
else if (url.scheme() == QStringLiteral("subsonic")) return Source::Subsonic;
|
||||
else if (url.scheme() == QStringLiteral("qobuz")) return Source::Qobuz;
|
||||
else if (url.scheme() == QStringLiteral("http") || url.scheme() == QStringLiteral("https") || url.scheme() == QStringLiteral("rtsp")) {
|
||||
if (url.host().endsWith(QLatin1String("tidal.com"), Qt::CaseInsensitive)) { return Source::Tidal; }
|
||||
if (url.host().endsWith(QLatin1String("qobuz.com"), Qt::CaseInsensitive)) { return Source::Qobuz; }
|
||||
if (url.host().endsWith(QLatin1String("somafm.com"), Qt::CaseInsensitive)) { return Source::SomaFM; }
|
||||
@@ -1075,7 +1075,7 @@ QIcon Song::IconForFiletype(const FileType filetype) {
|
||||
case FileType::CDDA: return IconLoader::Load(QStringLiteral("cd"));
|
||||
case FileType::Stream: return IconLoader::Load(QStringLiteral("applications-internet"));
|
||||
case FileType::Unknown:
|
||||
default: return IconLoader::Load(QStringLiteral("edit-delete"));
|
||||
default: return IconLoader::Load(QStringLiteral("edit-delete"));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1189,22 +1189,22 @@ QString Song::ImageCacheDir(const Source source) {
|
||||
|
||||
switch (source) {
|
||||
case Source::Collection:
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/collectionalbumcovers";
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/collectionalbumcovers");
|
||||
case Source::Subsonic:
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/subsonicalbumcovers";
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/subsonicalbumcovers");
|
||||
case Source::Tidal:
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/tidalalbumcovers";
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/tidalalbumcovers");
|
||||
case Source::Qobuz:
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/qobuzalbumcovers";
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/qobuzalbumcovers");
|
||||
case Source::Device:
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/devicealbumcovers";
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/devicealbumcovers");
|
||||
case Source::LocalFile:
|
||||
case Source::CDDA:
|
||||
case Source::Stream:
|
||||
case Source::SomaFM:
|
||||
case Source::RadioParadise:
|
||||
case Source::Unknown:
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + "/albumcovers";
|
||||
return QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation) + QStringLiteral("/albumcovers");
|
||||
}
|
||||
|
||||
return QString();
|
||||
@@ -1460,8 +1460,8 @@ void Song::InitArtManual() {
|
||||
|
||||
// If we don't have cover art, check if we have one in the cache
|
||||
if (d->art_manual_.isEmpty() && !effective_albumartist().isEmpty() && !effective_album().isEmpty()) {
|
||||
QString filename(CoverUtils::Sha1CoverHash(effective_albumartist(), effective_album()).toHex() + ".jpg");
|
||||
QString path(ImageCacheDir(d->source_) + "/" + filename);
|
||||
QString filename = QString::fromLatin1(CoverUtils::Sha1CoverHash(effective_albumartist(), effective_album()).toHex()) + QStringLiteral(".jpg");
|
||||
QString path(ImageCacheDir(d->source_) + QLatin1Char('/') + filename);
|
||||
if (QFile::exists(path)) {
|
||||
d->art_manual_ = QUrl::fromLocalFile(path);
|
||||
}
|
||||
@@ -1509,7 +1509,7 @@ void Song::InitFromItdb(Itdb_Track *track, const QString &prefix) {
|
||||
|
||||
d->source_ = Source::Device;
|
||||
QString filename = QString::fromLocal8Bit(track->ipod_path);
|
||||
filename.replace(':', '/');
|
||||
filename.replace(QLatin1Char(':'), QLatin1Char('/'));
|
||||
if (prefix.contains(QLatin1String("://"))) {
|
||||
set_url(QUrl(prefix + filename));
|
||||
}
|
||||
@@ -1533,7 +1533,7 @@ void Song::InitFromItdb(Itdb_Track *track, const QString &prefix) {
|
||||
QString cover_path = ImageCacheDir(Source::Device);
|
||||
QDir dir(cover_path);
|
||||
if (!dir.exists()) dir.mkpath(cover_path);
|
||||
QString cover_file = cover_path + "/" + CoverUtils::Sha1CoverHash(effective_albumartist(), effective_album()).toHex() + ".jpg";
|
||||
QString cover_file = cover_path + QLatin1Char('/') + QString::fromLatin1(CoverUtils::Sha1CoverHash(effective_albumartist(), effective_album()).toHex()) + QStringLiteral(".jpg");
|
||||
GError *error = nullptr;
|
||||
if (dir.exists() && gdk_pixbuf_save(pixbuf, cover_file.toUtf8().constData(), "jpeg", &error, nullptr)) {
|
||||
d->art_manual_ = QUrl::fromLocalFile(cover_file);
|
||||
|
||||
@@ -237,7 +237,7 @@ SongLoader::Result SongLoader::LoadLocal(const QString &filename) {
|
||||
QSqlDatabase db(collection_backend_->db()->Connect());
|
||||
|
||||
CollectionQuery query(db, collection_backend_->songs_table(), collection_backend_->fts_table());
|
||||
query.SetColumnSpec("%songs_table.ROWID, " + Song::kColumnSpec);
|
||||
query.SetColumnSpec(QStringLiteral("%songs_table.ROWID, ") + Song::kColumnSpec);
|
||||
query.AddWhere(QStringLiteral("url"), url.toEncoded());
|
||||
|
||||
if (query.Exec() && query.Next()) {
|
||||
@@ -302,7 +302,7 @@ SongLoader::Result SongLoader::LoadLocalAsync(const QString &filename) {
|
||||
// It's a CUE - create virtual tracks
|
||||
QFile cue(matching_cue);
|
||||
if (cue.open(QIODevice::ReadOnly)) {
|
||||
const SongList songs = cue_parser_->Load(&cue, matching_cue, QDir(filename.section('/', 0, -2)));
|
||||
const SongList songs = cue_parser_->Load(&cue, matching_cue, QDir(filename.section(QLatin1Char('/'), 0, -2)));
|
||||
cue.close();
|
||||
for (const Song &song : songs) {
|
||||
if (song.is_valid()) songs_ << song;
|
||||
@@ -542,9 +542,9 @@ void SongLoader::TypeFound(GstElement*, uint, GstCaps *caps, void *self) {
|
||||
if (instance->state_ != State::WaitingForType) return;
|
||||
|
||||
// Check the mimetype
|
||||
instance->mime_type_ = gst_structure_get_name(gst_caps_get_structure(caps, 0));
|
||||
instance->mime_type_ = QString::fromUtf8(gst_structure_get_name(gst_caps_get_structure(caps, 0)));
|
||||
qLog(Debug) << "Mime type is" << instance->mime_type_;
|
||||
if (instance->mime_type_ == "text/plain" || instance->mime_type_ == "text/uri-list") {
|
||||
if (instance->mime_type_ == QStringLiteral("text/plain") || instance->mime_type_ == QStringLiteral("text/uri-list")) {
|
||||
// Yeah it might be a playlist, let's get some data and have a better look
|
||||
instance->state_ = State::WaitingForMagic;
|
||||
return;
|
||||
@@ -634,12 +634,12 @@ void SongLoader::ErrorMessageReceived(GstMessage *msg) {
|
||||
qLog(Error) << error->message;
|
||||
qLog(Error) << debugs;
|
||||
|
||||
QString message_str = error->message;
|
||||
QString message_str = QString::fromUtf8(error->message);
|
||||
|
||||
g_error_free(error);
|
||||
g_free(debugs);
|
||||
|
||||
if (state_ == State::WaitingForType && message_str == gst_error_get_message(GST_STREAM_ERROR, GST_STREAM_ERROR_TYPE_NOT_FOUND)) {
|
||||
if (state_ == State::WaitingForType && message_str == QString::fromUtf8(gst_error_get_message(GST_STREAM_ERROR, GST_STREAM_ERROR_TYPE_NOT_FOUND))) {
|
||||
// Don't give up - assume it's a playlist and see if one of our parsers can read it.
|
||||
state_ = State::WaitingForMagic;
|
||||
return;
|
||||
@@ -697,7 +697,7 @@ void SongLoader::MagicReady() {
|
||||
|
||||
qLog(Debug) << "Magic says" << parser_->name();
|
||||
|
||||
if (parser_->name() == "ASX/INI" && url_.scheme() == "http") {
|
||||
if (parser_->name() == QStringLiteral("ASX/INI") && url_.scheme() == QStringLiteral("http")) {
|
||||
// This is actually a weird MS-WMSP stream. Changing the protocol to MMS from HTTP makes it playable.
|
||||
parser_ = nullptr;
|
||||
url_.setScheme(QStringLiteral("mms"));
|
||||
|
||||
@@ -115,7 +115,7 @@ void StyleSheetLoader::UpdateStyleSheet(QWidget *widget, SharedPtr<StyleSheetDat
|
||||
ReplaceColor(&stylesheet, QStringLiteral("LinkVisited"), p, QPalette::LinkVisited);
|
||||
|
||||
#ifdef Q_OS_MACOS
|
||||
stylesheet.replace("macos", "*");
|
||||
stylesheet.replace(QStringLiteral("macos"), QStringLiteral("*"));
|
||||
#endif
|
||||
|
||||
if (stylesheet != styledata->stylesheet_current_) {
|
||||
@@ -127,9 +127,9 @@ void StyleSheetLoader::UpdateStyleSheet(QWidget *widget, SharedPtr<StyleSheetDat
|
||||
|
||||
void StyleSheetLoader::ReplaceColor(QString *css, const QString &name, const QPalette &palette, const QPalette::ColorRole role) {
|
||||
|
||||
css->replace("%palette-" + name + "-lighter", palette.color(role).lighter().name(), Qt::CaseInsensitive);
|
||||
css->replace("%palette-" + name + "-darker", palette.color(role).darker().name(), Qt::CaseInsensitive);
|
||||
css->replace("%palette-" + name, palette.color(role).name(), Qt::CaseInsensitive);
|
||||
css->replace(QStringLiteral("%palette-") + name + QStringLiteral("-lighter"), palette.color(role).lighter().name(), Qt::CaseInsensitive);
|
||||
css->replace(QStringLiteral("%palette-") + name + QStringLiteral("-darker"), palette.color(role).darker().name(), Qt::CaseInsensitive);
|
||||
css->replace(QStringLiteral("%palette-") + name, palette.color(role).name(), Qt::CaseInsensitive);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <QByteArray>
|
||||
#include <QString>
|
||||
#include <QImage>
|
||||
#include <QSettings>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/workerpool.h"
|
||||
@@ -37,7 +36,10 @@
|
||||
#include "song.h"
|
||||
#include "tagreaderclient.h"
|
||||
|
||||
const char *TagReaderClient::kWorkerExecutableName = "strawberry-tagreader";
|
||||
namespace {
|
||||
constexpr char kWorkerExecutableName[] = "strawberry-tagreader";
|
||||
}
|
||||
|
||||
TagReaderClient *TagReaderClient::sInstance = nullptr;
|
||||
|
||||
TagReaderClient::TagReaderClient(QObject *parent) : QObject(parent), worker_pool_(new WorkerPool<HandlerType>(this)) {
|
||||
@@ -45,7 +47,7 @@ TagReaderClient::TagReaderClient(QObject *parent) : QObject(parent), worker_pool
|
||||
sInstance = this;
|
||||
original_thread_ = thread();
|
||||
|
||||
worker_pool_->SetExecutableName(kWorkerExecutableName);
|
||||
worker_pool_->SetExecutableName(QLatin1String(kWorkerExecutableName));
|
||||
QObject::connect(worker_pool_, &WorkerPool<HandlerType>::WorkerFailedToStart, this, &TagReaderClient::WorkerFailedToStart);
|
||||
|
||||
}
|
||||
|
||||
@@ -48,8 +48,6 @@ class TagReaderClient : public QObject {
|
||||
using HandlerType = AbstractMessageHandler<spb::tagreader::Message>;
|
||||
using ReplyType = HandlerType::ReplyType;
|
||||
|
||||
static const char *kWorkerExecutableName;
|
||||
|
||||
void Start();
|
||||
void ExitAsync();
|
||||
|
||||
|
||||
@@ -46,9 +46,9 @@ ThreadSafeNetworkDiskCache::ThreadSafeNetworkDiskCache(QObject *parent) : QAbstr
|
||||
if (!sCache) {
|
||||
sCache = new QNetworkDiskCache;
|
||||
#ifdef Q_OS_WIN32
|
||||
sCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + "/strawberry/networkcache");
|
||||
sCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::TempLocation) + QStringLiteral("/strawberry/networkcache"));
|
||||
#else
|
||||
sCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/networkcache");
|
||||
sCache->setCacheDirectory(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + QStringLiteral("/networkcache"));
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ Translations::~Translations() {
|
||||
void Translations::LoadTranslation(const QString &prefix, const QString &path, const QString &language) {
|
||||
|
||||
QTranslator *t = new PoTranslator;
|
||||
if (t->load(prefix + "_" + language, path)) {
|
||||
if (t->load(prefix + QLatin1Char('_') + language, path)) {
|
||||
QCoreApplication::installTranslator(t);
|
||||
translations_ << t;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user