Make it possible to use enter in shortcuts
This commit is contained in:
parent
9c3cb82fca
commit
676f8dc8be
|
@ -40,6 +40,10 @@ GlobalShortcutGrabber::GlobalShortcutGrabber(QWidget *parent)
|
||||||
ui_->setupUi(this);
|
ui_->setupUi(this);
|
||||||
|
|
||||||
modifier_keys_ << Qt::Key_Shift << Qt::Key_Control << Qt::Key_Meta << Qt::Key_Alt << Qt::Key_AltGr;
|
modifier_keys_ << Qt::Key_Shift << Qt::Key_Control << Qt::Key_Meta << Qt::Key_Alt << Qt::Key_AltGr;
|
||||||
|
|
||||||
|
connect(ui_->buttonBox, SIGNAL(accepted()), this, SLOT(Accepted()));
|
||||||
|
connect(ui_->buttonBox, SIGNAL(rejected()), this, SLOT(Rejected()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GlobalShortcutGrabber::~GlobalShortcutGrabber() {
|
GlobalShortcutGrabber::~GlobalShortcutGrabber() {
|
||||||
|
@ -48,8 +52,8 @@ GlobalShortcutGrabber::~GlobalShortcutGrabber() {
|
||||||
|
|
||||||
QKeySequence GlobalShortcutGrabber::GetKey(const QString &name) {
|
QKeySequence GlobalShortcutGrabber::GetKey(const QString &name) {
|
||||||
|
|
||||||
ui_->label->setText(tr("Press a key combination to use for %1...").arg(name));
|
ui_->label_shortcut->setText(tr("Press a key combination to use for %1...").arg(name));
|
||||||
ui_->combo->clear();
|
ui_->label_key->clear();
|
||||||
|
|
||||||
ret_ = QKeySequence();
|
ret_ = QKeySequence();
|
||||||
|
|
||||||
|
@ -102,5 +106,13 @@ bool GlobalShortcutGrabber::event(QEvent *e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalShortcutGrabber::UpdateText() {
|
void GlobalShortcutGrabber::UpdateText() {
|
||||||
ui_->combo->setText("<b>" + ret_.toString(QKeySequence::NativeText) + "</b>");
|
ui_->label_key->setText("<b>" + ret_.toString(QKeySequence::NativeText) + "</b>");
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalShortcutGrabber::Accepted() {
|
||||||
|
accept();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalShortcutGrabber::Rejected() {
|
||||||
|
if (ui_->label_key->text().isEmpty()) reject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,10 @@ class GlobalShortcutGrabber : public QDialog {
|
||||||
void grabKeyboard();
|
void grabKeyboard();
|
||||||
void releaseKeyboard();
|
void releaseKeyboard();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void Accepted();
|
||||||
|
void Rejected();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void UpdateText();
|
void UpdateText();
|
||||||
void SetupMacEventHandler();
|
void SetupMacEventHandler();
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>418</width>
|
<width>418</width>
|
||||||
<height>110</height>
|
<height>123</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label_shortcut">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Press a key combination to use for %1...</string>
|
<string>Press a key combination to use for %1...</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -29,7 +29,7 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="combo">
|
<widget class="QLabel" name="label_key">
|
||||||
<property name="textFormat">
|
<property name="textFormat">
|
||||||
<enum>Qt::RichText</enum>
|
<enum>Qt::RichText</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -54,38 +54,5 @@
|
||||||
<include location="../../data/data.qrc"/>
|
<include location="../../data/data.qrc"/>
|
||||||
<include location="../../data/icons.qrc"/>
|
<include location="../../data/icons.qrc"/>
|
||||||
</resources>
|
</resources>
|
||||||
<connections>
|
<connections/>
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>GlobalShortcutGrabber</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>GlobalShortcutGrabber</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
</ui>
|
||||||
|
|
Loading…
Reference in New Issue