eric6/Preferences/ConfigurationPages/NotificationsPage.py

changeset 7952
1849f61cf2b6
parent 7945
76daafe10009
child 7955
567f2ec958c3
--- a/eric6/Preferences/ConfigurationPages/NotificationsPage.py	Mon Jan 04 15:51:18 2021 +0100
+++ b/eric6/Preferences/ConfigurationPages/NotificationsPage.py	Mon Jan 04 15:59:22 2021 +0100
@@ -29,18 +29,11 @@
         self.setupUi(self)
         self.setObjectName("NotificationsPage")
         
-        minX, maxX = self.xSpinBox.maximum(), self.xSpinBox.minimum()
-        minY, maxY = self.ySpinBox.maximum(), self.ySpinBox.minimum()
-        for screen in QApplication.screens():
-            geom = screen.availableGeometry()
-            minX = min(minX, geom.x())
-            maxX = max(maxX, geom.x() + geom.width())
-            minY = min(minY, geom.y())
-            maxY = max(maxY, geom.y() + geom.height())
-        self.xSpinBox.setMinimum(minX)
-        self.xSpinBox.setMaximum(maxX)
-        self.ySpinBox.setMinimum(minY)
-        self.ySpinBox.setMaximum(maxY)
+        geom = QApplication.screens()[0].availableVirtualGeometry()
+        self.xSpinBox.setMinimum(geom.x())
+        self.xSpinBox.setMaximum(geom.width())
+        self.ySpinBox.setMinimum(geom.y())
+        self.ySpinBox.setMaximum(geom.height())
         
         self.__notification = None
         self.__firstTime = True
@@ -52,6 +45,9 @@
         point = Preferences.getUI("NotificationPosition")
         self.xSpinBox.setValue(point.x())
         self.ySpinBox.setValue(point.y())
+        
+        self.xSpinBox.valueChanged.connect(self.__moveNotification)
+        self.ySpinBox.valueChanged.connect(self.__moveNotification)
     
     def save(self):
         """
@@ -74,15 +70,15 @@
             from UI.NotificationWidget import NotificationWidget
             self.__notification = NotificationWidget(
                 parent=self, setPosition=True)
-            self.__notification.setPixmap(
-                UI.PixmapCache.getPixmap("notification48"))
-            self.__notification.setHeading(self.tr("Visual Selection"))
-            self.__notification.setText(
+            self.__notification.showNotification(
+                UI.PixmapCache.getPixmap("notification48"),
+                self.tr("Visual Selection"),
                 self.tr("Drag the notification window to"
-                        " the desired place and release the button."))
+                        " the desired place and release the button."),
+                timeout=0
+            )
             self.__notification.move(
                 QPoint(self.xSpinBox.value(), self.ySpinBox.value()))
-            self.__notification.show()
             if self.__firstTime:
                 # adjust the maximum values to the width of the notification
                 self.xSpinBox.setMaximum(
@@ -98,6 +94,17 @@
             self.__notification.close()
             self.__notification = None
     
+    @pyqtSlot()
+    def __moveNotification(self):
+        """
+        Private slot to move the notification widget.
+        """
+        if self.visualButton.isChecked():
+            self.__notification.move(
+                self.xSpinBox.value(),
+                self.ySpinBox.value()
+            )
+
 
 def create(dlg):
     """

eric ide

mercurial