summaryrefslogtreecommitdiff
path: root/client/widgets/combobox.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/widgets/combobox.cc')
-rw-r--r--client/widgets/combobox.cc38
1 files changed, 30 insertions, 8 deletions
diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc
index 2818db3..c4a7f13 100644
--- a/client/widgets/combobox.cc
+++ b/client/widgets/combobox.cc
@@ -33,11 +33,24 @@
#include "common.h"
+// Enable this to make the combobox drawn in windows style.
+// This will make its background red even when not expanded.
+//#define STYLE_HACK
+
+#ifdef STYLE_HACK
+#include <QWindowsStyle>
+QWindowsStyle s;
+#endif/*STYLE_HACK*/
+
ComboBox::ComboBox(QDomNode &node, MacroWindow *macrowindow)
: QComboBox(), Widget(node, macrowindow)
{
setCommonAttributes(this, node);
+#ifdef STYLE_HACK
+ setStyle(&s);
+#endif/*STYLE_HACK*/
+
setInsertPolicy(QComboBox::InsertAlphabetically);
QDomNodeList children = node.childNodes();
@@ -70,6 +83,12 @@ ComboBox::ComboBox(QDomNode &node, MacroWindow *macrowindow)
case SELECT:
setEditable(false);
+#ifndef STYLE_HACK
+ setEditable(true);
+ lineEdit()->setReadOnly(true);
+ lineEdit()->installEventFilter(this);
+#endif/*STYLE_HACK*/
+
connect(this, SIGNAL(currentIndexChanged(QString)), this, SLOT(changed()));
break;
@@ -190,14 +209,6 @@ void ComboBox::connectTo(const QObject *sender, const char *signal,
connect(sender, signal, this, method);
}
-/*
-bool ComboBox::eventFilter(QObject *, QEvent *event)
-{
- if (event->type() == QEvent::KeyPress) emit wasChanged();
- return false;
-}
-*/
-
bool ComboBox::setKeyboardFocus()
{
setFocus();
@@ -208,3 +219,14 @@ void ComboBox::setVisibility(bool visible)
{
setVisible(visible);
}
+
+bool ComboBox::eventFilter(QObject *obj, QEvent *event)
+{
+ if(combotype == SELECT) {
+ if(event->type() == QEvent::MouseButtonRelease) {
+ showPopup();
+ }
+ }
+
+ return QObject::eventFilter(obj, event);
+}