src/eric7/Preferences/ConfigurationPages/NotificationsPage.py

branch
eric7
changeset 9221
bf71ee032bb4
parent 9209
b99e7fd55fd3
child 9413
80c06d472826
--- a/src/eric7/Preferences/ConfigurationPages/NotificationsPage.py	Wed Jul 13 11:16:20 2022 +0200
+++ b/src/eric7/Preferences/ConfigurationPages/NotificationsPage.py	Wed Jul 13 14:55:47 2022 +0200
@@ -23,6 +23,7 @@
     """
     Class implementing the Notifications configuration page.
     """
+
     def __init__(self):
         """
         Constructor
@@ -30,90 +31,100 @@
         super().__init__()
         self.setupUi(self)
         self.setObjectName("NotificationsPage")
-        
+
         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.warningIcon.setPixmap(
-            NotificationFrame.getIcon(NotificationTypes.WARNING))
+
+        self.warningIcon.setPixmap(NotificationFrame.getIcon(NotificationTypes.WARNING))
         self.criticalIcon.setPixmap(
-            NotificationFrame.getIcon(NotificationTypes.CRITICAL))
-        
+            NotificationFrame.getIcon(NotificationTypes.CRITICAL)
+        )
+
         self.__notification = None
         self.__firstTime = True
-        
+
         # set initial values
         self.timeoutSpinBox.setValue(Preferences.getUI("NotificationTimeout"))
         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)
-        
+
         self.__colors = {}
         self.__colors["NotificationWarningForeground"] = Preferences.getUI(
-            "NotificationWarningForeground")
+            "NotificationWarningForeground"
+        )
         self.__colors["NotificationWarningBackground"] = Preferences.getUI(
-            "NotificationWarningBackground")
+            "NotificationWarningBackground"
+        )
         self.__colors["NotificationCriticalForeground"] = Preferences.getUI(
-            "NotificationCriticalForeground")
+            "NotificationCriticalForeground"
+        )
         self.__colors["NotificationCriticalBackground"] = Preferences.getUI(
-            "NotificationCriticalBackground")
-        
+            "NotificationCriticalBackground"
+        )
+
         self.warningFrame.setStyleSheet(
             NotificationFrame.NotificationStyleSheetTemplate.format(
                 self.__colors["NotificationWarningForeground"],
-                self.__colors["NotificationWarningBackground"]
+                self.__colors["NotificationWarningBackground"],
             )
         )
         self.criticalFrame.setStyleSheet(
             NotificationFrame.NotificationStyleSheetTemplate.format(
                 self.__colors["NotificationCriticalForeground"],
-                self.__colors["NotificationCriticalBackground"]
+                self.__colors["NotificationCriticalBackground"],
             )
         )
-    
+
     def save(self):
         """
         Public slot to save the Notifications configuration.
         """
         Preferences.setUI("NotificationTimeout", self.timeoutSpinBox.value())
-        Preferences.setUI("NotificationPosition", QPoint(
-            self.xSpinBox.value(), self.ySpinBox.value()))
-        
+        Preferences.setUI(
+            "NotificationPosition", QPoint(self.xSpinBox.value(), self.ySpinBox.value())
+        )
+
         for key in self.__colors:
             Preferences.setUI(key, self.__colors[key])
-    
+
     @pyqtSlot(bool)
     def on_visualButton_clicked(self, checked):
         """
         Private slot to select the position visually.
