diff options
author | senator <elsenator@gmail.com> | 2011-12-01 15:58:45 +0100 |
---|---|---|
committer | senator <elsenator@gmail.com> | 2011-12-01 15:58:45 +0100 |
commit | bf3029b893e7138593d2d185d4ce9de26491a15e (patch) | |
tree | 557cd81a1cd3f192346dca187f006f7814d8a5e3 /client | |
parent | 9989ea2f6bfa19bd349bbbdec8ec3f56c1427245 (diff) | |
parent | 5ed7a801b4194e72cc3898de57fb1d9ea0e8caa4 (diff) |
Merge branch 'master' of http://git.aasimon.org/public/pracro
Diffstat (limited to 'client')
-rw-r--r-- | client/collapser.cc | 14 | ||||
-rw-r--r-- | client/macrowindow.cc | 41 | ||||
-rw-r--r-- | client/macrowindow.h | 1 | ||||
-rw-r--r-- | client/mainwindow.cc | 3 | ||||
-rw-r--r-- | client/pcpviewer/pcpviewer.cc | 3 | ||||
-rw-r--r-- | client/pracro_dk.ts | 83 | ||||
-rw-r--r-- | client/widgets/altcombobox.cc | 6 | ||||
-rw-r--r-- | client/widgets/altcombobox.h | 2 | ||||
-rw-r--r-- | client/widgets/combobox.cc | 13 | ||||
-rw-r--r-- | client/widgets/widget.cc | 34 | ||||
-rw-r--r-- | client/widgets/widget.h | 1 | ||||
-rw-r--r-- | client/widgets/window.cc | 16 |
12 files changed, 166 insertions, 51 deletions
diff --git a/client/collapser.cc b/client/collapser.cc index 599397f..abbe295 100644 --- a/client/collapser.cc +++ b/client/collapser.cc @@ -32,8 +32,8 @@ #include "debug.h" -#define ANIM_TIME 300 // ms -#define ANIM_INTERVAL 5 // ms +#define ANIM_TIME 200 // ms +#define ANIM_INTERVAL 50 // ms Collapser::Collapser(QWidget *current, QScrollArea *scroll) { @@ -110,8 +110,14 @@ void Collapser::anim() placeholder.setWeight(x); - int height = (int)((1 - y) * placeholder.fromHeight() + - y * placeholder.toHeight()); + // Make sure we don't 'bounce' around when animating to the same height. + int height; + if(placeholder.fromHeight() == placeholder.toHeight()) { + height = placeholder.toHeight(); + } else { + height = (int)((1 - y) * placeholder.fromHeight() + + y * placeholder.toHeight()); + } setFixedHeight(height); diff --git a/client/macrowindow.cc b/client/macrowindow.cc index 44f2797..f924d8c 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; @@ -189,11 +190,13 @@ bool MacroWindow::doCommit() void MacroWindow::commit() { doCommit(); + drawer->setFocus(); } void MacroWindow::cancel() { collapseWrapper(); + drawer->setFocus(); } void MacroWindow::expandWrapper() @@ -271,9 +274,39 @@ void MacroWindow::clear() lua->clear(); if(mainwidget) { - delete mainwidget; - mainwidget = NULL; drawer->setFocus(); + mainwidget->deleteLater(); + mainwidget = NULL; + } +} + +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; + } } } @@ -292,7 +325,9 @@ void MacroWindow::animated(QWidget *w) if(is_static) return; + setTabOrderRecursive(scrollarea); + // Set keyboard focus on the first focusable widget in the macro. - mainwidget->setKeyboardFocus(); + mainwidget->setKeyboardFocusRecursive(); } } 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__*/ diff --git a/client/mainwindow.cc b/client/mainwindow.cc index 121412e..4cb721f 100644 --- a/client/mainwindow.cc +++ b/client/mainwindow.cc @@ -337,6 +337,9 @@ void MainWindow::updateMacros(QDomNodeList &nodes) break; } } + + QVBoxLayout *l = (QVBoxLayout*)central->layout(); + l->addStretch(1); } } diff --git a/client/pcpviewer/pcpviewer.cc b/client/pcpviewer/pcpviewer.cc index 5853e0a..ea59edb 100644 --- a/client/pcpviewer/pcpviewer.cc +++ b/client/pcpviewer/pcpviewer.cc @@ -42,6 +42,9 @@ PCPViewer::PCPViewer(QString patientid) : praxisd("sarge", 10000) { + setWindowTitle(tr("Pracro Patient View")); + setWindowIcon(QIcon(":/icons/icon.png")); + this->patientid = patientid; setLayout(new QVBoxLayout()); diff --git a/client/pracro_dk.ts b/client/pracro_dk.ts index 9c7fd40..72cda12 100644 --- a/client/pracro_dk.ts +++ b/client/pracro_dk.ts @@ -2,6 +2,19 @@ <!DOCTYPE TS> <TS version="2.0" language="da_DK"> <context> + <name>AboutBox</name> + <message> + <location filename="aboutbox.cc" line="40"/> + <source>About Pracro</source> + <translation>Om Pracro</translation> + </message> + <message> + <location filename="aboutbox.cc" line="72"/> + <source><h1>Pracro Client</h1><h2>v.</source> + <translation><h1>Pracro Klient</h1><h2>v.</translation> + </message> +</context> +<context> <name>DBWidget</name> <message> <source>Write something in the searchfield</source> @@ -53,43 +66,43 @@ et CPR nummer på 10 cifre.</translation> <context> <name>MacroWindow</name> <message> - <location filename="macrowindow.cc" line="177"/> + <location filename="macrowindow.cc" line="181"/> <source>Error</source> <translation>Der er sket en fejl</translation> </message> <message> - <location filename="macrowindow.cc" line="178"/> + <location filename="macrowindow.cc" line="182"/> <source>The macro </source> <translation>Makroen </translation> </message> <message> - <location filename="macrowindow.cc" line="179"/> + <location filename="macrowindow.cc" line="183"/> <source> was not filled out correctly, please try again. </source> <translation> er ikke.udfyldt korrekt. Prøv igen.</translation> </message> <message> - <location filename="macrowindow.cc" line="213"/> + <location filename="macrowindow.cc" line="219"/> <source>Save the macro changes?</source> <translation>Gem makro ændringer?</translation> </message> <message> - <location filename="macrowindow.cc" line="214"/> + <location filename="macrowindow.cc" line="220"/> <source>you have choosen to close the macro </source> <translation>Du har valgt at lukke makroen </translation> </message> <message> - <location filename="macrowindow.cc" line="216"/> + <location filename="macrowindow.cc" line="222"/> <source>do you want to save before closing?</source> <translation>ønsker du at gemme dine ændringer først?</translation> </message> <message> - <location filename="macrowindow.cc" line="241"/> + <location filename="macrowindow.cc" line="247"/> <source>Close first</source> <translation>Luk først</translation> </message> <message> - <location filename="macrowindow.cc" line="242"/> + <location filename="macrowindow.cc" line="248"/> <source>Close other one first.</source> <translation>Luk den åbne makro først.</translation> </message> @@ -97,26 +110,26 @@ et CPR nummer på 10 cifre.</translation> <context> <name>MainWindow</name> <message> - <location filename="mainwindow.cc" line="112"/> + <location filename="mainwindow.cc" line="124"/> <source>Close and commit</source> <translation>Gem i journal</translation> </message> <message> - <location filename="mainwindow.cc" line="115"/> + <location filename="mainwindow.cc" line="127"/> <source>Close no commit</source> <translation>Gem som kladde</translation> </message> <message> - <location filename="mainwindow.cc" line="150"/> - <location filename="mainwindow.cc" line="162"/> - <location filename="mainwindow.cc" line="174"/> + <location filename="mainwindow.cc" line="168"/> + <location filename="mainwindow.cc" line="180"/> + <location filename="mainwindow.cc" line="192"/> <source>Close first.</source> <translation>Luk først.</translation> </message> <message> - <location filename="mainwindow.cc" line="151"/> - <location filename="mainwindow.cc" line="163"/> - <location filename="mainwindow.cc" line="175"/> + <location filename="mainwindow.cc" line="169"/> + <location filename="mainwindow.cc" line="181"/> + <location filename="mainwindow.cc" line="193"/> <source>Close open macros first.</source> <translation>Luk åbne makroer først.</translation> </message> @@ -133,14 +146,14 @@ et CPR nummer på 10 cifre.</translation> <translation type="obsolete">Denne session bliver husket på denne specifikke maskine. For at genåbne på et senere tidspunkt, skal du blot genåbne på samme patient.</translation> </message> <message> - <location filename="mainwindow.cc" line="181"/> - <location filename="mainwindow.cc" line="203"/> + <location filename="mainwindow.cc" line="199"/> + <location filename="mainwindow.cc" line="221"/> <source>Discard</source> <translation>Kassér</translation> </message> <message> - <location filename="mainwindow.cc" line="182"/> - <location filename="mainwindow.cc" line="204"/> + <location filename="mainwindow.cc" line="200"/> + <location filename="mainwindow.cc" line="222"/> <source>This session will <strong>NOT</strong> be stored in the journal.<br/>Are you sure you want to continue?</source> <translation>Dette vil slette alle indtastede data. Denne session vil <strong>IKKE</strong> blive gemt i journalen hvis du fortsætter. Fortsætter du kan dataene <strong>IKKE</strong> gendannes.<br/>Er du sikker på du vil fortsætte?</translation> </message> @@ -158,6 +171,26 @@ et CPR nummer på 10 cifre.</translation> <oldsource>Remove form list</oldsource> <translation>Fjern fra listen</translation> </message> + <message> + <location filename="widgets/multilist.cc" line="133"/> + <source>Inner widget changed.</source> + <translation>Indre widget er ændret.</translation> + </message> + <message> + <location filename="widgets/multilist.cc" line="134"/> + <source>The inner widget changed, and you didn't add it to the list. +Do you want to continue and discard the change?</source> + <translation>Den indre widget har ændret sig men er ikke tilføjet til listen. +Vil du fortsætte og smide ændringerne væk?</translation> + </message> +</context> +<context> + <name>PCPViewer</name> + <message> + <location filename="pcpviewer/pcpviewer.cc" line="45"/> + <source>Pracro Patient View</source> + <translation>Pracro Patient Visning</translation> + </message> </context> <context> <name>QObject</name> @@ -252,9 +285,17 @@ et CPR nummer på 10 cifre.</translation> <translation>Ignorér</translation> </message> <message> - <location filename="macro.cc" line="121"/> + <location filename="macro.cc" line="122"/> <source>Depends on: </source> <translation>Afhænger af: </translation> </message> </context> +<context> + <name>Template</name> + <message> + <location filename="template.cc" line="54"/> + <source>Open</source> + <translation>Åbn</translation> + </message> +</context> </TS> 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; } |