File indexing completed on 2023-05-30 11:30:47

0001 /**
0002  * Copyright (C) 2003 Stefan Asserhall <stefan.asserhall@telia.com>
0003  * Copyright (C) 2007, 2008 Michael Pyne <mpyne@kde.org>
0004  *
0005  * This program is free software; you can redistribute it and/or modify it under
0006  * the terms of the GNU General Public License as published by the Free Software
0007  * Foundation; either version 2 of the License, or (at your option) any later
0008  * version.
0009  *
0010  * This program is distributed in the hope that it will be useful, but WITHOUT ANY
0011  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
0012  * PARTICULAR PURPOSE. See the GNU General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU General Public License along with
0015  * this program.  If not, see <http://www.gnu.org/licenses/>.
0016  */
0017 
0018 #ifndef JUK_KEYDIALOG_H
0019 #define JUK_KEYDIALOG_H
0020 
0021 #include <QDialog>
0022 
0023 class QButtonGroup;
0024 
0025 class KActionCollection;
0026 class KShortcutsEditor;
0027 
0028 /**
0029  * For keyboard shortcut management.
0030  */
0031 class KeyDialog : public QDialog
0032 {
0033     Q_OBJECT
0034 
0035 public:
0036     explicit KeyDialog(KActionCollection *actionCollection, QWidget *parent = nullptr);
0037 
0038     /**
0039      * This is a member function, provided to create a global accelerator with
0040      * standard keys.
0041      */
0042     static void setupActionShortcut(const QString &actionName);
0043 
0044     // Does exec() and auto-saves any changed config
0045     int configure();
0046 
0047 private:
0048 
0049     /**
0050      * Groups of keys that can be selected in the dialog.  If you add or remove
0051      * a group you must also adjust struct KeyInfo::shortcut to have enough
0052      * entries for all groups, and then adjust the keyInfo[] array.
0053      */
0054     enum KeyGroup { NoKeys = 0, StandardKeys = 1, MultimediaKeys = 2 };
0055 
0056 private slots:
0057     void slotKeys(int group);
0058     void slotDefault();
0059 
0060 private:
0061     KActionCollection *m_actionCollection = nullptr;
0062     KShortcutsEditor  *m_pKeyChooser      = nullptr;
0063     QButtonGroup      *m_group            = nullptr;
0064 
0065     struct KeyInfo;
0066 
0067     static const KeyInfo keyInfo[];
0068     static const uint    keyInfoCount;
0069 };
0070 
0071 #endif // JUK_KEYDIALOG_H
0072 
0073 // vim: set et sw=4 tw=0 sta: