Disable automatic conversions from 8-bit strings

This commit is contained in:
Jonas Kvinge
2024-04-11 02:56:01 +02:00
parent 58944993b8
commit 0c6872b352
310 changed files with 2501 additions and 2332 deletions

View File

@@ -110,7 +110,7 @@ bool GlobalShortcutGrabber::event(QEvent *e) {
}
void GlobalShortcutGrabber::UpdateText() {
ui_->label_key->setText("<b>" + ret_.toString(QKeySequence::NativeText) + "</b>");
ui_->label_key->setText(QStringLiteral("<b>") + ret_.toString(QKeySequence::NativeText) + QStringLiteral("</b>"));
}
void GlobalShortcutGrabber::Accepted() {

View File

@@ -37,9 +37,11 @@
#include "gnomesettingsdaemon.h"
const char *GlobalShortcutsBackendGnome::kService1 = "org.gnome.SettingsDaemon.MediaKeys";
const char *GlobalShortcutsBackendGnome::kService2 = "org.gnome.SettingsDaemon";
const char *GlobalShortcutsBackendGnome::kPath = "/org/gnome/SettingsDaemon/MediaKeys";
namespace {
constexpr char kService1[] = "org.gnome.SettingsDaemon.MediaKeys";
constexpr char kService2[] = "org.gnome.SettingsDaemon";
constexpr char kPath[] = "/org/gnome/SettingsDaemon/MediaKeys";
} // namespace
GlobalShortcutsBackendGnome::GlobalShortcutsBackendGnome(GlobalShortcutsManager *manager, QObject *parent)
: GlobalShortcutsBackend(manager, GlobalShortcutsBackend::Type::Gnome, parent),
@@ -52,7 +54,7 @@ bool GlobalShortcutsBackendGnome::IsAvailable() const {
bool GlobalShortcutsBackendGnome::IsGnomeAvailable() {
return QDBusConnection::sessionBus().interface()->isServiceRegistered(kService1) || QDBusConnection::sessionBus().interface()->isServiceRegistered(kService2);
return QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService1)) || QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService2));
}
@@ -61,11 +63,11 @@ bool GlobalShortcutsBackendGnome::DoRegister() {
qLog(Debug) << "Registering";
if (!interface_) {
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(kService1)) {
interface_ = new OrgGnomeSettingsDaemonMediaKeysInterface(kService1, kPath, QDBusConnection::sessionBus(), this);
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService1))) {
interface_ = new OrgGnomeSettingsDaemonMediaKeysInterface(QLatin1String(kService1), QLatin1String(kPath), QDBusConnection::sessionBus(), this);
}
else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(kService2)) {
interface_ = new OrgGnomeSettingsDaemonMediaKeysInterface(kService2, kPath, QDBusConnection::sessionBus(), this);
else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService2))) {
interface_ = new OrgGnomeSettingsDaemonMediaKeysInterface(QLatin1String(kService2), QLatin1String(kPath), QDBusConnection::sessionBus(), this);
}
}
@@ -116,9 +118,9 @@ void GlobalShortcutsBackendGnome::DoUnregister() {
void GlobalShortcutsBackendGnome::GnomeMediaKeyPressed(const QString&, const QString &key) {
auto shortcuts = manager_->shortcuts();
if (key == "Play") shortcuts[QStringLiteral("play_pause")].action->trigger();
if (key == "Stop") shortcuts[QStringLiteral("stop")].action->trigger();
if (key == "Next") shortcuts[QStringLiteral("next_track")].action->trigger();
if (key == "Previous") shortcuts[QStringLiteral("prev_track")].action->trigger();
if (key == QStringLiteral("Play")) shortcuts[QStringLiteral("play_pause")].action->trigger();
if (key == QStringLiteral("Stop")) shortcuts[QStringLiteral("stop")].action->trigger();
if (key == QStringLiteral("Next")) shortcuts[QStringLiteral("next_track")].action->trigger();
if (key == QStringLiteral("Previous")) shortcuts[QStringLiteral("prev_track")].action->trigger();
}

View File

@@ -52,10 +52,6 @@ class GlobalShortcutsBackendGnome : public GlobalShortcutsBackend {
void GnomeMediaKeyPressed(const QString &application, const QString &key);
private:
static const char *kService1;
static const char *kService2;
static const char *kPath;
OrgGnomeSettingsDaemonMediaKeysInterface *interface_;
bool is_connected_;
};

View File

@@ -38,8 +38,10 @@
#include "kglobalaccel.h"
#include "kglobalaccelcomponent.h"
const char *GlobalShortcutsBackendKDE::kKdeService = "org.kde.kglobalaccel";
const char *GlobalShortcutsBackendKDE::kKdePath = "/kglobalaccel";
namespace {
constexpr char kKdeService[] = "org.kde.kglobalaccel";
constexpr char kKdePath[] = "/kglobalaccel";
}
GlobalShortcutsBackendKDE::GlobalShortcutsBackendKDE(GlobalShortcutsManager *manager, QObject *parent)
: GlobalShortcutsBackend(manager, GlobalShortcutsBackend::Type::KDE, parent),
@@ -48,7 +50,7 @@ GlobalShortcutsBackendKDE::GlobalShortcutsBackendKDE(GlobalShortcutsManager *man
bool GlobalShortcutsBackendKDE::IsKDEAvailable() {
return QDBusConnection::sessionBus().interface()->isServiceRegistered(kKdeService);
return QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kKdeService));
}
@@ -72,13 +74,13 @@ bool GlobalShortcutsBackendKDE::DoRegister() {
qLog(Debug) << "Registering";
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(kKdeService)) {
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kKdeService))) {
qLog(Warning) << "KGlobalAccel is not registered";
return false;
}
if (!interface_) {
interface_ = new OrgKdeKGlobalAccelInterface(kKdeService, kKdePath, QDBusConnection::sessionBus(), this);
interface_ = new OrgKdeKGlobalAccelInterface(QLatin1String(kKdeService), QLatin1String(kKdePath), QDBusConnection::sessionBus(), this);
}
QList<GlobalShortcutsManager::Shortcut> shortcuts = manager_->shortcuts().values();
@@ -100,14 +102,14 @@ void GlobalShortcutsBackendKDE::RegisterFinished(QDBusPendingCallWatcher *watche
watcher->deleteLater();
if (!reply.isValid()) {
if (reply.error().name() != "org.kde.kglobalaccel.NoSuchComponent") {
if (reply.error().name() != QStringLiteral("org.kde.kglobalaccel.NoSuchComponent")) {
qLog(Error) << "Failed to register:" << reply.error().name() << reply.error().message();
}
return;
}
if (!component_) {
component_ = new org::kde::kglobalaccel::Component(kKdeService, reply.value().path(), QDBusConnection::sessionBus(), interface_);
component_ = new org::kde::kglobalaccel::Component(QLatin1String(kKdeService), reply.value().path(), QDBusConnection::sessionBus(), interface_);
}
if (!component_->isValid()) {
@@ -174,7 +176,7 @@ QStringList GlobalShortcutsBackendKDE::GetActionId(const QString &id, const QAct
ret << QCoreApplication::applicationName();
ret << id;
ret << QCoreApplication::applicationName();
ret << action->text().remove('&');
ret << action->text().remove(QLatin1Char('&'));
if (ret.back().isEmpty()) ret.back() = id;
return ret;

View File

@@ -62,9 +62,6 @@ class GlobalShortcutsBackendKDE : public GlobalShortcutsBackend {
void GlobalShortcutPressed(const QString &component_unique, const QString &shortcut_unique, qint64);
private:
static const char *kKdeService;
static const char *kKdePath;
OrgKdeKGlobalAccelInterface *interface_;
OrgKdeKglobalaccelComponentInterface *component_;
QMultiHash<QString, QAction*> actions_;

View File

@@ -35,9 +35,11 @@
#include "matesettingsdaemon.h"
const char *GlobalShortcutsBackendMate::kService1 = "org.mate.SettingsDaemon.MediaKeys";
const char *GlobalShortcutsBackendMate::kService2 = "org.mate.SettingsDaemon";
const char *GlobalShortcutsBackendMate::kPath = "/org/mate/SettingsDaemon/MediaKeys";
namespace {
constexpr char kService1[] = "org.mate.SettingsDaemon.MediaKeys";
constexpr char kService2[] = "org.mate.SettingsDaemon";
constexpr char kPath[] = "/org/mate/SettingsDaemon/MediaKeys";
}
GlobalShortcutsBackendMate::GlobalShortcutsBackendMate(GlobalShortcutsManager *manager, QObject *parent)
: GlobalShortcutsBackend(manager, GlobalShortcutsBackend::Type::Mate, parent),
@@ -52,7 +54,7 @@ bool GlobalShortcutsBackendMate::IsAvailable() const {
bool GlobalShortcutsBackendMate::IsMateAvailable() {
return QDBusConnection::sessionBus().interface()->isServiceRegistered(kService1) || QDBusConnection::sessionBus().interface()->isServiceRegistered(kService2);
return QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService1)) || QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService2));
}
@@ -61,11 +63,11 @@ bool GlobalShortcutsBackendMate::DoRegister() {
qLog(Debug) << "Registering";
if (!interface_) {
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(kService1)) {
interface_ = new OrgMateSettingsDaemonMediaKeysInterface(kService1, kPath, QDBusConnection::sessionBus(), this);
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService1))) {
interface_ = new OrgMateSettingsDaemonMediaKeysInterface(QLatin1String(kService1), QLatin1String(kPath), QDBusConnection::sessionBus(), this);
}
else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(kService2)) {
interface_ = new OrgMateSettingsDaemonMediaKeysInterface(kService2, kPath, QDBusConnection::sessionBus(), this);
else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService2))) {
interface_ = new OrgMateSettingsDaemonMediaKeysInterface(QLatin1String(kService2), QLatin1String(kPath), QDBusConnection::sessionBus(), this);
}
}
@@ -116,9 +118,9 @@ void GlobalShortcutsBackendMate::DoUnregister() {
void GlobalShortcutsBackendMate::MateMediaKeyPressed(const QString&, const QString &key) {
auto shortcuts = manager_->shortcuts();
if (key == "Play") shortcuts[QStringLiteral("play_pause")].action->trigger();
if (key == "Stop") shortcuts[QStringLiteral("stop")].action->trigger();
if (key == "Next") shortcuts[QStringLiteral("next_track")].action->trigger();
if (key == "Previous") shortcuts[QStringLiteral("prev_track")].action->trigger();
if (key == QStringLiteral("Play")) shortcuts[QStringLiteral("play_pause")].action->trigger();
if (key == QStringLiteral("Stop")) shortcuts[QStringLiteral("stop")].action->trigger();
if (key == QStringLiteral("Next")) shortcuts[QStringLiteral("next_track")].action->trigger();
if (key == QStringLiteral("Previous")) shortcuts[QStringLiteral("prev_track")].action->trigger();
}

View File

@@ -50,10 +50,6 @@ class GlobalShortcutsBackendMate : public GlobalShortcutsBackend {
void MateMediaKeyPressed(const QString &application, const QString &key);
private:
static const char *kService1;
static const char *kService2;
static const char *kPath;
OrgMateSettingsDaemonMediaKeysInterface *interface_;
bool is_connected_;
};

View File

@@ -45,7 +45,7 @@ bool GlobalShortcutsBackendX11::IsAvailable() const {
bool GlobalShortcutsBackendX11::IsX11Available() {
return QApplication::platformName() == "xcb";
return QApplication::platformName() == QStringLiteral("xcb");
}

View File

@@ -36,6 +36,8 @@
#include "globalshortcutsbackend.h"
#include "core/settings.h"
class QShortcut;
class QAction;
@@ -103,7 +105,7 @@ class GlobalShortcutsManager : public QWidget {
private:
QList<GlobalShortcutsBackend*> backends_;
QSettings settings_;
Settings settings_;
QList<GlobalShortcutsBackend::Type> backends_enabled_;
QMap<QString, Shortcut> shortcuts_;
};