Rename global shortcuts classes
This commit is contained in:
parent
bf7c8df353
commit
2a92ce867a
|
@ -69,8 +69,8 @@ Files: src/core/main.h
|
||||||
src/covermanager/spotifycoverprovider.h
|
src/covermanager/spotifycoverprovider.h
|
||||||
src/covermanager/musixmatchcoverprovider.cpp
|
src/covermanager/musixmatchcoverprovider.cpp
|
||||||
src/covermanager/musixmatchcoverprovider.h
|
src/covermanager/musixmatchcoverprovider.h
|
||||||
src/globalshortcuts/globalshortcutbackend-system.cpp
|
src/globalshortcuts/globalshortcutsbackend-system.cpp
|
||||||
src/globalshortcuts/globalshortcutbackend-system.h
|
src/globalshortcuts/globalshortcutsbackend-system.h
|
||||||
src/globalshortcuts/globalshortcut.cpp
|
src/globalshortcuts/globalshortcut.cpp
|
||||||
src/globalshortcuts/globalshortcut.h
|
src/globalshortcuts/globalshortcut.h
|
||||||
src/globalshortcuts/globalshortcut-X11.cpp
|
src/globalshortcuts/globalshortcut-X11.cpp
|
||||||
|
@ -172,8 +172,8 @@ Files: src/core/main.cpp
|
||||||
src/device/mtpconnection.h
|
src/device/mtpconnection.h
|
||||||
src/device/mtpdevice.cpp
|
src/device/mtpdevice.cpp
|
||||||
src/device/mtpdevice.h
|
src/device/mtpdevice.h
|
||||||
src/globalshortcuts/globalshortcuts.cpp
|
src/globalshortcuts/globalshortcutsmanager.cpp
|
||||||
src/globalshortcuts/globalshortcuts.h
|
src/globalshortcuts/globalshortcutsmanager.h
|
||||||
src/settings/shortcutssettingspage.cpp
|
src/settings/shortcutssettingspage.cpp
|
||||||
src/settings/shortcutssettingspage.h
|
src/settings/shortcutssettingspage.h
|
||||||
src/settings/appearancesettingspage.cpp
|
src/settings/appearancesettingspage.cpp
|
||||||
|
|
|
@ -546,23 +546,23 @@ endif()
|
||||||
|
|
||||||
if(HAVE_GLOBALSHORTCUTS)
|
if(HAVE_GLOBALSHORTCUTS)
|
||||||
optional_source(HAVE_GLOBALSHORTCUTS
|
optional_source(HAVE_GLOBALSHORTCUTS
|
||||||
SOURCES globalshortcuts/globalshortcuts.cpp globalshortcuts/globalshortcutbackend.cpp globalshortcuts/globalshortcutgrabber.cpp settings/shortcutssettingspage.cpp
|
SOURCES globalshortcuts/globalshortcutsmanager.cpp globalshortcuts/globalshortcutsbackend.cpp globalshortcuts/globalshortcutgrabber.cpp settings/globalshortcutssettingspage.cpp
|
||||||
HEADERS globalshortcuts/globalshortcuts.h globalshortcuts/globalshortcutbackend.h globalshortcuts/globalshortcutgrabber.h settings/shortcutssettingspage.h
|
HEADERS globalshortcuts/globalshortcutsmanager.h globalshortcuts/globalshortcutsbackend.h globalshortcuts/globalshortcutgrabber.h settings/globalshortcutssettingspage.h
|
||||||
UI globalshortcuts/globalshortcutgrabber.ui settings/shortcutssettingspage.ui
|
UI globalshortcuts/globalshortcutgrabber.ui settings/globalshortcutssettingspage.ui
|
||||||
)
|
)
|
||||||
if(HAVE_X11EXTRAS OR WIN32)
|
if(HAVE_X11EXTRAS OR WIN32)
|
||||||
set(X11_OR_WIN ON)
|
set(X11_OR_WIN ON)
|
||||||
endif()
|
endif()
|
||||||
optional_source(X11_OR_WIN
|
optional_source(X11_OR_WIN
|
||||||
SOURCES globalshortcuts/globalshortcutbackend-system.cpp globalshortcuts/globalshortcut.cpp
|
SOURCES globalshortcuts/globalshortcutsbackend-system.cpp globalshortcuts/globalshortcut.cpp
|
||||||
HEADERS globalshortcuts/globalshortcutbackend-system.h globalshortcuts/globalshortcut.h
|
HEADERS globalshortcuts/globalshortcutsbackend-system.h globalshortcuts/globalshortcut.h
|
||||||
)
|
)
|
||||||
optional_source(HAVE_X11EXTRAS
|
optional_source(HAVE_X11EXTRAS
|
||||||
SOURCES globalshortcuts/globalshortcut-x11.cpp
|
SOURCES globalshortcuts/globalshortcut-x11.cpp
|
||||||
)
|
)
|
||||||
optional_source(HAVE_DBUS
|
optional_source(HAVE_DBUS
|
||||||
SOURCES globalshortcuts/globalshortcutbackend-gsd.cpp globalshortcuts/globalshortcutbackend-kde.cpp
|
SOURCES globalshortcuts/globalshortcutsbackend-gsd.cpp globalshortcuts/globalshortcutsbackend-kde.cpp
|
||||||
HEADERS globalshortcuts/globalshortcutbackend-gsd.h globalshortcuts/globalshortcutbackend-kde.h
|
HEADERS globalshortcuts/globalshortcutsbackend-gsd.h globalshortcuts/globalshortcutsbackend-kde.h
|
||||||
)
|
)
|
||||||
optional_source(WIN32
|
optional_source(WIN32
|
||||||
SOURCES globalshortcuts/globalshortcut-win.cpp
|
SOURCES globalshortcuts/globalshortcut-win.cpp
|
||||||
|
@ -885,13 +885,13 @@ optional_source(APPLE
|
||||||
osd/osdmac.mm
|
osd/osdmac.mm
|
||||||
widgets/qsearchfield_mac.mm
|
widgets/qsearchfield_mac.mm
|
||||||
engine/macosdevicefinder.cpp
|
engine/macosdevicefinder.cpp
|
||||||
globalshortcuts/globalshortcutbackend-macos.mm
|
globalshortcuts/globalshortcutsbackend-macos.mm
|
||||||
globalshortcuts/globalshortcutgrabber.mm
|
globalshortcuts/globalshortcutgrabber.mm
|
||||||
HEADERS
|
HEADERS
|
||||||
core/macsystemtrayicon.h
|
core/macsystemtrayicon.h
|
||||||
core/macfslistener.h
|
core/macfslistener.h
|
||||||
osd/osdmac.h
|
osd/osdmac.h
|
||||||
globalshortcuts/globalshortcutbackend-macos.h
|
globalshortcuts/globalshortcutsbackend-macos.h
|
||||||
)
|
)
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#import <AppKit/NSApplication.h>
|
#import <AppKit/NSApplication.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "globalshortcuts/globalshortcutbackend-macos.h"
|
#include "globalshortcuts/globalshortcutsbackend-macos.h"
|
||||||
|
|
||||||
class PlatformInterface;
|
class PlatformInterface;
|
||||||
@class SPMediaKeyTap;
|
@class SPMediaKeyTap;
|
||||||
|
@ -9,7 +9,7 @@ class PlatformInterface;
|
||||||
@interface AppDelegate : NSObject<NSApplicationDelegate, NSUserNotificationCenterDelegate> {
|
@interface AppDelegate : NSObject<NSApplicationDelegate, NSUserNotificationCenterDelegate> {
|
||||||
PlatformInterface* application_handler_;
|
PlatformInterface* application_handler_;
|
||||||
NSMenu* dock_menu_;
|
NSMenu* dock_menu_;
|
||||||
GlobalShortcutBackendMacOS* shortcut_handler_;
|
GlobalShortcutsBackendMacOS* shortcut_handler_;
|
||||||
SPMediaKeyTap* key_tap_;
|
SPMediaKeyTap* key_tap_;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ class PlatformInterface;
|
||||||
shouldPresentNotification: (id)notification;
|
shouldPresentNotification: (id)notification;
|
||||||
|
|
||||||
- (void) setDockMenu: (NSMenu*)menu;
|
- (void) setDockMenu: (NSMenu*)menu;
|
||||||
- (GlobalShortcutBackendMacOS*) shortcut_handler;
|
- (GlobalShortcutsBackendMacOS*) shortcut_handler;
|
||||||
- (void) setShortcutHandler: (GlobalShortcutBackendMacOS*)backend;
|
- (void) setShortcutHandler: (GlobalShortcutsBackendMacOS*)backend;
|
||||||
- (void) mediaKeyTap: (SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
|
- (void) mediaKeyTap: (SPMediaKeyTap*)keyTap receivedMediaKeyEvent:(NSEvent*)event;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
class QObject;
|
class QObject;
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
class GlobalShortcutBackendMacOS;
|
class GlobalShortcutsBackendMacOS;
|
||||||
|
|
||||||
class PlatformInterface {
|
class PlatformInterface {
|
||||||
public:
|
public:
|
||||||
|
@ -23,7 +23,7 @@ class PlatformInterface {
|
||||||
namespace mac {
|
namespace mac {
|
||||||
|
|
||||||
void MacMain();
|
void MacMain();
|
||||||
void SetShortcutHandler(GlobalShortcutBackendMacOS *handler);
|
void SetShortcutHandler(GlobalShortcutsBackendMacOS *handler);
|
||||||
void SetApplicationHandler(PlatformInterface *handler);
|
void SetApplicationHandler(PlatformInterface *handler);
|
||||||
void CheckForUpdates();
|
void CheckForUpdates();
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,8 @@
|
||||||
#include "scoped_cftyperef.h"
|
#include "scoped_cftyperef.h"
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
#include "core/scoped_nsautorelease_pool.h"
|
#include "core/scoped_nsautorelease_pool.h"
|
||||||
#include "globalshortcuts/globalshortcuts.h"
|
#include "globalshortcuts/globalshortcutsmanager.h"
|
||||||
#include "globalshortcuts/globalshortcutbackend-macos.h"
|
#include "globalshortcuts/globalshortcutsbackend-macos.h"
|
||||||
|
|
||||||
#ifdef HAVE_SPARKLE
|
#ifdef HAVE_SPARKLE
|
||||||
# import <SUUpdater.h>
|
# import <SUUpdater.h>
|
||||||
|
@ -84,12 +84,12 @@ QDebug operator<<(QDebug dbg, NSObject* object) {
|
||||||
PlatformInterface* application_handler_;
|
PlatformInterface* application_handler_;
|
||||||
AppDelegate* delegate_;
|
AppDelegate* delegate_;
|
||||||
// shortcut_handler_ only used to temporarily save it AppDelegate does all the heavy-shortcut-lifting
|
// shortcut_handler_ only used to temporarily save it AppDelegate does all the heavy-shortcut-lifting
|
||||||
GlobalShortcutBackendMacOS* shortcut_handler_;
|
GlobalShortcutsBackendMacOS* shortcut_handler_;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (GlobalShortcutBackendMacOS*)shortcut_handler;
|
- (GlobalShortcutsBackendMacOS*)shortcut_handler;
|
||||||
- (void)SetShortcutHandler:(GlobalShortcutBackendMacOS*)handler;
|
- (void)SetShortcutHandler:(GlobalShortcutsBackendMacOS*)handler;
|
||||||
|
|
||||||
- (PlatformInterface*)application_handler;
|
- (PlatformInterface*)application_handler;
|
||||||
- (void)SetApplicationHandler:(PlatformInterface*)handler;
|
- (void)SetApplicationHandler:(PlatformInterface*)handler;
|
||||||
|
@ -138,11 +138,11 @@ QDebug operator<<(QDebug dbg, NSObject* object) {
|
||||||
return dock_menu_;
|
return dock_menu_;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setShortcutHandler:(GlobalShortcutBackendMacOS*)backend {
|
- (void)setShortcutHandler:(GlobalShortcutsBackendMacOS*)backend {
|
||||||
shortcut_handler_ = backend;
|
shortcut_handler_ = backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (GlobalShortcutBackendMacOS*)shortcut_handler {
|
- (GlobalShortcutsBackendMacOS*)shortcut_handler {
|
||||||
return shortcut_handler_;
|
return shortcut_handler_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,12 +229,12 @@ QDebug operator<<(QDebug dbg, NSObject* object) {
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (GlobalShortcutBackendMacOS*)shortcut_handler {
|
- (GlobalShortcutsBackendMacOS*)shortcut_handler {
|
||||||
// should be the same as delegate_'s shortcut handler
|
// should be the same as delegate_'s shortcut handler
|
||||||
return shortcut_handler_;
|
return shortcut_handler_;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)SetShortcutHandler:(GlobalShortcutBackendMacOS*)handler {
|
- (void)SetShortcutHandler:(GlobalShortcutsBackendMacOS*)handler {
|
||||||
shortcut_handler_ = handler;
|
shortcut_handler_ = handler;
|
||||||
if (delegate_) [delegate_ setShortcutHandler:handler];
|
if (delegate_) [delegate_ setShortcutHandler:handler];
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ void MacMain() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetShortcutHandler(GlobalShortcutBackendMacOS* handler) {
|
void SetShortcutHandler(GlobalShortcutsBackendMacOS* handler) {
|
||||||
[NSApp SetShortcutHandler:handler];
|
[NSApp SetShortcutHandler:handler];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,4 +469,3 @@ void EnableFullScreen(const QWidget& main_window) {
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace mac
|
} // namespace mac
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@
|
||||||
#include "analyzer/analyzercontainer.h"
|
#include "analyzer/analyzercontainer.h"
|
||||||
#include "equalizer/equalizer.h"
|
#include "equalizer/equalizer.h"
|
||||||
#ifdef HAVE_GLOBALSHORTCUTS
|
#ifdef HAVE_GLOBALSHORTCUTS
|
||||||
# include "globalshortcuts/globalshortcuts.h"
|
# include "globalshortcuts/globalshortcutsmanager.h"
|
||||||
#endif
|
#endif
|
||||||
#include "covermanager/albumcovermanager.h"
|
#include "covermanager/albumcovermanager.h"
|
||||||
#include "covermanager/albumcoverchoicecontroller.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)),
|
edit_tag_dialog_(std::bind(&MainWindow::CreateEditTagDialog, this)),
|
||||||
album_cover_choice_controller_(new AlbumCoverChoiceController(this)),
|
album_cover_choice_controller_(new AlbumCoverChoiceController(this)),
|
||||||
#ifdef HAVE_GLOBALSHORTCUTS
|
#ifdef HAVE_GLOBALSHORTCUTS
|
||||||
global_shortcuts_(new GlobalShortcuts(this)),
|
globalshortcuts_manager_(new GlobalShortcutsManager(this)),
|
||||||
#endif
|
#endif
|
||||||
context_view_(new ContextView(this)),
|
context_view_(new ContextView(this)),
|
||||||
collection_view_(new CollectionViewContainer(this)),
|
collection_view_(new CollectionViewContainer(this)),
|
||||||
|
@ -763,23 +763,23 @@ MainWindow::MainWindow(Application *app, SystemTrayIcon *tray_icon, OSDBase *osd
|
||||||
|
|
||||||
#ifdef HAVE_GLOBALSHORTCUTS
|
#ifdef HAVE_GLOBALSHORTCUTS
|
||||||
// Global shortcuts
|
// Global shortcuts
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::Play, app_->player(), &Player::Play);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Play, app_->player(), &Player::Play);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::Pause, app_->player(), &Player::Pause);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Pause, app_->player(), &Player::Pause);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::PlayPause, ui_->action_play_pause, &QAction::trigger);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::PlayPause, ui_->action_play_pause, &QAction::trigger);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::Stop, ui_->action_stop, &QAction::trigger);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Stop, ui_->action_stop, &QAction::trigger);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::StopAfter, ui_->action_stop_after_this_track, &QAction::trigger);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::StopAfter, ui_->action_stop_after_this_track, &QAction::trigger);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::Next, ui_->action_next_track, &QAction::trigger);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Next, ui_->action_next_track, &QAction::trigger);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::Previous, ui_->action_previous_track, &QAction::trigger);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Previous, ui_->action_previous_track, &QAction::trigger);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::IncVolume, app_->player(), &Player::VolumeUp);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::IncVolume, app_->player(), &Player::VolumeUp);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::DecVolume, app_->player(), &Player::VolumeDown);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::DecVolume, app_->player(), &Player::VolumeDown);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::Mute, app_->player(), &Player::Mute);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Mute, app_->player(), &Player::Mute);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::SeekForward, app_->player(), &Player::SeekForward);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::SeekForward, app_->player(), &Player::SeekForward);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::SeekBackward, app_->player(), &Player::SeekBackward);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::SeekBackward, app_->player(), &Player::SeekBackward);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::ShowHide, this, &MainWindow::ToggleShowHide);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::ShowHide, this, &MainWindow::ToggleShowHide);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::ShowOSD, app_->player(), &Player::ShowOSD);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::ShowOSD, app_->player(), &Player::ShowOSD);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::TogglePrettyOSD, app_->player(), &Player::TogglePrettyOSD);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::TogglePrettyOSD, app_->player(), &Player::TogglePrettyOSD);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::ToggleScrobbling, app_->scrobbler(), &AudioScrobbler::ToggleScrobbling);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::ToggleScrobbling, app_->scrobbler(), &AudioScrobbler::ToggleScrobbling);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::Love, app_->scrobbler(), &AudioScrobbler::Love);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::Love, app_->scrobbler(), &AudioScrobbler::Love);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Fancy tabs
|
// 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
|
// We need to connect these global shortcuts here after the playlist have been initialized
|
||||||
#ifdef HAVE_GLOBALSHORTCUTS
|
#ifdef HAVE_GLOBALSHORTCUTS
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::CycleShuffleMode, app_->playlist_manager()->sequence(), &PlaylistSequence::CycleShuffleMode);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::CycleShuffleMode, app_->playlist_manager()->sequence(), &PlaylistSequence::CycleShuffleMode);
|
||||||
QObject::connect(global_shortcuts_, &GlobalShortcuts::CycleRepeatMode, app_->playlist_manager()->sequence(), &PlaylistSequence::CycleRepeatMode);
|
QObject::connect(globalshortcuts_manager_, &GlobalShortcutsManager::CycleRepeatMode, app_->playlist_manager()->sequence(), &PlaylistSequence::CycleRepeatMode);
|
||||||
#endif
|
#endif
|
||||||
QObject::connect(app_->playlist_manager()->sequence(), &PlaylistSequence::RepeatModeChanged, osd_, &OSDBase::RepeatModeChanged);
|
QObject::connect(app_->playlist_manager()->sequence(), &PlaylistSequence::RepeatModeChanged, osd_, &OSDBase::RepeatModeChanged);
|
||||||
QObject::connect(app_->playlist_manager()->sequence(), &PlaylistSequence::ShuffleModeChanged, osd_, &OSDBase::ShuffleModeChanged);
|
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);
|
SettingsDialog *settings_dialog = new SettingsDialog(app_, osd_, this);
|
||||||
#ifdef HAVE_GLOBALSHORTCUTS
|
#ifdef HAVE_GLOBALSHORTCUTS
|
||||||
settings_dialog->SetGlobalShortcutManager(global_shortcuts_);
|
settings_dialog->SetGlobalShortcutManager(globalshortcuts_manager_);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Settings
|
// Settings
|
||||||
|
|
|
@ -77,7 +77,7 @@ class EditTagDialog;
|
||||||
class Equalizer;
|
class Equalizer;
|
||||||
class ErrorDialog;
|
class ErrorDialog;
|
||||||
class FileView;
|
class FileView;
|
||||||
class GlobalShortcuts;
|
class GlobalShortcutsManager;
|
||||||
class MimeData;
|
class MimeData;
|
||||||
class OrganizeDialog;
|
class OrganizeDialog;
|
||||||
class PlaylistListContainer;
|
class PlaylistListContainer;
|
||||||
|
@ -303,7 +303,7 @@ class MainWindow : public QMainWindow, public PlatformInterface {
|
||||||
Lazy<EditTagDialog> edit_tag_dialog_;
|
Lazy<EditTagDialog> edit_tag_dialog_;
|
||||||
AlbumCoverChoiceController *album_cover_choice_controller_;
|
AlbumCoverChoiceController *album_cover_choice_controller_;
|
||||||
|
|
||||||
GlobalShortcuts *global_shortcuts_;
|
GlobalShortcutsManager *globalshortcuts_manager_;
|
||||||
|
|
||||||
ContextView *context_view_;
|
ContextView *context_view_;
|
||||||
CollectionViewContainer *collection_view_;
|
CollectionViewContainer *collection_view_;
|
||||||
|
|
|
@ -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),
|
backend_(backend),
|
||||||
shortcut_(shortcut),
|
shortcut_(shortcut),
|
||||||
qt_key_(Qt::Key(0)),
|
qt_key_(Qt::Key(0)),
|
||||||
|
|
|
@ -32,17 +32,17 @@
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class GlobalShortcutBackend;
|
class GlobalShortcutsBackend;
|
||||||
|
|
||||||
class GlobalShortcut : public QObject, QAbstractNativeEventFilter {
|
class GlobalShortcut : public QObject, QAbstractNativeEventFilter {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GlobalShortcut(QObject *parent = nullptr);
|
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;
|
~GlobalShortcut() override;
|
||||||
|
|
||||||
GlobalShortcutBackend *backend() const { return backend_; }
|
GlobalShortcutsBackend *backend() const { return backend_; }
|
||||||
QKeySequence shortcut() const { return shortcut_; }
|
QKeySequence shortcut() const { return shortcut_; }
|
||||||
|
|
||||||
bool setShortcut(const QKeySequence &shortcut);
|
bool setShortcut(const QKeySequence &shortcut);
|
||||||
|
@ -71,7 +71,7 @@ class GlobalShortcut : public QObject, QAbstractNativeEventFilter {
|
||||||
static QHash<QPair<quint32, quint32>, GlobalShortcut*> internal_shortcuts_;
|
static QHash<QPair<quint32, quint32>, GlobalShortcut*> internal_shortcuts_;
|
||||||
static const QVector<quint32> mask_modifiers_;
|
static const QVector<quint32> mask_modifiers_;
|
||||||
|
|
||||||
GlobalShortcutBackend *backend_;
|
GlobalShortcutsBackend *backend_;
|
||||||
QKeySequence shortcut_;
|
QKeySequence shortcut_;
|
||||||
Qt::Key qt_key_;
|
Qt::Key qt_key_;
|
||||||
Qt::KeyboardModifiers qt_mods_;
|
Qt::KeyboardModifiers qt_mods_;
|
||||||
|
|
|
@ -34,20 +34,20 @@
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
#include "globalshortcuts.h"
|
#include "globalshortcutsmanager.h"
|
||||||
#include "globalshortcutbackend.h"
|
#include "globalshortcutsbackend.h"
|
||||||
#include "globalshortcutbackend-gsd.h"
|
#include "globalshortcutsbackend-gsd.h"
|
||||||
|
|
||||||
const char *GlobalShortcutBackendGSD::kGsdService = "org.gnome.SettingsDaemon.MediaKeys";
|
const char *GlobalShortcutsBackendGSD::kGsdService = "org.gnome.SettingsDaemon.MediaKeys";
|
||||||
const char *GlobalShortcutBackendGSD::kGsdService2 = "org.gnome.SettingsDaemon";
|
const char *GlobalShortcutsBackendGSD::kGsdService2 = "org.gnome.SettingsDaemon";
|
||||||
const char *GlobalShortcutBackendGSD::kGsdPath = "/org/gnome/SettingsDaemon/MediaKeys";
|
const char *GlobalShortcutsBackendGSD::kGsdPath = "/org/gnome/SettingsDaemon/MediaKeys";
|
||||||
|
|
||||||
GlobalShortcutBackendGSD::GlobalShortcutBackendGSD(GlobalShortcuts *parent)
|
GlobalShortcutsBackendGSD::GlobalShortcutsBackendGSD(GlobalShortcutsManager *parent)
|
||||||
: GlobalShortcutBackend(parent),
|
: GlobalShortcutsBackend(parent),
|
||||||
interface_(nullptr),
|
interface_(nullptr),
|
||||||
is_connected_(false) {}
|
is_connected_(false) {}
|
||||||
|
|
||||||
bool GlobalShortcutBackendGSD::DoRegister() {
|
bool GlobalShortcutsBackendGSD::DoRegister() {
|
||||||
|
|
||||||
qLog(Debug) << "Registering";
|
qLog(Debug) << "Registering";
|
||||||
|
|
||||||
|
@ -68,13 +68,13 @@ bool GlobalShortcutBackendGSD::DoRegister() {
|
||||||
QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(QCoreApplication::applicationName(), QDateTime::currentDateTime().toSecsSinceEpoch());
|
QDBusPendingReply<> reply = interface_->GrabMediaPlayerKeys(QCoreApplication::applicationName(), QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||||
|
|
||||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||||
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutBackendGSD::RegisterFinished);
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutsBackendGSD::RegisterFinished);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcutBackendGSD::RegisterFinished(QDBusPendingCallWatcher *watcher) {
|
void GlobalShortcutsBackendGSD::RegisterFinished(QDBusPendingCallWatcher *watcher) {
|
||||||
|
|
||||||
QDBusMessage reply = watcher->reply();
|
QDBusMessage reply = watcher->reply();
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
|
@ -84,14 +84,14 @@ void GlobalShortcutBackendGSD::RegisterFinished(QDBusPendingCallWatcher *watcher
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QObject::connect(interface_, &OrgGnomeSettingsDaemonMediaKeysInterface::MediaPlayerKeyPressed, this, &GlobalShortcutBackendGSD::GnomeMediaKeyPressed);
|
QObject::connect(interface_, &OrgGnomeSettingsDaemonMediaKeysInterface::MediaPlayerKeyPressed, this, &GlobalShortcutsBackendGSD::GnomeMediaKeyPressed);
|
||||||
is_connected_ = true;
|
is_connected_ = true;
|
||||||
|
|
||||||
qLog(Debug) << "Registered";
|
qLog(Debug) << "Registered";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcutBackendGSD::DoUnregister() {
|
void GlobalShortcutsBackendGSD::DoUnregister() {
|
||||||
|
|
||||||
qLog(Debug) << "Unregister";
|
qLog(Debug) << "Unregister";
|
||||||
|
|
||||||
|
@ -103,11 +103,11 @@ void GlobalShortcutBackendGSD::DoUnregister() {
|
||||||
is_connected_ = false;
|
is_connected_ = false;
|
||||||
|
|
||||||
interface_->ReleaseMediaPlayerKeys(QCoreApplication::applicationName());
|
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 == "Play") manager_->shortcuts()["play_pause"].action->trigger();
|
||||||
if (key == "Stop") manager_->shortcuts()["stop"].action->trigger();
|
if (key == "Stop") manager_->shortcuts()["stop"].action->trigger();
|
||||||
if (key == "Next") manager_->shortcuts()["next_track"].action->trigger();
|
if (key == "Next") manager_->shortcuts()["next_track"].action->trigger();
|
|
@ -18,25 +18,25 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GLOBALSHORTCUTBACKEND_GSD_H
|
#ifndef GLOBALSHORTCUTSBACKEND_GSD_H
|
||||||
#define GLOBALSHORTCUTBACKEND_GSD_H
|
#define GLOBALSHORTCUTSBACKEND_GSD_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "globalshortcutbackend.h"
|
#include "globalshortcutsbackend.h"
|
||||||
|
|
||||||
class QDBusPendingCallWatcher;
|
class QDBusPendingCallWatcher;
|
||||||
class GlobalShortcuts;
|
class GlobalShortcutsManager;
|
||||||
class OrgGnomeSettingsDaemonMediaKeysInterface;
|
class OrgGnomeSettingsDaemonMediaKeysInterface;
|
||||||
|
|
||||||
class GlobalShortcutBackendGSD : public GlobalShortcutBackend {
|
class GlobalShortcutsBackendGSD : public GlobalShortcutsBackend {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GlobalShortcutBackendGSD(GlobalShortcuts *parent);
|
explicit GlobalShortcutsBackendGSD(GlobalShortcutsManager *parent);
|
||||||
|
|
||||||
static const char *kGsdService;
|
static const char *kGsdService;
|
||||||
static const char *kGsdService2;
|
static const char *kGsdService2;
|
||||||
|
@ -58,4 +58,4 @@ class GlobalShortcutBackendGSD : public GlobalShortcutBackend {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GLOBALSHORTCUTBACKEND_GSD_H
|
#endif // GLOBALSHORTCUTSBACKEND_GSD_H
|
|
@ -36,14 +36,14 @@
|
||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
|
||||||
#include "globalshortcutbackend-kde.h"
|
#include "globalshortcutsbackend-kde.h"
|
||||||
|
|
||||||
const char *GlobalShortcutBackendKDE::kKdeService = "org.kde.kglobalaccel";
|
const char *GlobalShortcutsBackendKDE::kKdeService = "org.kde.kglobalaccel";
|
||||||
const char *GlobalShortcutBackendKDE::kKdePath = "/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";
|
qLog(Debug) << "Registering";
|
||||||
|
|
||||||
|
@ -56,19 +56,19 @@ bool GlobalShortcutBackendKDE::DoRegister() {
|
||||||
interface_ = new OrgKdeKGlobalAccelInterface(kKdeService, kKdePath, QDBusConnection::sessionBus(), this);
|
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);
|
RegisterShortcut(shortcut);
|
||||||
}
|
}
|
||||||
|
|
||||||
QDBusPendingReply<QDBusObjectPath> reply = interface_->getComponent(QCoreApplication::applicationName());
|
QDBusPendingReply<QDBusObjectPath> reply = interface_->getComponent(QCoreApplication::applicationName());
|
||||||
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(reply, this);
|
||||||
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutBackendKDE::RegisterFinished);
|
QObject::connect(watcher, &QDBusPendingCallWatcher::finished, this, &GlobalShortcutsBackendKDE::RegisterFinished);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcutBackendKDE::RegisterFinished(QDBusPendingCallWatcher *watcher) {
|
void GlobalShortcutsBackendKDE::RegisterFinished(QDBusPendingCallWatcher *watcher) {
|
||||||
|
|
||||||
QDBusReply<QDBusObjectPath> reply = watcher->reply();
|
QDBusReply<QDBusObjectPath> reply = watcher->reply();
|
||||||
watcher->deleteLater();
|
watcher->deleteLater();
|
||||||
|
@ -89,19 +89,19 @@ void GlobalShortcutBackendKDE::RegisterFinished(QDBusPendingCallWatcher *watcher
|
||||||
return;
|
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";
|
qLog(Debug) << "Registered";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcutBackendKDE::DoUnregister() {
|
void GlobalShortcutsBackendKDE::DoUnregister() {
|
||||||
|
|
||||||
if (!interface_ || !interface_->isValid()) return;
|
if (!interface_ || !interface_->isValid()) return;
|
||||||
|
|
||||||
qLog(Debug) << "Unregistering";
|
qLog(Debug) << "Unregistering";
|
||||||
|
|
||||||
for (const GlobalShortcuts::Shortcut &shortcut : manager_->shortcuts()) {
|
for (const GlobalShortcutsManager::Shortcut &shortcut : manager_->shortcuts()) {
|
||||||
if (actions_.contains(shortcut.id)) {
|
if (actions_.contains(shortcut.id)) {
|
||||||
interface_->unRegister(GetActionId(shortcut.id, shortcut.action));
|
interface_->unRegister(GetActionId(shortcut.id, shortcut.action));
|
||||||
actions_.remove(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;
|
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;
|
QStringList ret;
|
||||||
ret << QCoreApplication::applicationName();
|
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;
|
QList<int> ret;
|
||||||
for (const QKeySequence &sequence : sequence_list) {
|
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;
|
QList<QKeySequence> ret;
|
||||||
for (int sequence : sequence_list) {
|
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)) {
|
if (QCoreApplication::applicationName() == component_unique && actions_.contains(shortcut_unique)) {
|
||||||
for (QAction *action : actions_.values(shortcut_unique)) {
|
for (QAction *action : actions_.values(shortcut_unique)) {
|
|
@ -17,8 +17,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GLOBALSHORTCUTBACKEND_KDE_H
|
#ifndef GLOBALSHORTCUTSBACKEND_KDE_H
|
||||||
#define GLOBALSHORTCUTBACKEND_KDE_H
|
#define GLOBALSHORTCUTSBACKEND_KDE_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
|
|
||||||
#include "globalshortcutbackend.h"
|
#include "globalshortcutsbackend.h"
|
||||||
#include "globalshortcuts.h"
|
#include "globalshortcutsmanager.h"
|
||||||
|
|
||||||
class QDBusPendingCallWatcher;
|
class QDBusPendingCallWatcher;
|
||||||
class QAction;
|
class QAction;
|
||||||
|
@ -37,11 +37,11 @@ class QAction;
|
||||||
class OrgKdeKGlobalAccelInterface;
|
class OrgKdeKGlobalAccelInterface;
|
||||||
class OrgKdeKglobalaccelComponentInterface;
|
class OrgKdeKglobalaccelComponentInterface;
|
||||||
|
|
||||||
class GlobalShortcutBackendKDE : public GlobalShortcutBackend {
|
class GlobalShortcutsBackendKDE : public GlobalShortcutsBackend {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GlobalShortcutBackendKDE(GlobalShortcuts *parent);
|
explicit GlobalShortcutsBackendKDE(GlobalShortcutsManager *parent);
|
||||||
|
|
||||||
static const char *kKdeService;
|
static const char *kKdeService;
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ class GlobalShortcutBackendKDE : public GlobalShortcutBackend {
|
||||||
void DoUnregister() override;
|
void DoUnregister() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool RegisterShortcut(const GlobalShortcuts::Shortcut &shortcut);
|
bool RegisterShortcut(const GlobalShortcutsManager::Shortcut &shortcut);
|
||||||
static QStringList GetActionId(const QString &id, const QAction *action);
|
static QStringList GetActionId(const QString &id, const QAction *action);
|
||||||
static QList<int> ToIntList(const QList<QKeySequence> &sequence_list);
|
static QList<int> ToIntList(const QList<QKeySequence> &sequence_list);
|
||||||
static QList<QKeySequence> ToKeySequenceList(const QList<int> &sequence_list);
|
static QList<QKeySequence> ToKeySequenceList(const QList<int> &sequence_list);
|
||||||
|
@ -67,4 +67,4 @@ class GlobalShortcutBackendKDE : public GlobalShortcutBackend {
|
||||||
QMultiHash<QString, QAction*> actions_;
|
QMultiHash<QString, QAction*> actions_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GLOBALSHORTCUTBACKEND_KDE_H
|
#endif // GLOBALSHORTCUTSBACKEND_KDE_H
|
|
@ -18,14 +18,14 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GLOBALSHORTCUTBACKEND_MACOS_H
|
#ifndef GLOBALSHORTCUTSBACKEND_MACOS_H
|
||||||
#define GLOBALSHORTCUTBACKEND_MACOS_H
|
#define GLOBALSHORTCUTSBACKEND_MACOS_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "globalshortcutbackend.h"
|
#include "globalshortcutsbackend.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
@ -34,14 +34,14 @@
|
||||||
|
|
||||||
class GlobalShortcut;
|
class GlobalShortcut;
|
||||||
|
|
||||||
class GlobalShortcutBackendMacOSPrivate;
|
class GlobalShortcutsBackendMacOSPrivate;
|
||||||
|
|
||||||
class GlobalShortcutBackendMacOS : public GlobalShortcutBackend {
|
class GlobalShortcutsBackendMacOS : public GlobalShortcutsBackend {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GlobalShortcutBackendMacOS(GlobalShortcuts* parent);
|
explicit GlobalShortcutsBackendMacOS(GlobalShortcutsManager* parent);
|
||||||
virtual ~GlobalShortcutBackendMacOS();
|
virtual ~GlobalShortcutsBackendMacOS();
|
||||||
|
|
||||||
bool IsAccessibilityEnabled() const;
|
bool IsAccessibilityEnabled() const;
|
||||||
void ShowAccessibilityDialog();
|
void ShowAccessibilityDialog();
|
||||||
|
@ -57,8 +57,8 @@ class GlobalShortcutBackendMacOS : public GlobalShortcutBackend {
|
||||||
|
|
||||||
QMap<QKeySequence, QAction*> shortcuts_;
|
QMap<QKeySequence, QAction*> shortcuts_;
|
||||||
|
|
||||||
friend class GlobalShortcutBackendMacOSPrivate;
|
friend class GlobalShortcutsBackendMacOSPrivate;
|
||||||
std::unique_ptr<GlobalShortcutBackendMacOSPrivate> p_;
|
std::unique_ptr<GlobalShortcutsBackendMacOSPrivate> p_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GLOBALSHORTCUTBACKEND_MACOS_H
|
#endif // GLOBALSHORTCUTSBACKEND_MACOS_H
|
|
@ -20,7 +20,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "globalshortcutbackend-macos.h"
|
#include "globalshortcutsbackend-macos.h"
|
||||||
|
|
||||||
#include <boost/noncopyable.hpp>
|
#include <boost/noncopyable.hpp>
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "globalshortcuts.h"
|
#include "globalshortcutsmanager.h"
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
#include "core/mac_startup.h"
|
#include "core/mac_startup.h"
|
||||||
#include "core/utilities.h"
|
#include "core/utilities.h"
|
||||||
|
@ -45,9 +45,9 @@
|
||||||
#import "core/mac_utilities.h"
|
#import "core/mac_utilities.h"
|
||||||
#import "core/SBSystemPreferences.h"
|
#import "core/SBSystemPreferences.h"
|
||||||
|
|
||||||
class GlobalShortcutBackendMacOSPrivate : boost::noncopyable {
|
class GlobalShortcutsBackendMacOSPrivate : boost::noncopyable {
|
||||||
public:
|
public:
|
||||||
explicit GlobalShortcutBackendMacOSPrivate(GlobalShortcutBackendMacOS* backend)
|
explicit GlobalShortcutsBackendMacOSPrivate(GlobalShortcutsBackendMacOS* backend)
|
||||||
: global_monitor_(nil), local_monitor_(nil), backend_(backend) {}
|
: global_monitor_(nil), local_monitor_(nil), backend_(backend) {}
|
||||||
|
|
||||||
bool Register() {
|
bool Register() {
|
||||||
|
@ -74,21 +74,21 @@ class GlobalShortcutBackendMacOSPrivate : boost::noncopyable {
|
||||||
|
|
||||||
id global_monitor_;
|
id global_monitor_;
|
||||||
id local_monitor_;
|
id local_monitor_;
|
||||||
GlobalShortcutBackendMacOS* backend_;
|
GlobalShortcutsBackendMacOS* backend_;
|
||||||
};
|
};
|
||||||
|
|
||||||
GlobalShortcutBackendMacOS::GlobalShortcutBackendMacOS(GlobalShortcuts* parent)
|
GlobalShortcutsBackendMacOS::GlobalShortcutsBackendMacOS(GlobalShortcutsManager* parent)
|
||||||
: GlobalShortcutBackend(parent),
|
: GlobalShortcutsBackend(parent),
|
||||||
p_(new GlobalShortcutBackendMacOSPrivate(this)) {}
|
p_(new GlobalShortcutsBackendMacOSPrivate(this)) {}
|
||||||
|
|
||||||
GlobalShortcutBackendMacOS::~GlobalShortcutBackendMacOS() {}
|
GlobalShortcutsBackendMacOS::~GlobalShortcutsBackendMacOS() {}
|
||||||
|
|
||||||
bool GlobalShortcutBackendMacOS::DoRegister() {
|
bool GlobalShortcutsBackendMacOS::DoRegister() {
|
||||||
|
|
||||||
// Always enable media keys.
|
// Always enable media keys.
|
||||||
mac::SetShortcutHandler(this);
|
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;
|
shortcuts_[shortcut.action->shortcut()] = shortcut.action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,14 +96,14 @@ bool GlobalShortcutBackendMacOS::DoRegister() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcutBackendMacOS::DoUnregister() {
|
void GlobalShortcutsBackendMacOS::DoUnregister() {
|
||||||
|
|
||||||
p_->Unregister();
|
p_->Unregister();
|
||||||
shortcuts_.clear();
|
shortcuts_.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcutBackendMacOS::MacMediaKeyPressed(int key) {
|
void GlobalShortcutsBackendMacOS::MacMediaKeyPressed(int key) {
|
||||||
|
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case NX_KEYTYPE_PLAY:
|
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()) {
|
if (sequence.isEmpty()) {
|
||||||
return false;
|
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};
|
NSDictionary *options = @{(id)kAXTrustedCheckOptionPrompt: @YES};
|
||||||
return AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
|
return AXIsProcessTrustedWithOptions((CFDictionaryRef)options);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcutBackendMacOS::ShowAccessibilityDialog() {
|
void GlobalShortcutsBackendMacOS::ShowAccessibilityDialog() {
|
||||||
|
|
||||||
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSPreferencePanesDirectory, NSSystemDomainMask, YES);
|
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSPreferencePanesDirectory, NSSystemDomainMask, YES);
|
||||||
if ([paths count] == 1) {
|
if ([paths count] == 1) {
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "globalshortcutbackend-system.h"
|
#include "globalshortcutsbackend-system.h"
|
||||||
|
|
||||||
#include "core/logging.h"
|
#include "core/logging.h"
|
||||||
|
|
||||||
|
@ -29,21 +29,21 @@
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
#include <QtAlgorithms>
|
#include <QtAlgorithms>
|
||||||
|
|
||||||
#include "globalshortcuts.h"
|
#include "globalshortcutsmanager.h"
|
||||||
#include "globalshortcutbackend.h"
|
#include "globalshortcutsbackend.h"
|
||||||
#include "globalshortcut.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";
|
qLog(Debug) << "Registering";
|
||||||
|
|
||||||
if (!gshortcut_init_) gshortcut_init_ = new GlobalShortcut(this);
|
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);
|
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;
|
if (action->shortcut().isEmpty()) return false;
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ bool GlobalShortcutBackendSystem::AddShortcut(QAction *action) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcutBackendSystem::DoUnregister() {
|
void GlobalShortcutsBackendSystem::DoUnregister() {
|
||||||
|
|
||||||
qLog(Debug) << "Unregistering";
|
qLog(Debug) << "Unregistering";
|
||||||
|
|
||||||
|
@ -75,4 +75,3 @@ void GlobalShortcutBackendSystem::DoUnregister() {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GLOBALSHORTCUTBACKEND_SYSTEM_H
|
#ifndef GLOBALSHORTCUTSBACKEND_SYSTEM_H
|
||||||
#define GLOBALSHORTCUTBACKEND_SYSTEM_H
|
#define GLOBALSHORTCUTSBACKEND_SYSTEM_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
@ -28,18 +28,18 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
#include "globalshortcutbackend.h"
|
#include "globalshortcutsbackend.h"
|
||||||
|
|
||||||
class QAction;
|
class QAction;
|
||||||
class GlobalShortcuts;
|
class GlobalShortcutsManager;
|
||||||
class GlobalShortcut;
|
class GlobalShortcut;
|
||||||
|
|
||||||
class GlobalShortcutBackendSystem : public GlobalShortcutBackend {
|
class GlobalShortcutsBackendSystem : public GlobalShortcutsBackend {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GlobalShortcutBackendSystem(GlobalShortcuts *parent = nullptr);
|
explicit GlobalShortcutsBackendSystem(GlobalShortcutsManager *parent = nullptr);
|
||||||
~GlobalShortcutBackendSystem() override;
|
~GlobalShortcutsBackendSystem() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool DoRegister() override;
|
bool DoRegister() override;
|
||||||
|
@ -54,4 +54,4 @@ class GlobalShortcutBackendSystem : public GlobalShortcutBackend {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GLOBALSHORTCUTBACKEND_SYSTEM_H
|
#endif // GLOBALSHORTCUTSBACKEND_SYSTEM_H
|
|
@ -22,19 +22,19 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include "globalshortcutbackend.h"
|
#include "globalshortcutsbackend.h"
|
||||||
#include "globalshortcuts.h"
|
#include "globalshortcutsmanager.h"
|
||||||
|
|
||||||
GlobalShortcutBackend::GlobalShortcutBackend(GlobalShortcuts *parent)
|
GlobalShortcutsBackend::GlobalShortcutsBackend(GlobalShortcutsManager *parent)
|
||||||
: QObject(parent), manager_(parent), active_(false) {}
|
: QObject(parent), manager_(parent), active_(false) {}
|
||||||
|
|
||||||
bool GlobalShortcutBackend::Register() {
|
bool GlobalShortcutsBackend::Register() {
|
||||||
bool ret = DoRegister();
|
bool ret = DoRegister();
|
||||||
if (ret) active_ = true;
|
if (ret) active_ = true;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcutBackend::Unregister() {
|
void GlobalShortcutsBackend::Unregister() {
|
||||||
DoUnregister();
|
DoUnregister();
|
||||||
active_ = false;
|
active_ = false;
|
||||||
}
|
}
|
|
@ -18,21 +18,21 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GLOBALSHORTCUTBACKEND_H
|
#ifndef GLOBALSHORTCUTSBACKEND_H
|
||||||
#define GLOBALSHORTCUTBACKEND_H
|
#define GLOBALSHORTCUTSBACKEND_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class GlobalShortcuts;
|
class GlobalShortcutsManager;
|
||||||
|
|
||||||
class GlobalShortcutBackend : public QObject {
|
class GlobalShortcutsBackend : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GlobalShortcutBackend(GlobalShortcuts *parent = nullptr);
|
explicit GlobalShortcutsBackend(GlobalShortcutsManager *parent = nullptr);
|
||||||
|
|
||||||
bool is_active() const { return active_; }
|
bool is_active() const { return active_; }
|
||||||
|
|
||||||
|
@ -46,9 +46,9 @@ class GlobalShortcutBackend : public QObject {
|
||||||
virtual bool DoRegister() = 0;
|
virtual bool DoRegister() = 0;
|
||||||
virtual void DoUnregister() = 0;
|
virtual void DoUnregister() = 0;
|
||||||
|
|
||||||
GlobalShortcuts *manager_;
|
GlobalShortcutsManager *manager_;
|
||||||
bool active_;
|
bool active_;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GLOBALSHORTCUTBACKEND_H
|
#endif // GLOBALSHORTCUTSBACKEND_H
|
|
@ -34,23 +34,23 @@
|
||||||
# include <QX11Info>
|
# include <QX11Info>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "globalshortcuts.h"
|
#include "globalshortcutsmanager.h"
|
||||||
#include "globalshortcutbackend.h"
|
#include "globalshortcutsbackend.h"
|
||||||
|
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
# include "globalshortcutbackend-gsd.h"
|
# include "globalshortcutsbackend-gsd.h"
|
||||||
# include "globalshortcutbackend-kde.h"
|
# include "globalshortcutsbackend-kde.h"
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_X11EXTRAS) || defined(Q_OS_WIN)
|
#if defined(HAVE_X11EXTRAS) || defined(Q_OS_WIN)
|
||||||
# include "globalshortcutbackend-system.h"
|
# include "globalshortcutsbackend-system.h"
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
# include "globalshortcutbackend-macos.h"
|
# include "globalshortcutsbackend-macos.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "settings/shortcutssettingspage.h"
|
#include "settings/globalshortcutssettingspage.h"
|
||||||
|
|
||||||
GlobalShortcuts::GlobalShortcuts(QWidget *parent)
|
GlobalShortcutsManager::GlobalShortcutsManager(QWidget *parent)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
gsd_backend_(nullptr),
|
gsd_backend_(nullptr),
|
||||||
kde_backend_(nullptr),
|
kde_backend_(nullptr),
|
||||||
|
@ -85,28 +85,28 @@ GlobalShortcuts::GlobalShortcuts(QWidget *parent)
|
||||||
|
|
||||||
// Create backends - these do the actual shortcut registration
|
// Create backends - these do the actual shortcut registration
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
gsd_backend_ = new GlobalShortcutBackendGSD(this);
|
gsd_backend_ = new GlobalShortcutsBackendGSD(this);
|
||||||
kde_backend_ = new GlobalShortcutBackendKDE(this);
|
kde_backend_ = new GlobalShortcutsBackendKDE(this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
if (!system_backend_)
|
if (!system_backend_)
|
||||||
system_backend_ = new GlobalShortcutBackendMacOS(this);
|
system_backend_ = new GlobalShortcutsBackendMacOS(this);
|
||||||
#endif
|
#endif
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
if (!system_backend_)
|
if (!system_backend_)
|
||||||
system_backend_ = new GlobalShortcutBackendSystem(this);
|
system_backend_ = new GlobalShortcutsBackendSystem(this);
|
||||||
#endif
|
#endif
|
||||||
#if defined(HAVE_X11EXTRAS)
|
#if defined(HAVE_X11EXTRAS)
|
||||||
if (!system_backend_ && IsX11Available())
|
if (!system_backend_ && IsX11Available())
|
||||||
system_backend_ = new GlobalShortcutBackendSystem(this);
|
system_backend_ = new GlobalShortcutsBackendSystem(this);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ReloadSettings();
|
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.
|
// 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();
|
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);
|
Shortcut shortcut = AddShortcut(id, name, default_key);
|
||||||
QObject::connect(shortcut.action, SIGNAL(triggered()), this, signal);
|
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 shortcut;
|
||||||
shortcut.action = new QAction(name, this);
|
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
|
#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
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GlobalShortcuts::IsKdeAvailable() const {
|
bool GlobalShortcutsManager::IsKdeAvailable() const {
|
||||||
|
|
||||||
#ifdef HAVE_DBUS
|
#ifdef HAVE_DBUS
|
||||||
return QDBusConnection::sessionBus().interface()->isServiceRegistered(GlobalShortcutBackendKDE::kKdeService);
|
return QDBusConnection::sessionBus().interface()->isServiceRegistered(GlobalShortcutsBackendKDE::kKdeService);
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GlobalShortcuts::IsX11Available() const {
|
bool GlobalShortcutsManager::IsX11Available() const {
|
||||||
|
|
||||||
#ifdef HAVE_X11EXTRAS
|
#ifdef HAVE_X11EXTRAS
|
||||||
return QX11Info::isPlatformX11();
|
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_gsd_ && gsd_backend_ && gsd_backend_->Register()) return;
|
||||||
if (use_kde_ && kde_backend_ && kde_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 (gsd_backend_ && gsd_backend_->is_active()) gsd_backend_->Unregister();
|
||||||
if (kde_backend_ && kde_backend_->is_active()) kde_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
|
#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 false;
|
||||||
#else
|
#else
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcuts::ShowMacAccessibilityDialog() {
|
void GlobalShortcutsManager::ShowMacAccessibilityDialog() {
|
||||||
#ifdef Q_OS_MACOS
|
#ifdef Q_OS_MACOS
|
||||||
if (system_backend_) qobject_cast<GlobalShortcutBackendMacOS*>(system_backend_)->ShowAccessibilityDialog();
|
if (system_backend_) qobject_cast<GlobalShortcutsBackendMacOS*>(system_backend_)->ShowAccessibilityDialog();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
|
@ -19,8 +19,8 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef GLOBALSHORTCUTS_H
|
#ifndef GLOBALSHORTCUTSMANAGER_H
|
||||||
#define GLOBALSHORTCUTS_H
|
#define GLOBALSHORTCUTSMANAGER_H
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
@ -33,13 +33,13 @@
|
||||||
|
|
||||||
class QShortcut;
|
class QShortcut;
|
||||||
class QAction;
|
class QAction;
|
||||||
class GlobalShortcutBackend;
|
class GlobalShortcutsBackend;
|
||||||
|
|
||||||
class GlobalShortcuts : public QWidget {
|
class GlobalShortcutsManager : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit GlobalShortcuts(QWidget *parent = nullptr);
|
explicit GlobalShortcutsManager(QWidget *parent = nullptr);
|
||||||
|
|
||||||
struct Shortcut {
|
struct Shortcut {
|
||||||
QString id;
|
QString id;
|
||||||
|
@ -88,9 +88,9 @@ class GlobalShortcuts : public QWidget {
|
||||||
Shortcut AddShortcut(const QString &id, const QString &name, const QKeySequence &default_key);
|
Shortcut AddShortcut(const QString &id, const QString &name, const QKeySequence &default_key);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GlobalShortcutBackend *gsd_backend_;
|
GlobalShortcutsBackend *gsd_backend_;
|
||||||
GlobalShortcutBackend *kde_backend_;
|
GlobalShortcutsBackend *kde_backend_;
|
||||||
GlobalShortcutBackend *system_backend_;
|
GlobalShortcutsBackend *system_backend_;
|
||||||
|
|
||||||
QMap<QString, Shortcut> shortcuts_;
|
QMap<QString, Shortcut> shortcuts_;
|
||||||
QSettings settings_;
|
QSettings settings_;
|
||||||
|
@ -100,4 +100,4 @@ class GlobalShortcuts : public QWidget {
|
||||||
bool use_x11_;
|
bool use_x11_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GLOBALSHORTCUTS_H
|
#endif // GLOBALSHORTCUTSMANAGER_H
|
|
@ -46,11 +46,11 @@
|
||||||
# include "core/mac_utilities.h"
|
# include "core/mac_utilities.h"
|
||||||
#endif
|
#endif
|
||||||
#include "globalshortcuts/globalshortcutgrabber.h"
|
#include "globalshortcuts/globalshortcutgrabber.h"
|
||||||
#include "globalshortcuts/globalshortcuts.h"
|
#include "globalshortcuts/globalshortcutsmanager.h"
|
||||||
#include "settingspage.h"
|
#include "settingspage.h"
|
||||||
#include "settingsdialog.h"
|
#include "settingsdialog.h"
|
||||||
#include "shortcutssettingspage.h"
|
#include "globalshortcutssettingspage.h"
|
||||||
#include "ui_shortcutssettingspage.h"
|
#include "ui_globalshortcutssettingspage.h"
|
||||||
|
|
||||||
const char *GlobalShortcutsSettingsPage::kSettingsGroup = "GlobalShortcuts";
|
const char *GlobalShortcutsSettingsPage::kSettingsGroup = "GlobalShortcuts";
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ void GlobalShortcutsSettingsPage::Load() {
|
||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
|
|
||||||
GlobalShortcuts *manager = dialog()->global_shortcuts_manager();
|
GlobalShortcutsManager *manager = dialog()->global_shortcuts_manager();
|
||||||
|
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
|
@ -116,7 +116,7 @@ void GlobalShortcutsSettingsPage::Load() {
|
||||||
de_ = Utilities::DesktopEnvironment();
|
de_ = Utilities::DesktopEnvironment();
|
||||||
ui_->widget_warning->hide();
|
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 defined(Q_OS_UNIX) && !defined(Q_OS_MACOS)
|
||||||
if (manager->IsGsdAvailable()) {
|
if (manager->IsGsdAvailable()) {
|
||||||
|
@ -147,7 +147,7 @@ void GlobalShortcutsSettingsPage::Load() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (const GlobalShortcuts::Shortcut &i : manager->shortcuts().values()) {
|
for (const GlobalShortcutsManager::Shortcut &i : manager->shortcuts().values()) {
|
||||||
Shortcut shortcut;
|
Shortcut shortcut;
|
||||||
shortcut.s = i;
|
shortcut.s = i;
|
||||||
shortcut.key = i.action->shortcut();
|
shortcut.key = i.action->shortcut();
|
||||||
|
@ -291,7 +291,7 @@ void GlobalShortcutsSettingsPage::DefaultClicked() {
|
||||||
|
|
||||||
void GlobalShortcutsSettingsPage::ChangeClicked() {
|
void GlobalShortcutsSettingsPage::ChangeClicked() {
|
||||||
|
|
||||||
GlobalShortcuts *manager = dialog()->global_shortcuts_manager();
|
GlobalShortcutsManager *manager = dialog()->global_shortcuts_manager();
|
||||||
manager->Unregister();
|
manager->Unregister();
|
||||||
QKeySequence key = grabber_->GetKey(shortcuts_[current_id_].s.action->text());
|
QKeySequence key = grabber_->GetKey(shortcuts_[current_id_].s.action->text());
|
||||||
manager->Register();
|
manager->Register();
|
|
@ -32,7 +32,7 @@
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QKeySequence>
|
#include <QKeySequence>
|
||||||
|
|
||||||
#include "globalshortcuts/globalshortcuts.h"
|
#include "globalshortcuts/globalshortcutsmanager.h"
|
||||||
#include "settingspage.h"
|
#include "settingspage.h"
|
||||||
|
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
|
@ -65,7 +65,7 @@ class GlobalShortcutsSettingsPage : public SettingsPage {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Shortcut {
|
struct Shortcut {
|
||||||
GlobalShortcuts::Shortcut s;
|
GlobalShortcutsManager::Shortcut s;
|
||||||
QKeySequence key;
|
QKeySequence key;
|
||||||
QTreeWidgetItem *item;
|
QTreeWidgetItem *item;
|
||||||
};
|
};
|
|
@ -11,7 +11,7 @@
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Shortcuts</string>
|
<string>Global Shortcuts</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowIcon">
|
<property name="windowIcon">
|
||||||
<iconset resource="../../data/icons.qrc">
|
<iconset resource="../../data/icons.qrc">
|
|
@ -68,7 +68,7 @@
|
||||||
#include "appearancesettingspage.h"
|
#include "appearancesettingspage.h"
|
||||||
#include "contextsettingspage.h"
|
#include "contextsettingspage.h"
|
||||||
#include "notificationssettingspage.h"
|
#include "notificationssettingspage.h"
|
||||||
#include "shortcutssettingspage.h"
|
#include "globalshortcutssettingspage.h"
|
||||||
#ifdef HAVE_MOODBAR
|
#ifdef HAVE_MOODBAR
|
||||||
# include "moodbarsettingspage.h"
|
# include "moodbarsettingspage.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -51,7 +51,7 @@ class Application;
|
||||||
class Player;
|
class Player;
|
||||||
class Appearance;
|
class Appearance;
|
||||||
class CollectionDirectoryModel;
|
class CollectionDirectoryModel;
|
||||||
class GlobalShortcuts;
|
class GlobalShortcutsManager;
|
||||||
class SettingsPage;
|
class SettingsPage;
|
||||||
|
|
||||||
class Ui_SettingsDialog;
|
class Ui_SettingsDialog;
|
||||||
|
@ -97,7 +97,7 @@ class SettingsDialog : public QDialog {
|
||||||
Role_IsSeparator = Qt::UserRole
|
Role_IsSeparator = Qt::UserRole
|
||||||
};
|
};
|
||||||
|
|
||||||
void SetGlobalShortcutManager(GlobalShortcuts *manager) { manager_ = manager; }
|
void SetGlobalShortcutManager(GlobalShortcutsManager *manager) { manager_ = manager; }
|
||||||
|
|
||||||
bool is_loading_settings() const { return loading_settings_; }
|
bool is_loading_settings() const { return loading_settings_; }
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ class SettingsDialog : public QDialog {
|
||||||
Player *player() const { return player_; }
|
Player *player() const { return player_; }
|
||||||
EngineBase *engine() const { return engine_; }
|
EngineBase *engine() const { return engine_; }
|
||||||
CollectionDirectoryModel *collection_directory_model() const { return model_; }
|
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_; }
|
Appearance *appearance() const { return appearance_; }
|
||||||
|
|
||||||
void OpenAtPage(Page page);
|
void OpenAtPage(Page page);
|
||||||
|
@ -152,7 +152,7 @@ class SettingsDialog : public QDialog {
|
||||||
Player *player_;
|
Player *player_;
|
||||||
EngineBase *engine_;
|
EngineBase *engine_;
|
||||||
CollectionDirectoryModel *model_;
|
CollectionDirectoryModel *model_;
|
||||||
GlobalShortcuts *manager_;
|
GlobalShortcutsManager *manager_;
|
||||||
Appearance *appearance_;
|
Appearance *appearance_;
|
||||||
|
|
||||||
Ui_SettingsDialog *ui_;
|
Ui_SettingsDialog *ui_;
|
||||||
|
|
Loading…
Reference in New Issue