Krita Source Code Documentation
Loading...
Searching...
No Matches
ShortcutEditWidget Class Reference

#include <KisShortcutsDialog_p.h>

+ Inheritance diagram for ShortcutEditWidget:

Public Slots

void setKeySequence (const QKeySequence &activeSeq)
 Set the displayed sequences.
 

Signals

void keySequenceChanged (const QKeySequence &)
 Emitted when the key sequence is changed.
 
void stealShortcut (const QKeySequence &seq, QAction *action)
 

Public Member Functions

KisKKeySequenceWidget::ShortcutTypes checkForConflictsAgainst () const
 
bool multiKeyShortcutsAllowed () const
 
void paintEvent (QPaintEvent *pe) override
 
void setAction (QObject *action)
 
void setCheckActionCollections (const QList< KisKActionCollection * > checkActionCollections)
 
void setCheckForConflictsAgainst (KisKKeySequenceWidget::ShortcutTypes)
 
void setComponentName (const QString componentName)
 
void setMultiKeyShortcutsAllowed (bool)
 
 ShortcutEditWidget (QWidget *viewport, const QKeySequence &defaultSeq, const QKeySequence &activeSeq, bool allowLetterShortcuts)
 

Private Slots

void defaultToggled (bool)
 
void setCustom (const QKeySequence &)
 

Private Attributes

QObject * m_action
 
KisKKeySequenceWidgetm_customEditor
 
QRadioButton * m_customRadio
 
QKeySequence m_defaultKeySequence
 
QLabel * m_defaultLabel
 
QRadioButton * m_defaultRadio
 
bool m_isUpdating
 

Detailed Description

Edit a shortcut. This widget is displayed when a user clicks on a shortcut from the list. It contains radio buttons choosing between default and custom shortcuts, and a button to configure the custom shortcut.

See also
KisShortcutsEditorDelegate::itemActivated
KisShortcutWidget.cpp

Definition at line 165 of file KisShortcutsDialog_p.h.

Constructor & Destructor Documentation

◆ ShortcutEditWidget()

ShortcutEditWidget::ShortcutEditWidget ( QWidget * viewport,
const QKeySequence & defaultSeq,
const QKeySequence & activeSeq,
bool allowLetterShortcuts )

Definition at line 41 of file KisShortcutEditWidget.cpp.

43 : QWidget(viewport),
44 m_defaultKeySequence(defaultSeq),
45 m_isUpdating(false),
46 m_action(0)
47{
48 QGridLayout *layout = new QGridLayout(this);
49
50 m_defaultRadio = new QRadioButton(i18n("Default:"), this);
51 m_defaultLabel = new QLabel(i18nc("No shortcut defined", "None"), this);
52 QString defaultText = defaultSeq.toString(QKeySequence::NativeText);
53 if (defaultText.isEmpty()) {
54 defaultText = i18nc("No shortcut defined", "None");
55 }
56 m_defaultLabel->setText(defaultText);
57
58 m_customRadio = new QRadioButton(i18n("Custom:"), this);
60 m_customEditor->setModifierlessAllowed(allowLetterShortcuts);
61
62 layout->addWidget(m_defaultRadio, 0, 0);
63 layout->addWidget(m_defaultLabel, 0, 1);
64 layout->addWidget(m_customRadio, 1, 0);
65 layout->addWidget(m_customEditor, 1, 1);
66 layout->setColumnStretch(2, 1);
67
68 setKeySequence(activeSeq);
69
70 connect(m_defaultRadio, SIGNAL(toggled(bool)),
71 this, SLOT(defaultToggled(bool)));
72 connect(m_customEditor, SIGNAL(keySequenceChanged(QKeySequence)),
73 this, SLOT(setCustom(QKeySequence)));
74 connect(m_customEditor, SIGNAL(stealShortcut(QKeySequence,QAction*)),
75 this, SIGNAL(stealShortcut(QKeySequence,QAction*)));
76}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
A widget to input a QKeySequence.
void setModifierlessAllowed(bool allow)
void stealShortcut(const QKeySequence &seq, QAction *action)
KisKKeySequenceWidget * m_customEditor
QKeySequence m_defaultKeySequence
void setCustom(const QKeySequence &)
void keySequenceChanged(const QKeySequence &)
Emitted when the key sequence is changed.
void setKeySequence(const QKeySequence &activeSeq)
Set the displayed sequences.
QRadioButton * m_defaultRadio

