Rename global shortcuts classes

This commit is contained in:
Jonas Kvinge 2021-01-26 19:13:29 +01:00
parent bf7c8df353
commit 2a92ce867a
26 changed files with 210 additions and 212 deletions

8
debian/copyright vendored
View File

@ -69,8 +69,8 @@ Files: src/core/main.h
src/covermanager/spotifycoverprovider.h
src/covermanager/musixmatchcoverprovider.cpp
src/covermanager/musixmatchcoverprovider.h
src/globalshortcuts/globalshortcutbackend-system.cpp
src/globalshortcuts/globalshortcutbackend-system.h
src/globalshortcuts/globalshortcutsbackend-system.cpp
src/globalshortcuts/globalshortcutsbackend-system.h
src/globalshortcuts/globalshortcut.cpp
src/globalshortcuts/globalshortcut.h
src/globalshortcuts/globalshortcut-X11.cpp
@ -172,8 +172,8 @@ Files: src/core/main.cpp
src/device/mtpconnection.h
src/device/mtpdevice.cpp
src/device/mtpdevice.h
src/globalshortcuts/globalshortcuts.cpp
src/globalshortcuts/globalshortcuts.h
src/globalshortcuts/globalshortcutsmanager.cpp
src/globalshortcuts/globalshortcutsmanager.h
src/settings/shortcutssettingspage.cpp
src/settings/shortcutssettingspage.h
src/settings/appearancesettingspage.cpp

View File

