diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/mainwindow.cc | 38 | ||||
-rw-r--r-- | client/mainwindow.h | 2 |
2 files changed, 28 insertions, 12 deletions
diff --git a/client/mainwindow.cc b/client/mainwindow.cc index 9634f24..3d49752 100644 --- a/client/mainwindow.cc +++ b/client/mainwindow.cc @@ -48,6 +48,8 @@ MainWindow::MainWindow(QString cpr, QString templ, QString host, : QMainWindow(0, Qt::WindowContextHelpButtonHint), netcom(host, port) { + isStored = false; + header = NULL; this->cpr = cpr; @@ -65,10 +67,11 @@ MainWindow::MainWindow(QString cpr, QString templ, QString host, QAction *close_no_commit = toolbar->addAction("Close no commit"); close_no_commit->setIcon(QPixmap(":icons/icon_close_no_commit.png")); - + /* QAction *close_discard = toolbar->addAction("Close discard"); close_discard->setIcon(QPixmap(":icons/icon_discard.png")); - + connect(close_discard, SIGNAL(triggered()), this, SLOT(closeDiscard())); + */ toolbar->addSeparator(); QAction *show_sessions = toolbar->addAction("Show sessions"); @@ -76,7 +79,6 @@ MainWindow::MainWindow(QString cpr, QString templ, QString host, connect(close_commit, SIGNAL(triggered()), this, SLOT(closeCommit())); connect(close_no_commit, SIGNAL(triggered()), this, SLOT(closeNoCommit())); - connect(close_discard, SIGNAL(triggered()), this, SLOT(closeDiscard())); connect(show_sessions, SIGNAL(triggered()), this, SLOT(showSessions())); QScrollArea *s = new QScrollArea(); @@ -105,6 +107,7 @@ void MainWindow::closeCommit() { netcom.commit(); sessions.remove(cpr); + isStored = true; close(); } @@ -115,6 +118,7 @@ void MainWindow::closeNoCommit() "This session will be stored on this computer only." " To reopen it at a later time, simply open the same patient again."); sessions.add(cpr, user, netcom.sessionid); + isStored = true; close(); } @@ -124,10 +128,11 @@ void MainWindow::closeDiscard() "Discard", "This session will <strong>NOT</strong> be stored in the journal.<br/>" "Are you sure you want to continue?", - QMessageBox::Yes | QMessageBox::Abort) + QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) { netcom.discard(); sessions.remove(cpr); + isStored = true; close(); } } @@ -137,17 +142,26 @@ void MainWindow::showSessions() sessions.show(); } -void MainWindow::closeEvent(QCloseEvent *) +void MainWindow::closeEvent(QCloseEvent *event) { - QSettings settings("Aasimon.org", "Pracro"); + if(isStored || QMessageBox::question(this, + "Discard", + "This session will <strong>NOT</strong> be stored in the journal.<br/>" + "Are you sure you want to continue?", + QMessageBox::Yes | QMessageBox::No) + == QMessageBox::Yes) { + QSettings settings("Aasimon.org", "Pracro"); - settings.beginGroup("MainWindow"); - settings.setValue("size", size()); - settings.setValue("pos", pos()); - settings.setValue(QString("sessions"), sessions.toVariant()); - settings.endGroup(); + settings.beginGroup("MainWindow"); + settings.setValue("size", size()); + settings.setValue("pos", pos()); + settings.setValue(QString("sessions"), sessions.toVariant()); + settings.endGroup(); - QApplication::quit(); + event->accept(); + } else { + event->ignore(); + } } void MainWindow::init() diff --git a/client/mainwindow.h b/client/mainwindow.h index 68a0673..afc9d08 100644 --- a/client/mainwindow.h +++ b/client/mainwindow.h @@ -74,6 +74,8 @@ private: Sessions sessions; void init(); + + bool isStored; }; #endif/*__PRACRO_MAINWINDOW_H__*/ |