diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index e085f95119..454bbcdba6 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -376,15 +376,14 @@ void ActionSelector::on_downButton_clicked() AccelLineEdit::AccelLineEdit ( QWidget * parent ) : QLineEdit(parent) { - noneStr = tr("none"); - setText(noneStr); + setPlaceholderText(tr("Press a keyboard shortcut")); + setClearButtonEnabled(true); keyPressedCount = 0; } bool AccelLineEdit::isNone() const { - QString t = text(); - return t.isEmpty() || t == noneStr; + return text().isEmpty(); } /** @@ -399,7 +398,7 @@ void AccelLineEdit::keyPressEvent ( QKeyEvent * e) // Backspace clears the shortcut if text is present, else sets Backspace as shortcut. // If a modifier is pressed without any other key, return. - // AltGr is not a modifier but doesn't have a QtSring representation. + // AltGr is not a modifier but doesn't have a QString representation. switch(key) { case Qt::Key_Backspace: if (state == Qt::NoModifier) { @@ -407,8 +406,9 @@ void AccelLineEdit::keyPressEvent ( QKeyEvent * e) if (isNone()) { QKeySequence ks(key); setText(ks.toString(QKeySequence::NativeText)); - } else { - setText(noneStr); + } + else { + clear(); } } case Qt::Key_Control: @@ -431,7 +431,7 @@ void AccelLineEdit::keyPressEvent ( QKeyEvent * e) txtLine.clear(); break; default: - txtLine += QString::fromLatin1(","); + txtLine += QChar::fromLatin1(','); break; } diff --git a/src/Gui/Widgets.h b/src/Gui/Widgets.h index c9aacb80be..fb4affb45e 100644 --- a/src/Gui/Widgets.h +++ b/src/Gui/Widgets.h @@ -144,7 +144,6 @@ protected: void keyPressEvent(QKeyEvent * e); private: - QString noneStr; int keyPressedCount; };