diff options
-rw-r--r-- | client/widgets/combobox.cc | 26 | ||||
-rw-r--r-- | client/widgets/combobox.h | 2 | ||||
-rw-r--r-- | client/widgets/lineedit.cc | 43 | ||||
-rw-r--r-- | client/widgets/lineedit.h | 6 | ||||
-rw-r--r-- | client/widgets/radiobuttons.cc | 7 | ||||
-rw-r--r-- | client/widgets/radiobuttons.h | 3 |
6 files changed, 76 insertions, 11 deletions
diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc index bf25475..f81d989 100644 --- a/client/widgets/combobox.cc +++ b/client/widgets/combobox.cc @@ -30,6 +30,7 @@ #include <QRegExpValidator> #include <QRegExp> #include <QLineEdit> +#include <QCoreApplication> #include "common.h" @@ -170,12 +171,17 @@ void ComboBox::changed() QPalette palette; - if(isValid() && luaValidator()) { + if(isEnabled()) { + if(isValid() && luaValidator()) { + // valid string + palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255))); + } else { + // invalid string + palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200))); + } + } else { // valid string palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255))); - } else { - // invalid string - palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200))); } if(lineEdit()) lineEdit()->setPalette(palette); @@ -230,3 +236,15 @@ bool ComboBox::eventFilter(QObject *obj, QEvent *event) return QObject::eventFilter(obj, event); } + +void ComboBox::wheelEvent(QWheelEvent *e) +{ + QCoreApplication::sendEvent(nativeParentWidget(), e); +} + +void ComboBox::changeEvent(QEvent *event) +{ + if(event->type() == QEvent::EnabledChange) { + changed(); + } +} diff --git a/client/widgets/combobox.h b/client/widgets/combobox.h index af48ba5..8059e81 100644 --- a/client/widgets/combobox.h +++ b/client/widgets/combobox.h @@ -70,6 +70,8 @@ signals: protected: bool eventFilter(QObject *obj, QEvent *event); + void wheelEvent(QWheelEvent *); + void changeEvent(QEvent *event); private: QRegExp rx; diff --git a/client/widgets/lineedit.cc b/client/widgets/lineedit.cc index 49b3704..c3a799a 100644 --- a/client/widgets/lineedit.cc +++ b/client/widgets/lineedit.cc @@ -48,23 +48,30 @@ LineEdit::LineEdit(QDomNode &node, MacroWindow *macrowindow) connect(this, SIGNAL(textChanged(QString)), this, SLOT(changed())); connect(this, SIGNAL(textEdited(QString)), this, SLOT(user_changed())); + + installEventFilter(this); // Detect keyboard input. } void LineEdit::changed() { QPalette palette; - if(regexpValidator()) { - if(luaValidator()) { - // valid string - palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255))); + if(isEnabled()) { + if(regexpValidator()) { + if(luaValidator()) { + // valid string + palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255))); + } else { + // invalid string + palette.setBrush(QPalette::Base, QBrush(QColor(200, 230, 200))); + } } else { // invalid string - palette.setBrush(QPalette::Base, QBrush(QColor(200, 230, 200))); + palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200))); } } else { - // invalid string - palette.setBrush(QPalette::Base, QBrush(QColor(230, 200, 200))); + // valid string + palette.setBrush(QPalette::Base, QBrush(QColor(255, 255, 255))); } setPalette(palette); @@ -127,3 +134,25 @@ void LineEdit::setVisibility(bool visible) { setVisible(visible); } + + +#include <QCoreApplication> +bool LineEdit::eventFilter(QObject *, QEvent *event) +{ + if (event->type() == QEvent::KeyPress) { + QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event); + if(keyEvent->key() == Qt::Key_Return || + keyEvent->key() == Qt::Key_Enter) { + QKeyEvent tabevent(QEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier); + QCoreApplication::sendEvent(this, &tabevent); + } + } + return false; +} + +void LineEdit::changeEvent(QEvent *event) +{ + if(event->type() == QEvent::EnabledChange) { + changed(); + } +} diff --git a/client/widgets/lineedit.h b/client/widgets/lineedit.h index 5af912f..556e52c 100644 --- a/client/widgets/lineedit.h +++ b/client/widgets/lineedit.h @@ -60,6 +60,12 @@ public slots: signals: void wasChanged(); + +protected: + void changeEvent(QEvent *event); + +private: + bool eventFilter(QObject *, QEvent *event); }; #endif/*__PRACRO_LINEEDIT_H__*/ diff --git a/client/widgets/radiobuttons.cc b/client/widgets/radiobuttons.cc index d11c3e5..e4555ff 100644 --- a/client/widgets/radiobuttons.cc +++ b/client/widgets/radiobuttons.cc @@ -183,3 +183,10 @@ bool RadioButtons::isDisabled() { return isEnabled() == false; } + +void RadioButtons::changeEvent(QEvent *event) +{ + if(event->type() == QEvent::EnabledChange) { + setBGColor(isValid() || !isEnabled()); + } +} diff --git a/client/widgets/radiobuttons.h b/client/widgets/radiobuttons.h index a32147b..9b165c9 100644 --- a/client/widgets/radiobuttons.h +++ b/client/widgets/radiobuttons.h @@ -63,6 +63,9 @@ public slots: signals: void wasChanged(); +protected: + void changeEvent(QEvent *event); + private: QVector < RadioButton* > radiobutton_list; |