예제 #1
0
파일: presenter.py 프로젝트: ethoeng/mantid
 def save_on_closing(self):
     # make sure the Last Version is updated on closing
     settings = QSettings()
     settings.beginGroup(self.DO_NOT_SHOW_GROUP)
     settings.setValue(self.LAST_VERSION, release_notes_url())
     settings.endGroup()
     self.store_facility(self.view.cb_facility.currentText())
     self.action_instrument_changed(self.view.cb_instrument.currentText())
     ConfigService.saveConfig(ConfigService.getUserFilename())
     self.parent.config_updated()
예제 #2
0
    def action_close(self):
        # make sure the Last Version is updated on closing
        settings = QSettings()
        settings.beginGroup(self.DO_NOT_SHOW_GROUP)
        settings.setValue(self.LAST_VERSION, release_notes_url())
        settings.endGroup()

        ConfigService.saveConfig(ConfigService.getUserFilename())
        self.parent.config_updated()
        self.view.close()
예제 #3
0
 def save_on_closing(self):
     # make sure the Last Version is updated on closing
     settings = QSettings()
     settings.beginGroup(self.DO_NOT_SHOW_GROUP)
     settings.setValue(self.PREVIOUS_VERSION,
                       version().major + "." + version().minor)
     settings.endGroup()
     self.store_facility(self.view.about_widget.cb_facility.currentText())
     self.action_instrument_changed(
         self.view.about_widget.cb_instrument.currentText())
     ConfigService.saveConfig(ConfigService.getUserFilename())
     self.parent.config_updated()
예제 #4
0
    def closeEvent(self, event):
        if self.project is not None:
            if self.project.is_saving or self.project.is_loading:
                event.ignore()
                self.project.inform_user_not_possible()
                return

            # Check whether or not to save project
            if not self.project.saved:
                # Offer save
                if self.project.offer_save(self):
                    # Cancel has been clicked
                    event.ignore()
                    return

        # Close editors
        if self.editor is None or self.editor.app_closing():
            # write out any changes to the mantid config file
            ConfigService.saveConfig(ConfigService.getUserFilename())
            # write current window information to global settings object
            self.writeSettings(CONF)
            # Close all open plots
            # We don't want this at module scope here
            import matplotlib.pyplot as plt  # noqa
            plt.close('all')

            app = QApplication.instance()
            if app is not None:
                app.closeAllWindows()

            # Kill the project recovery thread and don't restart should a save be in progress and clear out current
            # recovery checkpoint as it is closing properly
            if self.project_recovery is not None:
                self.project_recovery.stop_recovery_thread()
                self.project_recovery.closing_workbench = True
                self.project_recovery.remove_current_pid_folder()

            # Cancel memory widget thread
            if self.memorywidget is not None:
                self.memorywidget.presenter.cancel_memory_update()

            if self.interface_manager is not None:
                self.interface_manager.closeHelpWindow()

            if self.workspacecalculator is not None:
                self.workspacecalculator.view.closeEvent(event)

            event.accept()
        else:
            # Cancel was pressed when closing an editor
            event.ignore()
예제 #5
0
    def closeEvent(self, event):
        # Check whether or not to save project
        if not self.project.saved:
            # Offer save
            if self.project.offer_save(self):
                # Cancel has been clicked
                event.ignore()
                return

        # Close editors
        if self.editor.app_closing():
            # write out any changes to the mantid config file
            ConfigService.saveConfig(ConfigService.getUserFilename())
            # write current window information to global settings object
            self.writeSettings(CONF)
            # Close all open plots
            # We don't want this at module scope here
            import matplotlib.pyplot as plt  # noqa
            plt.close('all')

            app = QApplication.instance()
            if app is not None:
                app.closeAllWindows()

            # Kill the project recovery thread and don't restart should a save be in progress and clear out current
            # recovery checkpoint as it is closing properly
            self.project_recovery.stop_recovery_thread()
            self.project_recovery.closing_workbench = True
            self.project_recovery.remove_current_pid_folder()

            self.interface_manager.closeHelpWindow()

            event.accept()
        else:
            # Cancel was pressed when closing an editor
            event.ignore()
예제 #6
0
    def closeEvent(self, event):
        if self.project is not None:
            if self.project.is_saving or self.project.is_loading:
                event.ignore()
                self.project.inform_user_not_possible()
                return

            # Check whether or not to save project
            if not self.project.saved:
                # Offer save
                if self.project.offer_save(self):
                    # Cancel has been clicked
                    event.ignore()
                    return

        # Close editors
        if self.editor is None or self.editor.app_closing():
            # write out any changes to the mantid config file
            ConfigService.saveConfig(ConfigService.getUserFilename())
            # write current window information to global settings object
            self.writeSettings(CONF)
            # Close all open plots
            # We don't want this at module scope here
            import matplotlib.pyplot as plt  # noqa
            plt.close('all')

            # Cancel all running (managed) algorithms
            AlgorithmManager.Instance().cancelAll()

            app = QApplication.instance()
            if app is not None:
                app.closeAllWindows()

            # Kill the project recovery thread and don't restart should a save be in progress and clear out current
            # recovery checkpoint as it is closing properly
            if self.project_recovery is not None:
                self.project_recovery.stop_recovery_thread()
                self.project_recovery.closing_workbench = True

            # Cancel memory widget thread
            if self.memorywidget is not None:
                self.memorywidget.presenter.cancel_memory_update()

            if self.interface_manager is not None:
                self.interface_manager.closeHelpWindow()

            if self.workspacecalculator is not None:
                self.workspacecalculator.view.closeEvent(event)

            if self.project_recovery is not None:
                # Do not merge this block with the above block that
                # starts with the same check.
                # We deliberately split the call to stop the recovery
                # thread and removal of the checkpoints folder to
                # allow for the maximum amount of time for the recovery
                # thread to finish. Any errors here are ignored as exceptions
                # on shutdown cannot be handled in a meaningful way.
                # Future runs of project recovery will clean any stale points
                # after a month
                self.project_recovery.remove_current_pid_folder(
                    ignore_errors=True)

            event.accept()
        else:
            # Cancel was pressed when closing an editor
            event.ignore()