83 gradient = QRadialGradient(wh, wh, wh, 0.8 * wh, 0.8 * wh) |
83 gradient = QRadialGradient(wh, wh, wh, 0.8 * wh, 0.8 * wh) |
84 gradient.setColorAt(0.0, color.lighter(200)) |
84 gradient.setColorAt(0.0, color.lighter(200)) |
85 gradient.setColorAt(0.6, color) |
85 gradient.setColorAt(0.6, color) |
86 if self.__framedLed: |
86 if self.__framedLed: |
87 gradient.setColorAt(0.9, color.darker()) |
87 gradient.setColorAt(0.9, color.darker()) |
88 gradient.setColorAt(1.0, self.palette().color(QPalette.Dark)) |
88 gradient.setColorAt( |
|
89 1.0, self.palette().color(QPalette.ColorRole.Dark)) |
89 else: |
90 else: |
90 gradient.setColorAt(1.0, color.darker()) |
91 gradient.setColorAt(1.0, color.darker()) |
91 |
92 |
92 # now do the drawing |
93 # now do the drawing |
93 paint = QPainter(self) |
94 paint = QPainter(self) |
94 paint.setRenderHint(QPainter.Antialiasing, True) |
95 paint.setRenderHint(QPainter.RenderHint.Antialiasing, True) |
95 paint.setBrush(QBrush(gradient)) |
96 paint.setBrush(QBrush(gradient)) |
96 paint.setPen(Qt.NoPen) |
97 paint.setPen(Qt.PenStyle.NoPen) |
97 paint.drawEllipse(1, 1, width, width) |
98 paint.drawEllipse(1, 1, width, width) |
98 paint.end() |
99 paint.end() |
99 |
100 |
100 def __paintRectangular(self): |
101 def __paintRectangular(self): |
101 """ |
102 """ |
107 right = min(int((self.width() + width) / 2), self.width()) |
108 right = min(int((self.width() + width) / 2), self.width()) |
108 height = self.height() |
109 height = self.height() |
109 |
110 |
110 # now do the drawing |
111 # now do the drawing |
111 painter = QPainter(self) |
112 painter = QPainter(self) |
112 painter.setRenderHint(QPainter.Antialiasing, True) |
113 painter.setRenderHint(QPainter.RenderHint.Antialiasing, True) |
113 color = self.__led_on and self.__led_color or self.__offcolor |
114 color = self.__led_on and self.__led_color or self.__offcolor |
114 |
115 |
115 painter.setPen(color.lighter(200)) |
116 painter.setPen(color.lighter(200)) |
116 painter.drawLine(left, 0, left, height - 1) |
117 painter.drawLine(left, 0, left, height - 1) |
117 painter.drawLine(left + 1, 0, right - 1, 0) |
118 painter.drawLine(left + 1, 0, right - 1, 0) |
118 if self.__framedLed: |
119 if self.__framedLed: |
119 painter.setPen(self.palette().color(QPalette.Dark)) |
120 painter.setPen(self.palette().color(QPalette.ColorRole.Dark)) |
120 else: |
121 else: |
121 painter.setPen(color.darker()) |
122 painter.setPen(color.darker()) |
122 painter.drawLine(left + 1, height - 1, right - 1, height - 1) |
123 painter.drawLine(left + 1, height - 1, right - 1, height - 1) |
123 painter.drawLine(right - 1, 1, right - 1, height - 1) |
124 painter.drawLine(right - 1, 1, right - 1, height - 1) |
124 painter.fillRect(left + 1, 1, right - 2, height - 2, QBrush(color)) |
125 painter.fillRect(left + 1, 1, right - 2, height - 2, QBrush(color)) |
293 @param shape shape of the LED (E5LedCircular, E5LedRectangular) |
294 @param shape shape of the LED (E5LedCircular, E5LedRectangular) |
294 @param rectRatio ratio width to height, if shape is rectangular (float) |
295 @param rectRatio ratio width to height, if shape is rectangular (float) |
295 """ |
296 """ |
296 super(E5ClickableLed, self).__init__(parent, color, shape, rectRatio) |
297 super(E5ClickableLed, self).__init__(parent, color, shape, rectRatio) |
297 |
298 |
298 self.setCursor(Qt.PointingHandCursor) |
299 self.setCursor(Qt.CursorShape.PointingHandCursor) |
299 |
300 |
300 def mouseReleaseEvent(self, evt): |
301 def mouseReleaseEvent(self, evt): |
301 """ |
302 """ |
302 Protected method handling mouse release events. |
303 Protected method handling mouse release events. |
303 |
304 |
304 @param evt mouse event (QMouseEvent) |
305 @param evt mouse event (QMouseEvent) |
305 """ |
306 """ |
306 if evt.button() == Qt.LeftButton and self.rect().contains(evt.pos()): |
307 if ( |
307 if evt.modifiers() == Qt.ControlModifier: |
308 evt.button() == Qt.MouseButton.LeftButton and |
|
309 self.rect().contains(evt.pos()) |
|
310 ): |
|
311 if evt.modifiers() == Qt.KeyboardModifier.ControlModifier: |
308 self.middleClicked.emit(evt.globalPos()) |
312 self.middleClicked.emit(evt.globalPos()) |
309 else: |
313 else: |
310 self.clicked.emit(evt.globalPos()) |
314 self.clicked.emit(evt.globalPos()) |
311 elif ( |
315 elif ( |
312 evt.button() == Qt.MidButton and |
316 evt.button() == Qt.MouseButton.MidButton and |
313 self.rect().contains(evt.pos()) |
317 self.rect().contains(evt.pos()) |
314 ): |
318 ): |
315 self.middleClicked.emit(evt.globalPos()) |
319 self.middleClicked.emit(evt.globalPos()) |
316 else: |
320 else: |
317 super(E5ClickableLed, self).mouseReleaseEvent(evt) |
321 super(E5ClickableLed, self).mouseReleaseEvent(evt) |