Пример #1
0
    def closeEvent(self, event: QCloseEvent):
        if self.settings['settings']['minimize']:
            event.ignore()

            if hasattr(self.ui, 'windows'):
                if hasattr(self.ui.windows, 'settings'):
                    self.ui.windows.settings.window.hide()

                if hasattr(self.ui.windows, 'chat'):
                    for key, val in self.ui.windows.chat.items():
                        val.window.hide()

            self.window.hide()
            self.window.tray_icon.showMessage(
                self.window.windowTitle(), "Application was minimized to Tray",
                QSystemTrayIcon.Information, 2000)
        else:
            if hasattr(self.ui, 'windows'):
                if hasattr(self.ui.windows, 'settings'):
                    self.ui.windows.settings.window.close()

                if hasattr(self.ui.windows, 'chat'):
                    for key, val in self.ui.windows.chat.items():
                        val.window.close()

            self.client.stop()
            event.accept()
Пример #2
0
    def closeEvent(self, event: QCloseEvent):
        if self.device.backend == Backends.network:
            event.accept()
            return

        self.device.stop("Dialog closed. Killing recording process.")
        if self.mode == Mode.receive and not self.already_saved and self.device.current_index > 0:
            reply = QMessageBox.question(self, self.tr("Save data?"),
                                         self.tr("Do you want to save the data you have captured so far?"),
                                         QMessageBox.Yes | QMessageBox.No | QMessageBox.Abort)
            if reply == QMessageBox.Yes:
                self.on_save_clicked()
            elif reply == QMessageBox.Abort:
                event.ignore()
                return

        time.sleep(0.1)
        if self.device.backend != Backends.none:
            self.device.cleanup()
            self.files_recorded.emit(self.recorded_files)
            self.recording_parameters.emit(str(self.device.frequency),
                                           str(self.device.sample_rate),
                                           str(self.device.bandwidth),
                                           str(self.device.gain),
                                           str(self.device.name))

        event.accept()
Пример #3
0
 def closeEvent(self, event: QCloseEvent) -> None:
     """Called on closing window."""
     if self.should_close_document(self.tr("Quit")):
         gp.dump_prefs(self.pref)
         event.accept()
     else:
         event.ignore()
Пример #4
0
    def closeEvent(self, event: QCloseEvent) -> None:
        """Reimplemented exit protocol.

        It doesn't make logical sense to exit the entire application when closing a
        test or batch launched from the GUI. This method takes the user back to the GUI
        under such circumstances.

        It also prevents a test from closing when  `ignore_close_event` is True. This is
        used to prevent crashes to desktop when a `closeEvent` events at an awkward time
        during a test, for instance while waiting for a stimulus to disappear from the
        screen.

        If in batch mode, a close event will kill the current test, not the whole batch.

        Args:
            event:

        """
        logger.debug("close event encountered in main window")
        if self.ignore_close_event:
            logger.debug("ignoring close event")
            event.ignore()
        else:
            if isinstance(self.centralWidget(), GUIWidget):
                logger.debug("at the gui, so properly closing")
                duration = datetime.now() - self.time_started
                s = ",".join([str(duration), str(self.time_started)]) + "\n"
                open(durations_path, "a").write(s)
                exit()
            else:
                logger.debug("at a test, safely closing")
                self.centralWidget().safe_close()
                event.ignore()
Пример #5
0
 def closeEvent(self, event: QtGui.QCloseEvent) -> None:
     reply = QMessageBox.question(self, "Message", "Are you sure to quit?",
                                  QMessageBox.No | QMessageBox.Yes, QMessageBox.No)
     if reply == QMessageBox.Yes:
         event.accept()
     else:
         event.ignore()
