From 5d5595b9e1c1c22f7033a262b8174a5f3d05adc8 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Thu, 1 Dec 2011 09:11:17 +0100 Subject: Reorganise TabOrder according to child nesting order. --- client/macrowindow.cc | 33 +++++++++++++++++++++++++++++++++ client/macrowindow.h | 1 + 2 files changed, 34 insertions(+) diff --git a/client/macrowindow.cc b/client/macrowindow.cc index 2e0f52a..48ace4e 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -52,6 +52,7 @@ MacroWindow::MacroWindow(NetCom &n, QString course, QString templ, MacroDrawer *d) : Collapser(NULL, is_static?NULL:scrollarea), netcom(n) { + this->scrollarea = scrollarea; drawer = d; this->is_static = is_static; @@ -279,6 +280,36 @@ void MacroWindow::clear() } } +QWidgetList getRecursiveWidgetList(QWidget *w) +{ + QWidgetList list; + + list.append(w); + + QObjectList objs = w->children(); + for(int i = 0; i < objs.size(); i++) { + if(objs[i]->isWidgetType()) { + QWidget *cw = (QWidget*)objs[i]; + list.append(getRecursiveWidgetList(cw)); + } + } + + return list; +} + +void setTabOrderRecursive(QWidget *w) +{ + QWidgetList list = getRecursiveWidgetList(w); + QWidget *last = NULL; + for(int i = 0; i < list.size(); i++) { + QWidget *w = list[i]; + if((w->focusPolicy() & Qt::TabFocus) != 0) { + if(last) QWidget::setTabOrder(last, w); + last = w; + } + } +} + void MacroWindow::animated(QWidget *w) { if(w == resumewidget) { @@ -294,6 +325,8 @@ void MacroWindow::animated(QWidget *w) if(is_static) return; + setTabOrderRecursive(scrollarea); + // Set keyboard focus on the first focusable widget in the macro. mainwidget->setKeyboardFocus(); } diff --git a/client/macrowindow.h b/client/macrowindow.h index afc144d..65a0d87 100644 --- a/client/macrowindow.h +++ b/client/macrowindow.h @@ -94,6 +94,7 @@ private: bool is_static; MacroDrawer *drawer; + QWidget *scrollarea; }; #endif/*__PRACRO_MACROWINDOW_H__*/ -- cgit v1.2.3