summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2011-11-08 12:46:56 +0100
committerBent Bisballe Nyeng <deva@aasimon.org>2011-11-08 12:46:56 +0100
commitaceed4cc78aaff9f62c4c6f4e6201c38e94a577f (patch)
tree27ba6237c3c2185de365ca0e9beac04a923dc6f7 /client
parent4eb60c04c87438f9e9ac5957980989fe46c39550 (diff)
Make sure top template and top (non-static) macro has keyboard focus after initialisation. Give central widget a sensible name.
Diffstat (limited to 'client')
-rw-r--r--client/mainwindow.cc30
-rw-r--r--client/mainwindow.h2
2 files changed, 25 insertions, 7 deletions
diff --git a/client/mainwindow.cc b/client/mainwindow.cc
index f415dcb..4e41418 100644
--- a/client/mainwindow.cc
+++ b/client/mainwindow.cc
@@ -78,11 +78,14 @@ MainWindow::MainWindow(QString patientid, QString title, QString course,
scrollarea = new QScrollArea();
setCentralWidget(scrollarea);
- w = new QWidget();
- scrollarea->setWidget(w);
+ central = new QWidget();
+ scrollarea->setWidget(central);
scrollarea->setWidgetResizable(true);
- w->setLayout(new QVBoxLayout());
+ scrollarea->setFocusPolicy(Qt::NoFocus);
+ central->setFocusPolicy(Qt::NoFocus);
+
+ central->setLayout(new QVBoxLayout());
connect(&netcom, SIGNAL(gotReply(QDomDocument&)),
this, SLOT(handle(QDomDocument&)));
@@ -107,6 +110,7 @@ MainWindow::MainWindow(QString patientid, QString title, QString course,
aboutButton = new QPushButton("Pracro v."VERSION, status);
aboutButton->setIcon(QIcon(":icons/icon.png"));
aboutButton->setMaximumHeight(18);
+ aboutButton->setFocusPolicy(Qt::NoFocus);
connect(aboutButton, SIGNAL(clicked()), this, SLOT(showAbout()));
status->addPermanentWidget(aboutButton);
@@ -278,7 +282,7 @@ void MainWindow::updateTemplateHeaders(QDomNode &node)
headerfont.setPointSize(headerfont.pointSize() + 4);
header->setFont(headerfont);
header->setAlignment(Qt::AlignHCenter);
- w->layout()->addWidget(header);
+ central->layout()->addWidget(header);
}
header->setText(title);
@@ -294,6 +298,8 @@ void MainWindow::showError(QString title, QString text)
void MainWindow::updateMacros(QDomNodeList &nodes)
{
+ bool creation = entities.size() == 0;
+
for(int j = 0; j < nodes.count(); j++) {
QDomNode node = nodes.at(j);
QDomElement elem = node.toElement();
@@ -311,7 +317,7 @@ void MainWindow::updateMacros(QDomNodeList &nodes)
}
entities[j] = e;
entities[j]->update(node);
- w->layout()->addWidget(e->widget());
+ central->layout()->addWidget(e->widget());
} else {
entities[j]->update(node);
}
@@ -321,7 +327,16 @@ void MainWindow::updateMacros(QDomNodeList &nodes)
showError("XML Error", "Expected macro/header tag. Got '" +
elem.tagName() + "' tag.");
continue;
+ }
+ if(creation) {
+ for(int i = 0; i < entities.size(); i++) {
+ Macro *macro = (Macro*)entities[i];
+ if(macro->isstatic == false) {
+ macro->widget()->setFocus();
+ break;
+ }
+ }
}
}
@@ -340,7 +355,7 @@ void MainWindow::updateTemplates(QDomNodeList &nodes)
this, SLOT(setTemplate(QString)));
entities[j] = e;
entities[j]->update(node);
- w->layout()->addWidget(e->widget());
+ central->layout()->addWidget(e->widget());
} else {
entities[j]->update(node);
}
@@ -350,7 +365,10 @@ void MainWindow::updateTemplates(QDomNodeList &nodes)
showError("XML Error", "Expected template tag. Got '" +
elem.tagName() + "' tag.");
continue;
+ }
+ if(entities.size() > 0) {
+ entities[0]->widget()->setFocus();
}
}
diff --git a/client/mainwindow.h b/client/mainwindow.h
index 84151ad..ad96154 100644
--- a/client/mainwindow.h
+++ b/client/mainwindow.h
@@ -77,7 +77,7 @@ private:
QString patientid;
QString user;
- QWidget *w;
+ QWidget *central;
Entities entities;