def event(self, event: Qt.QEvent) -> bool:
        if event.type() in (Qt.QEvent.Polish, Qt.QEvent.ApplicationPaletteChange):
            self.setPalette(self.main.palette())
            self.update()
            return True

        return super().event(event)
Exemple #2
0
    def notify(self, obj: Qt.QObject, event: Qt.QEvent) -> bool:
        import sys

        isex = False
        try:
            self.enter_count += 1
            ret, time = cast(
                Tuple[bool, float],
                measure_exec_time_ms(Qt.QApplication.notify, True,
                                     False)(self, obj, event))

            if (type(event).__name__ == 'QEvent'
                    and event.type() in qevent_info):
                event_name = qevent_info[event.type()][0]
            else:
                event_name = type(event).__name__

            try:
                obj_name = obj.objectName()
            except RuntimeError:
                obj_name = ''

            if obj_name == '':
                try:
                    if (obj.parent() is not None
                            and obj.parent().objectName() != ''):
                        obj_name = '(parent) ' + obj.parent().objectName()
                except RuntimeError:
                    pass

            recursive_indent = 2 * (self.enter_count - 1)

            print(
                f'{time:7.3f} ms, receiver: {type(obj).__name__:>25}, event: {event.type():3d} {" " * recursive_indent + event_name:<30}, name: {obj_name}'
            )

            self.enter_count -= 1

            return ret
        except Exception:  # pylint: disable=broad-except
            isex = True
            logging.error('Application: unexpected error')
            print(*sys.exc_info())
            return False
        finally:
            if isex:
                self.quit()
Exemple #3
0
    def eventFilter(self, obj: Qt.QObject, event: Qt.QEvent) -> bool:
        if (event.type() == Qt.QEvent.Show):
            logging.debug('--------------------------------')
            logging.debug(f'{obj.objectName()}')
            logging.debug('event:       Show')
            logging.debug(f'spontaneous: {event.spontaneous()}')
            logging.debug('')
            self.print_toolbars_state()
        elif (event.type() == Qt.QEvent.Hide):
            logging.debug('--------------------------------')
            logging.debug(f'{obj.objectName()}')
            logging.debug('event:       Hide')
            logging.debug(f'spontaneous: {event.spontaneous()}')
            logging.debug('')
            self.print_toolbars_state()

        # return Qt.QObject.eventFilter(object, event)
        return False
Exemple #4
0
    def event(self, event: Qt.QEvent) -> bool:
        if event.type() == Qt.QEvent.LayoutRequest:
            self.timeline.full_repaint()

        return super().event(event)
Exemple #5
0
 def changeEvent(self, event: QEvent):
     if event.type() == QEvent.WindowStateChange:
         # Если окно свернули
         if self.isMinimized():
             # Прячем окно с панели задач
             QTimer.singleShot(0, self.hide)