-        
+
         @param checked state of the button (boolean)
         """
         if checked:
             from UI.NotificationWidget import NotificationWidget
-            self.__notification = NotificationWidget(
-                parent=self, setPosition=True)
+
+            self.__notification = NotificationWidget(parent=self, setPosition=True)
             self.__notification.showNotification(
                 NotificationFrame.getIcon(NotificationTypes.OTHER),
                 self.tr("Visual Selection"),
-                self.tr("Drag the notification window to"
-                        " the desired place and release the button."),
-                timeout=0
+                self.tr(
+                    "Drag the notification window to"
+                    " the desired place and release the button."
+                ),
+                timeout=0,
             )
             self.__notification.move(
-                QPoint(self.xSpinBox.value(), self.ySpinBox.value()))
+                QPoint(self.xSpinBox.value(), self.ySpinBox.value())
+            )
             if self.__firstTime:
                 # adjust the maximum values to the width of the notification
                 self.xSpinBox.setMaximum(
-                    self.xSpinBox.maximum() - self.__notification.width())
+                    self.xSpinBox.maximum() - self.__notification.width()
+                )
                 self.ySpinBox.setMaximum(
-                    self.ySpinBox.maximum() - self.__notification.height())
+                    self.ySpinBox.maximum() - self.__notification.height()
+                )
                 self.__firstTime = False
         else:
             # retrieve the position
@@ -122,54 +133,53 @@
             self.ySpinBox.setValue(point.y())
             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()
-            )
-    
+            self.__notification.move(self.xSpinBox.value(), self.ySpinBox.value())
+
     ##################################################################
     ## colors for warning notifications
     ##################################################################
-    
+
     @pyqtSlot()
     def on_warningFgButton_clicked(self):
         """
         Private slot to set the foreground color of the warning notifications.
         """
         color = QColorDialog.getColor(
-            QColor(self.__colors["NotificationWarningForeground"]))
+            QColor(self.__colors["NotificationWarningForeground"])
+        )
         if color.isValid():
             self.__colors["NotificationWarningForeground"] = color.name()
             self.warningFrame.setStyleSheet(
                 NotificationFrame.NotificationStyleSheetTemplate.format(
                     self.__colors["NotificationWarningForeground"],
-                    self.__colors["NotificationWarningBackground"]
+                    self.__colors["NotificationWarningBackground"],
                 )
             )
-    
+
     @pyqtSlot()
     def on_warningBgButton_clicked(self):
         """
         Private slot to set the background color of the warning notifications.
         """
         color = QColorDialog.getColor(
-            QColor(self.__colors["NotificationWarningBackground"]))
+            QColor(self.__colors["NotificationWarningBackground"])
+        )
         if color.isValid():
             self.__colors["NotificationWarningBackground"] = color.name()
             self.warningFrame.setStyleSheet(
                 NotificationFrame.NotificationStyleSheetTemplate.format(
                     self.__colors["NotificationWarningForeground"],
-                    self.__colors["NotificationWarningBackground"]
+                    self.__colors["NotificationWarningBackground"],
                 )
             )
-    
+
     @pyqtSlot()
     def on_warningResetButton_clicked(self):
         """
