27 """ |
27 """ |
28 super(NotificationsPage, self).__init__() |
28 super(NotificationsPage, self).__init__() |
29 self.setupUi(self) |
29 self.setupUi(self) |
30 self.setObjectName("NotificationsPage") |
30 self.setObjectName("NotificationsPage") |
31 |
31 |
32 minX, maxX = self.xSpinBox.maximum(), self.xSpinBox.minimum() |
32 geom = QApplication.screens()[0].availableVirtualGeometry() |
33 minY, maxY = self.ySpinBox.maximum(), self.ySpinBox.minimum() |
33 self.xSpinBox.setMinimum(geom.x()) |
34 for screen in QApplication.screens(): |
34 self.xSpinBox.setMaximum(geom.width()) |
35 geom = screen.availableGeometry() |
35 self.ySpinBox.setMinimum(geom.y()) |
36 minX = min(minX, geom.x()) |
36 self.ySpinBox.setMaximum(geom.height()) |
37 maxX = max(maxX, geom.x() + geom.width()) |
|
38 minY = min(minY, geom.y()) |
|
39 maxY = max(maxY, geom.y() + geom.height()) |
|
40 self.xSpinBox.setMinimum(minX) |
|
41 self.xSpinBox.setMaximum(maxX) |
|
42 self.ySpinBox.setMinimum(minY) |
|
43 self.ySpinBox.setMaximum(maxY) |
|
44 |
37 |
45 self.__notification = None |
38 self.__notification = None |
46 self.__firstTime = True |
39 self.__firstTime = True |
47 |
40 |
48 # set initial values |
41 # set initial values |
50 Preferences.getUI("NotificationsEnabled")) |
43 Preferences.getUI("NotificationsEnabled")) |
51 self.timeoutSpinBox.setValue(Preferences.getUI("NotificationTimeout")) |
44 self.timeoutSpinBox.setValue(Preferences.getUI("NotificationTimeout")) |
52 point = Preferences.getUI("NotificationPosition") |
45 point = Preferences.getUI("NotificationPosition") |
53 self.xSpinBox.setValue(point.x()) |
46 self.xSpinBox.setValue(point.x()) |
54 self.ySpinBox.setValue(point.y()) |
47 self.ySpinBox.setValue(point.y()) |
|
48 |
|
49 self.xSpinBox.valueChanged.connect(self.__moveNotification) |
|
50 self.ySpinBox.valueChanged.connect(self.__moveNotification) |
55 |
51 |
56 def save(self): |
52 def save(self): |
57 """ |
53 """ |
58 Public slot to save the Notifications configuration. |
54 Public slot to save the Notifications configuration. |
59 """ |
55 """ |
72 """ |
68 """ |
73 if checked: |
69 if checked: |
74 from UI.NotificationWidget import NotificationWidget |
70 from UI.NotificationWidget import NotificationWidget |
75 self.__notification = NotificationWidget( |
71 self.__notification = NotificationWidget( |
76 parent=self, setPosition=True) |
72 parent=self, setPosition=True) |
77 self.__notification.setPixmap( |
73 self.__notification.showNotification( |
78 UI.PixmapCache.getPixmap("notification48")) |
74 UI.PixmapCache.getPixmap("notification48"), |
79 self.__notification.setHeading(self.tr("Visual Selection")) |
75 self.tr("Visual Selection"), |
80 self.__notification.setText( |
|
81 self.tr("Drag the notification window to" |
76 self.tr("Drag the notification window to" |
82 " the desired place and release the button.")) |
77 " the desired place and release the button."), |
|
78 timeout=0 |
|
79 ) |
83 self.__notification.move( |
80 self.__notification.move( |
84 QPoint(self.xSpinBox.value(), self.ySpinBox.value())) |
81 QPoint(self.xSpinBox.value(), self.ySpinBox.value())) |
85 self.__notification.show() |
|
86 if self.__firstTime: |
82 if self.__firstTime: |
87 # adjust the maximum values to the width of the notification |
83 # adjust the maximum values to the width of the notification |
88 self.xSpinBox.setMaximum( |
84 self.xSpinBox.setMaximum( |
89 self.xSpinBox.maximum() - self.__notification.width()) |
85 self.xSpinBox.maximum() - self.__notification.width()) |
90 self.ySpinBox.setMaximum( |
86 self.ySpinBox.setMaximum( |
96 self.xSpinBox.setValue(point.x()) |
92 self.xSpinBox.setValue(point.x()) |
97 self.ySpinBox.setValue(point.y()) |
93 self.ySpinBox.setValue(point.y()) |
98 self.__notification.close() |
94 self.__notification.close() |
99 self.__notification = None |
95 self.__notification = None |
100 |
96 |
|
97 @pyqtSlot() |
|
98 def __moveNotification(self): |
|
99 """ |
|
100 Private slot to move the notification widget. |
|
101 """ |
|
102 if self.visualButton.isChecked(): |
|
103 self.__notification.move( |
|
104 self.xSpinBox.value(), |
|
105 self.ySpinBox.value() |
|
106 ) |
|
107 |
101 |
108 |
102 def create(dlg): |
109 def create(dlg): |
103 """ |
110 """ |
104 Module function to create the configuration page. |
111 Module function to create the configuration page. |
105 |
112 |