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

@@ -122,9 +122,9 @@ void GlobalShortcutsBackendGnome::GnomeMediaKeyPressed(const QString &applicatio
Q_UNUSED(application)
auto shortcuts = manager_->shortcuts();
if (key == "Play"_L1) shortcuts[QStringLiteral("play_pause")].action->trigger();
if (key == "Stop"_L1) shortcuts[QStringLiteral("stop")].action->trigger();
if (key == "Next"_L1) shortcuts[QStringLiteral("next_track")].action->trigger();
if (key == "Previous"_L1) shortcuts[QStringLiteral("prev_track")].action->trigger();
if (key == "Play"_L1) shortcuts[u"play_pause"_s].action->trigger();
if (key == "Stop"_L1) shortcuts[u"stop"_s].action->trigger();
if (key == "Next"_L1) shortcuts[u"next_track"_s].action->trigger();
if (key == "Previous"_L1) shortcuts[u"prev_track"_s].action->trigger();
}

View File

@@ -38,6 +38,8 @@
#include "kglobalaccel.h"
#include "kglobalaccelcomponent.h"
using namespace Qt::Literals::StringLiterals;
namespace {
constexpr char kKdeService[] = "org.kde.kglobalaccel";
constexpr char kKdePath[] = "/kglobalaccel";
@@ -102,7 +104,7 @@ void GlobalShortcutsBackendKDE::RegisterFinished(QDBusPendingCallWatcher *watche
watcher->deleteLater();
if (!reply.isValid()) {
if (reply.error().name() != QStringLiteral("org.kde.kglobalaccel.NoSuchComponent")) {
if (reply.error().name() != u"org.kde.kglobalaccel.NoSuchComponent"_s) {
qLog(Error) << "Failed to register:" << reply.error().name() << reply.error().message();
}
return;

View File

@@ -122,9 +122,9 @@ void GlobalShortcutsBackendMate::MateMediaKeyPressed(const QString &application,
Q_UNUSED(application)
auto shortcuts = manager_->shortcuts();
if (key == "Play"_L1) shortcuts[QStringLiteral("play_pause")].action->trigger();
if (key == "Stop"_L1) shortcuts[QStringLiteral("stop")].action->trigger();
if (key == "Next"_L1) shortcuts[QStringLiteral("next_track")].action->trigger();
if (key == "Previous"_L1) shortcuts[QStringLiteral("prev_track")].action->trigger();
if (key == "Play"_L1) shortcuts[u"play_pause"_s].action->trigger();
if (key == "Stop"_L1) shortcuts[u"stop"_s].action->trigger();
if (key == "Next"_L1) shortcuts[u"next_track"_s].action->trigger();
if (key == "Previous"_L1) shortcuts[u"prev_track"_s].action->trigger();
}

View File

@@ -25,6 +25,8 @@
#include "globalshortcutsbackend.h"
#include "globalshortcutsmanager.h"
using namespace Qt::Literals::StringLiterals;
GlobalShortcutsBackend::GlobalShortcutsBackend(GlobalShortcutsManager *manager, const Type type, QObject *parent)
: QObject(parent),
manager_(manager),
@@ -35,19 +37,19 @@ QString GlobalShortcutsBackend::name() const {
switch (type_) {
case Type::None:
return QStringLiteral("None");
return u"None"_s;
case Type::KDE:
return QStringLiteral("KDE");
return u"KDE"_s;
case Type::Gnome:
return QStringLiteral("Gnome");
return u"Gnome"_s;
case Type::Mate:
return QStringLiteral("Mate");
return u"Mate"_s;
case Type::X11:
return QStringLiteral("X11");
return u"X11"_s;
case Type::macOS:
return QStringLiteral("macOS");
return u"macOS"_s;
case Type::Win:
return QStringLiteral("Windows");
return u"Windows"_s;
}
return QString();

View File

@@ -60,31 +60,33 @@
#include "settings/globalshortcutssettingspage.h"
using namespace Qt::Literals::StringLiterals;
GlobalShortcutsManager::GlobalShortcutsManager(QWidget *parent) : QWidget(parent) {
settings_.beginGroup(GlobalShortcutsSettingsPage::kSettingsGroup);
// Create actions
AddShortcut(QStringLiteral("play"), tr("Play"), std::bind(&GlobalShortcutsManager::Play, this));
AddShortcut(QStringLiteral("pause"), tr("Pause"), std::bind(&GlobalShortcutsManager::Pause, this));
AddShortcut(QStringLiteral("play_pause"), tr("Play/Pause"), std::bind(&GlobalShortcutsManager::PlayPause, this), QKeySequence(Qt::Key_MediaPlay));
AddShortcut(QStringLiteral("stop"), tr("Stop"), std::bind(&GlobalShortcutsManager::Stop, this), QKeySequence(Qt::Key_MediaStop));
AddShortcut(QStringLiteral("stop_after"), tr("Stop playing after current track"), std::bind(&GlobalShortcutsManager::StopAfter, this));
AddShortcut(QStringLiteral("next_track"), tr("Next track"), std::bind(&GlobalShortcutsManager::Next, this), QKeySequence(Qt::Key_MediaNext));
AddShortcut(QStringLiteral("prev_track"), tr("Previous track"), std::bind(&GlobalShortcutsManager::Previous, this), QKeySequence(Qt::Key_MediaPrevious));
AddShortcut(QStringLiteral("restart_or_prev_track"), tr("Restart or previous track"), std::bind(&GlobalShortcutsManager::RestartOrPrevious, this));
AddShortcut(QStringLiteral("inc_volume"), tr("Increase volume"), std::bind(&GlobalShortcutsManager::IncVolume, this));
AddShortcut(QStringLiteral("dec_volume"), tr("Decrease volume"), std::bind(&GlobalShortcutsManager::DecVolume, this));
AddShortcut(QStringLiteral("mute"), tr("Mute"), std::bind(&GlobalShortcutsManager::Mute, this));
AddShortcut(QStringLiteral("seek_forward"), tr("Seek forward"), std::bind(&GlobalShortcutsManager::SeekForward, this));
AddShortcut(QStringLiteral("seek_backward"), tr("Seek backward"), std::bind(&GlobalShortcutsManager::SeekBackward, this));
AddShortcut(QStringLiteral("show_hide"), tr("Show/Hide"), std::bind(&GlobalShortcutsManager::ShowHide, this));
AddShortcut(QStringLiteral("show_osd"), tr("Show OSD"), std::bind(&GlobalShortcutsManager::ShowOSD, this));
AddShortcut(QStringLiteral("toggle_pretty_osd"), tr("Toggle Pretty OSD"), std::bind(&GlobalShortcutsManager::TogglePrettyOSD, this)); // Toggling possible only for pretty OSD
AddShortcut(QStringLiteral("shuffle_mode"), tr("Change shuffle mode"), std::bind(&GlobalShortcutsManager::CycleShuffleMode, this));
AddShortcut(QStringLiteral("repeat_mode"), tr("Change repeat mode"), std::bind(&GlobalShortcutsManager::CycleRepeatMode, this));
AddShortcut(QStringLiteral("toggle_scrobbling"), tr("Enable/disable scrobbling"), std::bind(&GlobalShortcutsManager::ToggleScrobbling, this));
AddShortcut(QStringLiteral("love"), tr("Love"), std::bind(&GlobalShortcutsManager::Love, this));
AddShortcut(u"play"_s, tr("Play"), std::bind(&GlobalShortcutsManager::Play, this));
AddShortcut(u"pause"_s, tr("Pause"), std::bind(&GlobalShortcutsManager::Pause, this));
AddShortcut(u"play_pause"_s, tr("Play/Pause"), std::bind(&GlobalShortcutsManager::PlayPause, this), QKeySequence(Qt::Key_MediaPlay));
AddShortcut(u"stop"_s, tr("Stop"), std::bind(&GlobalShortcutsManager::Stop, this), QKeySequence(Qt::Key_MediaStop));
AddShortcut(u"stop_after"_s, tr("Stop playing after current track"), std::bind(&GlobalShortcutsManager::StopAfter, this));
AddShortcut(u"next_track"_s, tr("Next track"), std::bind(&GlobalShortcutsManager::Next, this), QKeySequence(Qt::Key_MediaNext));
AddShortcut(u"prev_track"_s, tr("Previous track"), std::bind(&GlobalShortcutsManager::Previous, this), QKeySequence(Qt::Key_MediaPrevious));
AddShortcut(u"restart_or_prev_track"_s, tr("Restart or previous track"), std::bind(&GlobalShortcutsManager::RestartOrPrevious, this));
AddShortcut(u"inc_volume"_s, tr("Increase volume"), std::bind(&GlobalShortcutsManager::IncVolume, this));
AddShortcut(u"dec_volume"_s, tr("Decrease volume"), std::bind(&GlobalShortcutsManager::DecVolume, this));
AddShortcut(u"mute"_s, tr("Mute"), std::bind(&GlobalShortcutsManager::Mute, this));
AddShortcut(u"seek_forward"_s, tr("Seek forward"), std::bind(&GlobalShortcutsManager::SeekForward, this));
AddShortcut(u"seek_backward"_s, tr("Seek backward"), std::bind(&GlobalShortcutsManager::SeekBackward, this));
AddShortcut(u"show_hide"_s, tr("Show/Hide"), std::bind(&GlobalShortcutsManager::ShowHide, this));
AddShortcut(u"show_osd"_s, tr("Show OSD"), std::bind(&GlobalShortcutsManager::ShowOSD, this));
AddShortcut(u"toggle_pretty_osd"_s, tr("Toggle Pretty OSD"), std::bind(&GlobalShortcutsManager::TogglePrettyOSD, this)); // Toggling possible only for pretty OSD
AddShortcut(u"shuffle_mode"_s, tr("Change shuffle mode"), std::bind(&GlobalShortcutsManager::CycleShuffleMode, this));
AddShortcut(u"repeat_mode"_s, tr("Change repeat mode"), std::bind(&GlobalShortcutsManager::CycleRepeatMode, this));
AddShortcut(u"toggle_scrobbling"_s, tr("Enable/disable scrobbling"), std::bind(&GlobalShortcutsManager::ToggleScrobbling, this));
AddShortcut(u"love"_s, tr("Love"), std::bind(&GlobalShortcutsManager::Love, this));
// Create backends - these do the actual shortcut registration