summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
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;