qscan345mainwindow.cpp

Go to the documentation of this file.
00001 #include "qscan345mainwindow.h"
00002 #include "qscan345controller.h"
00003 #include "qscan345settings.h"
00004 #include "qscan345application.h"
00005 
00006 #include <QCloseEvent>
00007 #include <QInputDialog>
00008 
00009 QScan345MainWindow::QScan345MainWindow(QScan345Application *app, QWidget *parent)
00010   : QMainWindow(parent),
00011     m_Application(app),
00012     m_ScanController(NULL)
00013 {
00014   setupUi(this);
00015 
00016   connect(actionQuit,    SIGNAL(triggered()),
00017           m_Application, SLOT(possiblyQuit()));
00018 
00019   connect(actionPreferences, SIGNAL(triggered()), this, SLOT(preferences()));
00020 }
00021 
00022 void
00023 QScan345MainWindow::preferences()
00024 {
00025   QScan345Settings s;
00026   bool ok;
00027   int nm = s.marscannernumber();
00028 
00029   nm = QInputDialog::getInteger(this, "Scanner Number", 
00030                                 "New Scanner Number:", nm, 0, 10000, 1, &ok);
00031 
00032   if (ok) {
00033     s.setMarscannernumber(nm);
00034 
00035     emit scanner_changed();
00036   }
00037 }
00038 
00039 void
00040 QScan345MainWindow::display_message(QString msg)
00041 {
00042   textEdit->append(msg.trimmed());
00043 }
00044 
00045 void
00046 QScan345MainWindow::display_spy_message(QString msg)
00047 {
00048   spyTextEdit->append(msg.trimmed());
00049 }
00050 
00051 void
00052 QScan345MainWindow::setScanController(QScan345Controller *ctrl)
00053 {
00054   m_ScanController = ctrl;
00055 }
00056 
00057 void 
00058 QScan345MainWindow::restoreStateRequest()
00059 {
00060   QScan345Settings settings;
00061 
00062   restoreGeometry(settings.windowGeometry("main"));
00063   restoreState(settings.windowState("main"), 1);
00064 }
00065 
00066 void 
00067 QScan345MainWindow::saveStateRequest(QSessionManager&)
00068 {
00069   saveStateRequest();
00070 }
00071 
00072 void
00073 QScan345MainWindow::saveStateRequest()
00074 {
00075   QByteArray savedGeometry = saveGeometry();
00076   QByteArray savedState = saveState(1);
00077   QScan345Settings settings;
00078 
00079   settings.setWindowGeometry("main",savedGeometry);
00080   settings.setWindowState("main",savedState);
00081 }
00082 
00083 void 
00084 QScan345MainWindow::closeEvent(QCloseEvent *ev)
00085 {
00086   if (m_Application -> wantToQuit()) {
00087     ev -> accept();
00088     m_Application -> quit();
00089   } else {
00090     ev -> ignore();
00091   }
00092 }
00093 
00094 void
00095 QScan345MainWindow::update_scanner_menu()
00096 {
00097   if (m_ScanController) {
00098     m_ScanController->updateScannerMenu();
00099   }
00100 }