Пример #6
0
 def closeEvent(self, event: QCloseEvent) -> None:
     if self._modified and not self._force_close_flag:
         self.confirm('There are unsaved changes. Discard them?',
                      self.force_close)
         event.ignore()
     else:
         super().closeEvent(event)
    def closeEvent(self, event: QCloseEvent):
        self.emit_editing_finished_signals()
        if self.device.backend == Backends.network:
            event.accept()
            return

        self.device.stop("Dialog closed. Killing recording process.")
        logger.debug("Device stopped successfully.")
        if not self.save_before_close():
            event.ignore()
            return

        time.sleep(0.1)
        if self.device.backend != Backends.none:
            # Backend none is selected, when no device is available
            logger.debug("Cleaning up device")
            self.device.cleanup()
            logger.debug("Successfully cleaned up device")
            self.recording_parameters.emit(
                str(self.device.name),
                dict(frequency=self.device.frequency,
                     sample_rate=self.device.sample_rate,
                     bandwidth=self.device.bandwidth,
                     gain=self.device.gain,
                     if_gain=self.device.if_gain,
                     baseband_gain=self.device.baseband_gain,
                     freq_correction=self.device.freq_correction))

        event.accept()
Пример #8
0
    def closeEvent(self, event: QCloseEvent):
        if self.device.backend is not Backends.none:
            self.emit_editing_finished_signals()

        self.timer.stop()

        self.device.stop("Dialog closed. Killing recording process.")
        logger.debug("Device stopped successfully.")

        if not self.testing_mode:
            if not self.save_before_close():
                event.ignore()
                return

        time.sleep(0.1)
        if self.device.backend not in (Backends.none, Backends.network):
            # Backend none is selected, when no device is available
            logger.debug("Cleaning up device")
            self.device.cleanup()
            logger.debug("Successfully cleaned up device")
            self.device_settings_widget.emit_device_parameters_changed()

        constants.SETTINGS.setValue("{}/geometry".format(self.__class__.__name__), self.saveGeometry())

        if self.device is not None:
            self.device.free_data()

        self.scene_manager.eliminate()

        self._eliminate_graphic_view()

        super().closeEvent(event)
Пример #9
0
    def closeEvent(self, event: QCloseEvent) -> None:
        # count unanswered quesitons and questions marked for review
        unanswered = ''
        with open(sys.argv[2]) as output_file:
            answers = output_file.readlines()
        for (i, answer) in enumerate(answers):
            if len(answer) == 1:
                unanswered += str(i + 1) + ', '

        if len(unanswered) > 0:
            unanswered = unanswered[:-2]
        else:
            unanswered = 'None'

        marked_for_review = ''
        for question in self.questions:
            if question.review.isChecked():
                marked_for_review += str(question.idx + 1) + ', '
        if len(marked_for_review) > 0:
            marked_for_review = marked_for_review[:-2]
        else:
            marked_for_review = 'None'
        quit_msg = 'Exit Qmark?\nQuestions marked for review: ' + marked_for_review + '\nQuestions unanswered: ' + unanswered

        reply = QMessageBox.question(self, 'Message', quit_msg,
                                     QMessageBox.Yes, QMessageBox.No)

        if reply == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore()
Пример #10
0
    def closeEvent(self, event: QtGui.QCloseEvent) -> None:
        """
        Close all windows when main is closed.
        :param event: A QtGui close event
        :return:
        """

        quit_msg = "Are you sure you want to exit the program?"
        if self.dp_w.are_changes_saved(
        ) is False or self.fm_w.are_changes_saved() is False:
            quit_msg = quit_msg + '\n\nAtention:'

        if self.dp_w.are_changes_saved() is False:
            quit_msg = quit_msg + '\n  - Data Pattern is not saved!'
        if self.fm_w.are_changes_saved() is False:
            quit_msg = quit_msg + '\n  - Fit results are not saved!'

        reply = QtWidgets.QMessageBox.question(self, 'Message', quit_msg,
                                               QtWidgets.QMessageBox.Yes,
                                               QtWidgets.QMessageBox.No)

        if reply == QtWidgets.QMessageBox.Yes:
            config.write()
            event.accept()
            sys.exit()
        else:
            event.ignore()
Пример #11
0
 def closeEvent(self, event: QtGui.QCloseEvent) -> None:
     if self.modified and not self.force_close_flag:
         self.confirm('There are unsaved changes. Discard them?',
                      self.force_close)
         event.ignore()
     else:
         super().closeEvent(event)
