keydialog.h 2.04 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
/**
 * Copyright (C) 2003 Stefan Asserhall <stefan.asserhall@telia.com>
 * Copyright (C) 2007, 2008 Michael Pyne <mpyne@kde.org>
 *
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
 * PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program.  If not, see <http://www.gnu.org/licenses/>.
 */
17

18 19
#ifndef JUK_KEYDIALOG_H
#define JUK_KEYDIALOG_H
20

21
#include <QDialog>
22 23 24 25 26

class QButtonGroup;

class KActionCollection;
class KShortcutsEditor;
27

28 29 30 31
/**
 * For keyboard shortcut management.
 */
class KeyDialog : public QDialog
32 33 34 35
{
    Q_OBJECT

public:
36
    explicit KeyDialog(KActionCollection *actionCollection, QWidget *parent = nullptr);
37 38 39

    /**
     * This is a member function, provided to create a global accelerator with
40
     * standard keys.
41
     */
42
    static void setupActionShortcut(const QString &actionName);
43

44 45 46
    // Does exec() and auto-saves any changed config
    int configure();

47 48 49
private:

    /**
50 51 52
     * Groups of keys that can be selected in the dialog.  If you add or remove
     * a group you must also adjust struct KeyInfo::shortcut to have enough
     * entries for all groups, and then adjust the keyInfo[] array.
53 54 55
     */
    enum KeyGroup { NoKeys = 0, StandardKeys = 1, MultimediaKeys = 2 };

56 57 58 59 60
private slots:
    void slotKeys(int group);
    void slotDefault();

private:
61 62 63
    KActionCollection *m_actionCollection = nullptr;
    KShortcutsEditor  *m_pKeyChooser      = nullptr;
    QButtonGroup      *m_group            = nullptr;
64 65

    struct KeyInfo;
66 67 68

    static const KeyInfo keyInfo[];
    static const uint    keyInfoCount;
69 70
};

71
#endif // JUK_KEYDIALOG_H
72 73

// vim: set et sw=4 tw=0 sta: