1 /* 2 * Strawberry Music Player 3 * This file was part of Clementine. 4 * Copyright 2010, David Sansome <me@davidsansome.com> 5 * Copyright 2018-2021, Jonas Kvinge <jonas@jkvinge.net> 6 * 7 * Strawberry is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation, either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * Strawberry is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with Strawberry. If not, see <http://www.gnu.org/licenses/>. 19 * 20 */ 21 22 #ifndef GLOBALSHORTCUTSBACKEND_MACOS_H 23 #define GLOBALSHORTCUTSBACKEND_MACOS_H 24 25 #include "config.h" 26 27 #include <memory> 28 29 #include "globalshortcutsbackend.h" 30 31 #include <QObject> 32 #include <QMap> 33 #include <QAction> 34 #include <QKeySequence> 35 36 class GlobalShortcutsBackendMacOSPrivate; 37 38 class GlobalShortcutsBackendMacOS : public GlobalShortcutsBackend { 39 Q_OBJECT 40 41 public: 42 explicit GlobalShortcutsBackendMacOS(GlobalShortcutsManager *manager, QObject *parent = nullptr); 43 virtual ~GlobalShortcutsBackendMacOS(); 44 IsAvailable()45 bool IsAvailable() const override { return true; } 46 47 static bool IsAccessibilityEnabled(); 48 static void ShowAccessibilityDialog(); 49 50 void MacMediaKeyPressed(const int key); 51 52 protected: 53 bool DoRegister() override; 54 void DoUnregister() override; 55 56 private: 57 bool KeyPressed(const QKeySequence &sequence); 58 59 QMap<QKeySequence, QAction*> shortcuts_; 60 61 friend class GlobalShortcutsBackendMacOSPrivate; 62 std::unique_ptr<GlobalShortcutsBackendMacOSPrivate> p_; 63 }; 64 65 #endif // GLOBALSHORTCUTSBACKEND_MACOS_H 66