Rename KDE global shortcuts to KGlobalAccel

This commit is contained in:
Jonas Kvinge 2024-11-12 23:03:57 +01:00
parent f2845b6632
commit 7a7550388d
13 changed files with 71 additions and 84 deletions

View File

@ -312,7 +312,7 @@ optional_component(X11_GLOBALSHORTCUTS ON "X11 global shortcuts"
DEPENDS "QX11Application" HAVE_QX11APPLICATION
)
optional_component(KDE_GLOBALSHORTCUTS ON "KDE global shortcuts"
optional_component(KGLOBALACCEL_GLOBALSHORTCUTS ON "KGlobalAccel global shortcuts"
DEPENDS "D-Bus support" HAVE_DBUS
)
@ -362,7 +362,7 @@ if(HAVE_SONGFINGERPRINTING OR HAVE_MUSICBRAINZ)
set(HAVE_CHROMAPRINT ON)
endif()
if(HAVE_X11_GLOBALSHORTCUTS OR HAVE_KDE_GLOBALSHORTCUTS OR APPLE OR WIN32)
if(HAVE_X11_GLOBALSHORTCUTS OR HAVE_KGLOBALACCEL_GLOBALSHORTCUTS OR APPLE OR WIN32)
set(HAVE_GLOBALSHORTCUTS ON)
endif()
@ -1226,10 +1226,10 @@ if(HAVE_GLOBALSHORTCUTS)
UI src/globalshortcuts/globalshortcutgrabber.ui src/settings/globalshortcutssettingspage.ui
)
if(HAVE_KDE_GLOBALSHORTCUTS)
optional_source(HAVE_KDE_GLOBALSHORTCUTS
SOURCES src/globalshortcuts/globalshortcutsbackend-kde.cpp
HEADERS src/globalshortcuts/globalshortcutsbackend-kde.h
if(HAVE_KGLOBALACCEL_GLOBALSHORTCUTS)
optional_source(HAVE_KGLOBALACCEL_GLOBALSHORTCUTS
SOURCES src/globalshortcuts/globalshortcutsbackend-kglobalaccel.cpp
HEADERS src/globalshortcuts/globalshortcutsbackend-kglobalaccel.h
)
qt_add_dbus_interface(SOURCES src/globalshortcuts/org.kde.KGlobalAccel.xml kglobalaccel)
qt_add_dbus_interface(SOURCES src/globalshortcuts/org.kde.KGlobalAccel.Component.xml kglobalaccelcomponent)

6
debian/copyright vendored
View File

@ -75,10 +75,8 @@ Files: src/core/main.h
src/covermanager/spotifycoverprovider.h
src/covermanager/musixmatchcoverprovider.cpp
src/covermanager/musixmatchcoverprovider.h
src/globalshortcuts/globalshortcutsbackend-kde.cpp
src/globalshortcuts/globalshortcutsbackend-kde.h
src/globalshortcuts/globalshortcutsbackend-mate.cpp
src/globalshortcuts/globalshortcutsbackend-mate.h
src/globalshortcuts/globalshortcutsbackend-kglobalaccel.cpp
src/globalshortcuts/globalshortcutsbackend-kglobalaccel.h
src/globalshortcuts/globalshortcutsbackend-x11.cpp
src/globalshortcuts/globalshortcutsbackend-x11.h
src/globalshortcuts/globalshortcutsbackend-win.cpp

View File

@ -25,7 +25,7 @@
#cmakedefine HAVE_EBUR128
#cmakedefine HAVE_GLOBALSHORTCUTS
#cmakedefine HAVE_X11_GLOBALSHORTCUTS
#cmakedefine HAVE_KDE_GLOBALSHORTCUTS
#cmakedefine HAVE_KGLOBALACCEL_GLOBALSHORTCUTS
#cmakedefine HAVE_SUBSONIC
#cmakedefine HAVE_TIDAL
#cmakedefine HAVE_SPOTIFY

View File

@ -23,7 +23,7 @@
namespace GlobalShortcutsSettings {
constexpr char kSettingsGroup[] = "GlobalShortcuts";
constexpr char kUseKDE[] = "use_kde";
constexpr char kUseKGlobalAccel[] = "use_kglobalaccel";
constexpr char kUseX11[] = "use_x11";
} // namespace

View File

@ -33,7 +33,7 @@
#include "core/logging.h"
#include "globalshortcutsbackend-kde.h"
#include "globalshortcutsbackend-kglobalaccel.h"
#include "kglobalaccel.h"
#include "kglobalaccelcomponent.h"
@ -41,28 +41,28 @@
using namespace Qt::Literals::StringLiterals;
namespace {
constexpr char kKdeService[] = "org.kde.kglobalaccel";
constexpr char kKdePath[] = "/kglobalaccel";
constexpr char kKGlobalAccelService[] = "org.kde.kglobalaccel";
constexpr char kKGlobalAccelPath[] = "/kglobalaccel";
}
GlobalShortcutsBackendKDE::GlobalShortcutsBackendKDE(GlobalShortcutsManager *manager, QObject *parent)
: GlobalShortcutsBackend(manager, GlobalShortcutsBackend::Type::KDE, parent),
GlobalShortcutsBackendKGlobalAccel::GlobalShortcutsBackendKGlobalAccel(GlobalShortcutsManager *manager, QObject *parent)
: GlobalShortcutsBackend(manager, GlobalShortcutsBackend::Type::KGlobalAccel, parent),
interface_(nullptr),
component_(nullptr) {}
bool GlobalShortcutsBackendKDE::IsKDEAvailable() {
bool GlobalShortcutsBackendKGlobalAccel::IsKGlobalAccelAvailable() {
return QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kKdeService));
return QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kKGlobalAccelService));
}
bool GlobalShortcutsBackendKDE::IsAvailable() const {
bool GlobalShortcutsBackendKGlobalAccel::IsAvailable() const {
return IsKDEAvailable();
return IsKGlobalAccelAvailable();
}
bool GlobalShortcutsBackendKDE::IsMediaShortcut(const GlobalShortcutsManager::Shortcut &shortcut) const {
bool GlobalShortcutsBackendKGlobalAccel::IsMediaShortcut(const GlobalShortcutsManager::Shortcut &shortcut) const {
return (shortcut.action->shortcut() == QKeySequence(Qt::Key_MediaPlay) ||
shortcut.action->shortcut() == QKeySequence(Qt::Key_MediaStop) ||
@ -72,17 +72,17 @@ bool GlobalShortcutsBackendKDE::IsMediaShortcut(const GlobalShortcutsManager::Sh
}
bool GlobalShortcutsBackendKDE::DoRegister() {
bool GlobalShortcutsBackendKGlobalAccel::DoRegister() {
qLog(Debug) << "Registering";
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kKdeService))) {
if (!QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kKGlobalAccelService))) {
qLog(Warning) << "KGlobalAccel is not registered";
return false;
}
if (!interface_) {
interface_ = new OrgKdeKGlobalAccelInterface(QLatin1String(kKdeService), QLatin1String(kKdePath), QDBusConnection::sessionBus(), this);
interface_ = new OrgKdeKGlobalAccelInterface(QLatin1String(kKGlobalAccelService), QLatin1String(kKGlobalAccelPath), QDBusConnection::sessionBus(), this);
}
const QList<GlobalShortcutsManager::Shortcut> shortcuts = manager_->shortcuts().values();
@ -92,13 +92,13 @@ bool GlobalShortcutsBackendKDE::DoRegister() {
QDBusPendingReply<QDBusObjectPath> reply = interface_->getComponent(QCoreApplication::applicationName());
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutsBackendKDE::RegisterFinished);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutsBackendKGlobalAccel::RegisterFinished);
return true;
}
void GlobalShortcutsBackendKDE::RegisterFinished(QDBusPendingCallWatcher *watcher) {
void GlobalShortcutsBackendKGlobalAccel::RegisterFinished(QDBusPendingCallWatcher *watcher) {
QDBusReply<QDBusObjectPath> reply = watcher->reply();
watcher->deleteLater();
@ -111,7 +111,7 @@ void GlobalShortcutsBackendKDE::RegisterFinished(QDBusPendingCallWatcher *watche
}
if (!component_) {
component_ = new org::kde::kglobalaccel::Component(QLatin1String(kKdeService), reply.value().path(), QDBusConnection::sessionBus(), interface_);
component_ = new org::kde::kglobalaccel::Component(QLatin1String(kKGlobalAccelService), reply.value().path(), QDBusConnection::sessionBus(), interface_);
}
if (!component_->isValid()) {
@ -119,13 +119,13 @@ void GlobalShortcutsBackendKDE::RegisterFinished(QDBusPendingCallWatcher *watche
return;
}
QObject::connect(component_, &org::kde::kglobalaccel::Component::globalShortcutPressed, this, &GlobalShortcutsBackendKDE::GlobalShortcutPressed, Qt::UniqueConnection);
QObject::connect(component_, &org::kde::kglobalaccel::Component::globalShortcutPressed, this, &GlobalShortcutsBackendKGlobalAccel::GlobalShortcutPressed, Qt::UniqueConnection);
qLog(Debug) << "Registered.";
}
void GlobalShortcutsBackendKDE::DoUnregister() {
void GlobalShortcutsBackendKGlobalAccel::DoUnregister() {
if (!interface_ || !interface_->isValid()) return;
@ -146,7 +146,7 @@ void GlobalShortcutsBackendKDE::DoUnregister() {
}
bool GlobalShortcutsBackendKDE::RegisterShortcut(const GlobalShortcutsManager::Shortcut &shortcut) {
bool GlobalShortcutsBackendKGlobalAccel::RegisterShortcut(const GlobalShortcutsManager::Shortcut &shortcut) {
if (!interface_ || !interface_->isValid() || shortcut.id.isEmpty() || !shortcut.action || shortcut.action->shortcut().isEmpty()) return false;
@ -172,7 +172,7 @@ bool GlobalShortcutsBackendKDE::RegisterShortcut(const GlobalShortcutsManager::S
}
QStringList GlobalShortcutsBackendKDE::GetActionId(const QString &id, const QAction *action) {
QStringList GlobalShortcutsBackendKGlobalAccel::GetActionId(const QString &id, const QAction *action) {
QStringList ret;
ret << QCoreApplication::applicationName();
@ -185,7 +185,7 @@ QStringList GlobalShortcutsBackendKDE::GetActionId(const QString &id, const QAct
}
QList<int> GlobalShortcutsBackendKDE::ToIntList(const QList<QKeySequence> &sequence_list) {
QList<int> GlobalShortcutsBackendKGlobalAccel::ToIntList(const QList<QKeySequence> &sequence_list) {
QList<int> ret;
ret.reserve(sequence_list.count());
@ -197,7 +197,7 @@ QList<int> GlobalShortcutsBackendKDE::ToIntList(const QList<QKeySequence> &seque
}
QList<QKeySequence> GlobalShortcutsBackendKDE::ToKeySequenceList(const QList<int> &sequence_list) {
QList<QKeySequence> GlobalShortcutsBackendKGlobalAccel::ToKeySequenceList(const QList<int> &sequence_list) {
QList<QKeySequence> ret;
ret.reserve(sequence_list.count());
@ -209,7 +209,7 @@ QList<QKeySequence> GlobalShortcutsBackendKDE::ToKeySequenceList(const QList<int
}
void GlobalShortcutsBackendKDE::GlobalShortcutPressed(const QString &component_unique, const QString &shortcut_unique, const qint64 timestamp) {
void GlobalShortcutsBackendKGlobalAccel::GlobalShortcutPressed(const QString &component_unique, const QString &shortcut_unique, const qint64 timestamp) {
Q_UNUSED(timestamp)

View File

@ -37,14 +37,14 @@ class QAction;
class OrgKdeKGlobalAccelInterface;
class OrgKdeKglobalaccelComponentInterface;
class GlobalShortcutsBackendKDE : public GlobalShortcutsBackend {
class GlobalShortcutsBackendKGlobalAccel : public GlobalShortcutsBackend {
Q_OBJECT
public:
explicit GlobalShortcutsBackendKDE(GlobalShortcutsManager *manager, QObject *parent = nullptr);
explicit GlobalShortcutsBackendKGlobalAccel(GlobalShortcutsManager *manager, QObject *parent = nullptr);
bool IsAvailable() const override;
static bool IsKDEAvailable();
static bool IsKGlobalAccelAvailable();
protected:
bool DoRegister() override;

View File

@ -38,8 +38,8 @@ QString GlobalShortcutsBackend::name() const {
switch (type_) {
case Type::None:
return u"None"_s;
case Type::KDE:
return u"KDE"_s;
case Type::KGlobalAccel:
return u"KGlobalAccel"_s;
case Type::X11:
return u"X11"_s;
case Type::macOS:

View File

@ -34,7 +34,7 @@ class GlobalShortcutsBackend : public QObject {
public:
enum class Type {
None = 0,
KDE,
KGlobalAccel,
X11,
macOS,
Win

View File

@ -36,8 +36,8 @@
#include "globalshortcutsmanager.h"
#include "globalshortcutsbackend.h"
#ifdef HAVE_KDE_GLOBALSHORTCUTS
#include "globalshortcutsbackend-kde.h"
#ifdef HAVE_KGLOBALACCEL_GLOBALSHORTCUTS
#include "globalshortcutsbackend-kglobalaccel.h"
#endif
#ifdef HAVE_X11_GLOBALSHORTCUTS
@ -84,8 +84,8 @@ GlobalShortcutsManager::GlobalShortcutsManager(QWidget *parent) : QWidget(parent
// Create backends - these do the actual shortcut registration
#ifdef HAVE_KDE_GLOBALSHORTCUTS
backends_ << new GlobalShortcutsBackendKDE(this, this);
#ifdef HAVE_KGLOBALACCEL_GLOBALSHORTCUTS
backends_ << new GlobalShortcutsBackendKGlobalAccel(this, this);
#endif
#ifdef Q_OS_MACOS
@ -116,9 +116,9 @@ void GlobalShortcutsManager::ReloadSettings() {
backends_enabled_ << GlobalShortcutsBackend::Type::Win;
#endif
#ifdef HAVE_KDE_GLOBALSHORTCUTS
if (settings_.value(GlobalShortcutsSettings::kUseKDE, true).toBool()) {
backends_enabled_ << GlobalShortcutsBackend::Type::KDE;
#ifdef HAVE_KGLOBALACCEL_GLOBALSHORTCUTS
if (settings_.value(GlobalShortcutsSettings::kUseKGlobalAccel, true).toBool()) {
backends_enabled_ << GlobalShortcutsBackend::Type::KGlobalAccel;
}
#endif
@ -159,11 +159,11 @@ GlobalShortcutsManager::Shortcut GlobalShortcutsManager::AddShortcut(const QStri
}
#ifdef HAVE_KDE_GLOBALSHORTCUTS
#ifdef HAVE_KGLOBALACCEL_GLOBALSHORTCUTS
bool GlobalShortcutsManager::IsKdeAvailable() {
bool GlobalShortcutsManager::IsKGlobalAccelAvailable() {
return GlobalShortcutsBackendKDE::IsKDEAvailable();
return GlobalShortcutsBackendKGlobalAccel::IsKGlobalAccelAvailable();
}

View File

@ -57,7 +57,7 @@ class GlobalShortcutsManager : public QWidget {
QMap<QString, Shortcut> shortcuts() const { return shortcuts_; }
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) && defined(HAVE_DBUS)
static bool IsKdeAvailable();
static bool IsKGlobalAccelAvailable();
#endif
#ifdef HAVE_X11_GLOBALSHORTCUTS

View File

@ -41,7 +41,6 @@
#include "core/iconloader.h"
#include "core/logging.h"
#include "core/settings.h"
#include "utilities/envutils.h"
#include "constants/globalshortcutssettings.h"
#include "globalshortcuts/globalshortcutgrabber.h"
#include "globalshortcuts/globalshortcutsmanager.h"
@ -72,10 +71,10 @@ GlobalShortcutsSettingsPage::GlobalShortcutsSettingsPage(SettingsDialog *dialog,
QObject::connect(ui_->radio_custom, &QRadioButton::clicked, this, &GlobalShortcutsSettingsPage::ChangeClicked);
QObject::connect(ui_->button_change, &QPushButton::clicked, this, &GlobalShortcutsSettingsPage::ChangeClicked);
#ifdef HAVE_KDE_GLOBALSHORTCUTS
QObject::connect(ui_->checkbox_kde, &QCheckBox::toggled, this, &GlobalShortcutsSettingsPage::ShortcutOptionsChanged);
#ifdef HAVE_KGLOBALACCEL_GLOBALSHORTCUTS
QObject::connect(ui_->checkbox_kglobalaccel, &QCheckBox::toggled, this, &GlobalShortcutsSettingsPage::ShortcutOptionsChanged);
#else
ui_->widget_kde->hide();
ui_->widget_kglobalaccel->hide();
#endif
#ifdef HAVE_X11_GLOBALSHORTCUTS
@ -100,21 +99,20 @@ void GlobalShortcutsSettingsPage::Load() {
if (!initialized_) {
initialized_ = true;
de_ = Utilities::DesktopEnvironment();
ui_->widget_warning->hide();
#ifdef Q_OS_MACOS
QObject::connect(ui_->button_macos_preferences, &QPushButton::clicked, global_shortcuts_manager_, &GlobalShortcutsManager::ShowMacAccessibilityDialog);
#endif
#ifdef HAVE_KDE_GLOBALSHORTCUTS
if (GlobalShortcutsManager::IsKdeAvailable()) {
qLog(Debug) << "KDE (KGlobalAccel) backend is available.";
ui_->widget_kde->show();
#ifdef HAVE_KGLOBALACCEL_GLOBALSHORTCUTS
if (GlobalShortcutsManager::IsKGlobalAccelAvailable()) {
qLog(Debug) << "KGlobalAccel backend is available.";
ui_->widget_kglobalaccel->show();
}
else {
qLog(Debug) << "KDE (KGlobalAccel) backend is unavailable.";
ui_->widget_kde->hide();
qLog(Debug) << "KGlobalAccel backend is unavailable.";
ui_->widget_kglobalaccel->hide();
}
#endif
@ -148,9 +146,9 @@ void GlobalShortcutsSettingsPage::Load() {
SetShortcut(shortcut.s.id, shortcut.s.action->shortcut());
}
#ifdef HAVE_KDE_GLOBALSHORTCUTS
if (ui_->widget_kde->isVisibleTo(this)) {
ui_->checkbox_kde->setChecked(s.value(kUseKDE, true).toBool());
#ifdef HAVE_KGLOBALACCEL_GLOBALSHORTCUTS
if (ui_->widget_kglobalaccel->isVisibleTo(this)) {
ui_->checkbox_kglobalaccel->setChecked(s.value(kUseKGlobalAccel, true).toBool());
}
#endif
@ -160,7 +158,7 @@ void GlobalShortcutsSettingsPage::Load() {
}
#endif
#if defined(HAVE_KDE_GLOBALSHORTCUTS) || defined(HAVE_X11_GLOBALSHORTCUTS)
#if defined(HAVE_KGLOBALACCEL_GLOBALSHORTCUTS) || defined(HAVE_X11_GLOBALSHORTCUTS)
ShortcutOptionsChanged();
#endif
@ -188,8 +186,8 @@ void GlobalShortcutsSettingsPage::Save() {
s.setValue(shortcut.s.id, shortcut.key.toString());
}
#ifdef HAVE_KDE_GLOBALSHORTCUTS
s.setValue(kUseKDE, ui_->checkbox_kde->isChecked());
#ifdef HAVE_KGLOBALACCEL_GLOBALSHORTCUTS
s.setValue(kUseKGlobalAccel, ui_->checkbox_kglobalaccel->isChecked());
#endif
#ifdef HAVE_X11_GLOBALSHORTCUTS
@ -204,7 +202,7 @@ void GlobalShortcutsSettingsPage::Save() {
void GlobalShortcutsSettingsPage::ShortcutOptionsChanged() {
bool configure_shortcuts = (ui_->widget_kde->isVisibleTo(this) && ui_->checkbox_kde->isChecked()) ||
bool configure_shortcuts = (ui_->widget_kglobalaccel->isVisibleTo(this) && ui_->checkbox_kglobalaccel->isChecked()) ||
(ui_->widget_x11->isVisibleTo(this) && ui_->checkbox_x11->isChecked());
ui_->list->setEnabled(configure_shortcuts);
@ -289,15 +287,7 @@ void GlobalShortcutsSettingsPage::ChangeClicked() {
void GlobalShortcutsSettingsPage::X11Warning() {
QString de = de_.toLower();
if (de == "kde"_L1 || de == "gnome"_L1 || de == "x-cinnamon"_L1 || de == "mate"_L1) {
QString text(tr("Using X11 shortcuts on %1 is not recommended and can cause keyboard to become unresponsive!").arg(de_));
text += tr(" Shortcuts on %1 are usually used through MPRIS and KGlobalAccel.").arg(de_);
ui_->label_warn_text->setText(text);
ui_->widget_warning->show();
}
else {
ui_->widget_warning->hide();
}
ui_->label_warn_text->setText(tr("Using X11 shortcuts is not recommended and can cause keyboard to become unresponsive! Shortcuts on should usually be used through MPRIS2 / KGlobalAccel."));
ui_->widget_warning->show();
}

View File

@ -78,7 +78,6 @@ class GlobalShortcutsSettingsPage : public SettingsPage {
QMap<QString, Shortcut> shortcuts_;
QString current_id_;
QString de_;
};
#endif // GLOBALSHORTCUTSSETTINGSPAGE_H

View File

@ -19,7 +19,7 @@
</property>
<layout class="QVBoxLayout" name="layout_globalshortcutssettingspage">
<item>
<widget class="QWidget" name="widget_kde" native="true">
<widget class="QWidget" name="widget_kglobalaccel" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<property name="leftMargin">
<number>0</number>
@ -34,9 +34,9 @@
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="checkbox_kde">
<widget class="QCheckBox" name="checkbox_kglobalaccel">
<property name="text">
<string>Use KDE (KGlobalAccel) shortcuts when available</string>
<string>Use KGlobalAccel shortcuts when available</string>
</property>
</widget>
</item>