24 """ |
24 """ |
25 Constructor |
25 Constructor |
26 """ |
26 """ |
27 super(SnapshotTimer, self).__init__(None) |
27 super(SnapshotTimer, self).__init__(None) |
28 |
28 |
29 self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint | |
29 self.setWindowFlags( |
30 Qt.X11BypassWindowManagerHint) |
30 Qt.WindowType.WindowStaysOnTopHint | |
|
31 Qt.WindowType.FramelessWindowHint | |
|
32 Qt.WindowType.X11BypassWindowManagerHint |
|
33 ) |
31 |
34 |
32 self.__timer = QTimer() |
35 self.__timer = QTimer() |
33 self.__textRect = QRect() |
36 self.__textRect = QRect() |
34 self.__time = 0 |
37 self.__time = 0 |
35 self.__length = 0 |
38 self.__length = 0 |
92 """ |
95 """ |
93 painter = QPainter(self) |
96 painter = QPainter(self) |
94 |
97 |
95 if self.__time < self.__length: |
98 if self.__time < self.__length: |
96 pal = QToolTip.palette() |
99 pal = QToolTip.palette() |
97 textBackgroundColor = pal.color(QPalette.Active, QPalette.Base) |
100 textBackgroundColor = pal.color(QPalette.ColorGroup.Active, |
|
101 QPalette.ColorRole.Base) |
98 if self.__toggle: |
102 if self.__toggle: |
99 textColor = pal.color(QPalette.Active, QPalette.Text) |
103 textColor = pal.color(QPalette.ColorGroup.Active, |
|
104 QPalette.ColorRole.Text) |
100 else: |
105 else: |
101 textColor = pal.color(QPalette.Active, QPalette.Base) |
106 textColor = pal.color(QPalette.ColorGroup.Active, |
|
107 QPalette.ColorRole.Base) |
102 painter.setPen(textColor) |
108 painter.setPen(textColor) |
103 painter.setBrush(textBackgroundColor) |
109 painter.setBrush(textBackgroundColor) |
104 helpText = self.tr("Snapshot will be taken in %n seconds", "", |
110 helpText = self.tr("Snapshot will be taken in %n seconds", "", |
105 self.__length - self.__time) |
111 self.__length - self.__time) |
106 textRect = painter.boundingRect( |
112 textRect = painter.boundingRect( |
107 self.rect().adjusted(2, 2, -2, -2), |
113 self.rect().adjusted(2, 2, -2, -2), |
108 Qt.AlignHCenter | Qt.TextSingleLine, helpText) |
114 Qt.AlignmentFlag.AlignHCenter | Qt.TextFlag.TextSingleLine, |
109 painter.drawText(textRect, Qt.AlignHCenter | Qt.TextSingleLine, |
115 helpText) |
110 helpText) |
116 painter.drawText( |
|
117 textRect, |
|
118 Qt.AlignmentFlag.AlignHCenter | Qt.TextFlag.TextSingleLine, |
|
119 helpText) |
111 |
120 |
112 def enterEvent(self, evt): |
121 def enterEvent(self, evt): |
113 """ |
122 """ |
114 Protected method handling the mouse cursor entering the widget. |
123 Protected method handling the mouse cursor entering the widget. |
115 |
124 |