From cc3e4ba1e4c93ab2198453e04039e57387a79e60 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Tue, 29 Nov 2011 12:19:19 +0100 Subject: remove old debug code. --- client/widgets/window.cc | 7 ------- 1 file changed, 7 deletions(-) (limited to 'client/widgets') diff --git a/client/widgets/window.cc b/client/widgets/window.cc index a305171..b491d44 100644 --- a/client/widgets/window.cc +++ b/client/widgets/window.cc @@ -30,14 +30,9 @@ #include #include -//#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,8 +60,6 @@ Window::Window(QDomNode &node, MacroWindow *macrowindow) Window::~Window() { - DEBUG("~window\n"); - //delete widget; } -- cgit v1.2.3 From 45336cbecb6eff3317a365f271dc548c297f4ffa Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 1 Dec 2011 09:33:12 +0100 Subject: Fix setKeyboardFocus to work recursive on all widgets. Fixes bug where MultiList did not receive keyboard focus when it is the first child in the macro window. --- client/widgets/widget.cc | 34 +++++++++++++++++++++++++++------- client/widgets/widget.h | 1 + client/widgets/window.cc | 9 --------- 3 files changed, 28 insertions(+), 16 deletions(-) (limited to 'client/widgets') 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 b491d44..7aa6374 100644 --- a/client/widgets/window.cc +++ b/client/widgets/window.cc @@ -65,14 +65,5 @@ Window::~Window() 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; } -- cgit v1.2.3 From 728e74df239bac0f61faea062bb5a45340ee6d24 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 1 Dec 2011 10:40:27 +0100 Subject: Force focus on combobox in altcombobox in order to avoid the inner widget gaining focus even though it is hidden. --- client/widgets/altcombobox.cc | 6 ++++++ client/widgets/altcombobox.h | 2 ++ 2 files changed, 8 insertions(+) (limited to 'client/widgets') 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(); -- cgit v1.2.3 From 8dbc6ee0fbc1dd4485ec0ff1cf4a48e24b0b41a8 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 1 Dec 2011 11:26:49 +0100 Subject: Make combobox selection list popup on spacebar or mousedown. --- client/widgets/combobox.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'client/widgets') 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 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); } -- cgit v1.2.3