References connect(), defaultToggled(), keySequenceChanged(), m_customEditor, m_customRadio, m_defaultLabel, m_defaultRadio, setCustom(), setKeySequence(), KisKKeySequenceWidget::setModifierlessAllowed(), and stealShortcut().

Member Function Documentation

◆ checkForConflictsAgainst()

KisKKeySequenceWidget::ShortcutTypes ShortcutEditWidget::checkForConflictsAgainst ( ) const
See also
KisKKeySequenceWidget::checkAgainstStandardShortcuts()

Definition at line 78 of file KisShortcutEditWidget.cpp.

79{
81}
ShortcutTypes checkForConflictsAgainst

References KisKKeySequenceWidget::checkForConflictsAgainst, and m_customEditor.

◆ defaultToggled

void ShortcutEditWidget::defaultToggled ( bool checked)
privateslot

Definition at line 84 of file KisShortcutEditWidget.cpp.

85{
86 if (m_isUpdating) {
87 return;
88 }
89
90 m_isUpdating = true;
91 if (checked) {
92 // The default key sequence should be activated. We check first if this
93 // is possible.
95 // Clear the customs widget
98 } else {
99 // We tried to switch to the default key sequence and failed.
100 // Go back.
101 m_customRadio->setChecked(true);
102 }
103 } else {
104 // The empty key sequence is always valid
105 Q_EMIT keySequenceChanged(QKeySequence());
106 }
107 m_isUpdating = false;
108}
bool isKeySequenceAvailable(const QKeySequence &seq) const

References KisKKeySequenceWidget::clearKeySequence(), KisKKeySequenceWidget::isKeySequenceAvailable(), keySequenceChanged(), m_customEditor, m_customRadio, m_defaultKeySequence, and m_isUpdating.

◆ keySequenceChanged

void ShortcutEditWidget::keySequenceChanged ( const QKeySequence & )
signal

Emitted when the key sequence is changed.

◆ multiKeyShortcutsAllowed()

bool ShortcutEditWidget::multiKeyShortcutsAllowed ( ) const
See also
KisKKeySequenceWidget::checkAgainstStandardShortcuts()

Definition at line 133 of file KisShortcutEditWidget.cpp.

References m_customEditor, and KisKKeySequenceWidget::multiKeyShortcutsAllowed.

◆ paintEvent()

void ShortcutEditWidget::paintEvent ( QPaintEvent * pe)
override

Definition at line 26 of file KisShortcutEditWidget.cpp.

27{
28 QWidget::paintEvent(e);
29 QPainter p(this);
30 QPen pen(QPalette().highlight().color());
31 pen.setWidth(6);
32 p.setPen(pen);
33 p.drawLine(0, 0, width(), 0);
34 if (qApp->isLeftToRight()) {
35 p.drawLine(0, 0, 0, height());
36 } else {
37 p.drawLine(width(), 0, width(), height());
38 }
39}
const Params2D p

References p.

◆ setAction()

void ShortcutEditWidget::setAction ( QObject * action)

Definition at line 138 of file KisShortcutEditWidget.cpp.

139{
140 m_action = action;
141}

References m_action.

◆ setCheckActionCollections()

void ShortcutEditWidget::setCheckActionCollections ( const QList< KisKActionCollection * > checkActionCollections)
See also
KisKKeySequenceWidget::setCheckActionCollections()

Definition at line 110 of file KisShortcutEditWidget.cpp.

112{
113 // We just forward them to out KisKKeySequenceWidget.
114 m_customEditor->setCheckActionCollections(checkActionCollections);
115}
void setCheckActionCollections(const QList< KisKActionCollection * > &actionCollections)

References m_customEditor, and KisKKeySequenceWidget::setCheckActionCollections().

◆ setCheckForConflictsAgainst()

