Changeset View
Changeset View
Standalone View
Standalone View
krita/ui/KisPart.cpp
Show First 20 Lines • Show All 67 Lines • ▼ Show 20 Line(s) | |||||
68 | #include "kis_image_from_clipboard_widget.h" | 68 | #include "kis_image_from_clipboard_widget.h" | ||
69 | #include "kis_shape_controller.h" | 69 | #include "kis_shape_controller.h" | ||
70 | #include "kis_resource_server_provider.h" | 70 | #include "kis_resource_server_provider.h" | ||
71 | #include "kis_animation_cache_populator.h" | 71 | #include "kis_animation_cache_populator.h" | ||
72 | #include "kis_idle_watcher.h" | 72 | #include "kis_idle_watcher.h" | ||
73 | #include "kis_image.h" | 73 | #include "kis_image.h" | ||
74 | #include "KisImportExportManager.h" | 74 | #include "KisImportExportManager.h" | ||
75 | #include "KisDocumentEntry.h" | 75 | #include "KisDocumentEntry.h" | ||
76 | #include "KoToolManager.h" | ||||
76 | 77 | | |||
77 | #include "kis_color_manager.h" | 78 | #include "kis_color_manager.h" | ||
78 | #include "kis_debug.h" | 79 | #include "kis_debug.h" | ||
79 | 80 | | |||
80 | #include "kis_action.h" | 81 | #include "kis_action.h" | ||
81 | #include "kis_action_registry.h" | 82 | #include "kis_action_registry.h" | ||
82 | 83 | | |||
83 | Q_GLOBAL_STATIC(KisPart, s_instance) | 84 | Q_GLOBAL_STATIC(KisPart, s_instance) | ||
Show All 26 Lines | 89 | public: | |||
110 | KActionCollection *actionCollection{0}; | 111 | KActionCollection *actionCollection{0}; | ||
111 | 112 | | |||
112 | KisIdleWatcher idleWatcher; | 113 | KisIdleWatcher idleWatcher; | ||
113 | KisAnimationCachePopulator animationCachePopulator; | 114 | KisAnimationCachePopulator animationCachePopulator; | ||
114 | 115 | | |||
115 | void loadActions(); | 116 | void loadActions(); | ||
116 | }; | 117 | }; | ||
117 | 118 | | |||
119 | // Basically, we are going to insert the current UI/MainWindow ActionCollection | ||||
120 | // into the KisActionRegistry. | ||||
118 | void KisPart::Private::loadActions() | 121 | void KisPart::Private::loadActions() | ||
119 | { | 122 | { | ||
120 | actionCollection = new KActionCollection(part, "krita"); | 123 | actionCollection = part->currentMainwindow()->viewManager()->actionCollection(); | ||
121 | KisActionRegistry * actionRegistry = KisActionRegistry::instance(); | | |||
122 | | ||||
123 | QStringList actionNames = actionRegistry->allActions(); | | |||
124 | actionCollection->readSettings(); // XXX: consider relocating & managing this | | |||
125 | | ||||
126 | | ||||
127 | foreach (const QString &name, actionNames) { | | |||
128 | 124 | | |||
129 | KisAction *a = new KisAction(); | 125 | KisActionRegistry * actionRegistry = KisActionRegistry::instance(); | ||
130 | actionRegistry->propertizeAction(name, a); | | |||
131 | | ||||
132 | if (!actionCollection->action(name)) { | | |||
133 | actionCollection->addAction(name, a); | | |||
134 | } | | |||
135 | else { | | |||
136 | dbgAction << "duplicate action" << name << a << "from" << actionCollection; | | |||
137 | // delete a; | | |||
138 | } | | |||
139 | 126 | | |||
127 | foreach (auto action, actionCollection->actions()) { | ||||
128 | auto name = action->objectName(); | ||||
129 | actionRegistry->addAction(action->objectName(), action); | ||||
140 | } | 130 | } | ||
141 | | ||||
142 | | ||||
143 | | ||||
144 | }; | 131 | }; | ||
145 | 132 | | |||
146 | KisPart* KisPart::instance() | 133 | KisPart* KisPart::instance() | ||
147 | { | 134 | { | ||
148 | return s_instance; | 135 | return s_instance; | ||
149 | } | 136 | } | ||
150 | 137 | | |||
151 | 138 | | |||
▲ Show 20 Lines • Show All 273 Lines • ▼ Show 20 Line(s) | 411 | if (d->startupWidget) { | |||
425 | d->startupWidget->setParent(0); | 412 | d->startupWidget->setParent(0); | ||
426 | d->startupWidget->hide(); | 413 | d->startupWidget->hide(); | ||
427 | } | 414 | } | ||
428 | qApp->restoreOverrideCursor(); | 415 | qApp->restoreOverrideCursor(); | ||
429 | } | 416 | } | ||
430 | 417 | | |||
431 | void KisPart::configureShortcuts() | 418 | void KisPart::configureShortcuts() | ||
432 | { | 419 | { | ||
433 | if (!d->actionCollection) { | | |||
434 | d->loadActions(); | 420 | d->loadActions(); | ||
435 | } | | |||
436 | | ||||
437 | // In kdelibs4 a hack was used to hide the shortcut schemes widget in the | | |||
438 | // normal shortcut editor KShortcutsDialog from kdelibs, by setting the | | |||
439 | // bottom buttons oneself. This does not work anymore (as the buttons are | | |||
440 | // no longer exposed), so for now running with a plain copy of the sources | | |||
441 | // of KShortcutsDialog, where the schemes editor is disabled directly. | | |||
442 | // Not nice, but then soon custom Krita-specific shortcut handling is | | |||
443 | // planned anyway. | | |||
444 | 421 | | |||
445 | // WidgetAction + WindowAction + ApplicationAction leaves only GlobalAction excluded | 422 | auto actionRegistry = KisActionRegistry::instance(); | ||
423 | actionRegistry->configureShortcuts(d->actionCollection); | ||||
446 | 424 | | |||
447 | KisActionRegistry::instance()->configureShortcuts(d->actionCollection); | 425 | // Update the non-UI actions. That includes: | ||
426 | // - Shortcuts called inside of tools | ||||
427 | // - Perhaps other things? | ||||
428 | KoToolManager::instance()->updateToolShortcuts(); | ||||
448 | 429 | | |||
449 | 430 | // Now update the UI actions. | |||
450 | // Now update the widget tooltips in the UI. | | |||
451 | foreach(KisMainWindow *mainWindow, d->mainWindows) { | 431 | foreach(KisMainWindow *mainWindow, d->mainWindows) { | ||
452 | KActionCollection *ac = mainWindow->actionCollection(); | 432 | KActionCollection *ac = mainWindow->actionCollection(); | ||
453 | ac->readSettings(); | 433 | | ||
434 | ac->updateShortcuts(); | ||||
454 | 435 | | |||
455 | // Loop through mainWindow->actionCollections() to modify tooltips | 436 | // Loop through mainWindow->actionCollections() to modify tooltips | ||
456 | // so that they list shortcuts at the end in parentheses | 437 | // so that they list shortcuts at the end in parentheses | ||
457 | foreach( QAction* action, ac->actions()) | 438 | foreach( QAction* action, ac->actions()) | ||
458 | { | 439 | { | ||
459 | // Remove any existing suffixes from the tooltips. | 440 | // Remove any existing suffixes from the tooltips. | ||
460 | // Note this regexp starts with a space, e.g. " (Ctrl-a)" | 441 | // Note this regexp starts with a space, e.g. " (Ctrl-a)" | ||
461 | QString strippedTooltip = action->toolTip().remove(QRegExp("\\s\\(.*\\)")); | 442 | QString strippedTooltip = action->toolTip().remove(QRegExp("\\s\\(.*\\)")); | ||
▲ Show 20 Lines • Show All 203 Lines • Show Last 20 Lines |