3 This file is part of Minitube.
4 Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
6 Minitube 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.
11 Minitube 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.
16 You should have received a copy of the GNU General Public License
17 along with Minitube. If not, see <http://www.gnu.org/licenses/>.
21 #include "globalshortcuts.h"
22 #include "globalshortcutbackend.h"
24 static GlobalShortcuts *singleton = 0;
26 GlobalShortcuts& GlobalShortcuts::instance() {
27 if (!singleton) singleton = new GlobalShortcuts();
31 GlobalShortcuts::GlobalShortcuts(QObject *parent)
36 AddShortcut("play", tr("Play"), SIGNAL(Play()));
37 AddShortcut("pause", tr("Pause"), SIGNAL(Pause()));
38 AddShortcut("play_pause", tr("Play/Pause"), SIGNAL(PlayPause()), QKeySequence(Qt::Key_MediaPlay));
39 AddShortcut("stop", tr("Stop"), SIGNAL(Stop()), QKeySequence(Qt::Key_MediaStop));
40 AddShortcut("stop_after", tr("Stop playing after current track"), SIGNAL(StopAfter()));
41 AddShortcut("next_track", tr("Next track"), SIGNAL(Next()), QKeySequence(Qt::Key_MediaNext));
42 AddShortcut("prev_track", tr("Previous track"), SIGNAL(Previous()), QKeySequence(Qt::Key_MediaPrevious));
43 AddShortcut("inc_volume", tr("Increase volume"), SIGNAL(IncVolume()));
44 AddShortcut("dec_volume", tr("Decrease volume"), SIGNAL(DecVolume()));
45 AddShortcut("mute", tr("Mute"), SIGNAL(Mute()));
46 AddShortcut("seek_forward", tr("Seek forward"), SIGNAL(SeekForward()));
47 AddShortcut("seek_backward", tr("Seek backward"), SIGNAL(SeekBackward()));
51 void GlobalShortcuts::AddShortcut(const QString &id, const QString &name,
53 const QKeySequence &default_key) {
55 shortcut.action = new QAction(name, this);
56 shortcut.action->setShortcut(default_key);
58 shortcut.default_key = default_key;
60 connect(shortcut.action, SIGNAL(triggered()), this, signal);
62 shortcuts_[id] = shortcut;
65 void GlobalShortcuts::reload() {
67 backend->Unregister();