Remove deprecated gnome/mate SettingsDaemon global shortcuts

This commit is contained in:
Jonas Kvinge 2024-11-12 22:38:21 +01:00
parent deaeab3cbb
commit f2845b6632
16 changed files with 8 additions and 666 deletions

View File

@ -316,14 +316,6 @@ optional_component(KDE_GLOBALSHORTCUTS ON "KDE global shortcuts"
DEPENDS "D-Bus support" HAVE_DBUS
)
optional_component(GNOME_GLOBALSHORTCUTS ON "Gnome global shortcuts"
DEPENDS "D-Bus support" HAVE_DBUS
)
optional_component(MATE_GLOBALSHORTCUTS ON "Mate global shortcuts"
DEPENDS "D-Bus support" HAVE_DBUS
)
optional_component(UDISKS2 ON "Devices: UDisks2 backend"
DEPENDS "D-Bus support" HAVE_DBUS
)
@ -370,7 +362,7 @@ if(HAVE_SONGFINGERPRINTING OR HAVE_MUSICBRAINZ)
set(HAVE_CHROMAPRINT ON)
endif()
if(HAVE_X11_GLOBALSHORTCUTS OR HAVE_KDE_GLOBALSHORTCUTS OR HAVE_GNOME_GLOBALSHORTCUTS OR HAVE_MATE_GLOBALSHORTCUTS OR APPLE OR WIN32)
if(HAVE_X11_GLOBALSHORTCUTS OR HAVE_KDE_GLOBALSHORTCUTS OR APPLE OR WIN32)
set(HAVE_GLOBALSHORTCUTS ON)
endif()
@ -1243,22 +1235,6 @@ if(HAVE_GLOBALSHORTCUTS)
qt_add_dbus_interface(SOURCES src/globalshortcuts/org.kde.KGlobalAccel.Component.xml kglobalaccelcomponent)
endif()
if(HAVE_GNOME_GLOBALSHORTCUTS)
optional_source(HAVE_GNOME_GLOBALSHORTCUTS
SOURCES src/globalshortcuts/globalshortcutsbackend-gnome.cpp
HEADERS src/globalshortcuts/globalshortcutsbackend-gnome.h
)
qt_add_dbus_interface(SOURCES src/globalshortcuts/org.gnome.SettingsDaemon.MediaKeys.xml gnomesettingsdaemon)
endif()
if(HAVE_MATE_GLOBALSHORTCUTS)
optional_source(HAVE_MATE_GLOBALSHORTCUTS
SOURCES src/globalshortcuts/globalshortcutsbackend-mate.cpp
HEADERS src/globalshortcuts/globalshortcutsbackend-mate.h
)
qt_add_dbus_interface(SOURCES src/globalshortcuts/org.mate.SettingsDaemon.MediaKeys.xml matesettingsdaemon)
endif()
optional_source(HAVE_X11_GLOBALSHORTCUTS
SOURCES src/globalshortcuts/globalshortcutsbackend-x11.cpp src/globalshortcuts/globalshortcut.cpp src/globalshortcuts/globalshortcut-x11.cpp
HEADERS src/globalshortcuts/globalshortcutsbackend-x11.h src/globalshortcuts/globalshortcut.h

View File

@ -26,8 +26,6 @@
#cmakedefine HAVE_GLOBALSHORTCUTS
#cmakedefine HAVE_X11_GLOBALSHORTCUTS
#cmakedefine HAVE_KDE_GLOBALSHORTCUTS
#cmakedefine HAVE_GNOME_GLOBALSHORTCUTS
#cmakedefine HAVE_MATE_GLOBALSHORTCUTS
#cmakedefine HAVE_SUBSONIC
#cmakedefine HAVE_TIDAL
#cmakedefine HAVE_SPOTIFY

View File

@ -24,8 +24,6 @@ namespace GlobalShortcutsSettings {
constexpr char kSettingsGroup[] = "GlobalShortcuts";
constexpr char kUseKDE[] = "use_kde";
constexpr char kUseGnome[] = "use_gnome";
constexpr char kUseMate[] = "use_mate";
constexpr char kUseX11[] = "use_x11";
} // namespace

View File

@ -1,130 +0,0 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2019-2021, 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 "config.h"
#include <QObject>
#include <QCoreApplication>
#include <QDateTime>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>
#include <QAction>
#include "core/logging.h"
#include "globalshortcutsmanager.h"
#include "globalshortcutsbackend.h"
#include "globalshortcutsbackend-gnome.h"
#include "gnomesettingsdaemon.h"
using namespace Qt::Literals::StringLiterals;
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),
interface_(nullptr),
is_connected_(false) {}
bool GlobalShortcutsBackendGnome::IsAvailable() const {
return IsGnomeAvailable();
}
bool GlobalShortcutsBackendGnome::IsGnomeAvailable() {
return QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService1)) || QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService2));
}
bool GlobalShortcutsBackendGnome::DoRegister() {
qLog(Debug) << "Registering";
if (!interface_) {
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService1))) {
interface_ = new OrgGnomeSettingsDaemonMediaKeysInterface(QLatin1String(kService1), QLatin1String(kPath), QDBusConnection::sessionBus(), this);
}
else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService2))) {
interface_ = new OrgGnomeSettingsDaemonMediaKeysInterface(QLatin1String(kService2), QLatin1String(kPath), QDBusConnection::sessionBus(), this);
}
}
if (!interface_) {
qLog(Warning) << "Gnome settings daemon not registered";
return false;
}
QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(QCoreApplication::applicationName(), QDateTime::currentSecsSinceEpoch());
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutsBackendGnome::RegisterFinished);
return true;
}
void GlobalShortcutsBackendGnome::RegisterFinished(QDBusPendingCallWatcher *watcher) {
QDBusMessage reply = watcher->reply();
watcher->deleteLater();
if (reply.type() == QDBusMessage::ErrorMessage) {
qLog(Warning) << "Failed to grab media keys" << reply.errorName() << reply.errorMessage();
return;
}
QObject::connect(interface_, &OrgGnomeSettingsDaemonMediaKeysInterface::MediaPlayerKeyPressed, this, &GlobalShortcutsBackendGnome::GnomeMediaKeyPressed);
is_connected_ = true;
qLog(Debug) << "Registered.";
}
void GlobalShortcutsBackendGnome::DoUnregister() {
qLog(Debug) << "Unregister";
if (!IsAvailable() || !interface_ || !is_connected_) return;
is_connected_ = false;
interface_->ReleaseMediaPlayerKeys(QCoreApplication::applicationName());
QObject::disconnect(interface_, &OrgGnomeSettingsDaemonMediaKeysInterface::MediaPlayerKeyPressed, this, &GlobalShortcutsBackendGnome::GnomeMediaKeyPressed);
}
void GlobalShortcutsBackendGnome::GnomeMediaKeyPressed(const QString &application, const QString &key) {
Q_UNUSED(application)
auto shortcuts = manager_->shortcuts();
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

@ -1,59 +0,0 @@
/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2019-2021, 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 GLOBALSHORTCUTSBACKEND_GNOME_H
#define GLOBALSHORTCUTSBACKEND_GNOME_H
#include "config.h"
#include <QObject>
#include <QString>
#include "globalshortcutsbackend.h"
class QDBusPendingCallWatcher;
class GlobalShortcutsManager;
class OrgGnomeSettingsDaemonMediaKeysInterface;
class GlobalShortcutsBackendGnome : public GlobalShortcutsBackend {
Q_OBJECT
public:
explicit GlobalShortcutsBackendGnome(GlobalShortcutsManager *manager, QObject *parent = nullptr);
bool IsAvailable() const override;
static bool IsGnomeAvailable();
protected:
bool DoRegister() override;
void DoUnregister() override;
private Q_SLOTS:
void RegisterFinished(QDBusPendingCallWatcher *watcher);
void GnomeMediaKeyPressed(const QString &application, const QString &key);
private:
OrgGnomeSettingsDaemonMediaKeysInterface *interface_;
bool is_connected_;
};
#endif // GLOBALSHORTCUTSBACKEND_GNOME_H

View File

@ -1,130 +0,0 @@
/*
* Strawberry Music Player
* Copyright 2021, 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 "config.h"
#include <QObject>
#include <QCoreApplication>
#include <QDateTime>
#include <QDBusConnection>
#include <QDBusMessage>
#include <QDBusPendingCallWatcher>
#include <QDBusPendingReply>
#include <QAction>
#include "core/logging.h"
#include "globalshortcutsmanager.h"
#include "globalshortcutsbackend.h"
#include "globalshortcutsbackend-mate.h"
#include "matesettingsdaemon.h"
using namespace Qt::Literals::StringLiterals;
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),
interface_(nullptr),
is_connected_(false) {}
bool GlobalShortcutsBackendMate::IsAvailable() const {
return IsMateAvailable();
}
bool GlobalShortcutsBackendMate::IsMateAvailable() {
return QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService1)) || QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService2));
}
bool GlobalShortcutsBackendMate::DoRegister() {
qLog(Debug) << "Registering";
if (!interface_) {
if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService1))) {
interface_ = new OrgMateSettingsDaemonMediaKeysInterface(QLatin1String(kService1), QLatin1String(kPath), QDBusConnection::sessionBus(), this);
}
else if (QDBusConnection::sessionBus().interface()->isServiceRegistered(QLatin1String(kService2))) {
interface_ = new OrgMateSettingsDaemonMediaKeysInterface(QLatin1String(kService2), QLatin1String(kPath), QDBusConnection::sessionBus(), this);
}
}
if (!interface_) {
qLog(Warning) << "Mate settings daemon not registered";
return false;
}
QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(QCoreApplication::applicationName(), QDateTime::currentSecsSinceEpoch());
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutsBackendMate::RegisterFinished);
return true;
}
void GlobalShortcutsBackendMate::RegisterFinished(QDBusPendingCallWatcher *watcher) {
QDBusMessage reply = watcher->reply();
watcher->deleteLater();
if (reply.type() == QDBusMessage::ErrorMessage) {
qLog(Warning) << "Failed to grab media keys" << reply.errorName() << reply.errorMessage();
return;
}
QObject::connect(interface_, &OrgMateSettingsDaemonMediaKeysInterface::MediaPlayerKeyPressed, this, &GlobalShortcutsBackendMate::MateMediaKeyPressed);
is_connected_ = true;
qLog(Debug) << "Registered.";
}
void GlobalShortcutsBackendMate::DoUnregister() {
qLog(Debug) << "Unregister";
if (!IsAvailable() || !interface_ || !is_connected_) return;
is_connected_ = false;
interface_->ReleaseMediaPlayerKeys(QCoreApplication::applicationName());
QObject::disconnect(interface_, &OrgMateSettingsDaemonMediaKeysInterface::MediaPlayerKeyPressed, this, &GlobalShortcutsBackendMate::MateMediaKeyPressed);
}
void GlobalShortcutsBackendMate::MateMediaKeyPressed(const QString &application, const QString &key) {
Q_UNUSED(application)
auto shortcuts = manager_->shortcuts();
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

@ -1,57 +0,0 @@
/*
* Strawberry Music Player
* Copyright 2021, 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 GLOBALSHORTCUTSBACKEND_MATE_H
#define GLOBALSHORTCUTSBACKEND_MATE_H
#include "config.h"
#include <QObject>
#include <QString>
#include "globalshortcutsbackend.h"
class QDBusPendingCallWatcher;
class GlobalShortcutsManager;
class OrgMateSettingsDaemonMediaKeysInterface;
class GlobalShortcutsBackendMate : public GlobalShortcutsBackend {
Q_OBJECT
public:
explicit GlobalShortcutsBackendMate(GlobalShortcutsManager *manager, QObject *parent = nullptr);
bool IsAvailable() const override;
static bool IsMateAvailable();
protected:
bool DoRegister() override;
void DoUnregister() override;
private Q_SLOTS:
void RegisterFinished(QDBusPendingCallWatcher *watcher);
void MateMediaKeyPressed(const QString &application, const QString &key);
private:
OrgMateSettingsDaemonMediaKeysInterface *interface_;
bool is_connected_;
};
#endif // GLOBALSHORTCUTSBACKEND_Mate_H

View File

@ -40,10 +40,6 @@ QString GlobalShortcutsBackend::name() const {
return u"None"_s;
case Type::KDE:
return u"KDE"_s;
case Type::Gnome:
return u"Gnome"_s;
case Type::Mate:
return u"Mate"_s;
case Type::X11:
return u"X11"_s;
case Type::macOS:

View File

@ -35,8 +35,6 @@ class GlobalShortcutsBackend : public QObject {
enum class Type {
None = 0,
KDE,
Gnome,
Mate,
X11,
macOS,
Win

View File

@ -40,14 +40,6 @@
#include "globalshortcutsbackend-kde.h"
#endif
#ifdef HAVE_GNOME_GLOBALSHORTCUTS
#include "globalshortcutsbackend-gnome.h"
#endif
#ifdef HAVE_MATE_GLOBALSHORTCUTS
#include "globalshortcutsbackend-mate.h"
#endif
#ifdef HAVE_X11_GLOBALSHORTCUTS
# include "globalshortcutsbackend-x11.h"
#endif
@ -96,14 +88,6 @@ GlobalShortcutsManager::GlobalShortcutsManager(QWidget *parent) : QWidget(parent
backends_ << new GlobalShortcutsBackendKDE(this, this);
#endif
#ifdef HAVE_GNOME_GLOBALSHORTCUTS
backends_ << new GlobalShortcutsBackendGnome(this, this);
#endif
#ifdef HAVE_MATE_GLOBALSHORTCUTS
backends_ << new GlobalShortcutsBackendMate(this, this);
#endif
#ifdef Q_OS_MACOS
backends_ << new GlobalShortcutsBackendMacOS(this, this);
#endif
@ -138,18 +122,6 @@ void GlobalShortcutsManager::ReloadSettings() {
}
#endif
#ifdef HAVE_GNOME_GLOBALSHORTCUTS
if (settings_.value(GlobalShortcutsSettings::kUseGnome, true).toBool()) {
backends_enabled_ << GlobalShortcutsBackend::Type::Gnome;
}
#endif
#ifdef HAVE_MATE_GLOBALSHORTCUTS
if (settings_.value(GlobalShortcutsSettings::kUseMate, true).toBool()) {
backends_enabled_ << GlobalShortcutsBackend::Type::Mate;
}
#endif
#ifdef HAVE_X11_GLOBALSHORTCUTS
if (settings_.value(GlobalShortcutsSettings::kUseX11, false).toBool()) {
backends_enabled_ << GlobalShortcutsBackend::Type::X11;
@ -197,26 +169,6 @@ bool GlobalShortcutsManager::IsKdeAvailable() {
#endif
#ifdef HAVE_GNOME_GLOBALSHORTCUTS
bool GlobalShortcutsManager::IsGnomeAvailable() {
return GlobalShortcutsBackendGnome::IsGnomeAvailable();
}
#endif
#ifdef HAVE_MATE_GLOBALSHORTCUTS
bool GlobalShortcutsManager::IsMateAvailable() {
return GlobalShortcutsBackendMate::IsMateAvailable();
}
#endif
#ifdef HAVE_X11_GLOBALSHORTCUTS
bool GlobalShortcutsManager::IsX11Available() {

View File

@ -58,17 +58,15 @@ class GlobalShortcutsManager : public QWidget {
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) && defined(HAVE_DBUS)
static bool IsKdeAvailable();
static bool IsGnomeAvailable();
static bool IsMateAvailable();
#endif // defined(Q_OS_UNIX) && !defined(Q_OS_MACOS) && defined(HAVE_DBUS)
#endif
#ifdef HAVE_X11_GLOBALSHORTCUTS
static bool IsX11Available();
#endif // HAVE_X11_GLOBALSHORTCUTS
#endif
#ifdef Q_OS_MACOS
static bool IsMacAccessibilityEnabled();
#endif // Q_OS_MACOS
#endif
bool Register();
void Unregister();

View File

@ -1,17 +0,0 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.gnome.SettingsDaemon.MediaKeys">
<method name="ReleaseMediaPlayerKeys">
<arg name="application" type="s" direction="in"/>
</method>
<method name="GrabMediaPlayerKeys">
<arg name="application" type="s" direction="in"/>
<arg name="time" type="u" direction="in"/>
</method>
<signal name="MediaPlayerKeyPressed">
<arg type="s"/>
<arg type="s"/>
</signal>
</interface>
</node>

View File

@ -1,17 +0,0 @@
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
<node>
<interface name="org.mate.SettingsDaemon.MediaKeys">
<method name="ReleaseMediaPlayerKeys">
<arg name="application" type="s" direction="in"/>
</method>
<method name="GrabMediaPlayerKeys">
<arg name="application" type="s" direction="in"/>
<arg name="time" type="u" direction="in"/>
</method>
<signal name="MediaPlayerKeyPressed">
<arg type="s"/>
<arg type="s"/>
</signal>
</interface>
</node>

View File

@ -77,18 +77,6 @@ GlobalShortcutsSettingsPage::GlobalShortcutsSettingsPage(SettingsDialog *dialog,
#else
ui_->widget_kde->hide();
#endif
#ifdef HAVE_GNOME_GLOBALSHORTCUTS
QObject::connect(ui_->checkbox_gnome, &QCheckBox::toggled, this, &GlobalShortcutsSettingsPage::ShortcutOptionsChanged);
QObject::connect(ui_->button_gnome_open, &QPushButton::clicked, this, &GlobalShortcutsSettingsPage::OpenGnomeKeybindingProperties);
#else
ui_->widget_gnome->hide();
#endif
#ifdef HAVE_MATE_GLOBALSHORTCUTS
QObject::connect(ui_->checkbox_mate, &QCheckBox::toggled, this, &GlobalShortcutsSettingsPage::ShortcutOptionsChanged);
QObject::connect(ui_->button_mate_open, &QPushButton::clicked, this, &GlobalShortcutsSettingsPage::OpenMateKeybindingProperties);
#else
ui_->widget_mate->hide();
#endif
#ifdef HAVE_X11_GLOBALSHORTCUTS
QObject::connect(ui_->checkbox_x11, &QCheckBox::toggled, this, &GlobalShortcutsSettingsPage::ShortcutOptionsChanged);
@ -130,28 +118,6 @@ void GlobalShortcutsSettingsPage::Load() {
}
#endif
#ifdef HAVE_GNOME_GLOBALSHORTCUTS
if (GlobalShortcutsManager::IsGnomeAvailable()) {
qLog(Debug) << "Gnome (GSD) backend is available.";
ui_->widget_gnome->show();
}
else {
qLog(Debug) << "Gnome (GSD) backend is unavailable.";
ui_->widget_gnome->hide();
}
#endif
#ifdef HAVE_MATE_GLOBALSHORTCUTS
if (GlobalShortcutsManager::IsMateAvailable()) {
qLog(Debug) << "MATE backend is available.";
ui_->widget_mate->show();
}
else {
qLog(Debug) << "MATE backend is unavailable.";
ui_->widget_mate->hide();
}
#endif
#ifdef HAVE_X11_GLOBALSHORTCUTS
if (GlobalShortcutsManager::IsX11Available()) {
qLog(Debug) << "X11 backend is available.";
@ -188,25 +154,13 @@ void GlobalShortcutsSettingsPage::Load() {
}
#endif
#ifdef HAVE_GNOME_GLOBALSHORTCUTS
if (ui_->widget_gnome->isVisibleTo(this)) {
ui_->checkbox_gnome->setChecked(s.value(kUseGnome, true).toBool());
}
#endif
#ifdef HAVE_MATE_GLOBALSHORTCUTS
if (ui_->widget_mate->isVisibleTo(this)) {
ui_->checkbox_mate->setChecked(s.value(kUseMate, true).toBool());
}
#endif
#ifdef HAVE_X11_GLOBALSHORTCUTS
if (ui_->widget_x11->isVisibleTo(this)) {
ui_->checkbox_x11->setChecked(s.value(kUseX11, false).toBool());
}
#endif
#if defined(HAVE_KDE_GLOBALSHORTCUTS) || defined(HAVE_GNOME_GLOBALSHORTCUTS) || defined(HAVE_MATE_GLOBALSHORTCUTS) || defined(HAVE_X11_GLOBALSHORTCUTS)
#if defined(HAVE_KDE_GLOBALSHORTCUTS) || defined(HAVE_X11_GLOBALSHORTCUTS)
ShortcutOptionsChanged();
#endif
@ -238,14 +192,6 @@ void GlobalShortcutsSettingsPage::Save() {
s.setValue(kUseKDE, ui_->checkbox_kde->isChecked());
#endif
#ifdef HAVE_GNOME_GLOBALSHORTCUTS
s.setValue(kUseGnome, ui_->checkbox_gnome->isChecked());
#endif
#ifdef HAVE_MATE_GLOBALSHORTCUTS
s.setValue(kUseMate, ui_->checkbox_mate->isChecked());
#endif
#ifdef HAVE_X11_GLOBALSHORTCUTS
s.setValue(kUseX11, ui_->checkbox_x11->isChecked());
#endif
@ -274,26 +220,6 @@ void GlobalShortcutsSettingsPage::ShortcutOptionsChanged() {
}
void GlobalShortcutsSettingsPage::OpenGnomeKeybindingProperties() {
if (!QProcess::startDetached(u"gnome-keybinding-properties"_s, QStringList())) {
if (!QProcess::startDetached(u"gnome-control-center"_s, QStringList() << u"keyboard"_s)) {
QMessageBox::warning(this, u"Error"_s, tr("The \"%1\" command could not be started.").arg("gnome-keybinding-properties"_L1));
}
}
}
void GlobalShortcutsSettingsPage::OpenMateKeybindingProperties() {
if (!QProcess::startDetached(u"mate-keybinding-properties"_s, QStringList())) {
if (!QProcess::startDetached(u"mate-control-center"_s, QStringList() << u"keyboard"_s)) {
QMessageBox::warning(this, u"Error"_s, tr("The \"%1\" command could not be started.").arg("mate-keybinding-properties"_L1));
}
}
}
void GlobalShortcutsSettingsPage::SetShortcut(const QString &id, const QKeySequence &key) {
Shortcut shortcut = shortcuts_.value(id);
@ -366,18 +292,7 @@ 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_));
if (de == "kde"_L1) {
text += tr(" Shortcuts on %1 are usually used through MPRIS and KGlobalAccel.").arg(de_);
}
else if (de == "gnome"_L1) {
text += tr(" Shortcuts on %1 are usually used through Gnome Settings Daemon and should be configured in gnome-settings-daemon instead.").arg(de_);
}
else if (de == "x-cinnamon"_L1) {
text += tr(" Shortcuts on %1 are usually used through Gnome Settings Daemon and should be configured in cinnamon-settings-daemon instead.").arg(de_);
}
else if (de == "mate"_L1) {
text += tr(" Shortcuts on %1 are usually used through MATE Settings Daemon and should be configured there instead.").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();
}

View File

@ -50,8 +50,6 @@ class GlobalShortcutsSettingsPage : public SettingsPage {
private Q_SLOTS:
void ShortcutOptionsChanged();
void OpenGnomeKeybindingProperties();
void OpenMateKeybindingProperties();
void ItemClicked(QTreeWidgetItem*);
void NoneClicked();

View File

@ -18,82 +18,6 @@
<normaloff>:/icons/64x64/strawberry.png</normaloff>:/icons/64x64/strawberry.png</iconset>
</property>
<layout class="QVBoxLayout" name="layout_globalshortcutssettingspage">
<item>
<widget class="QWidget" name="widget_gnome" native="true">
<layout class="QHBoxLayout" name="layout_gsd">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="checkbox_gnome">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Use Gnome (GSD) shortcuts when available</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_gnome_open">
<property name="text">
<string>Open...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_mate" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QCheckBox" name="checkbox_mate">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Use MATE shortcuts when available</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="button_mate_open">
<property name="text">
<string>Open...</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_kde" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
@ -384,8 +308,6 @@
</layout>
</widget>
<tabstops>
<tabstop>checkbox_gnome</tabstop>
<tabstop>button_gnome_open</tabstop>
<tabstop>checkbox_x11</tabstop>
<tabstop>button_macos_preferences</tabstop>
<tabstop>list</tabstop>
@ -395,7 +317,8 @@
<tabstop>button_change</tabstop>
</tabstops>
<resources>
<include location="../../data/data.qrc"/>
<include location="../../data/icons.qrc"/>
<include location="../../data/icons.qrc"/>
<include location="../../data/icons.qrc"/>
</resources>
<connections/>