add method to check if key sequence is none

This commit is contained in:
wmayer
2019-01-18 00:54:49 +01:00
parent 1444b64803
commit 307bb7744f
2 changed files with 14 additions and 5 deletions

View File

@@ -365,10 +365,17 @@ void ActionSelector::on_downButton_clicked()
AccelLineEdit::AccelLineEdit ( QWidget * parent )
: QLineEdit(parent)
{
setText(tr("none"));
noneStr = tr("none");
setText(noneStr);
keyPressedCount = 0;
}
bool AccelLineEdit::isNone() const
{
QString t = text();
return t.isEmpty() || t == noneStr;
}
/**
* Checks which keys are pressed and show it as text.
*/
@@ -386,7 +393,7 @@ void AccelLineEdit::keyPressEvent ( QKeyEvent * e)
case Qt::Key_Backspace:
if (state == Qt::NoModifier) {
keyPressedCount = 0;
setText(tr("none"));
setText(noneStr);
}
case Qt::Key_Control:
case Qt::Key_Shift:

View File

@@ -124,13 +124,15 @@ class GuiExport AccelLineEdit : public QLineEdit
Q_OBJECT
public:
AccelLineEdit ( QWidget * parent=0 );
AccelLineEdit(QWidget * parent=0);
bool isNone() const;
protected:
void keyPressEvent ( QKeyEvent * e);
void keyPressEvent(QKeyEvent * e);
private:
int keyPressedCount;
QString noneStr;
int keyPressedCount;
};
// ------------------------------------------------------------------------------