Port to QStringLiteral operator

This commit is contained in:
Jonas Kvinge
2024-10-20 06:38:55 +02:00
parent 722035913e
commit ef9ef63f02
202 changed files with 2036 additions and 1889 deletions

View File

@@ -49,6 +49,8 @@
#include "collection/collectionitemdelegate.h"
#include "streamingcollectionview.h"
using namespace Qt::Literals::StringLiterals;
StreamingCollectionView::StreamingCollectionView(QWidget *parent)
: AutoExpandingTreeView(parent),
app_(nullptr),
@@ -59,7 +61,7 @@ StreamingCollectionView::StreamingCollectionView(QWidget *parent)
total_song_count_(0),
total_artist_count_(0),
total_album_count_(0),
nomusic_(QStringLiteral(":/pictures/nomusic.png")),
nomusic_(u":/pictures/nomusic.png"_s),
context_menu_(nullptr),
load_(nullptr),
add_to_playlist_(nullptr),
@@ -78,7 +80,7 @@ StreamingCollectionView::StreamingCollectionView(QWidget *parent)
setSelectionMode(QAbstractItemView::ExtendedSelection);
SetAutoOpen(false);
setStyleSheet(QStringLiteral("QTreeView::item{padding-top:1px;}"));
setStyleSheet(u"QTreeView::item{padding-top:1px;}"_s);
}
@@ -326,18 +328,18 @@ void StreamingCollectionView::contextMenuEvent(QContextMenuEvent *e) {
if (!context_menu_) {
context_menu_ = new QMenu(this);
add_to_playlist_ = context_menu_->addAction(IconLoader::Load(QStringLiteral("media-playback-start")), tr("Append to current playlist"), this, &StreamingCollectionView::AddToPlaylist);
load_ = context_menu_->addAction(IconLoader::Load(QStringLiteral("media-playback-start")), tr("Replace current playlist"), this, &StreamingCollectionView::Load);
open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load(QStringLiteral("document-new")), tr("Open in new playlist"), this, &StreamingCollectionView::OpenInNewPlaylist);
add_to_playlist_ = context_menu_->addAction(IconLoader::Load(u"media-playback-start"_s), tr("Append to current playlist"), this, &StreamingCollectionView::AddToPlaylist);
load_ = context_menu_->addAction(IconLoader::Load(u"media-playback-start"_s), tr("Replace current playlist"), this, &StreamingCollectionView::Load);
open_in_new_playlist_ = context_menu_->addAction(IconLoader::Load(u"document-new"_s), tr("Open in new playlist"), this, &StreamingCollectionView::OpenInNewPlaylist);
context_menu_->addSeparator();
add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load(QStringLiteral("go-next")), tr("Queue track"), this, &StreamingCollectionView::AddToPlaylistEnqueue);
add_to_playlist_enqueue_next_ = context_menu_->addAction(IconLoader::Load(QStringLiteral("go-next")), tr("Queue to play next"), this, &StreamingCollectionView::AddToPlaylistEnqueueNext);
add_to_playlist_enqueue_ = context_menu_->addAction(IconLoader::Load(u"go-next"_s), tr("Queue track"), this, &StreamingCollectionView::AddToPlaylistEnqueue);
add_to_playlist_enqueue_next_ = context_menu_->addAction(IconLoader::Load(u"go-next"_s), tr("Queue to play next"), this, &StreamingCollectionView::AddToPlaylistEnqueueNext);
context_menu_->addSeparator();
if (favorite_) {
remove_songs_ = context_menu_->addAction(IconLoader::Load(QStringLiteral("edit-delete")), tr("Remove from favorites"), this, &StreamingCollectionView::RemoveSelectedSongs);
remove_songs_ = context_menu_->addAction(IconLoader::Load(u"edit-delete"_s), tr("Remove from favorites"), this, &StreamingCollectionView::RemoveSelectedSongs);
context_menu_->addSeparator();
}

View File

