1
0
Fork 0

ShortcutEdit styling rework

This commit is contained in:
JustasMasiulis 2020-06-04 22:39:11 +03:00 committed by Duncan Ogilvie
parent 7c7b2ef2d5
commit b0dd282d92
2 changed files with 14 additions and 4 deletions

View File

@ -1,8 +1,10 @@
#include "ShortcutEdit.h"
#include <QStyle>
ShortcutEdit::ShortcutEdit(QWidget* parent) : QLineEdit(parent)
{
keyInt = -1;
mError = true;
}
const QKeySequence ShortcutEdit::getKeysequence() const
@ -13,12 +15,17 @@ const QKeySequence ShortcutEdit::getKeysequence() const
return QKeySequence(keyInt);
}
bool ShortcutEdit::error() const
{
return mError;
}
void ShortcutEdit::setErrorState(bool error)
{
if(error)
setStyleSheet("color: #DD0000");
else
setStyleSheet("color: #222222");
this->mError = error;
this->style()->unpolish(this);
this->style()->polish(this);
}
void ShortcutEdit::keyPressEvent(QKeyEvent* event)

View File

@ -8,11 +8,14 @@
class ShortcutEdit : public QLineEdit
{
Q_OBJECT
Q_PROPERTY(bool error MEMBER mError READ error)
int keyInt;
bool mError;
public:
explicit ShortcutEdit(QWidget* parent = 0);
const QKeySequence getKeysequence() const;
bool error() const;
public slots:
void setErrorState(bool error);