diff options
author | deva <deva> | 2010-05-31 09:42:07 +0000 |
---|---|---|
committer | deva <deva> | 2010-05-31 09:42:07 +0000 |
commit | 6c1a6da848075c2978116de68a43719db4c46c86 (patch) | |
tree | ab6798bf2b92964d9f4e5730ed60a014ba2e20c9 | |
parent | 0ce24ae367bb8c274663f097c65ea1abc325b08b (diff) |
Add warning on window close. Renmove discard button.
-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__*/ |