@@ -44,8 +44,8 @@ StreamingSearchModel::StreamingSearchModel(StreamingServicePtr service, QObject
service_(service),
proxy_(nullptr),
use_pretty_covers_(true),
artist_icon_(IconLoader::Load(QStringLiteral("folder-sound"))),
album_icon_(IconLoader::Load(QStringLiteral("cdcase"))) {
artist_icon_(IconLoader::Load(u"folder-sound"_s)),
album_icon_(IconLoader::Load(u"cdcase"_s)) {
group_by_[0] = CollectionModel::GroupBy::AlbumArtist;
group_by_[1] = CollectionModel::GroupBy::AlbumDisc;

View File

@@ -85,6 +85,7 @@
#include "settings/appearancesettingspage.h"
using std::make_unique;
using namespace Qt::Literals::StringLiterals;
namespace {
constexpr int kSwapModelsTimeoutMsec = 250;
@@ -117,12 +118,12 @@ StreamingSearchView::StreamingSearchView(QWidget *parent)
ui_->search->installEventFilter(this);
ui_->results_stack->installEventFilter(this);
ui_->settings->setIcon(IconLoader::Load(QStringLiteral("configure")));
ui_->settings->setIcon(IconLoader::Load(u"configure"_s));
// Set the appearance of the results list
ui_->results->setItemDelegate(new StreamingSearchItemDelegate(this));
ui_->results->setAttribute(Qt::WA_MacShowFocusRect, false);
ui_->results->setStyleSheet(QStringLiteral("QTreeView::item{padding-top:1px;}"));
ui_->results->setStyleSheet(u"QTreeView::item{padding-top:1px;}"_s);
// Show the help page initially
ui_->results_stack->setCurrentWidget(ui_->help_page);
@@ -179,7 +180,7 @@ void StreamingSearchView::Init(Application *app, StreamingServicePtr service) {
QMenu *settings_menu = new QMenu(this);
settings_menu->addActions(group_by_actions_->actions());
settings_menu->addSeparator();
settings_menu->addAction(IconLoader::Load(QStringLiteral("configure")), tr("Configure %1...").arg(Song::DescriptionForSource(service_->source())), this, &StreamingSearchView::OpenSettingsDialog);
settings_menu->addAction(IconLoader::Load(u"configure"_s), tr("Configure %1...").arg(Song::DescriptionForSource(service_->source())), this, &StreamingSearchView::OpenSettingsDialog);
ui_->settings->setMenu(settings_menu);
swap_models_timer_->setSingleShot(true);
@@ -316,36 +317,36 @@ bool StreamingSearchView::ResultsContextMenuEvent(QContextMenuEvent *e) {
if (!context_menu_) {
context_menu_ = new QMenu(this);
context_actions_ << context_menu_->addAction(IconLoader::Load(QStringLiteral("media-playback-start")), tr("Append to current playlist"), this, &StreamingSearchView::AddSelectedToPlaylist);
context_actions_ << context_menu_->addAction(IconLoader::Load(QStringLiteral("media-playback-start")), tr("Replace current playlist"), this, &StreamingSearchView::LoadSelected);
context_actions_ << context_menu_->addAction(IconLoader::Load(QStringLiteral("document-new")), tr("Open in new playlist"), this, &StreamingSearchView::OpenSelectedInNewPlaylist);
context_actions_ << context_menu_->addAction(IconLoader::Load(u"media-playback-start"_s), tr("Append to current playlist"), this, &StreamingSearchView::AddSelectedToPlaylist);
context_actions_ << context_menu_->addAction(IconLoader::Load(u"media-playback-start"_s), tr("Replace current playlist"), this, &StreamingSearchView::LoadSelected);
context_actions_ << context_menu_->addAction(IconLoader::Load(u"document-new"_s), tr("Open in new playlist"), this, &StreamingSearchView::OpenSelectedInNewPlaylist);
context_menu_->addSeparator();
context_actions_ << context_menu_->addAction(IconLoader::Load(QStringLiteral("go-next")), tr("Queue track"), this, &StreamingSearchView::AddSelectedToPlaylistEnqueue);
context_actions_ << context_menu_->addAction(IconLoader::Load(u"go-next"_s), tr("Queue track"), this, &StreamingSearchView::AddSelectedToPlaylistEnqueue);
context_menu_->addSeparator();
if (service_->artists_collection_model() || service_->albums_collection_model() || service_->songs_collection_model()) {
if (service_->artists_collection_model()) {
context_actions_ << context_menu_->addAction(IconLoader::Load(QStringLiteral("folder-new")), tr("Add to artists"), this, &StreamingSearchView::AddArtists);
context_actions_ << context_menu_->addAction(IconLoader::Load(u"folder-new"_s), tr("Add to artists"), this, &StreamingSearchView::AddArtists);
}
if (service_->albums_collection_model()) {
context_actions_ << context_menu_->addAction(IconLoader::Load(QStringLiteral("folder-new")), tr("Add to albums"), this, &StreamingSearchView::AddAlbums);
context_actions_ << context_menu_->addAction(IconLoader::Load(u"folder-new"_s), tr("Add to albums"), this, &StreamingSearchView::AddAlbums);
}
if (service_->songs_collection_model()) {
context_actions_ << context_menu_->addAction(IconLoader::Load(QStringLiteral("folder-new")), tr("Add to songs"), this, &StreamingSearchView::AddSongs);
context_actions_ << context_menu_->addAction(IconLoader::Load(u"folder-new"_s), tr("Add to songs"), this, &StreamingSearchView::AddSongs);
}
context_menu_->addSeparator();
}
if (ui_->results->selectionModel() && ui_->results->selectionModel()->selectedRows().length() == 1) {
context_actions_ << context_menu_->addAction(IconLoader::Load(QStringLiteral("search")), tr("Search for this"), this, &StreamingSearchView::SearchForThis);
context_actions_ << context_menu_->addAction(IconLoader::Load(u"search"_s), tr("Search for this"), this, &StreamingSearchView::SearchForThis);
}
context_menu_->addSeparator();
context_menu_->addMenu(tr("Group by"))->addActions(group_by_actions_->actions());
context_menu_->addAction(IconLoader::Load(QStringLiteral("configure")), tr("Configure %1...").arg(Song::TextForSource(service_->source())), this, &StreamingSearchView::OpenSettingsDialog);
context_menu_->addAction(IconLoader::Load(u"configure"_s), tr("Configure %1...").arg(Song::TextForSource(service_->source())), this, &StreamingSearchView::OpenSettingsDialog);
}
@@ -436,7 +437,7 @@ void StreamingSearchView::SwapModels() {
QStringList StreamingSearchView::TokenizeQuery(const QString &query) {
static const QRegularExpression regex_whitespaces(QStringLiteral("\\s+"));
static const QRegularExpression regex_whitespaces(u"\\s+"_s);
QStringList tokens = query.split(regex_whitespaces);
for (QStringList::iterator it = tokens.begin(); it != tokens.end(); ++it) {

View File

@@ -40,6 +40,8 @@
#include "streamingcollectionview.h"
#include "ui_streamingcollectionviewcontainer.h"
using namespace Qt::Literals::StringLiterals;
StreamingSongsView::StreamingSongsView(Application *app, StreamingServicePtr service, const QString &settings_group, const SettingsDialog::Page settings_page, QWidget *parent)
: QWidget(parent),
app_(app),
@@ -57,7 +59,7 @@ StreamingSongsView::StreamingSongsView(Application *app, StreamingServicePtr ser
ui_->filter_widget->SetSettingsGroup(settings_group);
ui_->filter_widget->Init(service_->songs_collection_model(), service_->songs_collection_filter_model());
QAction *action_configure = new QAction(IconLoader::Load(QStringLiteral("configure")), tr("Configure %1...").arg(Song::DescriptionForSource(service_->source())), this);
QAction *action_configure = new QAction(IconLoader::Load(u"configure"_s), tr("Configure %1...").arg(Song::DescriptionForSource(service_->source())), this);
QObject::connect(action_configure, &QAction::triggered, this, &StreamingSongsView::OpenSettingsDialog);
ui_->filter_widget->AddMenuAction(action_configure);

View File

@@ -63,7 +63,7 @@ StreamingTabsView::StreamingTabsView(Application *app, StreamingServicePtr servi
QObject::connect(ui_->search_view, &StreamingSearchView::AddAlbumsSignal, &*service_, &StreamingService::AddAlbums);
QObject::connect(ui_->search_view, &StreamingSearchView::AddSongsSignal, &*service_, &StreamingService::AddSongs);
QAction *action_configure = new QAction(IconLoader::Load(QStringLiteral("configure")), tr("Configure %1...").arg(Song::TextForSource(service_->source())), this);
QAction *action_configure = new QAction(IconLoader::Load(u"configure"_s), tr("Configure %1...").arg(Song::TextForSource(service_->source())), this);
QObject::connect(action_configure, &QAction::triggered, this, &StreamingTabsView::OpenSettingsDialog);
if (service_->artists_collection_model()) {
@@ -72,7 +72,7 @@ StreamingTabsView::StreamingTabsView(Application *app, StreamingServicePtr servi
ui_->artists_collection->view()->setModel(service_->artists_collection_filter_model());
ui_->artists_collection->view()->SetFilter(ui_->artists_collection->filter_widget());
ui_->artists_collection->filter_widget()->SetSettingsGroup(settings_group);
ui_->artists_collection->filter_widget()->SetSettingsPrefix(QStringLiteral("artists"));
ui_->artists_collection->filter_widget()->SetSettingsPrefix(u"artists"_s);
ui_->artists_collection->filter_widget()->Init(service_->artists_collection_model(), service_->artists_collection_filter_model());
ui_->artists_collection->filter_widget()->AddMenuAction(action_configure);
@@ -104,7 +104,7 @@ StreamingTabsView::StreamingTabsView(Application *app, StreamingServicePtr servi
ui_->albums_collection->view()->setModel(service_->albums_collection_filter_model());
ui_->albums_collection->view()->SetFilter(ui_->albums_collection->filter_widget());
ui_->albums_collection->filter_widget()->SetSettingsGroup(settings_group);
ui_->albums_collection->filter_widget()->SetSettingsPrefix(QStringLiteral("albums"));
ui_->albums_collection->filter_widget()->SetSettingsPrefix(u"albums"_s);
ui_->albums_collection->filter_widget()->Init(service_->albums_collection_model(), service_->albums_collection_filter_model());
ui_->albums_collection->filter_widget()->AddMenuAction(action_configure);
@@ -136,7 +136,7 @@ StreamingTabsView::StreamingTabsView(Application *app, StreamingServicePtr servi
ui_->songs_collection->view()->setModel(service_->songs_collection_filter_model());
ui_->songs_collection->view()->SetFilter(ui_->songs_collection->filter_widget());
ui_->songs_collection->filter_widget()->SetSettingsGroup(settings_group);
ui_->songs_collection->filter_widget()->SetSettingsPrefix(QStringLiteral("songs"));
ui_->songs_collection->filter_widget()->SetSettingsPrefix(u"songs"_s);
ui_->songs_collection->filter_widget()->Init(service_->songs_collection_model(), service_->songs_collection_filter_model());
ui_->songs_collection->filter_widget()->AddMenuAction(action_configure);
@@ -164,7 +164,7 @@ StreamingTabsView::StreamingTabsView(Application *app, StreamingServicePtr servi
Settings s;
s.beginGroup(settings_group_);
QString tab = s.value("tab", QStringLiteral("artists")).toString().toLower();
QString tab = s.value("tab", u"artists"_s).toString().toLower();
s.endGroup();
if (tab == "artists"_L1) {