]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Handle Alt+F4 as regular exit action. Do not exit on exit->save->cancel. Fixes #43
authorsbh <sergey.belash@opencascade.com>
Fri, 23 May 2014 05:03:04 +0000 (09:03 +0400)
committersbh <sergey.belash@opencascade.com>
Fri, 23 May 2014 05:03:04 +0000 (09:03 +0400)
src/XGUI/XGUI_MainWindow.cpp
src/XGUI/XGUI_MainWindow.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 4b8c9e0918f1ff863213d116d277b848b610dc39..1400fc0ccc7f4c502b092cbdae6bc5b93cd4532b 100644 (file)
@@ -14,6 +14,7 @@
 #include <QDockWidget>
 #include <QApplication>
 #include <QTimer>
+#include <QCloseEvent>
 
 XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
     : QMainWindow(parent), 
@@ -197,4 +198,10 @@ void XGUI_MainWindow::onViewActivated(QMdiSubWindow* theSubWnd)
     if (aAct->isCheckable())
       aAct->setChecked(aAct->text() == aWndTitle);
   }
-}
\ No newline at end of file
+}
+
+void XGUI_MainWindow::closeEvent(QCloseEvent * event)
+{
+  emit exitKeySequence();
+  event->ignore();
+}
index 9b29ec3ea17d48f77809ee283684e1e94e2b1b76..010f9e309530b3cb12289015b259a85908bfdcee 100644 (file)
@@ -11,6 +11,7 @@ class XGUI_ViewWindow;
 class QMdiArea;
 class QMdiSubWindow;
 class PyConsole_EnhConsole;
+class QCloseEvent;
 
 /**\class XGUI_MainWindow
  * \ingroup GUI
@@ -53,6 +54,12 @@ private slots:
   void activateView();
   void onViewActivated(QMdiSubWindow* theSubWnd);
 
+signals:
+  void exitKeySequence();
+
+protected:
+  void closeEvent(QCloseEvent* event);
+
 private:
   XGUI_MainMenu* myMenuBar;
   XGUI_Viewer* myViewer;
index 14a965db7f92ae0ccff88e2b03b1b78af24f903e..08713ee470cea09fcef4cb02b30affea929cbd07 100644 (file)
@@ -95,6 +95,7 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   connect(myOperationMgr, SIGNAL(operationStarted()), SLOT(onOperationStarted()));
   connect(myOperationMgr, SIGNAL(operationResumed()), SLOT(onOperationStarted()));
   connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), SLOT(onOperationStopped(ModuleBase_Operation*)));
+  connect(myMainWindow, SIGNAL(exitKeySequence()), SLOT(onExit()));
   connect(myOperationMgr, SIGNAL(operationStarted()), myActionsMgr, SLOT(update()));
   connect(myOperationMgr, SIGNAL(operationStopped()), myActionsMgr, SLOT(update()));
   connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
@@ -411,7 +412,10 @@ void XGUI_Workshop::onExit()
         tr("The document is modified, save before exit?"),
         QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Cancel);
     if(anAnswer == QMessageBox::Save) {
-      onSave();
+      bool saved = onSave();
+      if(!saved) {
+        return;
+      }
     } else if (anAnswer == QMessageBox::Cancel) {
       return;
     }
@@ -476,18 +480,18 @@ void XGUI_Workshop::onOpen()
 }
 
 //******************************************************
-void XGUI_Workshop::onSave()
+bool XGUI_Workshop::onSave()
 {
   if(myCurrentDir.isEmpty()) {
-    onSaveAs();
-    return;
+    return onSaveAs();
   }
   saveDocument(myCurrentDir);
   updateCommandStatus();
+  return true;
 }
 
 //******************************************************
-void XGUI_Workshop::onSaveAs()
+bool XGUI_Workshop::onSaveAs()
 {
   QFileDialog dialog(mainWindow());
   dialog.setWindowTitle(tr("Select directory to save files..."));
@@ -497,7 +501,7 @@ void XGUI_Workshop::onSaveAs()
   dialog.setViewMode(QFileDialog::Detail);
 
   if(!dialog.exec()) {
-    return;
+    return false;
   }
   QString aTempDir = dialog.selectedFiles().first();
   QDir aDir(aTempDir);
@@ -506,11 +510,12 @@ void XGUI_Workshop::onSaveAs()
                                        QString(),
                                        tr("The folder already contains some files, save anyway?"),
                                        QMessageBox::Save|QMessageBox::Cancel);
-    if(answer == QMessageBox::Cancel)
-      return;
+    if(answer == QMessageBox::Cancel) {
+      return false;
+    }
   }
   myCurrentDir = aTempDir;
-  onSave();
+  return onSave();
 }
 
 //******************************************************
index 8ffb703b82a02815e36e2deeae0e7f1a46cecec6..42d893f1d116e3de7486a1d05be0d93545902d40 100644 (file)
@@ -113,8 +113,8 @@ public slots:
 
   void onNew();
   void onOpen();
-  void onSave();
-  void onSaveAs();
+  bool onSave();
+  bool onSaveAs();
   void onExit();
   void onUndo();
   void onRedo();