summaryrefslogtreecommitdiff
path: root/client/mainwindow.cc
diff options
context:
space:
mode:
Diffstat (limited to 'client/mainwindow.cc')
-rw-r--r--client/mainwindow.cc81
1 files changed, 53 insertions, 28 deletions
diff --git a/client/mainwindow.cc b/client/mainwindow.cc
index 86de48a..639c9d0 100644
--- a/client/mainwindow.cc
+++ b/client/mainwindow.cc
@@ -34,15 +34,20 @@
#include <QHBoxLayout>
#include <QLabel>
#include <QPushButton>
-#include <QGroupBox>
#include <QScrollArea>
+#include <QSettings>
+#include <QStatusBar>
+
+#include "macrodrawer.h"
MainWindow::MainWindow(QString cpr, QString course, QString host, quint16 port, QString user)
- : netcom(host, port, user, cpr)
+ : QMainWindow(0, Qt::WindowContextHelpButtonHint),
+ netcom(host, port, user, cpr)
{
- resize(768, 1024);
+ setWindowTitle("Pracro - " + cpr);
- setWindowFlags(windowFlags() | Qt::WindowContextHelpButtonHint );
+ QStatusBar *status = statusBar();
+ status->addPermanentWidget(new QLabel("Pracro v.1.0.0 - test2"));
QScrollArea *s = new QScrollArea();
setCentralWidget(s);
@@ -54,14 +59,33 @@ MainWindow::MainWindow(QString cpr, QString course, QString host, quint16 port,
this->course = course;
init();
+
+ status->showMessage("Makroen blev succesfuldt indlęst.");
}
MainWindow::~MainWindow()
{
}
+void MainWindow::closeEvent(QCloseEvent *)
+{
+ QSettings settings("Aasimon.org", "Pracro");
+
+ settings.beginGroup("MainWindow");
+ settings.setValue("size", size());
+ settings.setValue("pos", pos());
+ settings.endGroup();
+}
+
void MainWindow::init()
{
+ QSettings settings("Aasimon.org", "Pracro");
+
+ settings.beginGroup("MainWindow");
+ resize(settings.value("size", QSize(700, 800)).toSize());
+ move(settings.value("pos", QPoint(0, 0)).toPoint());
+ settings.endGroup();
+
initialising = true;
update();
initialising = false;
@@ -108,31 +132,10 @@ void MainWindow::update()
if(xml_elem.attribute("static", "false") == "true") isstatic = true;
if(xml_elem.attribute("compact", "false") == "true") iscompact = true;
macros[macroname] = new MacroWindow(&netcom, macronode, course, !isstatic, iscompact);
+ macros[macroname]->isstatic = isstatic;
- QGroupBox *g = new QGroupBox();
- g->setTitle(" " + xml_elem.attribute("caption", macroname));
- g->setFlat(true);
- {
- QFont f = g->font();
- //f.setBold(true);
- f.setItalic(true);
- g->setFont(f);
- }
+ MacroDrawer *g = new MacroDrawer(macros[macroname], xml_elem.attribute("caption", macroname));
((QBoxLayout*)w->layout())->addWidget(g);
-
- if(!isstatic) {
- QPushButton *b = new QPushButton("±", g);
- b->setFixedSize(16,16);
- b->move(0,0);
- {
- QFont f = b->font();
- f.setBold(false);
- f.setItalic(false);
- b->setFont(f);
- }
-
- connect(b, SIGNAL(clicked()), macros[macroname], SLOT(toggleMacro()));
- }
QHBoxLayout *l = new QHBoxLayout();
l->setContentsMargins(10,0,10,0);
@@ -145,6 +148,7 @@ void MainWindow::update()
f.setItalic(false);
macros[macroname]->setFont(f);
}
+
} else {
macros[macroname]->update(macronode);
@@ -155,5 +159,26 @@ void MainWindow::update()
}
}
}
-}
+ // Make sure that all macros will collapse when a new one is expanded.
+ QMap< QString, MacroWindow* >::iterator i = macros.begin();
+ while(i != macros.end()) {
+ MacroWindow *m1 = i.value();
+
+ QMap< QString, MacroWindow* >::iterator j = macros.begin();
+ while(j != macros.end()) {
+ MacroWindow *m2 = j.value();
+
+ if(m1 != m2 && m2->isstatic == false) {
+ // Remove old connection (if any), to avoid multiple connections.
+ disconnect(m1, SIGNAL(expanding()), m2, SLOT(collapseWrapper()));
+
+ connect(m1, SIGNAL(expanding()), m2, SLOT(collapseWrapper()));
+ }
+
+ j++;
+ }
+
+ i++;
+ }
+}