void ShortcutEditWidget::setCheckForConflictsAgainst ( KisKKeySequenceWidget::ShortcutTypes types)

◆ setComponentName()

void ShortcutEditWidget::setComponentName ( const QString componentName)
See also
KisKKeySequenceWidget::setComponentName

Definition at line 122 of file KisShortcutEditWidget.cpp.

123{
124 m_customEditor->setComponentName(componentName);
125}
void setComponentName(const QString &componentName)

References m_customEditor, and KisKKeySequenceWidget::setComponentName().

◆ setCustom

void ShortcutEditWidget::setCustom ( const QKeySequence & seq)
privateslot

Definition at line 144 of file KisShortcutEditWidget.cpp.

145{
146 if (m_isUpdating) {
147 return;
148 }
149
150 // seq is a const reference to a private variable of KisKKeySequenceWidget.
151 // Somewhere below we possible change that one. But we want to Q_EMIT seq
152 // whatever happens. So we make a copy.
153 QKeySequence original = seq;
154
155 m_isUpdating = true;
156
157 // Check if the user typed in the default sequence into the custom field.
158 // We do this by calling setKeySequence which will do the right thing.
159 setKeySequence(original);
160
161 Q_EMIT keySequenceChanged(original);
162 m_isUpdating = false;
163}

References keySequenceChanged(), m_isUpdating, and setKeySequence().

◆ setKeySequence

void ShortcutEditWidget::setKeySequence ( const QKeySequence & activeSeq)
slot

Set the displayed sequences.

Definition at line 165 of file KisShortcutEditWidget.cpp.

166{
167 if (activeSeq.toString(QKeySequence::NativeText) == m_defaultKeySequence.toString(QKeySequence::NativeText)) {
168 m_defaultRadio->setChecked(true);
170 } else {
171 m_customRadio->setChecked(true);
172 // m_customEditor->setKeySequence does some stuff we only want to
173 // execute when the sequence really changes.
174 if (activeSeq != m_customEditor->keySequence()) {
175 m_customEditor->setKeySequence(activeSeq);
176 }
177 }
178}
void setKeySequence(const QKeySequence &seq, Validation val=NoValidate)
QKeySequence keySequence() const

References KisKKeySequenceWidget::clearKeySequence(), KisKKeySequenceWidget::keySequence(), m_customEditor, m_customRadio, m_defaultKeySequence, m_defaultRadio, and KisKKeySequenceWidget::setKeySequence().

◆ setMultiKeyShortcutsAllowed()

void ShortcutEditWidget::setMultiKeyShortcutsAllowed ( bool allowed)

Definition at line 127 of file KisShortcutEditWidget.cpp.

128{
129 // We just forward them to out KisKKeySequenceWidget.
131}

References m_customEditor, and KisKKeySequenceWidget::setMultiKeyShortcutsAllowed().

◆ stealShortcut

void ShortcutEditWidget::stealShortcut ( const QKeySequence & seq,
QAction * action )
signal

Member Data Documentation

◆ m_action

QObject* ShortcutEditWidget::m_action
private

Definition at line 219 of file KisShortcutsDialog_p.h.

◆ m_customEditor

KisKKeySequenceWidget* ShortcutEditWidget::m_customEditor
private

Definition at line 217 of file KisShortcutsDialog_p.h.

◆ m_customRadio

QRadioButton* ShortcutEditWidget::m_customRadio
private

Definition at line 216 of file KisShortcutsDialog_p.h.

◆ m_defaultKeySequence

QKeySequence ShortcutEditWidget::m_defaultKeySequence
private

Definition at line 214 of file KisShortcutsDialog_p.h.

◆ m_defaultLabel

QLabel* ShortcutEditWidget::m_defaultLabel
private

Definition at line 213 of file KisShortcutsDialog_p.h.

◆ m_defaultRadio

QRadioButton* ShortcutEditWidget::m_defaultRadio
private

Definition at line 215 of file KisShortcutsDialog_p.h.

◆ m_isUpdating

bool ShortcutEditWidget::m_isUpdating
private

Definition at line 218 of file KisShortcutsDialog_p.h.


The documentation for this class was generated from the following files: