Krita Source Code Documentation
Loading...
Searching...
No Matches
KisShortcutsEditor_p.h
Go to the documentation of this file.
1
15#ifndef KISSHORTCUTSEDITOR_P
16#define KISSHORTCUTSEDITOR_P
17
18#include "KisShortcutsEditor.h"
19#include <QTreeWidget>
20#include <ktreewidgetsearchline.h>
21
23
24// NEEDED FOR KisShortcutsEditorPrivate
25#include "ui_KisShortcutsDialog.h"
26
27
28
29
32
38{
39public:
40
42 enum hierarchyLevel {Root = 0, /* Base level node (Tools, Krita...) */
43 Program, /* We use this like "Path Tool, Default Tool," */
44 Action}; /* Individual actions */
45
46
47
49
50 void initGUI(KisShortcutsEditor::ActionTypes actionTypes, KisShortcutsEditor::LetterShortcuts allowLetterShortcuts);
51 void appendToView(uint nList, const QString &title = QString());
52 //used in appendToView
53 QTreeWidgetItem *findOrMakeItem(QTreeWidgetItem *parent, const QString &name);
54
55 // Set all shortcuts to their default values (bindings).
56 void allDefault();
57
58 // clear all shortcuts
59 void clearConfiguration();
60
61 //changeXXX were described as "conflict resolution functions"
62 void changeKeyShortcut(KisShortcutsEditorItem *item, uint column, const QKeySequence &capture);
63
64 //this invokes the appropriate conflict resolution function
65 void capturedShortcut(const QVariant &, const QModelIndex &);
66
74 bool addAction(QAction *action, QTreeWidgetItem *hier[], hierarchyLevel level);
75
76 void printShortcuts() const;
77
78 // TODO: Is this necessary w/o global actions?
79 void setActionTypes(KisShortcutsEditor::ActionTypes actionTypes);
80
81public:
82
83 // Members
86
87 Ui::KisShortcutsDialog ui;
88
89 KisShortcutsEditor::ActionTypes actionTypes;
91};
92
93
94
95// Hack to make two protected methods public.
96// Used by both KisShortcutsEditorPrivate and KisShortcutsEditorDelegate
97class QTreeWidgetHack : public QTreeWidget
98{
99public:
100 QTreeWidgetItem *itemFromIndex(const QModelIndex &index) const
101 {
102 return QTreeWidget::itemFromIndex(index);
103 }
104 QModelIndex indexFromItem(QTreeWidgetItem *item, int column) const
105 {
106 return QTreeWidget::indexFromItem(item, column);
107 }
108};
109
110
118class KisShortcutsEditorItem : public QTreeWidgetItem
119{
120public:
121
122 KisShortcutsEditorItem(QTreeWidgetItem *parent, QAction *action);
123
125 ~KisShortcutsEditorItem() override;
126
128 void undo();
129
131 void commit();
132
133 QVariant data(int column, int role = Qt::DisplayRole) const override;
134 bool operator<(const QTreeWidgetItem &other) const override;
135
136 QKeySequence keySequence(uint column) const;
137 void setKeySequence(uint column, const QKeySequence &seq);
138
139 bool isModified(uint column) const;
140 bool isModified() const;
141
142 void setNameBold(bool flag)
143 {
144 m_isNameBold = flag;
145 }
146
147private:
149
151 void updateModified();
152
154 QAction *m_action;
155
157 bool m_isNameBold{false};
158
160
163
166
168 QString m_id;
169
171 QCollator m_collator;
172};
173
174
175
176#endif // KISSHORTCUTSEDITOR_P
unsigned int uint
QAction * m_action
The action this item is responsible for.
void commit()
Commit the changes.
void undo()
Undo the changes since the last commit.
QList< QKeySequence > * m_oldLocalShortcut
The original shortcuts before user changes. 0 means no change.
~KisShortcutsEditorItem() override
Destructor will erase unsaved changes.
bool operator<(const QTreeWidgetItem &other) const override
bool m_isNameBold
Should the Name column be painted in bold?
QKeySequence keySequence(uint column) const
QString m_id
The action id. Needed for exporting and importing.
KisShortcutsEditorItem(QTreeWidgetItem *parent, QAction *action)
QCollator m_collator
The collator, for sorting.
void updateModified()
Recheck modified status - could have changed back to initial value.
QVariant data(int column, int role=Qt::DisplayRole) const override
QString m_actionNameInTable
The localized action name.
void setKeySequence(uint column, const QKeySequence &seq)
void capturedShortcut(const QVariant &, const QModelIndex &)
QList< KisKActionCollection * > actionCollections
KisShortcutsEditorDelegate * delegate
KisShortcutsEditor::ActionTypes actionTypes
Ui::KisShortcutsDialog ui
void initGUI(KisShortcutsEditor::ActionTypes actionTypes, KisShortcutsEditor::LetterShortcuts allowLetterShortcuts)
QTreeWidgetItem * findOrMakeItem(QTreeWidgetItem *parent, const QString &name)
hierarchyLevel
Represents the three hierarchies the dialog displays.
void appendToView(uint nList, const QString &title=QString())
bool addAction(QAction *action, QTreeWidgetItem *hier[], hierarchyLevel level)
void changeKeyShortcut(KisShortcutsEditorItem *item, uint column, const QKeySequence &capture)
void setActionTypes(KisShortcutsEditor::ActionTypes actionTypes)
KisShortcutsEditorPrivate(KisShortcutsEditor *q)
Widget for configuration of KAccel and KGlobalAccel.
QTreeWidgetItem * itemFromIndex(const QModelIndex &index) const
QModelIndex indexFromItem(QTreeWidgetItem *item, int column) const