summaryrefslogtreecommitdiff
path: root/client/widgets
diff options
context:
space:
mode:
authorsenator <elsenator@gmail.com>2011-12-01 15:58:45 +0100
committersenator <elsenator@gmail.com>2011-12-01 15:58:45 +0100
commitbf3029b893e7138593d2d185d4ce9de26491a15e (patch)
tree557cd81a1cd3f192346dca187f006f7814d8a5e3 /client/widgets
parent9989ea2f6bfa19bd349bbbdec8ec3f56c1427245 (diff)
parent5ed7a801b4194e72cc3898de57fb1d9ea0e8caa4 (diff)
Merge branch 'master' of http://git.aasimon.org/public/pracro
Diffstat (limited to 'client/widgets')
-rw-r--r--client/widgets/altcombobox.cc6
-rw-r--r--client/widgets/altcombobox.h2
-rw-r--r--client/widgets/combobox.cc13
-rw-r--r--client/widgets/widget.cc34
-rw-r--r--client/widgets/widget.h1
-rw-r--r--client/widgets/window.cc16
6 files changed, 49 insertions, 23 deletions
diff --git a/client/widgets/altcombobox.cc b/client/widgets/altcombobox.cc
index 9956fff..082601a 100644
--- a/client/widgets/altcombobox.cc
+++ b/client/widgets/altcombobox.cc
@@ -107,6 +107,12 @@ AltComboBox::~AltComboBox()
{
}
+bool AltComboBox::setKeyboardFocus()
+{
+ combobox->setFocus();
+ return true;
+}
+
QComboBox *AltComboBox::qcombobox()
{
return combobox;
diff --git a/client/widgets/altcombobox.h b/client/widgets/altcombobox.h
index e6a21d7..b0fb61c 100644
--- a/client/widgets/altcombobox.h
+++ b/client/widgets/altcombobox.h
@@ -94,6 +94,8 @@ public:
QComboBox *qcombobox();
+ bool setKeyboardFocus();
+
public slots:
void comboChanged();
void onChildChange();
diff --git a/client/widgets/combobox.cc b/client/widgets/combobox.cc
index eed2d10..935f620 100644
--- a/client/widgets/combobox.cc
+++ b/client/widgets/combobox.cc
@@ -93,6 +93,8 @@ ComboBox::ComboBox(QDomNode &node, MacroWindow *macrowindow)
// Make empty default selection.
combobox->setCurrentIndex(-1);
+ combobox->installEventFilter(this);
+
QDomElement elem = node.toElement();
combotype = SELECT;
@@ -213,15 +215,26 @@ void ComboBox::changed()
emit eventOnChange();
}
+#include <QKeyEvent>
bool ComboBox::eventFilter(QObject *obj, QEvent *event)
{
if(ignoreChangeEvents == true) return false;
+
if(combotype == SELECT) {
if(event->type() == QEvent::MouseButtonRelease) {
if(enabled()) combobox->showPopup();
}
}
+ if(event->type() == QEvent::KeyPress) {
+ QKeyEvent *ke = (QKeyEvent*)event;
+ // printf("KEY: %d\n", ke->key());
+ // if(ke->key() == Qt::Key_Up || ke->key() == Qt::Key_Down) {
+ if(ke->key() == Qt::Key_Space) {
+ if(enabled()) combobox->showPopup();
+ }
+ }
+
return QObject::eventFilter(obj, event);
}
diff --git a/client/widgets/widget.cc b/client/widgets/widget.cc
index ac90ef2..a57eb78 100644
--- a/client/widgets/widget.cc
+++ b/client/widgets/widget.cc
@@ -313,8 +313,26 @@ bool Widget::hidden()
bool Widget::setKeyboardFocus()
{
- widget->setFocus();
- return true;
+ if((widget->focusPolicy() & Qt::TabFocus) != 0) {
+ widget->setFocus();
+ return true;
+ }
+
+ return false;
+}
+
+bool Widget::setKeyboardFocusRecursive()
+{
+ if(setKeyboardFocus()) return true;
+
+ QVector< Widget* >::iterator i = children.begin();
+ while(i != children.end()) {
+ Widget *w = *i;
+ if(w && w->setKeyboardFocusRecursive()) return true;
+ i++;
+ }
+
+ return false;
}
Widget *Widget::findWidget(QString n, bool deep)
@@ -514,11 +532,13 @@ void Widget::createWidget(QDomNode &xml_node, QLayout *layout)
}
- addChild(widget);
-
- if(layout) layout->addWidget(widget->qwidget());
-
- if(widget && widget->qwidget()) widget->qwidget()->show();
+ if(widget) {
+ addChild(widget);
+ if(widget->qwidget()) {
+ if(layout) layout->addWidget(widget->qwidget());
+ widget->qwidget()->show();
+ }
+ }
}
int wdg_name(lua_State *L)
diff --git a/client/widgets/widget.h b/client/widgets/widget.h
index 4f23790..6199aa4 100644
--- a/client/widgets/widget.h
+++ b/client/widgets/widget.h
@@ -111,6 +111,7 @@ public:
virtual bool hidden();
virtual bool setKeyboardFocus();
+ bool setKeyboardFocusRecursive();
virtual void setForegroundColour(unsigned char red,
unsigned char green,
diff --git a/client/widgets/window.cc b/client/widgets/window.cc
index a305171..7aa6374 100644
--- a/client/widgets/window.cc
+++ b/client/widgets/window.cc
@@ -30,14 +30,9 @@
#include <QWidget>
#include <QIcon>
-//#define DEBUG(fmt...) printf(fmt)
-#define DEBUG(ftm...)
-
Window::Window(QDomNode &node, MacroWindow *macrowindow)
: Widget(node, macrowindow)
{
- DEBUG("window\n");
-
widget = new QWidget(NULL);
widget->setWindowFlags(Qt::WindowContextHelpButtonHint |
@@ -65,21 +60,10 @@ Window::Window(QDomNode &node, MacroWindow *macrowindow)
Window::~Window()
{
- DEBUG("~window\n");
-
//delete widget;
}
bool Window::setKeyboardFocus()
{
- QVector< Widget* >::iterator i = children.begin();
- while(i != children.end()) {
- Widget *w = *i;
- if(w) {
- if(w->setKeyboardFocus()) return true;
- }
- i++;
- }
-
return false;
}