From 33ca5716dd3bb93caf87bce65de15986dde86c63 Mon Sep 17 00:00:00 2001 From: deva Date: Fri, 11 Mar 2011 13:41:42 +0000 Subject: Huge improvements on 'keyboard-only' use. --- client/macro.cc | 8 +++++--- client/macrowindow.cc | 13 +++++++++++-- client/macrowindow.h | 8 ++++++-- client/widgets/frame.h | 2 ++ client/widgets/groupbox.h | 2 ++ client/widgets/label.h | 2 ++ client/widgets/textedit.cc | 4 ++++ client/widgets/window.h | 2 ++ 8 files changed, 34 insertions(+), 7 deletions(-) (limited to 'client') diff --git a/client/macro.cc b/client/macro.cc index ad21cc4..0dcf590 100644 --- a/client/macro.cc +++ b/client/macro.cc @@ -61,11 +61,15 @@ void Macro::update(QDomNode &node) name = elem.attribute("name"); iscompleted = elem.attribute("completed", "false") == "true"; + if(drawer == NULL) { + drawer = new MacroDrawer(this, elem.attribute("caption", name)); + if(window == NULL) { isstatic = elem.attribute("static", "false") == "true"; iscompact = elem.attribute("compact", "false") == "true"; - window = new MacroWindow(netcom, templ, isstatic, iscompact, scrollarea); + window = new MacroWindow(netcom, templ, isstatic, iscompact, + scrollarea, drawer); QFont f = window->font(); f.setBold(false); @@ -73,8 +77,6 @@ void Macro::update(QDomNode &node) window->setFont(f); } - if(drawer == NULL) { - drawer = new MacroDrawer(this, elem.attribute("caption", name)); QHBoxLayout *l = new QHBoxLayout(); l->setContentsMargins(10,0,10,0); drawer->setLayout(l); diff --git a/client/macrowindow.cc b/client/macrowindow.cc index ca76b46..d96facb 100644 --- a/client/macrowindow.cc +++ b/client/macrowindow.cc @@ -37,6 +37,7 @@ #include "widgets/window.h" #include "lua.h" #include "mainwindow.h" +#include "macrodrawer.h" #include "debug.h" @@ -47,9 +48,11 @@ extern QString user; MacroWindow::MacroWindow(NetCom &n, QString templ, bool is_static, bool compact, - QScrollArea *scrollarea) + QScrollArea *scrollarea, + MacroDrawer *d) : Collapser(NULL, compact?NULL:scrollarea), netcom(n) { + drawer = d; this->is_static = is_static; DEBUG(macrowindow, "Constructor %p\n", this); @@ -267,6 +270,7 @@ void MacroWindow::clear() if(mainwidget) { delete mainwidget; mainwidget = NULL; + drawer->setFocus(); } } @@ -283,15 +287,20 @@ void MacroWindow::animated(QWidget *w) waschanged = false; mainwidget->setValues(); + if(is_static) return; + + printf("SetFocus:\n"); // Set keyboard focus on the first focusable widget in the macro. QVector< Widget* > widgets; widgets = mainwidget->widgetList(true); QVector< Widget* >::iterator i = widgets.begin(); while(i != widgets.end()) { Widget *w = *i; + if(w) { + printf("\t%s\n", w->type().toStdString().c_str()); + } if(w && w->setKeyboardFocus()) break; i++; } - } } diff --git a/client/macrowindow.h b/client/macrowindow.h index 65fcbf1..f92b4c0 100644 --- a/client/macrowindow.h +++ b/client/macrowindow.h @@ -36,13 +36,15 @@ class LUA; class Widget; +class MacroDrawer; class MacroWindow : public Collapser { Q_OBJECT public: MacroWindow(NetCom &netcom, QString templ, - bool is_static = false, bool compact = false, - QScrollArea *scrollarea = NULL); + bool is_static, bool compact, + QScrollArea *scrollarea, + MacroDrawer *drawer); ~MacroWindow(); LUA *lua; void update(QDomNode &xml_doc); @@ -88,6 +90,8 @@ private: bool active; bool is_static; + + MacroDrawer *drawer; }; #endif/*__PRACRO_MACROWINDOW_H__*/ diff --git a/client/widgets/frame.h b/client/widgets/frame.h index fe57a0f..219ecf8 100644 --- a/client/widgets/frame.h +++ b/client/widgets/frame.h @@ -43,6 +43,8 @@ public: void setWdgValid(bool) {} + bool setKeyboardFocus() { return false; } + private: QFrame *frame; }; diff --git a/client/widgets/groupbox.h b/client/widgets/groupbox.h index bf12765..22aa644 100644 --- a/client/widgets/groupbox.h +++ b/client/widgets/groupbox.h @@ -43,6 +43,8 @@ public: void setWdgValid(bool) {} + bool setKeyboardFocus() { return false; } + private: QGroupBox *groupbox; }; diff --git a/client/widgets/label.h b/client/widgets/label.h index 529a79e..b4e352c 100644 --- a/client/widgets/label.h +++ b/client/widgets/label.h @@ -44,6 +44,8 @@ public: void setWdgValid(bool) {} + bool setKeyboardFocus() { return false; } + private: QLabel *label; }; diff --git a/client/widgets/textedit.cc b/client/widgets/textedit.cc index c597359..757a353 100644 --- a/client/widgets/textedit.cc +++ b/client/widgets/textedit.cc @@ -85,6 +85,10 @@ bool TextEdit::eventFilter(QObject *, QEvent *event) { if (event->type() == QEvent::KeyPress) { QKeyEvent *keyEvent = static_cast(event); + if(keyEvent->text() == "\t") { + event->ignore(); + return true; + } if(keyEvent->text() != "") emit wasChanged(); } return false; diff --git a/client/widgets/window.h b/client/widgets/window.h index b7098d6..2214b16 100644 --- a/client/widgets/window.h +++ b/client/widgets/window.h @@ -40,6 +40,8 @@ public: void setValue(QString, QString) {} void setWdgValid(bool) {} + + bool setKeyboardFocus() { return false; } }; #endif/*__PRACRO_WINDOW_H__*/ -- cgit v1.2.3