Corrected the screen grabbing code for Qt5.

Tue, 09 Oct 2012 19:59:01 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 09 Oct 2012 19:59:01 +0200
changeset 2131
e79d0610347a
parent 2130
626f6fe486be
child 2132
8f013b041e8a

Corrected the screen grabbing code for Qt5.

Snapshot/SnapWidget.py file | annotate | diff | comparison | revisions
Snapshot/SnapshotFreehandGrabber.py file | annotate | diff | comparison | revisions
Snapshot/SnapshotRegionGrabber.py file | annotate | diff | comparison | revisions
--- a/Snapshot/SnapWidget.py	Tue Oct 09 19:31:30 2012 +0200
+++ b/Snapshot/SnapWidget.py	Tue Oct 09 19:59:01 2012 +0200
@@ -17,8 +17,6 @@
     QEvent, QRegExp, qVersion
 from PyQt4.QtGui import QWidget, QImageWriter, QApplication, QPixmap, QCursor, QDrag, \
     QShortcut, QKeySequence, QDesktopServices
-if qVersion() >= "5.0.0":
-    from PyQt4.QtGui import QScreen
 
 from E5Gui import E5FileDialog, E5MessageBox
 
@@ -353,7 +351,7 @@
         if self.__mode == SnapWidget.ModeFullscreen:
             desktop = QApplication.desktop()
             if qVersion() >= "5.0.0":
-                self.__snapshot = QScreen.grabWindow(desktop.winId(),
+                self.__snapshot = QApplication.screens()[0].grabWindow(desktop.winId(),
                     desktop.x(), desktop.y(), desktop.width(), desktop.height())
             else:
                 self.__snapshot = QPixmap.grabWindow(desktop.winId(),
@@ -365,7 +363,7 @@
             x = geom.x()
             y = geom.y()
             if qVersion() >= "5.0.0":
-                self.__snapshot = QScreen.grabWindow(
+                self.__snapshot = QApplication.screens()[0].grabWindow(
                     desktop.winId(), x, y, geom.width(), geom.height())
             else:
                 self.__snapshot = QPixmap.grabWindow(
--- a/Snapshot/SnapshotFreehandGrabber.py	Tue Oct 09 19:31:30 2012 +0200
+++ b/Snapshot/SnapshotFreehandGrabber.py	Tue Oct 09 19:59:01 2012 +0200
@@ -10,8 +10,6 @@
 from PyQt4.QtCore import pyqtSignal, Qt, QRect, QPoint, QTimer, qVersion
 from PyQt4.QtGui import QWidget, QPixmap, QColor, QRegion, QApplication, QPainter, \
     QPalette, QToolTip, QPolygon, QPen, QBrush, QPaintEngine
-if qVersion() >= "5.0.0":
-    from PyQt4.QtGui import QScreen
 
 
 def drawPolygon(painter, polygon, outline, fill=QColor()):
@@ -83,7 +81,8 @@
         x = self.__desktop.x()
         y = self.__desktop.y()
         if qVersion() >= "5.0.0":
-            self.__pixmap = QScreen.grabWindow(self.__desktop.winId(), x, y,
+            self.__pixmap = QApplication.screens()[0].grabWindow(
+                self.__desktop.winId(), x, y,
                 self.__desktop.width(), self.__desktop.height())
         else:
             self.__pixmap = QPixmap.grabWindow(self.__desktop.winId(), x, y,
--- a/Snapshot/SnapshotRegionGrabber.py	Tue Oct 09 19:31:30 2012 +0200
+++ b/Snapshot/SnapshotRegionGrabber.py	Tue Oct 09 19:59:01 2012 +0200
@@ -10,8 +10,6 @@
 from PyQt4.QtCore import pyqtSignal, Qt, QRect, QPoint, QTimer, qVersion
 from PyQt4.QtGui import QWidget, QPixmap, QColor, QRegion, QApplication, QPainter, \
     QPalette, QToolTip, QPaintEngine, QPen, QBrush
-if qVersion() >= "5.0.0":
-    from PyQt4.QtGui import QScreen
 
 def drawRect(painter, rect, outline, fill=QColor()):
     """
@@ -110,7 +108,8 @@
         x = self.__desktop.x()
         y = self.__desktop.y()
         if qVersion() >= "5.0.0":
-            self.__pixmap = QScreen.grabWindow(self.__desktop.winId(), x, y,
+            self.__pixmap = QApplication.screens()[0].grabWindow(
+                self.__desktop.winId(), x, y,
                 self.__desktop.width(), self.__desktop.height())
         else:
             self.__pixmap = QPixmap.grabWindow(self.__desktop.winId(), x, y,

eric ide

mercurial