Changeset View
Changeset View
Standalone View
Standalone View
src/KeyBindingEditor.h
Show All 15 Lines | 1 | /* | |||
---|---|---|---|---|---|
16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301 USA. | 17 | 02110-1301 USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #ifndef KEYBINDINGEDITOR_H | 20 | #ifndef KEYBINDINGEDITOR_H | ||
21 | #define KEYBINDINGEDITOR_H | 21 | #define KEYBINDINGEDITOR_H | ||
22 | 22 | | |||
23 | // Qt | 23 | // Qt | ||
24 | #include <QWidget> | 24 | #include <QDialog> | ||
25 | | ||||
26 | // Konsole | ||||
27 | #include "Profile.h" | ||||
25 | 28 | | |||
26 | class QTableWidgetItem; | 29 | class QTableWidgetItem; | ||
27 | 30 | | |||
28 | namespace Ui { | 31 | namespace Ui { | ||
29 | class KeyBindingEditor; | 32 | class KeyBindingEditor; | ||
30 | } | 33 | } | ||
31 | 34 | | |||
32 | namespace Konsole { | 35 | namespace Konsole { | ||
33 | class KeyboardTranslator; | 36 | class KeyboardTranslator; | ||
34 | 37 | | |||
35 | /** | 38 | /** | ||
36 | * A dialog which allows the user to edit a key bindings list | 39 | * A dialog which allows the user to edit a key bindings scheme | ||
37 | * which maps between key combinations input by the user and | 40 | * which maps between key combinations input by the user and | ||
38 | * the character sequence sent to the terminal when those | 41 | * the character sequence sent to the terminal when those | ||
39 | * combinations are pressed. | 42 | * combinations are pressed. | ||
40 | * | 43 | * | ||
41 | * The dialog can be initialized with the settings of an | 44 | * The dialog can be initialized with the settings of an | ||
42 | * existing key bindings list using the setup() method. | 45 | * existing key bindings scheme using the setup() method. | ||
43 | * | 46 | * | ||
44 | * The dialog creates a copy of the supplied keyboard translator | 47 | * The dialog creates a copy of the supplied keyboard translator | ||
45 | * to which any changes are applied. The modified translator | 48 | * to which any changes are applied. The modified translator | ||
46 | * can be retrieved using the translator() method. | 49 | * can be retrieved using the translator() method. | ||
47 | */ | 50 | */ | ||
48 | class KeyBindingEditor : public QWidget | 51 | class KeyBindingEditor : public QDialog | ||
49 | { | 52 | { | ||
50 | Q_OBJECT | 53 | Q_OBJECT | ||
51 | 54 | | |||
52 | public: | 55 | public: | ||
53 | /** Constructs a new key bindings editor with the specified parent. */ | 56 | /** Constructs a new key bindings editor with the specified parent. */ | ||
54 | explicit KeyBindingEditor(QWidget *parent = nullptr); | 57 | explicit KeyBindingEditor(QWidget *parent = nullptr); | ||
55 | ~KeyBindingEditor() Q_DECL_OVERRIDE; | 58 | ~KeyBindingEditor() Q_DECL_OVERRIDE; | ||
56 | 59 | | |||
57 | /** | 60 | /** | ||
58 | * Initializes the dialog with the bindings and other settings | 61 | * Initializes the dialog with the bindings and other settings | ||
59 | * from the specified @p translator. | 62 | * from the specified @p translator. | ||
63 | * @p currentProfileTranslator the name of the translator set in the | ||||
64 | * current profile | ||||
65 | * @p isNewTranslator specifies whether the translator being edited | ||||
66 | * is an already existing one or a newly created | ||||
67 | * one, defaults to false. | ||||
60 | */ | 68 | */ | ||
61 | void setup(const KeyboardTranslator *translator); | 69 | void setup(const KeyboardTranslator *translator, const QString ¤tProfileTranslator, | ||
70 | bool isNewTranslator = false); | ||||
62 | 71 | | |||
63 | /** | 72 | /** | ||
64 | * Returns the modified translator describing the changes to the bindings | 73 | * Returns the modified translator describing the changes to the bindings | ||
65 | * and other settings which the user made. | 74 | * and other settings which the user made. | ||
66 | */ | 75 | */ | ||
67 | KeyboardTranslator *translator() const; | 76 | KeyboardTranslator *translator() const; | ||
68 | 77 | | |||
69 | /** | 78 | /** | ||
70 | * Sets the text of the editor's description field. | 79 | * Sets the text of the editor's description field. | ||
71 | */ | 80 | */ | ||
72 | void setDescription(const QString &description); | 81 | void setDescription(const QString &description); | ||
73 | 82 | | |||
74 | /** | 83 | /** | ||
75 | * Returns the text of the editor's description field. | 84 | * Returns the text of the editor's description field. | ||
76 | */ | 85 | */ | ||
77 | QString description() const; | 86 | QString description() const; | ||
78 | 87 | | |||
79 | // reimplemented to handle test area input | 88 | // reimplemented to handle test area input | ||
80 | bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; | 89 | bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE; | ||
81 | 90 | | |||
91 | Q_SIGNALS: | ||||
92 | /** | ||||
93 | * Emitted when the user clicks the OK button to save the changes. This | ||||
94 | * signal is connected to EditProfileDialog::updateKeyBindingsList() | ||||
95 | * to update the key bindings list on the Keyboard tab in the Edit | ||||
96 | * Profile dialog. | ||||
97 | * @p translatorName is the translator that has just been edited | ||||
98 | */ | ||||
99 | void updateKeyBindingsListRequest(const QString &translatorName); | ||||
100 | | ||||
101 | /** | ||||
102 | * Emitted when the user clicks the OK button to save the changes to | ||||
103 | * the translator that's set in the current profile; this signal is | ||||
104 | * connected to EditProfileDialog::updateTempProfileProperty() to | ||||
105 | * request applying the changes to the _tempProfile. | ||||
106 | * @p newTranslatorName is the name of the translator, that has just | ||||
107 | * been edited/saved, and which is also the translator | ||||
108 | * set in the current Profile | ||||
109 | */ | ||||
110 | void updateTempProfileKeyBindingsRequest(Profile::Property, const QString &newTranslatorName); | ||||
111 | | ||||
82 | private Q_SLOTS: | 112 | private Q_SLOTS: | ||
113 | // reimplemented | ||||
114 | void accept() Q_DECL_OVERRIDE; | ||||
115 | | ||||
83 | void setTranslatorDescription(const QString &description); | 116 | void setTranslatorDescription(const QString &description); | ||
84 | void bindingTableItemChanged(QTableWidgetItem *item); | 117 | void bindingTableItemChanged(QTableWidgetItem *item); | ||
85 | void removeSelectedEntry(); | 118 | void removeSelectedEntry(); | ||
86 | void addNewEntry(); | 119 | void addNewEntry(); | ||
87 | 120 | | |||
88 | private: | 121 | private: | ||
89 | Q_DISABLE_COPY(KeyBindingEditor) | 122 | Q_DISABLE_COPY(KeyBindingEditor) | ||
90 | 123 | | |||
91 | void setupKeyBindingTable(const KeyboardTranslator *translator); | 124 | void setupKeyBindingTable(const KeyboardTranslator *translator); | ||
92 | 125 | | |||
93 | Ui::KeyBindingEditor *_ui; | 126 | Ui::KeyBindingEditor *_ui; | ||
94 | 127 | | |||
95 | // translator to which modifications are made as the user makes | 128 | // translator to which modifications are made as the user makes | ||
96 | // changes in the UI. | 129 | // changes in the UI. | ||
97 | // this is initialized as a copy of the translator specified | 130 | // this is initialized as a copy of the translator specified | ||
98 | // when setup() is called | 131 | // when setup() is called | ||
99 | KeyboardTranslator *_translator; | 132 | KeyboardTranslator *_translator; | ||
133 | | ||||
134 | // Show only the rows that match the text entered by the user in the | ||||
135 | // filter search box | ||||
136 | void filterRows(const QString &text); | ||||
137 | | ||||
138 | bool _isNewTranslator; | ||||
139 | | ||||
140 | // The translator set in the current profile | ||||
141 | QString _currentProfileTranslator; | ||||
142 | | ||||
143 | // Sets the size hint of the dialog to be slightly smaller than the | ||||
144 | // size of EditProfileDialog | ||||
145 | QSize sizeHint() const Q_DECL_OVERRIDE; | ||||
100 | }; | 146 | }; | ||
101 | } | 147 | } | ||
102 | 148 | | |||
103 | #endif //KEYBINDINGEDITOR_H | 149 | #endif //KEYBINDINGEDITOR_H |