Replaced some obsoleted methods of QPrinter.

Sat, 08 May 2021 19:47:48 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 08 May 2021 19:47:48 +0200
changeset 8298
83ddb87b3bc1
parent 8297
c1f9e30c6219
child 8299
58cf45497dc0

Replaced some obsoleted methods of QPrinter.

eric6/Graphics/PixmapDiagram.py file | annotate | diff | comparison | revisions
eric6/Graphics/SvgDiagram.py file | annotate | diff | comparison | revisions
eric6/QScintilla/Editor.py file | annotate | diff | comparison | revisions
eric6/QScintilla/MiniEditor.py file | annotate | diff | comparison | revisions
eric6/Tools/UIPreviewer.py file | annotate | diff | comparison | revisions
--- a/eric6/Graphics/PixmapDiagram.py	Sat May 08 18:38:57 2021 +0200
+++ b/eric6/Graphics/PixmapDiagram.py	Sat May 08 19:47:48 2021 +0200
@@ -384,12 +384,18 @@
         painter.setFont(font)
         fm = painter.fontMetrics()
         fontHeight = fm.lineSpacing()
-        marginX = printer.pageRect().x() - printer.paperRect().x()
+        marginX = (
+            printer.pageLayout().paintRectPixels(printer.resolution()).x() -
+            printer.pageLayout().fullRectPixels(printer.resolution()).x()
+        )
         marginX = (
             Preferences.getPrinter("LeftMargin") *
             int(printer.resolution() / 2.54) - marginX
         )
-        marginY = printer.pageRect().y() - printer.paperRect().y()
+        marginY = (
+            printer.pageLayout().paintRectPixels(printer.resolution()).y() -
+            printer.pageLayout().fullRectPixels(printer.resolution()).y()
+        )
         marginY = (
             Preferences.getPrinter("TopMargin") *
             int(printer.resolution() / 2.54) - marginY
--- a/eric6/Graphics/SvgDiagram.py	Sat May 08 18:38:57 2021 +0200
+++ b/eric6/Graphics/SvgDiagram.py	Sat May 08 19:47:48 2021 +0200
@@ -353,12 +353,18 @@
         painter.setFont(font)
         fm = painter.fontMetrics()
         fontHeight = fm.lineSpacing()
-        marginX = printer.pageRect().x() - printer.paperRect().x()
+        marginX = (
+            printer.pageLayout().paintRectPixels(printer.resolution()).x() -
+            printer.pageLayout().fullRectPixels(printer.resolution()).x()
+        )
         marginX = (
             Preferences.getPrinter("LeftMargin") *
             int(printer.resolution() / 2.54) - marginX
         )
-        marginY = printer.pageRect().y() - printer.paperRect().y()
+        marginY = (
+            printer.pageLayout().paintRectPixels(printer.resolution()).y() -
+            printer.pageLayout().fullRectPixels(printer.resolution()).y()
+        )
         marginY = (
             Preferences.getPrinter("TopMargin") *
             int(printer.resolution() / 2.54) - marginY
--- a/eric6/QScintilla/Editor.py	Sat May 08 18:38:57 2021 +0200
+++ b/eric6/QScintilla/Editor.py	Sat May 08 19:47:48 2021 +0200
@@ -2723,7 +2723,7 @@
                 fromLine, fromIndex, toLine, toIndex = self.getSelection()
                 if toIndex == 0:
                     toLine -= 1
-                # Qscintilla seems to print one line more than told
+                # QScintilla seems to print one line more than told
                 res = printer.printRange(self, fromLine, toLine - 1)
             else:
                 res = printer.printRange(self)
--- a/eric6/QScintilla/MiniEditor.py	Sat May 08 18:38:57 2021 +0200
+++ b/eric6/QScintilla/MiniEditor.py	Sat May 08 19:47:48 2021 +0200
@@ -3060,7 +3060,7 @@
                 )
                 if toIndex == 0:
                     toLine -= 1
-                # Qscintilla seems to print one line more than told
+                # QScintilla seems to print one line more than told
                 res = printer.printRange(self.__textEdit, fromLine, toLine - 1)
             else:
                 res = printer.printRange(self.__textEdit)
--- a/eric6/Tools/UIPreviewer.py	Sat May 08 18:38:57 2021 +0200
+++ b/eric6/Tools/UIPreviewer.py	Sat May 08 19:47:48 2021 +0200
@@ -581,8 +581,14 @@
         @param printer reference to the printer object (QPrinter)
         """
         p = QPainter(printer)
-        marginX = (printer.pageRect().x() - printer.paperRect().x()) // 2
-        marginY = (printer.pageRect().y() - printer.paperRect().y()) // 2
+        marginX = (
+            printer.pageLayout().paintRectPixels(printer.resolution()).x() -
+            printer.pageLayout().fullRectPixels(printer.resolution()).x()
+        ) // 2
+        marginY = (
+            printer.pageLayout().paintRectPixels(printer.resolution()).y() -
+            printer.pageLayout().fullRectPixels(printer.resolution()).y()
+        ) // 2
 
         # double the margin on bottom of page
         if printer.orientation() == QPrinter.Orientation.Portrait:

eric ide

mercurial