Changed some code to avoid obsolete Qt functions.

Sun, 31 Mar 2019 14:38:46 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sun, 31 Mar 2019 14:38:46 +0200
changeset 6911
8f4a050c6895
parent 6910
5b938c17bc0a
child 6912
03264dcdd83e
child 6913
be170600edcd

Changed some code to avoid obsolete Qt functions.

E5Gui/E5PassivePopup.py file | annotate | diff | comparison | revisions
Preferences/ConfigurationPages/NotificationsPage.py file | annotate | diff | comparison | revisions
Snapshot/SnapWidget.py file | annotate | diff | comparison | revisions
Snapshot/SnapshotTimer.py file | annotate | diff | comparison | revisions
--- a/E5Gui/E5PassivePopup.py	Sun Mar 31 12:38:25 2019 +0200
+++ b/E5Gui/E5PassivePopup.py	Sun Mar 31 14:38:46 2019 +0200
@@ -13,6 +13,7 @@
 from PyQt5.QtCore import pyqtSignal, Qt, QTimer, QPoint, QRect
 from PyQt5.QtWidgets import QFrame, QVBoxLayout, QApplication
 
+from Globals import qVersionTuple
 
 class E5PassivePopup(QFrame):
     """
@@ -189,8 +190,12 @@
         w = self.minimumSizeHint().width()
         h = self.minimumSizeHint().height()
         
-        r = QApplication.desktop().screenGeometry(
-            QPoint(x + w // 2, y + h // 2))
+        if qVersionTuple() >= (5, 10, 0):
+            r = QApplication.screenAt(QPoint(x + w // 2, y + h // 2))\
+            .geometry()
+        else:
+            r = QApplication.desktop().screenGeometry(
+                QPoint(x + w // 2, y + h // 2))
         
         if x < r.center().x():
             x += target.width()
--- a/Preferences/ConfigurationPages/NotificationsPage.py	Sun Mar 31 12:38:25 2019 +0200
+++ b/Preferences/ConfigurationPages/NotificationsPage.py	Sun Mar 31 14:38:46 2019 +0200
@@ -18,6 +18,8 @@
 import Preferences
 import UI.PixmapCache
 
+from Globals import qVersionTuple
+
 
 class NotificationsPage(ConfigurationPageBase, Ui_NotificationsPage):
     """
@@ -33,13 +35,21 @@
         
         minX, maxX = self.xSpinBox.maximum(), self.xSpinBox.minimum()
         minY, maxY = self.ySpinBox.maximum(), self.ySpinBox.minimum()
-        desk = QApplication.desktop()
-        for screen in range(desk.screenCount()):
-            geom = desk.availableGeometry(screen)
-            minX = min(minX, geom.x())
-            maxX = max(maxX, geom.x() + geom.width())
-            minY = min(minY, geom.y())
-            maxY = max(maxY, geom.y() + geom.height())
+        if qVersionTuple() >= (5, 10, 0):
+            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())
+        else:
+            desk = QApplication.desktop()
+            for screen in range(desk.screenCount()):
+                geom = desk.availableGeometry(screen)
+                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)
--- a/Snapshot/SnapWidget.py	Sun Mar 31 12:38:25 2019 +0200
+++ b/Snapshot/SnapWidget.py	Sun Mar 31 14:38:46 2019 +0200
@@ -57,9 +57,14 @@
         
         self.modeCombo.addItem(self.tr("Fullscreen"),
                                SnapWidget.ModeFullscreen)
-        if QApplication.desktop().screenCount() > 1:
-            self.modeCombo.addItem(self.tr("Current Screen"),
-                                   SnapWidget.ModeScreen)
+        if qVersionTuple() >= (5, 10, 0):
+            if len(QApplication.screens()) > 1:
+                self.modeCombo.addItem(self.tr("Current Screen"),
+                                       SnapWidget.ModeScreen)
+        else:
+            if QApplication.desktop().screenCount() > 1:
+                self.modeCombo.addItem(self.tr("Current Screen"),
+                                       SnapWidget.ModeScreen)
         self.modeCombo.addItem(self.tr("Rectangular Selection"),
                                SnapWidget.ModeRectangle)
         self.modeCombo.addItem(self.tr("Elliptical Selection"),
@@ -382,9 +387,13 @@
                     desktop.winId(), desktop.x(), desktop.y(),
                     desktop.width(), desktop.height())
         elif self.__mode == SnapWidget.ModeScreen:
-            desktop = QApplication.desktop()
-            screenId = desktop.screenNumber(QCursor.pos())
-            geom = desktop.screenGeometry(screenId)
+            if qVersionTuple() >= (5, 10, 0):
+                screen = QApplication.screenAt(QCursor.pos())
+                geom = screen.geometry()
+            else:
+                desktop = QApplication.desktop()
+                screenId = desktop.screenNumber(QCursor.pos())
+                geom = desktop.screenGeometry(screenId)
             x = geom.x()
             y = geom.y()
             if qVersionTuple() >= (5, 0, 0):
--- a/Snapshot/SnapshotTimer.py	Sun Mar 31 12:38:25 2019 +0200
+++ b/Snapshot/SnapshotTimer.py	Sun Mar 31 14:38:46 2019 +0200
@@ -13,6 +13,7 @@
 from PyQt5.QtGui import QPainter, QPalette
 from PyQt5.QtWidgets import QWidget, QApplication, QToolTip
 
+from Globals import qVersionTuple
 
 class SnapshotTimer(QWidget):
     """
@@ -51,7 +52,10 @@
         
         @param seconds timeout value (integer)
         """
-        screenGeom = QApplication.desktop().screenGeometry()
+        if qVersionTuple() >= (5, 10, 0):
+            screenGeom = QApplication.screens()[0].geometry()
+        else:
+            screenGeom = QApplication.desktop().screenGeometry()
         self.move(screenGeom.width() // 2 - self.size().width() // 2,
                   screenGeom.top())
         self.__toggle = True
@@ -114,7 +118,10 @@
         
         @param evt enter event (QEvent)
         """
-        screenGeom = QApplication.desktop().screenGeometry()
+        if qVersionTuple() >= (5, 10, 0):
+            screenGeom = QApplication.screens()[0].geometry()
+        else:
+            screenGeom = QApplication.desktop().screenGeometry()
         if self.x() == screenGeom.left():
             self.move(
                 screenGeom.x() +

eric ide

mercurial