31 self.setupUi(self) |
29 self.setupUi(self) |
32 self.setObjectName("NotificationsPage") |
30 self.setObjectName("NotificationsPage") |
33 |
31 |
34 minX, maxX = self.xSpinBox.maximum(), self.xSpinBox.minimum() |
32 minX, maxX = self.xSpinBox.maximum(), self.xSpinBox.minimum() |
35 minY, maxY = self.ySpinBox.maximum(), self.ySpinBox.minimum() |
33 minY, maxY = self.ySpinBox.maximum(), self.ySpinBox.minimum() |
36 if qVersionTuple() >= (5, 10, 0): |
34 for screen in QApplication.screens(): |
37 for screen in QApplication.screens(): |
35 geom = screen.availableGeometry() |
38 geom = screen.availableGeometry() |
36 minX = min(minX, geom.x()) |
39 minX = min(minX, geom.x()) |
37 maxX = max(maxX, geom.x() + geom.width()) |
40 maxX = max(maxX, geom.x() + geom.width()) |
38 minY = min(minY, geom.y()) |
41 minY = min(minY, geom.y()) |
39 maxY = max(maxY, geom.y() + geom.height()) |
42 maxY = max(maxY, geom.y() + geom.height()) |
|
43 else: |
|
44 desk = QApplication.desktop() |
|
45 for screen in range(desk.screenCount()): |
|
46 geom = desk.availableGeometry(screen) |
|
47 minX = min(minX, geom.x()) |
|
48 maxX = max(maxX, geom.x() + geom.width()) |
|
49 minY = min(minY, geom.y()) |
|
50 maxY = max(maxY, geom.y() + geom.height()) |
|
51 self.xSpinBox.setMinimum(minX) |
40 self.xSpinBox.setMinimum(minX) |
52 self.xSpinBox.setMaximum(maxX) |
41 self.xSpinBox.setMaximum(maxX) |
53 self.ySpinBox.setMinimum(minY) |
42 self.ySpinBox.setMinimum(minY) |
54 self.ySpinBox.setMaximum(maxY) |
43 self.ySpinBox.setMaximum(maxY) |
55 |
44 |
56 self.__notification = None |
45 self.__notification = None |
|
46 self.__firstTime = True |
57 |
47 |
58 # set initial values |
48 # set initial values |
59 self.enableCheckBox.setChecked( |
49 self.enableCheckBox.setChecked( |
60 Preferences.getUI("NotificationsEnabled")) |
50 Preferences.getUI("NotificationsEnabled")) |
61 self.timeoutSpinBox.setValue(Preferences.getUI("NotificationTimeout")) |
51 self.timeoutSpinBox.setValue(Preferences.getUI("NotificationTimeout")) |
91 self.tr("Drag the notification window to" |
81 self.tr("Drag the notification window to" |
92 " the desired place and release the button.")) |
82 " the desired place and release the button.")) |
93 self.__notification.move( |
83 self.__notification.move( |
94 QPoint(self.xSpinBox.value(), self.ySpinBox.value())) |
84 QPoint(self.xSpinBox.value(), self.ySpinBox.value())) |
95 self.__notification.show() |
85 self.__notification.show() |
|
86 if self.__firstTime: |
|
87 # adjust the maximum values to the width of the notification |
|
88 self.xSpinBox.setMaximum( |
|
89 self.xSpinBox.maximum() - self.__notification.width()) |
|
90 self.ySpinBox.setMaximum( |
|
91 self.ySpinBox.maximum() - self.__notification.height()) |
|
92 self.__firstTime = False |
96 else: |
93 else: |
97 # retrieve the position |
94 # retrieve the position |
98 point = self.__notification.frameGeometry().topLeft() |
95 point = self.__notification.frameGeometry().topLeft() |
99 self.xSpinBox.setValue(point.x()) |
96 self.xSpinBox.setValue(point.x()) |
100 self.ySpinBox.setValue(point.y()) |
97 self.ySpinBox.setValue(point.y()) |