Пример #12
0
 def closeEvent(self, event: QCloseEvent) -> None:
     self.saveSettings()
     if self.rapidApp is None:
         event.accept()
     else:
         event.ignore()
         self.hide()
Пример #13
0
    def closeEvent(self, event: QCloseEvent) -> None:
        if self.minimize_on_close and not self.need_close:
            self.hide()
            event.ignore()

            # This notification is disabled on Mac since minimizing apps on
            # close is the standard behaviour on this OS.
            if not self.minimize_on_close_notif_already_send and sys.platform != "darwin":
                self.minimize_on_close_notif_already_send = True
                self.systray_notification.emit(
                    "Parsec", _("TEXT_TRAY_PARSEC_STILL_RUNNING_MESSAGE"), 2000
                )
        else:
            if self.config.gui_confirmation_before_close and not self.force_close:
                result = ask_question(
                    self if self.isVisible() else None,
                    _("TEXT_PARSEC_QUIT_TITLE"),
                    _("TEXT_PARSEC_QUIT_INSTRUCTIONS"),
                    [_("ACTION_PARSEC_QUIT_CONFIRM"), _("ACTION_CANCEL")],
                )
                if result != _("ACTION_PARSEC_QUIT_CONFIRM"):
                    event.ignore()
                    self.force_close = False
                    self.need_close = False
                    return

            state = self.saveGeometry()
            self.event_bus.send(CoreEvent.GUI_CONFIG_CHANGED, gui_geometry=state)
            self.close_all_tabs()
            event.accept()
            QApplication.quit()
Пример #14
0
    def closeEvent(self, event: Qg.QCloseEvent):
        self.setHidden(True)

        # save all config files, in case something was pending
        self.config.friend_codes.flush()
        self.config.preferences.flush()

        if not self.config.preferences['config']['tray']['minimize_on_exit']:
            event.accept()
            return

        if self.do_close:
            ok = util.MsgBoxes.promptyesno('Are you sure you want to quit?')
            if ok:
                event.accept()
        else:
            event.ignore()
            if self.config.preferences['config']['tray']['show_notice']:
                self.config.preferences['config']['tray'][
                    'show_notice'] = False

                self.sys_tray.showMessage(
                    'Wiimmfi-RPC',
                    'Wiimmfi-RPC has been minimized to tray and will '
                    'keep running in the background. To quit the program, '
                    'right-click on this icon and select "Quit".')
    def closeEvent(self, event: QtGui.QCloseEvent) -> None:

        if self.unsaved_changes is False:
            event.accept()
            return

        reply = QtWidgets.QMessageBox()
        reply.setIcon(QtWidgets.QMessageBox.Question)
        reply.setWindowTitle("Save Changes")
        reply.setText("Save changes before exit?")
        reply.setStandardButtons(QtWidgets.QMessageBox.Yes
                                 | QtWidgets.QMessageBox.No
                                 | QtWidgets.QMessageBox.Cancel)

        save = reply.exec_()

        if save == QtWidgets.QMessageBox.Yes:
            logging.info("Saving and exiting")
            self.save_animation_data()
            event.accept()
        elif save == QtWidgets.QMessageBox.No:
            logging.info("Exiting without saving")
            event.accept()
        else:
            event.ignore()
Пример #16
0
 def closeEvent(self, event: QCloseEvent) -> None:
     """Called on closing window."""
     if self.prompt_save():
         gp.dump_prefs(self.pref)
         event.accept()
     else:
         event.ignore()
