Changeset View
Changeset View
Standalone View
Standalone View
libs/widgetutils/xmlgui/KisShortcutsEditor.cpp
Show All 37 Lines | |||||
38 | #include <QTextTable> | 38 | #include <QTextTable> | ||
39 | #include <QTextCursor> | 39 | #include <QTextCursor> | ||
40 | #include <QTextTableFormat> | 40 | #include <QTextTableFormat> | ||
41 | #include <QPrinter> | 41 | #include <QPrinter> | ||
42 | #include <QDebug> | 42 | #include <QDebug> | ||
43 | 43 | | |||
44 | #include <kconfig.h> | 44 | #include <kconfig.h> | ||
45 | #include <kconfiggroup.h> | 45 | #include <kconfiggroup.h> | ||
46 | #include <ksharedconfig.h> | ||||
46 | #include <kmessagebox.h> | 47 | #include <kmessagebox.h> | ||
47 | #include "kactioncollection.h" | 48 | #include "kactioncollection.h" | ||
48 | #include "kactioncategory.h" | 49 | #include "kactioncategory.h" | ||
49 | #include <ktreewidgetsearchline.h> | 50 | #include <ktreewidgetsearchline.h> | ||
50 | 51 | | |||
51 | //--------------------------------------------------------------------- | 52 | //--------------------------------------------------------------------- | ||
52 | // KisShortcutsEditor | 53 | // KisShortcutsEditor | ||
53 | //--------------------------------------------------------------------- | 54 | //--------------------------------------------------------------------- | ||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | 103 | { | |||
107 | } | 108 | } | ||
108 | 109 | | |||
109 | // Pause updating. | 110 | // Pause updating. | ||
110 | setUpdatesEnabled(false); | 111 | setUpdatesEnabled(false); | ||
111 | 112 | | |||
112 | 113 | | |||
113 | /** | 114 | /** | ||
114 | * Forward this actioncollection to the delegate which will do conflict checking. | 115 | * Forward this actioncollection to the delegate which will do conflict checking. | ||
115 | * TODO this seems to _replace_ any existing collections in the delegate. So, is that cool? | 116 | * This _replaces_ existing collections in the delegate. | ||
116 | */ | 117 | */ | ||
117 | d->actionCollections.append(collection); | 118 | d->actionCollections.append(collection); | ||
118 | d->delegate->setCheckActionCollections(d->actionCollections); | 119 | d->delegate->setCheckActionCollections(d->actionCollections); | ||
119 | 120 | | |||
120 | 121 | | |||
121 | // Determine how we should label this collection in the widget. | 122 | // Determine how we should label this collection in the widget. | ||
122 | QString collectionTitle; | 123 | QString collectionTitle; | ||
123 | if (!title.isEmpty()) { | 124 | if (!title.isEmpty()) { | ||
Show All 13 Lines | |||||
137 | // Remember which actions we have seen. We will be adding categorized | 138 | // Remember which actions we have seen. We will be adding categorized | ||
138 | // actions first, so this will help us keep track of which actions haven't | 139 | // actions first, so this will help us keep track of which actions haven't | ||
139 | // been categorized yet, so we can add them as uncategorized at the end. | 140 | // been categorized yet, so we can add them as uncategorized at the end. | ||
140 | QSet<QAction *> actionsSeen; | 141 | QSet<QAction *> actionsSeen; | ||
141 | 142 | | |||
142 | // Add a subtree for each category? Perhaps easier to think that this | 143 | // Add a subtree for each category? Perhaps easier to think that this | ||
143 | // doesn't exist. Basically you add KActionCategory as a QObject child of | 144 | // doesn't exist. Basically you add KActionCategory as a QObject child of | ||
144 | // KActionCollection, and then tag objects as belonging to the category. | 145 | // KActionCollection, and then tag objects as belonging to the category. | ||
145 | QList<KActionCategory *> categories = collection->findChildren<KActionCategory *>(); | 146 | foreach (KActionCategory *category, collection->categories()) { | ||
146 | foreach (KActionCategory *category, categories) { | 147 | | ||
148 | // Don't display empty categories. | ||||
149 | if (category->actions().isEmpty()) { | ||||
150 | continue; | ||||
151 | } | ||||
152 | | ||||
147 | hierarchy[KisShortcutsEditorPrivate::Action] = | 153 | hierarchy[KisShortcutsEditorPrivate::Action] = | ||
148 | d->findOrMakeItem(hierarchy[KisShortcutsEditorPrivate::Program], category->text()); | 154 | d->findOrMakeItem(hierarchy[KisShortcutsEditorPrivate::Program], category->text()); | ||
149 | 155 | | |||
150 | // Add every item from each category. | 156 | // Add every item from each category. | ||
151 | foreach (QAction *action, category->actions()) { | 157 | foreach (QAction *action, category->actions()) { | ||
152 | actionsSeen.insert(action); | 158 | actionsSeen.insert(action); | ||
153 | d->addAction(action, hierarchy, KisShortcutsEditorPrivate::Action); | 159 | d->addAction(action, hierarchy, KisShortcutsEditorPrivate::Action); | ||
154 | } | 160 | } | ||
Show All 38 Lines | 196 | if (d->actionTypes) { | |||
193 | foreach (KActionCollection *collection, d->actionCollections) { | 199 | foreach (KActionCollection *collection, d->actionCollections) { | ||
194 | collection->writeSettings(&group, true); | 200 | collection->writeSettings(&group, true); | ||
195 | } | 201 | } | ||
196 | } | 202 | } | ||
197 | } | 203 | } | ||
198 | 204 | | |||
199 | void KisShortcutsEditor::writeConfiguration(KConfigGroup *config) const | 205 | void KisShortcutsEditor::writeConfiguration(KConfigGroup *config) const | ||
200 | { | 206 | { | ||
207 | // This is a horrible mess with pointers... | ||||
208 | auto cg = KConfigGroup(KSharedConfig::openConfig("kritashortcutsrc"), "Shortcuts"); | ||||
209 | if (config == 0) { | ||||
210 | config = &cg; | ||||
211 | } | ||||
212 | | ||||
201 | foreach (KActionCollection *collection, d->actionCollections) { | 213 | foreach (KActionCollection *collection, d->actionCollections) { | ||
202 | collection->writeSettings(config); | 214 | collection->writeSettings(config, true); | ||
203 | } | 215 | } | ||
204 | } | 216 | } | ||
205 | 217 | | |||
206 | //slot | 218 | //slot | ||
207 | void KisShortcutsEditor::resizeColumns() | 219 | void KisShortcutsEditor::resizeColumns() | ||
208 | { | 220 | { | ||
209 | for (int i = 0; i < d->ui.list->columnCount(); i++) { | 221 | for (int i = 0; i < d->ui.list->columnCount(); i++) { | ||
210 | d->ui.list->resizeColumnToContents(i); | 222 | d->ui.list->resizeColumnToContents(i); | ||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |