Python PyQt5.QtGui.QCloseEvent() Examples

The following are 22 code examples for showing how to use PyQt5.QtGui.QCloseEvent(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.

You may check out the related API usage on the sidebar.

You may also want to check out all available functions/classes of the module PyQt5.QtGui , or try the search function .

Example 1
Project: track   Author: frans-fuerst   File: mainwindow.py    License: Apache License 2.0 7 votes vote down vote up
def event(self, e):
        if not isinstance(e, (
                QtCore.QEvent,
                QtCore.QChildEvent,
                QtCore.QDynamicPropertyChangeEvent,
                QtGui.QPaintEvent,
                QtGui.QHoverEvent,
                QtGui.QMoveEvent,
                QtGui.QEnterEvent,
                QtGui.QResizeEvent,
                QtGui.QShowEvent,
                QtGui.QPlatformSurfaceEvent,
                QtGui.QWindowStateChangeEvent,
                QtGui.QKeyEvent,
                QtGui.QWheelEvent,
                QtGui.QMouseEvent,
                QtGui.QFocusEvent,
                QtGui.QHelpEvent,
                QtGui.QHideEvent,
                QtGui.QCloseEvent,
                QtGui.QInputMethodQueryEvent,
                QtGui.QContextMenuEvent,
                )):
            log().warning("unknown event: %r %r", e.type(), e)
        return super().event(e) 
Example 2
Project: QualCoder   Author: ccbogel   File: qualcoder.py    License: MIT License 6 votes vote down vote up
def closeEvent(self, event):
        """ Override the QWindow close event.
        Close all dialogs and database connection.
        If selected via menu option exit: event == False
        If selected via window x close: event == QtGui.QCloseEvent
        """

        if not self.force_quit:
            quit_msg = _("Are you sure you want to quit?")
            reply = QtWidgets.QMessageBox.question(self, 'Message', quit_msg,
            QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No)
            if reply == QtWidgets.QMessageBox.Yes:
                self.dialogList = None
                if self.app.conn is not None:
                    try:
                        self.app.conn.commit()
                        self.app.conn.close()
                    except:
                        pass
                QtWidgets.qApp.quit()
                return
            if event is False:
                return
            else:
                event.ignore() 
Example 3
Project: qutebrowser   Author: qutebrowser   File: inspector.py    License: GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, _e: QCloseEvent) -> None:
        """Save the geometry when closed."""
        data = self._widget.saveGeometry().data()
        geom = base64.b64encode(data).decode('ASCII')
        configfiles.state['inspector']['window'] = geom 
Example 4
Project: imperialism-remake   Author: Trilarion   File: graphics.py    License: GNU General Public License v3.0 5 votes vote down vote up
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() 
Example 5
Project: vidcutter   Author: ozmartian   File: videoconsole.py    License: GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event: QCloseEvent):
        self.parent.cutter.consoleButton.setChecked(False)
        super(ConsoleWidget, self).closeEvent(event) 
Example 6
Project: nanovna-saver   Author: NanoVNA-Saver   File: NanoVNASaver.py    License: GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, a0: QtGui.QCloseEvent) -> None:
        self.worker.stopped = True
        self.settings.setValue("MarkerCount", Marker.count())
        for marker in self.markers:
            marker.update_settings()

        self.settings.setValue("WindowHeight", self.height())
        self.settings.setValue("WindowWidth", self.width())
        self.settings.sync()
        self.bands.saveSettings()
        self.threadpool.waitForDone(2500)
        a0.accept()
        sys.exit() 
Example 7
Project: CvStudio   Author: haruiz   File: loading_dialog.py    License: MIT License 5 votes vote down vote up
def closeEvent(self, e: QCloseEvent):
        if self.movie.state() == QMovie.Running:
            self.movie.stop() 
Example 8
Project: autokey   Author: autokey   File: configwindow.py    License: GNU General Public License v3.0 5 votes vote down vote up
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) 
Example 9
Project: EliteQuant_Python   Author: EliteQuant   File: ui_main_window.py    License: Apache License 2.0 5 votes vote down vote up
def closeEvent(self, a0: QtGui.QCloseEvent):
        print('closing main window')
        self._ui_events_engine.stop()
        self._outgoing_request_events_engine.stop()
        self._client_mq.stop() 
Example 10
Project: urh   Author: jopohl   File: ContinuousSendDialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event: QCloseEvent):
        self.continuous_modulator.stop()
        super().closeEvent(event) 
Example 11
Project: urh   Author: jopohl   File: MessageTypeDialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event: QCloseEvent):
        self.ui.tblViewRuleset.setItemDelegateForColumn(2, None)
        self.ui.tblViewRuleset.setItemDelegateForColumn(3, None)
        settings.write("{}/geometry".format(self.__class__.__name__), self.saveGeometry())
        super().closeEvent(event) 
Example 12
Project: urh   Author: jopohl   File: ModulatorDialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event: QCloseEvent):
        self.ui.lineEditParameters.editingFinished.emit()
        settings.write("{}/geometry".format(self.__class__.__name__), self.saveGeometry())

        for gv in (self.ui.gVCarrier, self.ui.gVData, self.ui.gVModulated, self.ui.gVOriginalSignal):
            # Eliminate graphic views to prevent segfaults
            gv.eliminate()

        super().closeEvent(event) 
Example 13
Project: urh   Author: jopohl   File: OptionsDialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event: QCloseEvent):
        changed_values = {}
        if bool(self.ui.checkBoxPauseTime.isChecked()) != self.old_show_pause_as_time:
            changed_values['show_pause_as_time'] = bool(self.ui.checkBoxPauseTime.isChecked())
        if self.old_default_view != self.ui.comboBoxDefaultView.currentIndex():
            changed_values['default_view'] = self.ui.comboBoxDefaultView.currentIndex()
        if self.old_num_sending_repeats != self.ui.spinBoxNumSendingRepeats.value():
            changed_values["num_sending_repeats"] = self.ui.spinBoxNumSendingRepeats.value()

        settings.write('default_view', self.ui.comboBoxDefaultView.currentIndex())
        settings.write('num_sending_repeats', self.ui.spinBoxNumSendingRepeats.value())
        settings.write('show_pause_as_time', self.ui.checkBoxPauseTime.isChecked())

        FieldType.save_to_xml(self.field_type_table_model.field_types)
        self.plugin_controller.save_enabled_states()
        for plugin in self.plugin_controller.model.plugins:
            plugin.destroy_settings_frame()

        for i in range(self.ui.scrollAreaWidgetSpectrogramColormapContents.layout().count()):
            widget = self.ui.scrollAreaWidgetSpectrogramColormapContents.layout().itemAt(i).widget()
            if isinstance(widget, QRadioButton) and widget.isChecked():
                selected_colormap_name = widget.objectName()
                if selected_colormap_name != colormaps.read_selected_colormap_name_from_settings():
                    colormaps.choose_colormap(selected_colormap_name)
                    colormaps.write_selected_colormap_to_settings(selected_colormap_name)
                    changed_values["spectrogram_colormap"] = selected_colormap_name
                break

        self.values_changed.emit(changed_values)

        settings.write("{}/geometry".format(self.__class__.__name__), self.saveGeometry())
        super().closeEvent(event) 
Example 14
Project: urh   Author: jopohl   File: SimulatorDialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event: QCloseEvent):
        self.timer.stop()
        self.simulator.stop()
        time.sleep(0.1)
        self.simulator.cleanup()

        self.emit_editing_finished_signals()
        if self.device_settings_rx_widget:
            self.device_settings_rx_widget.emit_device_parameters_changed()
        if self.device_settings_tx_widget:
            self.device_settings_tx_widget.emit_device_parameters_changed()
        if self.sniff_settings_widget:
            self.sniff_settings_widget.emit_sniff_parameters_changed()

        super().closeEvent(event) 
Example 15
Project: urh   Author: jopohl   File: ProtocolSniffDialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event: QCloseEvent):
        self.sniff_settings_widget.emit_sniff_parameters_changed()
        super().closeEvent(event) 
Example 16
Project: urh   Author: jopohl   File: FuzzingDialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event: QCloseEvent):
        settings.write("{}/geometry".format(self.__class__.__name__), self.saveGeometry())
        super().closeEvent(event) 
Example 17
Project: urh   Author: jopohl   File: ProtocolLabelDialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event: QCloseEvent):
        settings.write("{}/geometry".format(self.__class__.__name__), self.saveGeometry())
        super().closeEvent(event) 
Example 18
Project: urh   Author: jopohl   File: SendRecvDialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
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()

        settings.write("{}/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) 
Example 19
Project: urh   Author: jopohl   File: DecoderDialog.py    License: GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event: QCloseEvent):
        settings.write("{}/geometry".format(self.__class__.__name__), self.saveGeometry())
        super().closeEvent(event) 
Example 20
Project: urh   Author: jopohl   File: MainController.py    License: GNU General Public License v3.0 5 votes vote down vote up
def closeEvent(self, event: QCloseEvent):
        self.save_project()
        settings.write("{}/geometry".format(self.__class__.__name__), self.saveGeometry())
        super().closeEvent(event) 
Example 21
Project: corrscope   Author: corrscope   File: __init__.py    License: BSD 2-Clause "Simplified" License 5 votes vote down vote up
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() 
Example 22
Project: vidcutter   Author: ozmartian   File: mediastream.py    License: GNU General Public License v3.0 4 votes vote down vote up
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)