5 |
5 |
6 """ |
6 """ |
7 Module implementing a clickable label. |
7 Module implementing a clickable label. |
8 """ |
8 """ |
9 |
9 |
10 from PyQt5.QtCore import pyqtSignal, Qt, QPoint |
10 from PyQt6.QtCore import pyqtSignal, Qt, QPoint |
11 from PyQt5.QtWidgets import QLabel |
11 from PyQt6.QtWidgets import QLabel |
12 |
12 |
13 |
13 |
14 class E5ClickableLabel(QLabel): |
14 class E5ClickableLabel(QLabel): |
15 """ |
15 """ |
16 Class implementing a clickable label. |
16 Class implementing a clickable label. |
39 |
39 |
40 @param evt mouse event (QMouseEvent) |
40 @param evt mouse event (QMouseEvent) |
41 """ |
41 """ |
42 if ( |
42 if ( |
43 evt.button() == Qt.MouseButton.LeftButton and |
43 evt.button() == Qt.MouseButton.LeftButton and |
44 self.rect().contains(evt.pos()) |
44 self.rect().contains(evt.position().toPoint()) |
45 ): |
45 ): |
46 if evt.modifiers() == Qt.KeyboardModifier.ControlModifier: |
46 if evt.modifiers() == Qt.KeyboardModifier.ControlModifier: |
47 self.middleClicked.emit(evt.globalPos()) |
47 self.middleClicked.emit(evt.globalPos()) |
48 else: |
48 else: |
49 self.clicked.emit(evt.globalPos()) |
49 self.clicked.emit(evt.globalPos()) |
50 elif ( |
50 elif ( |
51 evt.button() == Qt.MouseButton.MidButton and |
51 evt.button() == Qt.MouseButton.MiddleButton and |
52 self.rect().contains(evt.pos()) |
52 self.rect().contains(evt.position().toPoint()) |
53 ): |
53 ): |
54 self.middleClicked.emit(evt.globalPos()) |
54 self.middleClicked.emit(evt.globalPos()) |
55 else: |
55 else: |
56 super().mouseReleaseEvent(evt) |
56 super().mouseReleaseEvent(evt) |