@@ -177,69 +187,75 @@
         current values.
         """
         self.__colors["NotificationWarningForeground"] = Preferences.getUI(
-            "NotificationWarningForeground")
+            "NotificationWarningForeground"
+        )
         self.__colors["NotificationWarningBackground"] = Preferences.getUI(
-            "NotificationWarningBackground")
+            "NotificationWarningBackground"
+        )
         self.warningFrame.setStyleSheet(
             NotificationFrame.NotificationStyleSheetTemplate.format(
                 self.__colors["NotificationWarningForeground"],
-                self.__colors["NotificationWarningBackground"]
+                self.__colors["NotificationWarningBackground"],
             )
         )
-    
+
     @pyqtSlot()
     def on_warningDefaultButton_clicked(self):
         """
         Private slot to reset the colors for warning notifications to their
         default values.
         """
-        self.__colors["NotificationWarningForeground"] = (
-            Preferences.Prefs.uiDefaults["NotificationWarningForeground"])
-        self.__colors["NotificationWarningBackground"] = (
-            Preferences.Prefs.uiDefaults["NotificationWarningBackground"])
+        self.__colors["NotificationWarningForeground"] = Preferences.Prefs.uiDefaults[
+            "NotificationWarningForeground"
+        ]
+        self.__colors["NotificationWarningBackground"] = Preferences.Prefs.uiDefaults[
+            "NotificationWarningBackground"
+        ]
         self.warningFrame.setStyleSheet(
             NotificationFrame.NotificationStyleSheetTemplate.format(
                 self.__colors["NotificationWarningForeground"],
-                self.__colors["NotificationWarningBackground"]
+                self.__colors["NotificationWarningBackground"],
             )
         )
-    
+
     ##################################################################
     ## colors for critical notifications
     ##################################################################
-    
+
     @pyqtSlot()
     def on_criticalFgButton_clicked(self):
         """
         Private slot to set the foreground color of the critical notifications.
         """
         color = QColorDialog.getColor(
-            QColor(self.__colors["NotificationCriticalForeground"]))
+            QColor(self.__colors["NotificationCriticalForeground"])
+        )
         if color.isValid():
             self.__colors["NotificationCriticalForeground"] = color.name()
             self.criticalFrame.setStyleSheet(
                 NotificationFrame.NotificationStyleSheetTemplate.format(
                     self.__colors["NotificationCriticalForeground"],
-                    self.__colors["NotificationCriticalBackground"]
+                    self.__colors["NotificationCriticalBackground"],
                 )
             )
-    
+
     @pyqtSlot()
     def on_criticalBgButton_clicked(self):
         """
         Private slot to set the background color of the critical notifications.
         """
         color = QColorDialog.getColor(
-            QColor(self.__colors["NotificationCriticalBackground"]))
+            QColor(self.__colors["NotificationCriticalBackground"])
+        )
         if color.isValid():
             self.__colors["NotificationCriticalBackground"] = color.name()
             self.criticalFrame.setStyleSheet(
                 NotificationFrame.NotificationStyleSheetTemplate.format(
                     self.__colors["NotificationCriticalForeground"],
-                    self.__colors["NotificationCriticalBackground"]
+                    self.__colors["NotificationCriticalBackground"],
                 )
             )
-    
+
     @pyqtSlot()
     def on_criticalResetButton_clicked(self):
         """
@@ -247,30 +263,34 @@
         current values.
         """
         self.__colors["NotificationCriticalForeground"] = Preferences.getUI(
-            "NotificationCriticalForeground")
+            "NotificationCriticalForeground"
+        )
         self.__colors["NotificationCriticalBackground"] = Preferences.getUI(
-            "NotificationCriticalBackground")
+            "NotificationCriticalBackground"
+        )
         self.criticalFrame.setStyleSheet(
             NotificationFrame.NotificationStyleSheetTemplate.format(
                 self.__colors["NotificationCriticalForeground"],
-                self.__colors["NotificationCriticalBackground"]
+                self.__colors["NotificationCriticalBackground"],
             )
         )
-    
+
     @pyqtSlot()
     def on_criticalDefaultButton_clicked(self):
         """
         Private slot to reset the colors for critical notifications to their
         default values.
         """
-        self.__colors["NotificationCriticalForeground"] = (
-            Preferences.Prefs.uiDefaults["NotificationCriticalForeground"])
-        self.__colors["NotificationCriticalBackground"] = (
-            Preferences.Prefs.uiDefaults["NotificationCriticalBackground"])
+        self.__colors["NotificationCriticalForeground"] = Preferences.Prefs.uiDefaults[
+            "NotificationCriticalForeground"
+        ]
+        self.__colors["NotificationCriticalBackground"] = Preferences.Prefs.uiDefaults[
+            "NotificationCriticalBackground"
+        ]
         self.criticalFrame.setStyleSheet(
             NotificationFrame.NotificationStyleSheetTemplate.format(
                 self.__colors["NotificationCriticalForeground"],
-                self.__colors["NotificationCriticalBackground"]
+                self.__colors["NotificationCriticalBackground"],
             )
         )
 
@@ -278,7 +298,7 @@
 def create(dlg):
     """
     Module function to create the configuration page.
-    
+
     @param dlg reference to the configuration dialog
     @return reference to the instantiated page (ConfigurationPageBase)
     """

eric ide

mercurial