summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authordeva <deva>2010-04-29 12:26:01 +0000
committerdeva <deva>2010-04-29 12:26:01 +0000
commit0d76adfb6dce6dec1367913752f7b0a818e1bc21 (patch)
treedb67eab193681dea72df4a14bbdac39b67fcf106 /client
parentc96a2e557f0a9322c9369a06041e894cc2f11e93 (diff)
Backported some widget behaviour from head.
Diffstat (limited to 'client')
-rw-r--r--client/widgets/combobox.cc26
-rw-r--r--client/widgets/combobox.h2
-rw-r--r--client/widgets/lineedit.cc43
-rw-r--r--client/widgets/lineedit.h6
-rw-r--r--client/widgets/radiobuttons.cc7
-rw-r--r--client/widgets/radiobuttons.h3
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;