Krita Source Code Documentation
Loading...
Searching...
No Matches
KisShortcutsDialog_p.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015 Michael Abrahams <miabraha@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-3.0-or-later
5 */
6
7
10#include "kxmlguiclient.h"
11#include <QDomDocument>
12#include "kactioncollection.h"
13#include "kxmlguifactory.h"
14#include <QAction>
15#include <QApplication>
16#include <QDebug>
17#include "kis_action_registry.h"
18#include <KSharedConfig>
19#include <KConfigGroup>
21
22
23QKeySequence primarySequence(const QList<QKeySequence> &sequences)
24{
25 return sequences.isEmpty() ? QKeySequence() : sequences.at(0);
26}
27
28QKeySequence alternateSequence(const QList<QKeySequence> &sequences)
29{
30 return sequences.size() <= 1 ? QKeySequence() : sequences.at(1);
31}
32
33
37
39{
40 // KTreeWidgetSearchLine is unhappy if the contents of the tree change
41 m_shortcutsEditor->clearSearch();
42
43 QString dialogText = i18n("The current shortcut scheme is modified. Save before switching to the new one?");
44 if (m_shortcutsEditor->isModified() &&
45 KMessageBox::questionTwoActions(q,
46 i18n("The current shortcut scheme is modified. Save before switching to the new one?"),
47 QString(),
48 KStandardGuiItem::save(),
49 KStandardGuiItem::discard())
50 == KMessageBox::PrimaryAction) {
51 m_shortcutsEditor->save();
52 } else {
53 m_shortcutsEditor->undo();
54 }
55
56 KisCursorOverrideLock cursorLock(Qt::WaitCursor);
57 m_shortcutsEditor->clearCollections();
58
59 KConfigGroup cg = KSharedConfig::openConfig()->group("Shortcut Schemes");
60 cg.writeEntry("Current Scheme", schemeName);
62
63
64 // Update actions themselves, and re-add to dialog box to refresh
65 auto it = m_collections.constBegin();
66 while (it != m_collections.constEnd()) {
67 it.value()->updateShortcuts();
68 // TODO: BAD
69 m_shortcutsEditor->addCollection(it.value(), it.key());
70 it++;
71 }
72}
73
75{
76 m_shortcutsEditor->undo();
77}
78
80{
81 m_shortcutsEditor->save();
82}
83
84#include "moc_KisShortcutsDialog_p.cpp"
QKeySequence alternateSequence(const QList< QKeySequence > &sequences)
QKeySequence primarySequence(const QList< QKeySequence > &sequences)
static KisActionRegistry * instance()
void loadShortcutScheme(const QString &schemeName)
loadShortcutScheme