24 #include <QHBoxLayout>
27 #include <QSizePolicy>
31 : QWidget(parent), CurrentKeySequence(), LineEdit(nullptr)
35 LineEdit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
42 QHBoxLayout* layout =
new QHBoxLayout(
this);
43 layout->setSpacing(0);
58 if (event->type() == QEvent::KeyPress)
60 QKeyEvent *keyEvent =
static_cast<QKeyEvent*
>(event);
62 int keys = keyEvent->key();
64 if (keys != Qt::Key_Shift &&
65 keys != Qt::Key_Control &&
66 keys != Qt::Key_Meta &&
67 keys != Qt::Key_AltGr &&
70 keys += keyEvent->modifiers();
71 setShortcut(QKeySequence(keys),
true);
77 return QWidget::eventFilter(obj, event);
82 return CurrentKeySequence.toString();
88 return CurrentKeySequence;
93 setShortcut(QKeySequence::fromString(shortcut), emit_signal);
98 if (shortcut != CurrentKeySequence)
100 CurrentKeySequence = shortcut;
101 LineEdit->setText(CurrentKeySequence.toString());
104 emit dataChangedByUser(CurrentKeySequence,
this);
111 setShortcut(text,
true);