Krita Source Code Documentation
Loading...
Searching...
No Matches
kshortcutwidget.cpp
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 SPDX-FileCopyrightText: 2007 Andreas Hartmetz <ahartmetz@gmail.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "kshortcutwidget.h"
8#include "ui_kshortcutwidget.h"
9
11{
12public:
14
15//private slots
16 void priKeySequenceChanged(const QKeySequence &);
17 void altKeySequenceChanged(const QKeySequence &);
18
19//members
21 Ui::KisKShortcutWidget ui;
23 bool holdChangedSignal {false};
24};
25
27 : QWidget(parent),
28 d(new KisKShortcutWidgetPrivate(this))
29{
30 d->holdChangedSignal = false;
31 d->ui.setupUi(this);
32 connect(d->ui.priEditor, SIGNAL(keySequenceChanged(QKeySequence)),
33 this, SLOT(priKeySequenceChanged(QKeySequence)));
34 connect(d->ui.altEditor, SIGNAL(keySequenceChanged(QKeySequence)),
35 this, SLOT(altKeySequenceChanged(QKeySequence)));
36}
37
42
44{
45 d->ui.priEditor->setModifierlessAllowed(allow);
46 d->ui.altEditor->setModifierlessAllowed(allow);
47}
48
50{
51 return d->ui.priEditor->isModifierlessAllowed();
52}
53
55{
56 d->ui.priEditor->setClearButtonShown(show);
57 d->ui.altEditor->setClearButtonShown(show);
58}
59
61{
63 ret << d->ui.priEditor->keySequence()
64 << d->ui.altEditor->keySequence();
65 return ret;
66}
67
68
70{
71 d->ui.priEditor->setCheckActionCollections(actionCollections);
72 d->ui.altEditor->setCheckActionCollections(actionCollections);
73}
74
75//slot
77{
78 d->ui.priEditor->applyStealShortcut();
79 d->ui.altEditor->applyStealShortcut();
80}
81
82//slot
84{
85 if (newSc == d->cut) {
86 return;
87 }
88
89 d->holdChangedSignal = true;
90
91 if (!newSc.isEmpty()) {
92 d->ui.priEditor->setKeySequence(newSc.first());
93 }
94
95 if (newSc.size() > 1) {
96 d->ui.altEditor->setKeySequence(newSc.at(1));
97 }
98
99 d->holdChangedSignal = false;
100
101 Q_EMIT shortcutChanged(d->cut);
102}
103
104//slot
109
110//private slot
112{
113 if (cut.isEmpty()) {
114 cut << seq;
115 } else {
116 cut[0] = seq;
117 }
118
119 if (!holdChangedSignal) {
120 Q_EMIT q->shortcutChanged(cut);
121 }
122}
123
124//private slot
126{
127 if (cut.size() <= 1) {
128 cut << seq;
129 } else {
130 cut[1] = seq;
131 }
132
133 if (!holdChangedSignal) {
134 Q_EMIT q->shortcutChanged(cut);
135 }
136}
137
138#include "moc_kshortcutwidget.cpp"
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
Ui::KisKShortcutWidget ui
KisKShortcutWidget *const q
KisKShortcutWidgetPrivate(KisKShortcutWidget *q)
QList< QKeySequence > cut
void altKeySequenceChanged(const QKeySequence &)
void priKeySequenceChanged(const QKeySequence &)
void shortcutChanged(const QList< QKeySequence > &cut)
~KisKShortcutWidget() override
void setShortcut(const QList< QKeySequence > &cut)
void setModifierlessAllowed(bool allow)
void setCheckActionCollections(const QList< KisKActionCollection * > &actionCollections)
KisKShortcutWidgetPrivate *const d
QList< QKeySequence > shortcut() const
void setClearButtonsShown(bool show)
KisKShortcutWidget(QWidget *parent=0)