eric6/Preferences/ConfigurationPages/NotificationsPage.py

changeset 7945
76daafe10009
parent 7923
91e843545d9a
child 7952
1849f61cf2b6
equal deleted inserted replaced
7941:cf988a30ba47 7945:76daafe10009
14 from .Ui_NotificationsPage import Ui_NotificationsPage 14 from .Ui_NotificationsPage import Ui_NotificationsPage
15 15
16 import Preferences 16 import Preferences
17 import UI.PixmapCache 17 import UI.PixmapCache
18 18
19 from Globals import qVersionTuple
20
21 19
22 class NotificationsPage(ConfigurationPageBase, Ui_NotificationsPage): 20 class NotificationsPage(ConfigurationPageBase, Ui_NotificationsPage):
23 """ 21 """
24 Class implementing the Notifications configuration page. 22 Class implementing the Notifications configuration page.
25 """ 23 """
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())

eric ide

mercurial