summaryrefslogtreecommitdiff
path: root/src/frontend/settingsdialogs/btshortcutseditor.h
blob: f9a812aa26ee611501d2930342deb3c84a3e57d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2011 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/


#ifndef BT_SHORTCUTS_EDITOR_H
#define BT_SHORTCUTS_EDITOR_H

#include <QWidget>


class BtActionCollection;
class BtShortcutsEditorItem;
class BtShortcutsDialog;
class QLabel;
class QPushButton;
class QRadioButton;
class QTableWidget;

// This class is the table in the center of the Shortcuts page of the config dialog
class BtShortcutsEditor : public QWidget {
        Q_OBJECT
    public:
        BtShortcutsEditor(BtActionCollection* collection, QWidget* parent);
        BtShortcutsEditor(QWidget* parent);

        // saves shortcut keys into the QAction
        void commitChanges();

        // puts actions and shortcut keys into QTableWidget
        void addCollection(BtActionCollection *collection, const QString &title = QString::null);

        // clears any shortcut keys in the table matching the specified keys
        void clearConflictWithKeys(const QString& keys);

        // finds any shortcut keys in the table matching the specified keys - returns the Action Name for it.
        QString findConflictWithKeys(const QString& keys);

        // used by application to complete the keyChangeRequest signal
        // stores "keys" into the custom shortcuts dialog field
        void changeShortcutInDialog(const QString& keys);

    signals:
        // make a keyChangeRequest back to the application
        void keyChangeRequest(BtShortcutsEditor*, const QString& keys);

    private slots:

        // called when a different action name row is selected
        void changeRow(int row, int column);

        // called when the none radio button is clicked
        void noneButtonClicked(bool checked);

        // called when the default radio button is clicked
        void defaultButtonClicked(bool checked);

        // called when the custom radio button is clicked
        void customButtonClicked(bool checked);

        // makes the keyChangeRequest
        void makeKeyChangeRequest(const QString& keys);

    private:

        // create the action and shortcuts table
        QTableWidget* createShortcutsTable();

        // create the area below the table where the shortcuts are edited
        QWidget* createShortcutChooser();

        // get the shortcut editor item from the zeroth column of the table
        BtShortcutsEditorItem* getShortcutsEditor(int row);

        // initialize this widget
        void init();

        BtShortcutsDialog* m_dlg;
        QTableWidget* m_table;
        QWidget* m_shortcutChooser;
        QRadioButton* m_noneButton;
        QRadioButton* m_defaultButton;
        QRadioButton* m_customButton;
        QPushButton* m_customPushButton;
        QLabel* m_defaultLabelValue;
        int m_currentRow;
};

#endif