34 self.__length = 0 |
34 self.__length = 0 |
35 self.__toggle = True |
35 self.__toggle = True |
36 |
36 |
37 # text is taken from paintEvent with maximum number plus some margin |
37 # text is taken from paintEvent with maximum number plus some margin |
38 self.resize( |
38 self.resize( |
39 self.fontMetrics().width( |
39 self.fontMetrics().width(self.trUtf8( |
40 self.trUtf8("Snapshot will be taken in %n seconds", "", 99)) + 6, |
40 "Snapshot will be taken in %n seconds", "", 99)) + 6, |
41 self.fontMetrics().height() + 4) |
41 self.fontMetrics().height() + 4) |
42 |
42 |
43 self.__timer.timeout.connect(self.__bell) |
43 self.__timer.timeout.connect(self.__bell) |
44 |
44 |
45 def start(self, seconds): |
45 def start(self, seconds): |
47 Public method to start the timer. |
47 Public method to start the timer. |
48 |
48 |
49 @param seconds timeout value (integer) |
49 @param seconds timeout value (integer) |
50 """ |
50 """ |
51 screenGeom = QApplication.desktop().screenGeometry() |
51 screenGeom = QApplication.desktop().screenGeometry() |
52 self.move(screenGeom.width() // 2 - self.size().width() // 2, screenGeom.top()) |
52 self.move(screenGeom.width() // 2 - self.size().width() // 2, |
|
53 screenGeom.top()) |
53 self.__toggle = True |
54 self.__toggle = True |
54 self.__time = 0 |
55 self.__time = 0 |
55 self.__length = seconds |
56 self.__length = seconds |
56 self.__timer.start(1000) |
57 self.__timer.start(1000) |
57 self.show() |
58 self.show() |
98 painter.setBrush(textBackgroundColor) |
99 painter.setBrush(textBackgroundColor) |
99 helpText = self.trUtf8("Snapshot will be taken in %n seconds", "", |
100 helpText = self.trUtf8("Snapshot will be taken in %n seconds", "", |
100 self.__length - self.__time) |
101 self.__length - self.__time) |
101 textRect = painter.boundingRect(self.rect().adjusted(2, 2, -2, -2), |
102 textRect = painter.boundingRect(self.rect().adjusted(2, 2, -2, -2), |
102 Qt.AlignHCenter | Qt.TextSingleLine, helpText) |
103 Qt.AlignHCenter | Qt.TextSingleLine, helpText) |
103 painter.drawText(textRect, Qt.AlignHCenter | Qt.TextSingleLine, helpText) |
104 painter.drawText(textRect, Qt.AlignHCenter | Qt.TextSingleLine, |
|
105 helpText) |
104 |
106 |
105 def enterEvent(self, evt): |
107 def enterEvent(self, evt): |
106 """ |
108 """ |
107 Protected method handling the mouse cursor entering the widget. |
109 Protected method handling the mouse cursor entering the widget. |
108 |
110 |
109 @param evt enter event (QEvent) |
111 @param evt enter event (QEvent) |
110 """ |
112 """ |
111 screenGeom = QApplication.desktop().screenGeometry() |
113 screenGeom = QApplication.desktop().screenGeometry() |
112 if self.x() == screenGeom.left(): |
114 if self.x() == screenGeom.left(): |
113 self.move( |
115 self.move( |
114 screenGeom.x() + (screenGeom.width() // 2 - self.size().width() // 2), |
116 screenGeom.x() + (screenGeom.width() // 2 - \ |
|
117 self.size().width() // 2), |
115 screenGeom.top()) |
118 screenGeom.top()) |
116 else: |
119 else: |
117 self.move(screenGeom.topLeft()) |
120 self.move(screenGeom.topLeft()) |