1 /* $BEGIN_LICENSE 2 3 This file is part of Musique. 4 Copyright 2013, Flavio Tordini <flavio.tordini@gmail.com> 5 6 Musique is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 Musique is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with Musique. If not, see <http://www.gnu.org/licenses/>. 18 19 $END_LICENSE */ 20 21 #ifndef GLOBALSHORTCUTS_H 22 #define GLOBALSHORTCUTS_H 23 24 #include <QtCore> 25 #include <QAction> 26 27 class GlobalShortcutBackend; 28 29 class GlobalShortcuts : public QObject { 30 31 Q_OBJECT 32 33 public: 34 static GlobalShortcuts& instance(); 35 36 struct Shortcut { 37 QString id; 38 QKeySequence default_key; 39 QAction* action; 40 }; 41 shortcuts()42 QMap<QString, Shortcut> shortcuts() const { return shortcuts_; } setBackend(GlobalShortcutBackend * backend)43 void setBackend(GlobalShortcutBackend* backend) { 44 this->backend = backend; 45 reload(); 46 } 47 48 public slots: 49 void reload(); 50 51 signals: 52 void Play(); 53 void Pause(); 54 void PlayPause(); 55 void Stop(); 56 void StopAfter(); 57 void Next(); 58 void Previous(); 59 void IncVolume(); 60 void DecVolume(); 61 void Mute(); 62 void SeekForward(); 63 void SeekBackward(); 64 65 private: 66 GlobalShortcuts(QObject* parent = 0); 67 void AddShortcut(const QString& id, const QString& name, const char* signal, 68 const QKeySequence& default_key = QKeySequence(0)); 69 70 private: 71 GlobalShortcutBackend* backend; 72 73 QMap<QString, Shortcut> shortcuts_; 74 }; 75 76 #endif 77