29 #include "dynamic-shortcuts/shortcutcatcher.h"
31 #include "dynamic-shortcuts/shortcutbutton.h"
32 #include "gui/plaintoolbutton.h"
33 #include "miscellaneous/iconfactory.h"
35 #include <QHBoxLayout>
41 m_layout =
new QHBoxLayout(
this);
42 m_layout->setMargin(0);
43 m_layout->setSpacing(1);
48 m_btnReset->setFocusPolicy(Qt::NoFocus);
49 m_btnReset->setToolTip(tr(
"Reset to original shortcut."));
54 m_btnClear->setFocusPolicy(Qt::NoFocus);
55 m_btnClear->setToolTip(tr(
"Clear current shortcut."));
59 m_btnChange->setFocusPolicy(Qt::StrongFocus);
60 m_btnChange->setToolTip(tr(
"Click and hit new shortcut."));
63 m_layout->addWidget(m_btnChange);
64 m_layout->addWidget(m_btnReset);
65 m_layout->addWidget(m_btnClear);
68 connect(m_btnReset, SIGNAL(clicked()),
this, SLOT(
resetShortcut()));
69 connect(m_btnClear, SIGNAL(clicked()),
this, SLOT(
clearShortcut()));
70 connect(m_btnChange, SIGNAL(clicked()),
this, SLOT(startRecording()));
76 ShortcutCatcher::~ShortcutCatcher() {
83 void ShortcutCatcher::startRecording() {
86 m_currentSequence = QKeySequence();
88 m_btnChange->setDown(
true);
89 m_btnChange->grabKeyboard();
94 void ShortcutCatcher::doneRecording() {
95 m_isRecording =
false;
96 m_btnChange->releaseKeyboard();
97 m_btnChange->setDown(
false);
101 emit shortcutChanged(m_currentSequence);
105 if (m_numKey && !m_modifierKeys) {
111 QString str = m_currentSequence.toString(QKeySequence::NativeText);
112 str.replace(
'&', QLatin1String(
"&&"));
115 if (m_modifierKeys) {
116 if (!str.isEmpty()) {
119 if (m_modifierKeys & Qt::META) {
122 if (m_modifierKeys & Qt::CTRL) {
125 if (m_modifierKeys & Qt::ALT) {
128 if (m_modifierKeys & Qt::SHIFT) {
134 m_btnChange->setText(str);
ShortcutCatcher(QWidget *parent=0)
Constructor.
void updateDisplayShortcut()
Updates text displayed in catcher according to active shortcut.
void resetShortcut()
Resets active shortcut to default shortcut.
void clearShortcut()
Clears current active shortcut.
void controlModifierlessTimeout()
Performs time-dependent check of current shortcut check and stops the recording if time is up...
static IconFactory * instance()
Singleton getter.