@ -546,23 +546,23 @@ endif()
if(HAVE_GLOBALSHORTCUTS)
optional_source(HAVE_GLOBALSHORTCUTS
SOURCES globalshortcuts/globalshortcuts.cpp globalshortcuts/globalshortcutbackend.cpp globalshortcuts/globalshortcutgrabber.cpp settings/shortcutssettingspage.cpp
HEADERS globalshortcuts/globalshortcuts.h globalshortcuts/globalshortcutbackend.h globalshortcuts/globalshortcutgrabber.h settings/shortcutssettingspage.h
UI globalshortcuts/globalshortcutgrabber.ui settings/shortcutssettingspage.ui
SOURCES globalshortcuts/globalshortcutsmanager.cpp globalshortcuts/globalshortcutsbackend.cpp globalshortcuts/globalshortcutgrabber.cpp settings/globalshortcutssettingspage.cpp
HEADERS globalshortcuts/globalshortcutsmanager.h globalshortcuts/globalshortcutsbackend.h globalshortcuts/globalshortcutgrabber.h settings/globalshortcutssettingspage.h
UI globalshortcuts/globalshortcutgrabber.ui settings/globalshortcutssettingspage.ui
)
if(HAVE_X11EXTRAS OR WIN32)
set(X11_OR_WIN ON)
endif()
optional_source(X11_OR_WIN
SOURCES globalshortcuts/globalshortcutbackend-system.cpp globalshortcuts/globalshortcut.cpp
HEADERS globalshortcuts/globalshortcutbackend-system.h globalshortcuts/globalshortcut.h
SOURCES globalshortcuts/globalshortcutsbackend-system.cpp globalshortcuts/globalshortcut.cpp
HEADERS globalshortcuts/globalshortcutsbackend-system.h globalshortcuts/globalshortcut.h
)
optional_source(HAVE_X11EXTRAS
SOURCES globalshortcuts/globalshortcut-x11.cpp
)
optional_source(HAVE_DBUS
SOURCES globalshortcuts/globalshortcutbackend-gsd.cpp globalshortcuts/globalshortcutbackend-kde.cpp
HEADERS globalshortcuts/globalshortcutbackend-gsd.h globalshortcuts/globalshortcutbackend-kde.h
SOURCES globalshortcuts/globalshortcutsbackend-gsd.cpp globalshortcuts/globalshortcutsbackend-kde.cpp
HEADERS globalshortcuts/globalshortcutsbackend-gsd.h globalshortcuts/globalshortcutsbackend-kde.h
)
optional_source(WIN32
SOURCES globalshortcuts/globalshortcut-win.cpp
@ -885,13 +885,13 @@ optional_source(APPLE
osd/osdmac.mm
widgets/qsearchfield_mac.mm
engine/macosdevicefinder.cpp
globalshortcuts/globalshortcutbackend-macos.mm
globalshortcuts/globalshortcutsbackend-macos.mm
globalshortcuts/globalshortcutgrabber.mm
HEADERS
core/macsystemtrayicon.h
core/macfslistener.h
osd/osdmac.h
globalshortcuts/globalshortcutbackend-macos.h
globalshortcuts/globalshortcutsbackend-macos.h
)
if (APPLE)

View File

@ -1,7 +1,7 @@
#import <AppKit/NSApplication.h>
#include "config.h"
#include "globalshortcuts/globalshortcutbackend-macos.h"
#include "globalshortcuts/globalshortcutsbackend-macos.h"
class PlatformInterface;
@class SPMediaKeyTap;
@ -9,7 +9,7 @@ class PlatformInterface;
@interface AppDelegate : NSObject<NSApplicationDelegate, NSUserNotificationCenterDelegate> {
PlatformInterface* application_handler_;
NSMenu* dock_menu_;
GlobalShortcutBackendMacOS* shortcut_handler_;
GlobalShortcutsBackendMacOS* shortcut_handler_;
SPMediaKeyTap* key_tap_;
}
@ -27,7 +27,7 @@ class PlatformInterface;
shouldPresentNotification: (id)notification;
- (void) setDockMenu: (NSMenu*)menu;
- (GlobalShortcutBackendMacOS*) shortcut_handler;
- (void) setShortcutHandler: (GlobalShortcutBackendMacOS*)backend;
- (GlobalShortcutsBackendMacOS*) shortcut_handler;
- (void) setShortcutHandler: (GlobalShortcutsBackendMacOS*)backend;
- (void) mediaKeyTap: (SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
@end

View File

@ -9,7 +9,7 @@
class QObject;
class QWidget;
class GlobalShortcutBackendMacOS;
class GlobalShortcutsBackendMacOS;
class PlatformInterface {
public:
@ -23,7 +23,7 @@ class PlatformInterface {
namespace mac {
void MacMain();
void SetShortcutHandler(GlobalShortcutBackendMacOS *handler);
void SetShortcutHandler(GlobalShortcutsBackendMacOS *handler);
void SetApplicationHandler(PlatformInterface *handler);
void CheckForUpdates();

View File

@ -51,8 +51,8 @@
#include "scoped_cftyperef.h"
#include "core/logging.h"
#include "core/scoped_nsautorelease_pool.h"
#include "globalshortcuts/globalshortcuts.h"
#include "globalshortcuts/globalshortcutbackend-macos.h"
#include "globalshortcuts/globalshortcutsmanager.h"
#include "globalshortcuts/globalshortcutsbackend-macos.h"
#ifdef HAVE_SPARKLE
# import <SUUpdater.h>
@ -84,12 +84,12 @@ QDebug operator<<(QDebug dbg, NSObject* object) {
PlatformInterface* application_handler_;
AppDelegate* delegate_;
// shortcut_handler_ only used to temporarily save it AppDelegate does all the heavy-shortcut-lifting
GlobalShortcutBackendMacOS* shortcut_handler_;
GlobalShortcutsBackendMacOS* shortcut_handler_;
}
- (GlobalShortcutBackendMacOS*)shortcut_handler;
- (void)SetShortcutHandler:(GlobalShortcutBackendMacOS*)handler;
- (GlobalShortcutsBackendMacOS*)shortcut_handler;
- (void)SetShortcutHandler:(GlobalShortcutsBackendMacOS*)handler;
- (PlatformInterface*)application_handler;
- (void)SetApplicationHandler:(PlatformInterface*)handler;
@ -138,11 +138,11 @@ QDebug operator<<(QDebug dbg, NSObject* object) {
return dock_menu_;
}
- (void)setShortcutHandler:(GlobalShortcutBackendMacOS*)backend {
- (void)setShortcutHandler:(GlobalShortcutsBackendMacOS*)backend {
shortcut_handler_ = backend;
}
- (GlobalShortcutBackendMacOS*)shortcut_handler {
- (GlobalShortcutsBackendMacOS*)shortcut_handler {
return shortcut_handler_;
}
@ -229,12 +229,12 @@ QDebug operator<<(QDebug dbg, NSObject* object) {
return self;
}
- (GlobalShortcutBackendMacOS*)shortcut_handler {
- (GlobalShortcutsBackendMacOS*)shortcut_handler {
// should be the same as delegate_'s shortcut handler
return shortcut_handler_;
}
- (void)SetShortcutHandler:(GlobalShortcutBackendMacOS*)handler {
- (void)SetShortcutHandler:(GlobalShortcutsBackendMacOS*)handler {
shortcut_handler_ = handler;
if (delegate_) [delegate_ setShortcutHandler:handler];
}
@ -282,7 +282,7 @@ void MacMain() {
}
void SetShortcutHandler(GlobalShortcutBackendMacOS* handler) {
void SetShortcutHandler(GlobalShortcutsBackendMacOS* handler) {
[NSApp SetShortcutHandler:handler];
}
@ -469,4 +469,3 @@ void EnableFullScreen(const QWidget& main_window) {
}
} // namespace mac

View File

@ -136,7 +136,7 @@
#include "analyzer/analyzercontainer.h"
#include "equalizer/equalizer.h"
#ifdef HAVE_GLOBALSHORTCUTS
# include "globalshortcuts/globalshortcuts.h"
# include "globalshortcuts/globalshortcutsmanager.h"
#endif
#include "covermanager/albumcovermanager.h"
#include "covermanager/albumcoverchoicecontroller.h"
@ -229,7 +229,7 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd
edit_tag_dialog_(std::bind(&MainWindow::CreateEditTagDialog, this)),
album_cover_choice_controller_(new AlbumCoverChoiceController(this)),
#ifdef HAVE_GLOBALSHORTCUTS
global_shortcuts_(new GlobalShortcuts(this)),
globalshortcuts_manager_(new GlobalShortcutsManager(this)),
#endif
context_view_(new ContextView(this)),
collection_view_(new CollectionViewContainer(this)),
@ -763,23 +763,23 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd
#ifdef HAVE_GLOBALSHORTCUTS
// Global shortcuts
QObject::connect(global_shortcuts_, &GlobalShortcuts::Play, app_->player(), &Player::Play);
QObject::connect(global_shortcuts_, &GlobalShortcuts::Pause, app_->player(), &Player::Pause);
QObject::connect(global_shortcuts_, &GlobalShortcuts::PlayPause, ui_->action_play_pause, &QAction::trigger);
QObject::connect(global_shortcuts_, &GlobalShortcuts::Stop, ui_->action_stop, &QAction::trigger);
QObject::connect(global_shortcuts_, &GlobalShortcuts::StopAfter, ui_->action_stop_after_this_track, &QAction::trigger);
QObject::connect(global_shortcuts_, &GlobalShortcuts::Next, ui_->action_next_track, &QAction::trigger);
QObject::connect(global_shortcuts_, &GlobalShortcuts::Previous, ui_->action_previous_track, &QAction::trigger);
QObject::connect(global_shortcuts_, &GlobalShortcuts::IncVolume, app_->player(), &Player::VolumeUp);
QObject::connect(global_shortcuts_, &GlobalShortcuts::DecVolume, app_->player(), &Player::VolumeDown);
QObject::connect(global_shortcuts_, &GlobalShortcuts::Mute, app_->player(), &Player::Mute);
QObject::connect(global_shortcuts_, &GlobalShortcuts::SeekForward, app_->player(), &Player::SeekForward);
QObject::connect(global_shortcuts_, &GlobalShortcuts::SeekBackward, app_->player(), &Player::SeekBackward);
QObject::connect(global_shortcuts_, &GlobalShortcuts::ShowHide, this, &MainWindow::ToggleShowHide);
QObject::connect(global_shortcuts_, &GlobalShortcuts::ShowOSD, app_->player(), &Player::ShowOSD);
QObject::connect(global_shortcuts_, &GlobalShortcuts::TogglePrettyOSD, app_->player(), &Player::TogglePrettyOSD);
QObject::connect(global_shortcuts_, &GlobalShortcuts::ToggleScrobbling, app_->scrobbler(), &AudioScrobbler::ToggleScrobbling);
QObject::connect(global_shortcuts_, &GlobalShortcuts::Love, app_->scrobbler(), &AudioScrobbler::Love);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Play, app_->player(), &Player::Play);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Pause, app_->player(), &Player::Pause);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::PlayPause, ui_->action_play_pause, &QAction::trigger);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Stop, ui_->action_stop, &QAction::trigger);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::StopAfter, ui_->action_stop_after_this_track, &QAction::trigger);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Next, ui_->action_next_track, &QAction::trigger);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Previous, ui_->action_previous_track, &QAction::trigger);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::IncVolume, app_->player(), &Player::VolumeUp);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::DecVolume, app_->player(), &Player::VolumeDown);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Mute, app_->player(), &Player::Mute);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::SeekForward, app_->player(), &Player::SeekForward);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::SeekBackward, app_->player(), &Player::SeekBackward);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::ShowHide, this, &MainWindow::ToggleShowHide);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::ShowOSD, app_->player(), &Player::ShowOSD);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::TogglePrettyOSD, app_->player(), &Player::TogglePrettyOSD);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::ToggleScrobbling, app_->scrobbler(), &AudioScrobbler::ToggleScrobbling);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Love, app_->scrobbler(), &AudioScrobbler::Love);
#endif
// Fancy tabs
@ -849,8 +849,8 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd
// We need to connect these global shortcuts here after the playlist have been initialized
#ifdef HAVE_GLOBALSHORTCUTS
QObject::connect(global_shortcuts_, &GlobalShortcuts::CycleShuffleMode, app_->playlist_manager()->sequence(), &PlaylistSequence::CycleShuffleMode);
QObject::connect(global_shortcuts_, &GlobalShortcuts::CycleRepeatMode, app_->playlist_manager()->sequence(), &PlaylistSequence::CycleRepeatMode);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::CycleShuffleMode, app_->playlist_manager()->sequence(), &PlaylistSequence::CycleShuffleMode);
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::CycleRepeatMode, app_->playlist_manager()->sequence(), &PlaylistSequence::CycleRepeatMode);
#endif
QObject::connect(app_->playlist_manager()->sequence(), &PlaylistSequence::RepeatModeChanged, osd_, &OSDBase::RepeatModeChanged);
QObject::connect(app_->playlist_manager()->sequence(), &PlaylistSequence::ShuffleModeChanged, osd_, &OSDBase::ShuffleModeChanged);
@ -2658,7 +2658,7 @@ SettingsDialog *MainWindow::CreateSettingsDialog() {
SettingsDialog *settings_dialog = new SettingsDialog(app_, osd_, this);
#ifdef HAVE_GLOBALSHORTCUTS
settings_dialog->SetGlobalShortcutManager(global_shortcuts_);
settings_dialog->SetGlobalShortcutManager(globalshortcuts_manager_);
#endif
// Settings

View File

@ -77,7 +77,7 @@ class EditTagDialog;
class Equalizer;
class ErrorDialog;
class FileView;
class GlobalShortcuts;
class GlobalShortcutsManager;
class MimeData;
class OrganizeDialog;
class PlaylistListContainer;
@ -303,7 +303,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
Lazy<EditTagDialog> edit_tag_dialog_;
AlbumCoverChoiceController *album_cover_choice_controller_;
GlobalShortcuts *global_shortcuts_;
GlobalShortcutsManager *globalshortcuts_manager_;
ContextView *context_view_;
CollectionViewContainer *collection_view_;

View File

@ -51,7 +51,7 @@ GlobalShortcut::GlobalShortcut(QObject *parent) : QObject(parent),
}
GlobalShortcut::GlobalShortcut(QKeySequence shortcut, GlobalShortcutBackend *backend, QObject *parent) : QObject(parent),
GlobalShortcut::GlobalShortcut(QKeySequence shortcut, GlobalShortcutsBackend *backend, QObject *parent) : QObject(parent),
backend_(backend),
shortcut_(shortcut),
qt_key_(Qt::Key(0)),

View File

@ -32,17 +32,17 @@
#include <QByteArray>
#include <QString>
class GlobalShortcutBackend;
class GlobalShortcutsBackend;
class GlobalShortcut : public QObject, QAbstractNativeEventFilter {
Q_OBJECT
public:
explicit GlobalShortcut(QObject *parent = nullptr);
explicit GlobalShortcut(QKeySequence shortcut, GlobalShortcutBackend *backend, QObject *parent = nullptr);
explicit GlobalShortcut(QKeySequence shortcut, GlobalShortcutsBackend *backend, QObject *parent = nullptr);
~GlobalShortcut() override;
GlobalShortcutBackend *backend() const { return backend_; }
GlobalShortcutsBackend *backend() const { return backend_; }
QKeySequence shortcut() const { return shortcut_; }
bool setShortcut(const QKeySequence &shortcut);
@ -71,7 +71,7 @@ class GlobalShortcut : public QObject, QAbstractNativeEventFilter {
static QHash<QPair<quint32, quint32>, GlobalShortcut*> internal_shortcuts_;
static const QVector<quint32> mask_modifiers_;
GlobalShortcutBackend *backend_;
GlobalShortcutsBackend *backend_;
QKeySequence shortcut_;
Qt::Key qt_key_;
Qt::KeyboardModifiers qt_mods_;

View File

@ -34,20 +34,20 @@
#include <QtDebug>
#include "core/logging.h"
#include "globalshortcuts.h"
#include "globalshortcutbackend.h"
#include "globalshortcutbackend-gsd.h"
#include "globalshortcutsmanager.h"
#include "globalshortcutsbackend.h"
#include "globalshortcutsbackend-gsd.h"
const char *GlobalShortcutBackendGSD::kGsdService = "org.gnome.SettingsDaemon.MediaKeys";
const char *GlobalShortcutBackendGSD::kGsdService2 = "org.gnome.SettingsDaemon";
const char *GlobalShortcutBackendGSD::kGsdPath = "/org/gnome/SettingsDaemon/MediaKeys";
const char *GlobalShortcutsBackendGSD::kGsdService = "org.gnome.SettingsDaemon.MediaKeys";
const char *GlobalShortcutsBackendGSD::kGsdService2 = "org.gnome.SettingsDaemon";
const char *GlobalShortcutsBackendGSD::kGsdPath = "/org/gnome/SettingsDaemon/MediaKeys";
GlobalShortcutBackendGSD::GlobalShortcutBackendGSD(GlobalShortcuts *parent)
: GlobalShortcutBackend(parent),
GlobalShortcutsBackendGSD::GlobalShortcutsBackendGSD(GlobalShortcutsManager *parent)
: GlobalShortcutsBackend(parent),
interface_(nullptr),
is_connected_(false) {}
bool GlobalShortcutBackendGSD::DoRegister() {
bool GlobalShortcutsBackendGSD::DoRegister() {
qLog(Debug) << "Registering";
@ -68,13 +68,13 @@ bool GlobalShortcutBackendGSD::DoRegister() {
QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(QCoreApplication::applicationName(), QDateTime::currentDateTime().toSecsSinceEpoch());
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutBackendGSD::RegisterFinished);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutsBackendGSD::RegisterFinished);
return true;
}
void GlobalShortcutBackendGSD::RegisterFinished(QDBusPendingCallWatcher *watcher) {
void GlobalShortcutsBackendGSD::RegisterFinished(QDBusPendingCallWatcher *watcher) {
QDBusMessage reply = watcher->reply();
watcher->deleteLater();
@ -84,14 +84,14 @@ void GlobalShortcutBackendGSD::RegisterFinished(QDBusPendingCallWatcher *watcher
return;
}
QObject::connect(interface_, &OrgGnomeSettingsDaemonMediaKeysInterface::MediaPlayerKeyPressed, this, &GlobalShortcutBackendGSD::GnomeMediaKeyPressed);
QObject::connect(interface_, &OrgGnomeSettingsDaemonMediaKeysInterface::MediaPlayerKeyPressed, this, &GlobalShortcutsBackendGSD::GnomeMediaKeyPressed);
is_connected_ = true;
qLog(Debug) << "Registered";
}
void GlobalShortcutBackendGSD::DoUnregister() {
void GlobalShortcutsBackendGSD::DoUnregister() {
qLog(Debug) << "Unregister";
@ -103,11 +103,11 @@ void GlobalShortcutBackendGSD::DoUnregister() {
is_connected_ = false;
interface_->ReleaseMediaPlayerKeys(QCoreApplication::applicationName());
QObject::disconnect(interface_, &OrgGnomeSettingsDaemonMediaKeysInterface::MediaPlayerKeyPressed, this, &GlobalShortcutBackendGSD::GnomeMediaKeyPressed);
QObject::disconnect(interface_, &OrgGnomeSettingsDaemonMediaKeysInterface::MediaPlayerKeyPressed, this, &GlobalShortcutsBackendGSD::GnomeMediaKeyPressed);
}
void GlobalShortcutBackendGSD::GnomeMediaKeyPressed(const QString&, const QString& key) {
void GlobalShortcutsBackendGSD::GnomeMediaKeyPressed(const QString&, const QString& key) {
if (key == "Play") manager_->shortcuts()["play_pause"].action->trigger();
if (key == "Stop") manager_->shortcuts()["stop"].action->trigger();
if (key == "Next") manager_->shortcuts()["next_track"].action->trigger();

View File

@ -18,25 +18,25 @@
*
*/
#ifndef GLOBALSHORTCUTBACKEND_GSD_H
#define GLOBALSHORTCUTBACKEND_GSD_H
#ifndef GLOBALSHORTCUTSBACKEND_GSD_H
#define GLOBALSHORTCUTSBACKEND_GSD_H
#include "config.h"
#include <QObject>
#include <QString>
#include "globalshortcutbackend.h"
#include "globalshortcutsbackend.h"
class QDBusPendingCallWatcher;
class GlobalShortcuts;
class GlobalShortcutsManager;
class OrgGnomeSettingsDaemonMediaKeysInterface;
class GlobalShortcutBackendGSD : public GlobalShortcutBackend {
class GlobalShortcutsBackendGSD : public GlobalShortcutsBackend {
Q_OBJECT
public:
explicit GlobalShortcutBackendGSD(GlobalShortcuts *parent);
explicit GlobalShortcutsBackendGSD(GlobalShortcutsManager *parent);
static const char *kGsdService;
static const char *kGsdService2;
@ -58,4 +58,4 @@ class GlobalShortcutBackendGSD : public GlobalShortcutBackend {
};
#endif // GLOBALSHORTCUTBACKEND_GSD_H
#endif // GLOBALSHORTCUTSBACKEND_GSD_H

View File

@ -36,14 +36,14 @@
#include "core/logging.h"
#include "globalshortcutbackend-kde.h"
#include "globalshortcutsbackend-kde.h"
const char *GlobalShortcutBackendKDE::kKdeService = "org.kde.kglobalaccel";
const char *GlobalShortcutBackendKDE::kKdePath = "/kglobalaccel";
const char *GlobalShortcutsBackendKDE::kKdeService = "org.kde.kglobalaccel";
const char *GlobalShortcutsBackendKDE::kKdePath = "/kglobalaccel";
GlobalShortcutBackendKDE::GlobalShortcutBackendKDE(GlobalShortcuts *parent) : GlobalShortcutBackend(parent), interface_(nullptr), component_(nullptr) {}
GlobalShortcutsBackendKDE::GlobalShortcutsBackendKDE(GlobalShortcutsManager *parent) : GlobalShortcutsBackend(parent), interface_(nullptr), component_(nullptr) {}
bool GlobalShortcutBackendKDE::DoRegister() {
bool GlobalShortcutsBackendKDE::DoRegister() {
qLog(Debug) << "Registering";
@ -56,19 +56,19 @@ bool GlobalShortcutBackendKDE::DoRegister() {
interface_ = new OrgKdeKGlobalAccelInterface(kKdeService, kKdePath, QDBusConnection::sessionBus(), this);
}
for (const GlobalShortcuts::Shortcut &shortcut : manager_->shortcuts().values()) {
for (const GlobalShortcutsManager::Shortcut &shortcut : manager_->shortcuts().values()) {
RegisterShortcut(shortcut);
}
QDBusPendingReply<QDBusObjectPath> reply = interface_->getComponent(QCoreApplication::applicationName());
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutBackendKDE::RegisterFinished);
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutsBackendKDE::RegisterFinished);
return true;
}
void GlobalShortcutBackendKDE::RegisterFinished(QDBusPendingCallWatcher *watcher) {
void GlobalShortcutsBackendKDE::RegisterFinished(QDBusPendingCallWatcher *watcher) {
QDBusReply<QDBusObjectPath> reply = watcher->reply();
watcher->deleteLater();
@ -89,19 +89,19 @@ void GlobalShortcutBackendKDE::RegisterFinished(QDBusPendingCallWatcher *watcher
return;
}
QObject::connect(component_, &org::kde::kglobalaccel::Component::globalShortcutPressed, this, &GlobalShortcutBackendKDE::GlobalShortcutPressed, Qt::UniqueConnection);
QObject::connect(component_, &org::kde::kglobalaccel::Component::globalShortcutPressed, this, &GlobalShortcutsBackendKDE::GlobalShortcutPressed, Qt::UniqueConnection);
qLog(Debug) << "Registered";
}
void GlobalShortcutBackendKDE::DoUnregister() {
void GlobalShortcutsBackendKDE::DoUnregister() {
if (!interface_ || !interface_->isValid()) return;
qLog(Debug) << "Unregistering";
for (const GlobalShortcuts::Shortcut &shortcut : manager_->shortcuts()) {
for (const GlobalShortcutsManager::Shortcut &shortcut : manager_->shortcuts()) {
if (actions_.contains(shortcut.id)) {
interface_->unRegister(GetActionId(shortcut.id, shortcut.action));
actions_.remove(shortcut.id, shortcut.action);
@ -115,7 +115,7 @@ void GlobalShortcutBackendKDE::DoUnregister() {
}
bool GlobalShortcutBackendKDE::RegisterShortcut(const GlobalShortcuts::Shortcut &shortcut) {
bool GlobalShortcutsBackendKDE::RegisterShortcut(const GlobalShortcutsManager::Shortcut &shortcut) {
if (!interface_ || !interface_->isValid() || shortcut.id.isEmpty() || !shortcut.action || shortcut.action->shortcut().isEmpty()) return false;
@ -150,7 +150,7 @@ bool GlobalShortcutBackendKDE::RegisterShortcut(const GlobalShortcuts::Shortcut
}
QStringList GlobalShortcutBackendKDE::GetActionId(const QString &id, const QAction *action) {
QStringList GlobalShortcutsBackendKDE::GetActionId(const QString &id, const QAction *action) {
QStringList ret;
ret << QCoreApplication::applicationName();
@ -163,7 +163,7 @@ QStringList GlobalShortcutBackendKDE::GetActionId(const QString &id, const QActi
}
QList<int> GlobalShortcutBackendKDE::ToIntList(const QList<QKeySequence> &sequence_list) {
QList<int> GlobalShortcutsBackendKDE::ToIntList(const QList<QKeySequence> &sequence_list) {
QList<int> ret;
for (const QKeySequence &sequence : sequence_list) {
@ -178,7 +178,7 @@ QList<int> GlobalShortcutBackendKDE::ToIntList(const QList<QKeySequence> &sequen
}
QList<QKeySequence> GlobalShortcutBackendKDE::ToKeySequenceList(const QList<int> &sequence_list) {
QList<QKeySequence> GlobalShortcutsBackendKDE::ToKeySequenceList(const QList<int> &sequence_list) {
QList<QKeySequence> ret;
for (int sequence : sequence_list) {
@ -189,7 +189,7 @@ QList<QKeySequence> GlobalShortcutBackendKDE::ToKeySequenceList(const QList<int>
}
void GlobalShortcutBackendKDE::GlobalShortcutPressed(const QString &component_unique, const QString &shortcut_unique, qlonglong) {
void GlobalShortcutsBackendKDE::GlobalShortcutPressed(const QString &component_unique, const QString &shortcut_unique, qlonglong) {
if (QCoreApplication::applicationName() == component_unique && actions_.contains(shortcut_unique)) {
for (QAction *action : actions_.values(shortcut_unique)) {

View File

@ -17,8 +17,8 @@
*
*/
#ifndef GLOBALSHORTCUTBACKEND_KDE_H
#define GLOBALSHORTCUTBACKEND_KDE_H
#ifndef GLOBALSHORTCUTSBACKEND_KDE_H
#define GLOBALSHORTCUTSBACKEND_KDE_H
#include "config.h"
@ -28,8 +28,8 @@
#include <QStringList>
#include <QKeySequence>
#include "globalshortcutbackend.h"
#include "globalshortcuts.h"
#include "globalshortcutsbackend.h"
#include "globalshortcutsmanager.h"
class QDBusPendingCallWatcher;
class QAction;
@ -37,11 +37,11 @@ class QAction;
class OrgKdeKGlobalAccelInterface;
class OrgKdeKglobalaccelComponentInterface;
class GlobalShortcutBackendKDE : public GlobalShortcutBackend {
class GlobalShortcutsBackendKDE : public GlobalShortcutsBackend {
Q_OBJECT
public:
explicit GlobalShortcutBackendKDE(GlobalShortcuts *parent);
explicit GlobalShortcutsBackendKDE(GlobalShortcutsManager *parent);
static const char *kKdeService;
@ -50,7 +50,7 @@ class GlobalShortcutBackendKDE : public GlobalShortcutBackend {
void DoUnregister() override;
private:
bool RegisterShortcut(const GlobalShortcuts::Shortcut &shortcut);
bool RegisterShortcut(const GlobalShortcutsManager::Shortcut &shortcut);
static QStringList GetActionId(const QString &id, const QAction *action);
static QList<int> ToIntList(const QList<QKeySequence> &sequence_list);
static QList<QKeySequence> ToKeySequenceList(const QList<int> &sequence_list);
@ -67,4 +67,4 @@ class GlobalShortcutBackendKDE : public GlobalShortcutBackend {
QMultiHash<QString, QAction*> actions_;
};
#endif // GLOBALSHORTCUTBACKEND_KDE_H
#endif // GLOBALSHORTCUTSBACKEND_KDE_H

View File

@ -18,14 +18,14 @@
*
*/
#ifndef GLOBALSHORTCUTBACKEND_MACOS_H
#define GLOBALSHORTCUTBACKEND_MACOS_H
#ifndef GLOBALSHORTCUTSBACKEND_MACOS_H
#define GLOBALSHORTCUTSBACKEND_MACOS_H
#include "config.h"
#include <memory>
#include "globalshortcutbackend.h"
#include "globalshortcutsbackend.h"
#include <QObject>
#include <QMap>
@ -34,14 +34,14 @@
class GlobalShortcut;
class GlobalShortcutBackendMacOSPrivate;
class GlobalShortcutsBackendMacOSPrivate;
class GlobalShortcutBackendMacOS : public GlobalShortcutBackend {
class GlobalShortcutsBackendMacOS : public GlobalShortcutsBackend {
Q_OBJECT
public:
explicit GlobalShortcutBackendMacOS(GlobalShortcuts* parent);
virtual ~GlobalShortcutBackendMacOS();
explicit GlobalShortcutsBackendMacOS(GlobalShortcutsManager* parent);
virtual ~GlobalShortcutsBackendMacOS();
bool IsAccessibilityEnabled() const;
void ShowAccessibilityDialog();
@ -57,8 +57,8 @@ class GlobalShortcutBackendMacOS : public GlobalShortcutBackend {
QMap<QKeySequence, QAction*> shortcuts_;
friend class GlobalShortcutBackendMacOSPrivate;
std::unique_ptr<GlobalShortcutBackendMacOSPrivate> p_;
friend class GlobalShortcutsBackendMacOSPrivate;
std::unique_ptr<GlobalShortcutsBackendMacOSPrivate> p_;
};
#endif // GLOBALSHORTCUTBACKEND_MACOS_H
#endif // GLOBALSHORTCUTSBACKEND_MACOS_H

View File

@ -20,7 +20,7 @@
#include "config.h"
#include "globalshortcutbackend-macos.h"
#include "globalshortcutsbackend-macos.h"
#include <boost/noncopyable.hpp>
@ -37,7 +37,7 @@
#include <QtDebug>
#include "config.h"
#include "globalshortcuts.h"
#include "globalshortcutsmanager.h"
#include "core/logging.h"
#include "core/mac_startup.h"
#include "core/utilities.h"
@ -45,9 +45,9 @@
#import "core/mac_utilities.h"
#import "core/SBSystemPreferences.h"
class GlobalShortcutBackendMacOSPrivate : boost::noncopyable {
class GlobalShortcutsBackendMacOSPrivate : boost::noncopyable {
public:
explicit GlobalShortcutBackendMacOSPrivate(GlobalShortcutBackendMacOS* backend)
explicit GlobalShortcutsBackendMacOSPrivate(GlobalShortcutsBackendMacOS* backend)
: global_monitor_(nil), local_monitor_(nil), backend_(backend) {}
bool Register() {
@ -74,21 +74,21 @@ class GlobalShortcutBackendMacOSPrivate : boost::noncopyable {
id global_monitor_;
id local_monitor_;
GlobalShortcutBackendMacOS* backend_;
GlobalShortcutsBackendMacOS* backend_;
};
GlobalShortcutBackendMacOS::GlobalShortcutBackendMacOS(GlobalShortcuts* parent)
: GlobalShortcutBackend(parent),
p_(new GlobalShortcutBackendMacOSPrivate(this)) {}
GlobalShortcutsBackendMacOS::GlobalShortcutsBackendMacOS(GlobalShortcutsManager* parent)
: GlobalShortcutsBackend(parent),
p_(new GlobalShortcutsBackendMacOSPrivate(this)) {}
GlobalShortcutBackendMacOS::~GlobalShortcutBackendMacOS() {}
GlobalShortcutsBackendMacOS::~GlobalShortcutsBackendMacOS() {}
bool GlobalShortcutBackendMacOS::DoRegister() {
bool GlobalShortcutsBackendMacOS::DoRegister() {
// Always enable media keys.
mac::SetShortcutHandler(this);
for (const GlobalShortcuts::Shortcut& shortcut : manager_->shortcuts().values()) {
for (const GlobalShortcutsManager::Shortcut& shortcut : manager_->shortcuts().values()) {
shortcuts_[shortcut.action->shortcut()] = shortcut.action;
}
@ -96,14 +96,14 @@ bool GlobalShortcutBackendMacOS::DoRegister() {
}
void GlobalShortcutBackendMacOS::DoUnregister() {
void GlobalShortcutsBackendMacOS::DoUnregister() {
p_->Unregister();
shortcuts_.clear();
}
void GlobalShortcutBackendMacOS::MacMediaKeyPressed(int key) {
void GlobalShortcutsBackendMacOS::MacMediaKeyPressed(int key) {
switch (key) {
case NX_KEYTYPE_PLAY:
@ -119,7 +119,7 @@ void GlobalShortcutBackendMacOS::MacMediaKeyPressed(int key) {
}
bool GlobalShortcutBackendMacOS::KeyPressed(const QKeySequence& sequence) {
bool GlobalShortcutsBackendMacOS::KeyPressed(const QKeySequence& sequence) {
if (sequence.isEmpty()) {
return false;
@ -133,14 +133,14 @@ bool GlobalShortcutBackendMacOS::KeyPressed(const QKeySequence& sequence) {
}
bool GlobalShortcutBackendMacOS::IsAccessibilityEnabled() const {
bool GlobalShortcutsBackendMacOS::IsAccessibilityEnabled() const {
NSDictionary *options = @{(id)kAXTrustedCheckOptionPrompt: @YES};
return AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
}
void GlobalShortcutBackendMacOS::ShowAccessibilityDialog() {
void GlobalShortcutsBackendMacOS::ShowAccessibilityDialog() {
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSPreferencePanesDirectory, NSSystemDomainMask, YES);
if ([paths count] == 1) {

View File

@ -19,7 +19,7 @@
#include "config.h"
#include "globalshortcutbackend-system.h"
#include "globalshortcutsbackend-system.h"
#include "core/logging.h"
@ -29,21 +29,21 @@
#include <QKeySequence>
#include <QtAlgorithms>
#include "globalshortcuts.h"
#include "globalshortcutbackend.h"
#include "globalshortcutsmanager.h"
#include "globalshortcutsbackend.h"
#include "globalshortcut.h"
GlobalShortcutBackendSystem::GlobalShortcutBackendSystem(GlobalShortcuts *parent) : GlobalShortcutBackend(parent), gshortcut_init_(nullptr) {}
GlobalShortcutsBackendSystem::GlobalShortcutsBackendSystem(GlobalShortcutsManager *parent) : GlobalShortcutsBackend(parent), gshortcut_init_(nullptr) {}
GlobalShortcutBackendSystem::~GlobalShortcutBackendSystem() { DoUnregister(); }
GlobalShortcutsBackendSystem::~GlobalShortcutsBackendSystem() { DoUnregister(); }
bool GlobalShortcutBackendSystem::DoRegister() {
bool GlobalShortcutsBackendSystem::DoRegister() {
qLog(Debug) << "Registering";
if (!gshortcut_init_) gshortcut_init_ = new GlobalShortcut(this);
for (const GlobalShortcuts::Shortcut &shortcut : manager_->shortcuts().values()) {
for (const GlobalShortcutsManager::Shortcut &shortcut : manager_->shortcuts().values()) {
AddShortcut(shortcut.action);
}
@ -51,7 +51,7 @@ bool GlobalShortcutBackendSystem::DoRegister() {
}
bool GlobalShortcutBackendSystem::AddShortcut(QAction *action) {
bool GlobalShortcutsBackendSystem::AddShortcut(QAction *action) {
if (action->shortcut().isEmpty()) return false;
@ -62,7 +62,7 @@ bool GlobalShortcutBackendSystem::AddShortcut(QAction *action) {
}
void GlobalShortcutBackendSystem::DoUnregister() {
void GlobalShortcutsBackendSystem::DoUnregister() {
qLog(Debug) << "Unregistering";
@ -75,4 +75,3 @@ void GlobalShortcutBackendSystem::DoUnregister() {
}
}

View File

@ -17,8 +17,8 @@
*
*/
#ifndef GLOBALSHORTCUTBACKEND_SYSTEM_H
#define GLOBALSHORTCUTBACKEND_SYSTEM_H
#ifndef GLOBALSHORTCUTSBACKEND_SYSTEM_H
#define GLOBALSHORTCUTSBACKEND_SYSTEM_H
#include "config.h"
@ -28,18 +28,18 @@
#include <QList>
#include <QString>
#include "globalshortcutbackend.h"
#include "globalshortcutsbackend.h"
class QAction;
class GlobalShortcuts;
class GlobalShortcutsManager;
class GlobalShortcut;
class GlobalShortcutBackendSystem : public GlobalShortcutBackend {
class GlobalShortcutsBackendSystem : public GlobalShortcutsBackend {
Q_OBJECT
public:
explicit GlobalShortcutBackendSystem(GlobalShortcuts *parent = nullptr);
~GlobalShortcutBackendSystem() override;
explicit GlobalShortcutsBackendSystem(GlobalShortcutsManager *parent = nullptr);
~GlobalShortcutsBackendSystem() override;
protected:
bool DoRegister() override;
@ -54,4 +54,4 @@ class GlobalShortcutBackendSystem : public GlobalShortcutBackend {
};
#endif // GLOBALSHORTCUTBACKEND_SYSTEM_H
#endif // GLOBALSHORTCUTSBACKEND_SYSTEM_H

View File

@ -22,19 +22,19 @@
#include <QObject>
#include "globalshortcutbackend.h"
#include "globalshortcuts.h"
#include "globalshortcutsbackend.h"
#include "globalshortcutsmanager.h"
GlobalShortcutBackend::GlobalShortcutBackend(GlobalShortcuts *parent)
GlobalShortcutsBackend::GlobalShortcutsBackend(GlobalShortcutsManager *parent)
: QObject(parent), manager_(parent), active_(false) {}
bool GlobalShortcutBackend::Register() {
bool GlobalShortcutsBackend::Register() {
bool ret = DoRegister();
if (ret) active_ = true;
return ret;
}
void GlobalShortcutBackend::Unregister() {
void GlobalShortcutsBackend::Unregister() {
DoUnregister();
active_ = false;
}

View File

@ -18,21 +18,21 @@
*
*/
#ifndef GLOBALSHORTCUTBACKEND_H
#define GLOBALSHORTCUTBACKEND_H
#ifndef GLOBALSHORTCUTSBACKEND_H
#define GLOBALSHORTCUTSBACKEND_H
#include "config.h"
#include <QObject>
#include <QString>
class GlobalShortcuts;
class GlobalShortcutsManager;
class GlobalShortcutBackend : public QObject {
class GlobalShortcutsBackend : public QObject {
Q_OBJECT
public:
explicit GlobalShortcutBackend(GlobalShortcuts *parent = nullptr);
explicit GlobalShortcutsBackend(GlobalShortcutsManager *parent = nullptr);
bool is_active() const { return active_; }
@ -46,9 +46,9 @@ class GlobalShortcutBackend : public QObject {
virtual bool DoRegister() = 0;
virtual void DoUnregister() = 0;
GlobalShortcuts *manager_;
GlobalShortcutsManager *manager_;
bool active_;
};
#endif // GLOBALSHORTCUTBACKEND_H
#endif // GLOBALSHORTCUTSBACKEND_H

View File

@ -34,23 +34,23 @@
# include <QX11Info>
#endif
#include "globalshortcuts.h"
#include "globalshortcutbackend.h"
#include "globalshortcutsmanager.h"
#include "globalshortcutsbackend.h"
#ifdef HAVE_DBUS
# include "globalshortcutbackend-gsd.h"
# include "globalshortcutbackend-kde.h"
# include "globalshortcutsbackend-gsd.h"
# include "globalshortcutsbackend-kde.h"
#endif
#if defined(HAVE_X11EXTRAS) || defined(Q_OS_WIN)
# include "globalshortcutbackend-system.h"
# include "globalshortcutsbackend-system.h"
#endif
#ifdef Q_OS_MACOS
# include "globalshortcutbackend-macos.h"
# include "globalshortcutsbackend-macos.h"
#endif
#include "settings/shortcutssettingspage.h"
#include "settings/globalshortcutssettingspage.h"
GlobalShortcuts::GlobalShortcuts(QWidget *parent)
GlobalShortcutsManager::GlobalShortcutsManager(QWidget *parent)
: QWidget(parent),
gsd_backend_(nullptr),
kde_backend_(nullptr),
@ -85,28 +85,28 @@ GlobalShortcuts::GlobalShortcuts(QWidget *parent)
// Create backends - these do the actual shortcut registration
#ifdef HAVE_DBUS
gsd_backend_ = new GlobalShortcutBackendGSD(this);
kde_backend_ = new GlobalShortcutBackendKDE(this);
gsd_backend_ = new GlobalShortcutsBackendGSD(this);
kde_backend_ = new GlobalShortcutsBackendKDE(this);
#endif
#ifdef Q_OS_MACOS
if (!system_backend_)
system_backend_ = new GlobalShortcutBackendMacOS(this);
system_backend_ = new GlobalShortcutsBackendMacOS(this);
#endif
#if defined(Q_OS_WIN)
if (!system_backend_)
system_backend_ = new GlobalShortcutBackendSystem(this);
system_backend_ = new GlobalShortcutsBackendSystem(this);
#endif
#if defined(HAVE_X11EXTRAS)
if (!system_backend_ && IsX11Available())
system_backend_ = new GlobalShortcutBackendSystem(this);
system_backend_ = new GlobalShortcutsBackendSystem(this);
#endif
ReloadSettings();
}
void GlobalShortcuts::ReloadSettings() {
void GlobalShortcutsManager::ReloadSettings() {
// The actual shortcuts have been set in our actions for us by the config dialog already - we just need to reread the gnome settings.
use_gsd_ = settings_.value("use_gsd", true).toBool();
@ -118,14 +118,14 @@ void GlobalShortcuts::ReloadSettings() {
}
void GlobalShortcuts::AddShortcut(const QString &id, const QString &name, const char *signal, const QKeySequence &default_key) {
void GlobalShortcutsManager::AddShortcut(const QString &id, const QString &name, const char *signal, const QKeySequence &default_key) {
Shortcut shortcut = AddShortcut(id, name, default_key);
QObject::connect(shortcut.action, SIGNAL(triggered()), this, signal);
}
GlobalShortcuts::Shortcut GlobalShortcuts::AddShortcut(const QString &id, const QString &name, const QKeySequence &default_key) {
GlobalShortcutsManager::Shortcut GlobalShortcutsManager::AddShortcut(const QString &id, const QString &name, const QKeySequence &default_key) {
Shortcut shortcut;
shortcut.action = new QAction(name, this);
@ -144,27 +144,27 @@ GlobalShortcuts::Shortcut GlobalShortcuts::AddShortcut(const QString &id, const
}
bool GlobalShortcuts::IsGsdAvailable() const {
bool GlobalShortcutsManager::IsGsdAvailable() const {
#ifdef HAVE_DBUS
return QDBusConnection::sessionBus().interface()->isServiceRegistered(GlobalShortcutBackendGSD::kGsdService) || QDBusConnection::sessionBus().interface()->isServiceRegistered(GlobalShortcutBackendGSD::kGsdService2);
return QDBusConnection::sessionBus().interface()->isServiceRegistered(GlobalShortcutsBackendGSD::kGsdService) || QDBusConnection::sessionBus().interface()->isServiceRegistered(GlobalShortcutsBackendGSD::kGsdService2);
#else
return false;
#endif
}
bool GlobalShortcuts::IsKdeAvailable() const {
bool GlobalShortcutsManager::IsKdeAvailable() const {
#ifdef HAVE_DBUS
return QDBusConnection::sessionBus().interface()->isServiceRegistered(GlobalShortcutBackendKDE::kKdeService);
return QDBusConnection::sessionBus().interface()->isServiceRegistered(GlobalShortcutsBackendKDE::kKdeService);
#else
return false;
#endif
}
bool GlobalShortcuts::IsX11Available() const {
bool GlobalShortcutsManager::IsX11Available() const {
#ifdef HAVE_X11EXTRAS
return QX11Info::isPlatformX11();
@ -174,7 +174,7 @@ bool GlobalShortcuts::IsX11Available() const {
}
void GlobalShortcuts::Register() {
void GlobalShortcutsManager::Register() {
if (use_gsd_ && gsd_backend_ && gsd_backend_->Register()) return;
if (use_kde_ && kde_backend_ && kde_backend_->Register()) return;
@ -189,7 +189,7 @@ void GlobalShortcuts::Register() {
}
void GlobalShortcuts::Unregister() {
void GlobalShortcutsManager::Unregister() {
if (gsd_backend_ && gsd_backend_->is_active()) gsd_backend_->Unregister();
if (kde_backend_ && kde_backend_->is_active()) kde_backend_->Unregister();
@ -197,17 +197,17 @@ void GlobalShortcuts::Unregister() {
}
bool GlobalShortcuts::IsMacAccessibilityEnabled() const {
bool GlobalShortcutsManager::IsMacAccessibilityEnabled() const {
#ifdef Q_OS_MACOS
if (system_backend_) return qobject_cast<GlobalShortcutBackendMacOS*>(system_backend_)->IsAccessibilityEnabled();
if (system_backend_) return qobject_cast<GlobalShortcutsBackendMacOS*>(system_backend_)->IsAccessibilityEnabled();
else return false;
#else
return true;
#endif
}
void GlobalShortcuts::ShowMacAccessibilityDialog() {
void GlobalShortcutsManager::ShowMacAccessibilityDialog() {
#ifdef Q_OS_MACOS
if (system_backend_) qobject_cast<GlobalShortcutBackendMacOS*>(system_backend_)->ShowAccessibilityDialog();
if (system_backend_) qobject_cast<GlobalShortcutsBackendMacOS*>(system_backend_)->ShowAccessibilityDialog();
#endif
}

View File

@ -19,8 +19,8 @@
*
*/
#ifndef GLOBALSHORTCUTS_H
#define GLOBALSHORTCUTS_H
#ifndef GLOBALSHORTCUTSMANAGER_H
#define GLOBALSHORTCUTSMANAGER_H
#include "config.h"
@ -33,13 +33,13 @@
class QShortcut;
class QAction;
class GlobalShortcutBackend;
class GlobalShortcutsBackend;
class GlobalShortcuts : public QWidget {
class GlobalShortcutsManager : public QWidget {
Q_OBJECT
public:
explicit GlobalShortcuts(QWidget *parent = nullptr);
explicit GlobalShortcutsManager(QWidget *parent = nullptr);
struct Shortcut {
QString id;
@ -88,9 +88,9 @@ class GlobalShortcuts : public QWidget {
Shortcut AddShortcut(const QString &id, const QString &name, const QKeySequence &default_key);
private:
GlobalShortcutBackend *gsd_backend_;
GlobalShortcutBackend *kde_backend_;
GlobalShortcutBackend *system_backend_;
GlobalShortcutsBackend *gsd_backend_;
GlobalShortcutsBackend *kde_backend_;
GlobalShortcutsBackend *system_backend_;
QMap<QString, Shortcut> shortcuts_;
QSettings settings_;
@ -100,4 +100,4 @@ class GlobalShortcuts : public QWidget {
bool use_x11_;
};
#endif // GLOBALSHORTCUTS_H
#endif // GLOBALSHORTCUTSMANAGER_H

View File

@ -46,11 +46,11 @@
# include "core/mac_utilities.h"
#endif
#include "globalshortcuts/globalshortcutgrabber.h"
#include "globalshortcuts/globalshortcuts.h"
#include "globalshortcuts/globalshortcutsmanager.h"
#include "settingspage.h"
#include "settingsdialog.h"
#include "shortcutssettingspage.h"
#include "ui_shortcutssettingspage.h"
#include "globalshortcutssettingspage.h"
#include "ui_globalshortcutssettingspage.h"
const char *GlobalShortcutsSettingsPage::kSettingsGroup = "GlobalShortcuts";
@ -108,7 +108,7 @@ void GlobalShortcutsSettingsPage::Load() {
QSettings s;
s.beginGroup(kSettingsGroup);
GlobalShortcuts *manager = dialog()->global_shortcuts_manager();
GlobalShortcutsManager *manager = dialog()->global_shortcuts_manager();
if (!initialized_) {
initialized_ = true;
@ -116,7 +116,7 @@ void GlobalShortcutsSettingsPage::Load() {
de_ = Utilities::DesktopEnvironment();
ui_->widget_warning->hide();
QObject::connect(ui_->button_macos_open, &QPushButton::clicked, manager, &GlobalShortcuts::ShowMacAccessibilityDialog);
QObject::connect(ui_->button_macos_open, &QPushButton::clicked, manager, &GlobalShortcutsManager::ShowMacAccessibilityDialog);
#if defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
if (manager->IsGsdAvailable()) {
@ -147,7 +147,7 @@ void GlobalShortcutsSettingsPage::Load() {
}
#endif
for (const GlobalShortcuts::Shortcut &i : manager->shortcuts().values()) {
for (const GlobalShortcutsManager::Shortcut &i : manager->shortcuts().values()) {
Shortcut shortcut;
shortcut.s = i;
shortcut.key = i.action->shortcut();
@ -291,7 +291,7 @@ void GlobalShortcutsSettingsPage::DefaultClicked() {
void GlobalShortcutsSettingsPage::ChangeClicked() {
GlobalShortcuts *manager = dialog()->global_shortcuts_manager();
GlobalShortcutsManager *manager = dialog()->global_shortcuts_manager();
manager->Unregister();
QKeySequence key = grabber_->GetKey(shortcuts_[current_id_].s.action->text());
manager->Register();

View File

@ -32,7 +32,7 @@
#include <QString>
#include <QKeySequence>
#include "globalshortcuts/globalshortcuts.h"
#include "globalshortcuts/globalshortcutsmanager.h"
#include "settingspage.h"
class QTreeWidgetItem;
@ -65,7 +65,7 @@ class GlobalShortcutsSettingsPage : public SettingsPage {
private:
struct Shortcut {
GlobalShortcuts::Shortcut s;
GlobalShortcutsManager::Shortcut s;
QKeySequence key;
QTreeWidgetItem *item;
};

View File

@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
<string>Shortcuts</string>
<string>Global Shortcuts</string>
</property>
<property name="windowIcon">
<iconset resource="../../data/icons.qrc">

View File

@ -68,7 +68,7 @@
#include "appearancesettingspage.h"
#include "contextsettingspage.h"
#include "notificationssettingspage.h"
#include "shortcutssettingspage.h"
#include "globalshortcutssettingspage.h"
#ifdef HAVE_MOODBAR
# include "moodbarsettingspage.h"
#endif

View File

@ -51,7 +51,7 @@ class Application;
class Player;
class Appearance;
class CollectionDirectoryModel;
class GlobalShortcuts;
class GlobalShortcutsManager;
class SettingsPage;
class Ui_SettingsDialog;
@ -97,7 +97,7 @@ class SettingsDialog : public QDialog {
Role_IsSeparator = Qt::UserRole
};
void SetGlobalShortcutManager(GlobalShortcuts *manager) { manager_ = manager; }
void SetGlobalShortcutManager(GlobalShortcutsManager *manager) { manager_ = manager; }
bool is_loading_settings() const { return loading_settings_; }
@ -106,7 +106,7 @@ class SettingsDialog : public QDialog {
Player *player() const { return player_; }
EngineBase *engine() const { return engine_; }
CollectionDirectoryModel *collection_directory_model() const { return model_; }
GlobalShortcuts *global_shortcuts_manager() const { return manager_; }
GlobalShortcutsManager *global_shortcuts_manager() const { return manager_; }
Appearance *appearance() const { return appearance_; }
void OpenAtPage(Page page);
@ -152,7 +152,7 @@ class SettingsDialog : public QDialog {
Player *player_;
EngineBase *engine_;
CollectionDirectoryModel *model_;
GlobalShortcuts *manager_;
GlobalShortcutsManager *manager_;
Appearance *appearance_;
Ui_SettingsDialog *ui_;