1 /*  smplayer, GUI front-end for mplayer.
2     Copyright (C) 2006-2021 Ricardo Villalba <ricardo@smplayer.info>
3 
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8 
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13 
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17 */
18 
19 #include "globalshortcutsdialog.h"
20 #include "globalshortcuts/globalshortcuts.h"
21 
GlobalShortcutsDialog(QWidget * parent,Qt::WindowFlags f)22 GlobalShortcutsDialog::GlobalShortcutsDialog(QWidget* parent, Qt::WindowFlags f )
23 	: QDialog(parent, f)
24 {
25 	setupUi(this);
26 	setWindowTitle("SMPlayer - " + tr("Global Shortcuts"));
27 }
28 
~GlobalShortcutsDialog()29 GlobalShortcutsDialog::~GlobalShortcutsDialog() {
30 }
31 
setGrabbedKeys(int keys)32 void GlobalShortcutsDialog::setGrabbedKeys(int keys) {
33 	GlobalShortcuts::MediaKeys k = (GlobalShortcuts::MediaKeys) keys;
34 
35 	play_check->setChecked(k.testFlag(GlobalShortcuts::MediaPlay));
36 	stop_check->setChecked(k.testFlag(GlobalShortcuts::MediaStop));
37 	previous_check->setChecked(k.testFlag(GlobalShortcuts::MediaPrevious));
38 	next_check->setChecked(k.testFlag(GlobalShortcuts::MediaNext));
39 	pause_check->setChecked(k.testFlag(GlobalShortcuts::MediaPause));
40 	record_check->setChecked(k.testFlag(GlobalShortcuts::MediaRecord));
41 	mute_check->setChecked(k.testFlag(GlobalShortcuts::VolumeMute));
42 	voldown_check->setChecked(k.testFlag(GlobalShortcuts::VolumeDown));
43 	volup_check->setChecked(k.testFlag(GlobalShortcuts::VolumeUp));
44 }
45 
grabbedKeys()46 int GlobalShortcutsDialog::grabbedKeys() {
47 	GlobalShortcuts::MediaKeys k(QFlag (0));
48 
49 	if (play_check->isChecked()) k = k | GlobalShortcuts::MediaPlay;
50 	if (stop_check->isChecked()) k = k | GlobalShortcuts::MediaStop;
51 	if (previous_check->isChecked()) k = k | GlobalShortcuts::MediaPrevious;
52 	if (next_check->isChecked()) k = k | GlobalShortcuts::MediaNext;
53 	if (pause_check->isChecked()) k = k | GlobalShortcuts::MediaPause;
54 	if (record_check->isChecked()) k = k | GlobalShortcuts::MediaRecord;
55 	if (mute_check->isChecked()) k = k | GlobalShortcuts::VolumeMute;
56 	if (voldown_check->isChecked()) k = k | GlobalShortcuts::VolumeDown;
57 	if (volup_check->isChecked()) k = k | GlobalShortcuts::VolumeUp;
58 
59 	return k;
60 }
61 
62 #include "moc_globalshortcutsdialog.cpp"
63