summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
Diffstat (limited to 'client')
-rw-r--r--client/macrowindow.cc2
-rw-r--r--client/widgets/widget.cc34
-rw-r--r--client/widgets/widget.h1
-rw-r--r--client/widgets/window.cc9
4 files changed, 29 insertions, 17 deletions
diff --git a/client/macrowindow.cc b/client/macrowindow.cc
index 48ace4e..f924d8c 100644
--- a/client/macrowindow.cc
+++ b/client/macrowindow.cc
@@ -328,6 +328,6 @@ void MacroWindow::animated(QWidget *w)
setTabOrderRecursive(scrollarea);
// Set keyboard focus on the first focusable widget in the macro.
- mainwidget->setKeyboardFocus();
+ mainwidget->setKeyboardFocusRecursive();
}
}
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;
}