Пример #17
0
 def closeEvent(self, a0: QCloseEvent) -> None:
     """
     主窗体退出时的事件,包括弹框提示等。Mac 上测试点击无法退出,修改为QMessageBox.Warning
     """
     reply = QMessageBox(QMessageBox.Warning, '关闭', '是否关闭!')
     reply.addButton('确定', QMessageBox.ActionRole)
     reply.addButton('取消', QMessageBox.RejectRole)
     if reply.exec_() == QMessageBox.RejectRole:
         a0.ignore()
         return
     else:
         a0.accept()
     """
     reply = QMessageBox.question(
         self,
         '注意',
         '确认退出吗?',
         QMessageBox.Ok | QMessageBox.Cancel,
         QMessageBox.Cancel)
     if reply == QMessageBox.Ok:
         a0.accept()
     else:
         a0.ignore()
         return
     """
     self.delete_temporary_dock_windows()
     self.save_layout()
     Settings.get_instance().save()
     self.close_signal.emit()
     self.extensions_manager.stop()
     for k in self.dock_widgets.keys():
         self.dock_widgets[k].widget().closeEvent(a0)
     super().closeEvent(a0)
Пример #18
0
    def closeEvent(self, a0: QtGui.QCloseEvent):
        reply = QMessageBox.question(self, 'Message', 'are you sure to quit', QMessageBox.Yes | QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.No:
            QCloseEvent.ignore()
        else:
            QCloseEvent.appect()
Пример #19
0
    def closeEvent(self, event: QtGui.QCloseEvent):
        if self._quitting:
            event.accept()

        else:
            event.ignore()
            self.hide()
Пример #20
0
    def closeEvent(self, a_event: QtGui.QCloseEvent):
        if not self.measure_manager.is_saved() and not self.ignore_save:
            answer = self.close_configuration()

            if answer == MainWindow.CloseConfigOptions.SAVE:
                if self.save_configuration_by_name(
                        self.current_configuration_path):
                    a_event.ignore()
                    self.clb_signal_off_timer.start(self.SIGNAL_OFF_TIME_MS)
                else:
                    QtWidgets.QMessageBox.critical(
                        self, "Ошибка", "Не удалось сохранить конфигурацию")
                    a_event.ignore()

            elif answer == MainWindow.CloseConfigOptions.DONT_SAVE:
                self.ignore_save = True
                self.clb_signal_off_timer.start(self.SIGNAL_OFF_TIME_MS)
                a_event.ignore()
            else:
                a_event.ignore()

        else:
            if self.calibrator.signal_enable:
                self.calibrator.signal_enable = False
                self.clb_signal_off_timer.start(self.SIGNAL_OFF_TIME_MS)
                a_event.ignore()
            else:
                self.settings.save_qwidget_state(self.ui.mainwindow_splitter)
                self.settings.save_qwidget_state(self.ui.mainwindow_splitter_2)
                self.settings.save_qwidget_state(self.ui.measures_table)
                self.settings.save_qwidget_state(self)

                a_event.accept()
Пример #21
0
 def handleClose(self, retVal, a0: QCloseEvent):
     if retVal == 1:  # if OK clicked - Close
         a0.accept()
         self.handleWidgetClosing()
     # if Cancel or MessageBox is closed - Ignore the signal
     if retVal == 0:
         a0.ignore()
Пример #22
0
    def closeEvent(self, event: QCloseEvent):
        if self.device.backend is not Backends.none:
            self.emit_editing_finished_signals()

        self.timer.stop()

        self.device.stop("Dialog closed. Killing recording process.")
        logger.debug("Device stopped successfully.")

        if not self.testing_mode:
            if not self.save_before_close():
                event.ignore()
                return

        time.sleep(0.1)
        if self.device.backend not in (Backends.none, Backends.network):
            # Backend none is selected, when no device is available
            logger.debug("Cleaning up device")
            self.device.cleanup()
            logger.debug("Successfully cleaned up device")
            self.device_settings_widget.emit_device_parameters_changed()

        constants.SETTINGS.setValue(
            "{}/geometry".format(self.__class__.__name__), self.saveGeometry())

        if self.device is not None:
            self.device.free_data()

        self.scene_manager.eliminate()

        self._eliminate_graphic_view()

        super().closeEvent(event)
Пример #23
0
 def closeEvent(self, event: QtGui.QCloseEvent):
     reply = QtWidgets.QMessageBox.question(self, "确认退出", "你确定要退出么?",
                                            QtWidgets.QMessageBox.Yes,
                                            QtWidgets.QMessageBox.No)
     if reply == QtWidgets.QMessageBox.Yes:
         event.accept()
     else:
         event.ignore()
Пример #24
0
    def closeEvent(self, event: QtGui.QCloseEvent):  # noqa: N802
        """
        Can be used to prevent Alt+F4 or other automatic closes.

        :param event: The close event
        """
        if self.close_callback and not self.close_callback(self):
            event.ignore()
Пример #25
0
 def closeEvent(self, event: Qtqg.QCloseEvent):
     if self.centralWidget.changeFlag == 1:
         replay = Qtqw.QMessageBox.question(self, "提示", "放弃修改并退出?",
                                            Qtqw.QMessageBox.Yes | Qtqw.QMessageBox.No, Qtqw.QMessageBox.No)
         if replay == Qtqw.QMessageBox.Yes:
             event.accept()
         else:
             event.ignore()
Пример #26
0
 def closeEvent(self, event: QCloseEvent) -> None:
     reply = QMessageBox.warning(self, 'Exit', 'Exit the program?',
                                 QMessageBox.Yes | QMessageBox.No,
                                 QMessageBox.No)
     if reply == QMessageBox.Yes:
         event.accept()
     else:
         event.ignore()
Пример #27
0
 def closeEvent(self, event: QCloseEvent) -> None:
     """Trap exit."""
     if not self.may_close:
         # log.debug("LogWindow: ignore closeEvent")
         event.ignore()
     else:
         # log.debug("LogWindow: accept closeEvent")
         event.accept()
Пример #28
0
 def closeEvent(self, QCloseEvent):
     reply = MyQMessageBox('温馨提示', '是否要退出应用程序?', '是', '否')
     if reply == 16384:
         self.c.close()
         self.conn.close()
         QCloseEvent.accept()
     else:
         QCloseEvent.ignore()
Пример #29
0
 def closeEvent(self, event: Qtqg.QCloseEvent):
     replay = Qtqw.QMessageBox.question(
         self, "消息", "确认退出么?", Qtqw.QMessageBox.Yes | Qtqw.QMessageBox.No,
         Qtqw.QMessageBox.No)
     if replay == Qtqw.QMessageBox.Yes:
         event.accept()
     else:
         event.ignore()
Пример #30
0
    def closeEvent(self, event: QtGui.QCloseEvent):
        """
        Can be used to prevent Alt+F4 or other automatic closes.

        :param event: The close event
        """
        if self.close_callback and not self.close_callback(self):
            event.ignore()
Пример #31
0
 def closeEvent(self, event: QCloseEvent) -> None:
     """Trap exit."""
     if not self.may_close:
         # log.debug("LogWindow: ignore closeEvent")
         event.ignore()
     else:
         # log.debug("LogWindow: accept closeEvent")
         event.accept()
Пример #32
0
    def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
        reply = QMessageBox.question(
            self, "窗口", "是否需要退出", QMessageBox.Yes | QMessageBox.No, QMessageBox.No)

        if reply == QMessageBox.Yes:
            a0.accept()
        else:
            a0.ignore()
Пример #33
0
 def closeEvent(self, event: QtGui.QCloseEvent) -> None:
     confirmation = self.confirm_box(
         title="Exit", msg="Are you sure you wish to exit the app?"
     )
     if not confirmation:
         event.ignore()
     else:
         event.accept()
Пример #34
0
 def closeEvent(self, event: QCloseEvent) -> None:
     # check if all audio streams are off
     idx = [stream.index for stream in self.streams.audio]
     no_audio = len(
         self.streams.audio) and True not in [self.config[i] for i in idx]
     # check if all subtitle streams are off
     idx = [stream.index for stream in self.streams.subtitle]
     no_subtitles = len(self.streams.subtitle) and True not in [
         self.config[i] for i in idx
     ]
     # warn user if all audio and/or subtitle streams are off
     if no_audio or no_subtitles:
         if no_audio and not no_subtitles:
             warnsubtext = 'All audio streams have been deselected which will produce a file with <b>NO AUDIO</b> ' \
                           'when you save.'
         elif not no_audio and no_subtitles:
             warnsubtext = 'All subtitle streams have been deselected which will produce a file with ' \
                           '<b>NO SUBTITLES</b> when you save.'
         else:
             warnsubtext = 'All audio and subtitle streams have been deselected which will produce a file ' \
                           'with <b>NO AUDIO</b> and <b>NO SUBTITLES</b> when you save.'
         warntext = '''
             <style>
                 h2 {{
                     color: {};
                     font-family: "Futura LT", sans-serif;
                     font-weight: normal;
                 }}
             </style>
             <table border="0" cellpadding="6" cellspacing="0" width="350">
                 <tr>
                     <td><h2>A friendly configuration warning</h2></td>
                 </tr>
                 <tr>
                     <td>{}</td>
                 </tr>
                 <tr>
                     <td>Are you sure this is what you want?</td>
                 </tr>
             </table>'''.format(
             '#C681D5' if self.parent.theme == 'dark' else '#642C68',
             warnsubtext)
         warnmsg = QMessageBox(QMessageBox.Warning,
                               'Warning',
                               warntext,
                               parent=self)
         warnmsg.setIconPixmap(QPixmap(':images/warning.png'))
         warnmsg.addButton('Yes', QMessageBox.YesRole)
         cancelbtn = warnmsg.addButton('No', QMessageBox.RejectRole)
         warnmsg.exec_()
         res = warnmsg.clickedButton()
         if res == cancelbtn:
             event.ignore()
             return
     event.accept()
     self.deleteLater()
     super(StreamSelector, self).closeEvent(event)
Пример #35
0
    def closeEvent(self, event: QCloseEvent):
        """
        This function is automatically called when the window is closed using the close [X] button in the window
        decorations or by right clicking in the system window list and using the close action, or similar ways to close
        the window.
        Just ignore this event and simulate that the user used the action_close_window instead.

        To quote the Qt5 QCloseEvent documentation: If you do not want your widget to be hidden, or want some special
        handling, you should reimplement the event handler and ignore() the event.
        """
        event.ignore()
        # Be safe and emit this signal, because it might be connected to multiple slots.
        self.action_close_window.triggered.emit(True)
Пример #36
0
    def closeEvent(self, event: QCloseEvent):
        self.timer.stop()
        if self.device.backend is not Backends.none:
            self.emit_editing_finished_signals()

        self.device.stop("Dialog closed. Killing recording process.")
        logger.debug("Device stopped successfully.")

        if not self.testing_mode:
            if not self.save_before_close():
                event.ignore()
                return

        time.sleep(0.1)
        if self.device.backend not in (Backends.none, Backends.network):
            # Backend none is selected, when no device is available
            logger.debug("Cleaning up device")
            try:
                # For Protocol Sniffer
                self.device.index_changed.disconnect()
            except TypeError:
                pass

            self.device.cleanup()
            logger.debug("Successfully cleaned up device")
            self.recording_parameters.emit(str(self.device.name), dict(frequency=self.device.frequency,
                                                                       sample_rate=self.device.sample_rate,
                                                                       bandwidth=self.device.bandwidth,
                                                                       gain=self.device.gain,
                                                                       if_gain=self.device.if_gain,
                                                                       baseband_gain=self.device.baseband_gain,
                                                                       freq_correction=self.device.freq_correction
                                                                       ))

        constants.SETTINGS.setValue("{}/geometry".format(self.__class__.__name__), self.saveGeometry())

        if self.device is not None:
            self.device.free_data()

        self.scene_manager.eliminate()

        if self.graphics_view is not None:
            self.graphics_view.eliminate()

        self.graphics_view = None

        super().closeEvent(event)
Пример #37
0
 def closeEvent(self, event: QCloseEvent):
     from genial.controllers.maincontroller import MainController
     if MainController.request_quit():
         event.accept()
     else:
         event.ignore()