Fri, 06 Sep 2024 14:33:48 +0200
Fixed a few issues related to printing and image generation in the Graphics package.
--- a/src/eric7/EricGraphics/EricGraphicsView.py Thu Sep 05 17:07:25 2024 +0200 +++ b/src/eric7/EricGraphics/EricGraphicsView.py Fri Sep 06 14:33:48 2024 +0200 @@ -341,13 +341,15 @@ paintDevice.fill(self.backgroundBrush().color()) else: paintDevice = QSvgGenerator() + paintDevice.setFileName(filename) paintDevice.setResolution(100) # 100 dpi paintDevice.setSize(QSize(int(rect.width()), int(rect.height()))) paintDevice.setViewBox(rect) - paintDevice.setFileName(filename) painter = QPainter(paintDevice) painter.setRenderHint(QPainter.RenderHint.Antialiasing, True) - self.scene().render(painter, QRectF(), rect) + painter.begin(paintDevice) + self.render(painter, QRectF(), rect.toRect()) + painter.end() # step 3: reselect the widgets if selectedItems: @@ -395,7 +397,7 @@ - printer.pageLayout().fullRectPixels(printer.resolution()).x() ) marginX = ( - Preferences.getPrinter("LeftMargin") * int(printer.resolution() / 2.54) + int(Preferences.getPrinter("LeftMargin") * printer.resolution() / 2.54) - marginX ) marginY = ( @@ -403,24 +405,24 @@ - printer.pageLayout().fullRectPixels(printer.resolution()).y() ) marginY = ( - Preferences.getPrinter("TopMargin") * int(printer.resolution() / 2.54) + int(Preferences.getPrinter("TopMargin") * printer.resolution() / 2.54) - marginY ) width = ( printer.width() - marginX - - Preferences.getPrinter("RightMargin") * int(printer.resolution() / 2.54) + - int(Preferences.getPrinter("RightMargin") * printer.resolution() / 2.54) ) height = ( printer.height() - fontHeight - 4 - marginY - - Preferences.getPrinter("BottomMargin") * int(printer.resolution() / 2.54) + - int(Preferences.getPrinter("BottomMargin") * printer.resolution() / 2.54) ) - self.scene().render(painter, target=QRectF(marginX, marginY, width, height)) + self.render(painter, target=QRectF(marginX, marginY, width, height)) # write a foot note tc = QColor(50, 50, 50)
--- a/src/eric7/Graphics/PixmapDiagram.py Thu Sep 05 17:07:25 2024 +0200 +++ b/src/eric7/Graphics/PixmapDiagram.py Fri Sep 06 14:33:48 2024 +0200 @@ -434,7 +434,7 @@ - printer.pageLayout().fullRectPixels(printer.resolution()).x() ) marginX = ( - Preferences.getPrinter("LeftMargin") * int(printer.resolution() / 2.54) + int(Preferences.getPrinter("LeftMargin") * printer.resolution() / 2.54) - marginX ) marginY = ( @@ -442,21 +442,21 @@ - printer.pageLayout().fullRectPixels(printer.resolution()).y() ) marginY = ( - Preferences.getPrinter("TopMargin") * int(printer.resolution() / 2.54) + int(Preferences.getPrinter("TopMargin") * printer.resolution() / 2.54) - marginY ) width = ( printer.width() - marginX - - Preferences.getPrinter("RightMargin") * int(printer.resolution() / 2.54) + - int(Preferences.getPrinter("RightMargin") * printer.resolution() / 2.54) ) height = ( printer.height() - fontHeight - 4 - marginY - - Preferences.getPrinter("BottomMargin") * int(printer.resolution() / 2.54) + - int(Preferences.getPrinter("BottomMargin") * printer.resolution() / 2.54) ) # write a foot note
--- a/src/eric7/Graphics/SvgDiagram.py Thu Sep 05 17:07:25 2024 +0200 +++ b/src/eric7/Graphics/SvgDiagram.py Fri Sep 06 14:33:48 2024 +0200 @@ -411,7 +411,7 @@ - printer.pageLayout().fullRectPixels(printer.resolution()).x() ) marginX = ( - Preferences.getPrinter("LeftMargin") * int(printer.resolution() / 2.54) + int(Preferences.getPrinter("LeftMargin") * printer.resolution() / 2.54) - marginX ) marginY = ( @@ -419,21 +419,21 @@ - printer.pageLayout().fullRectPixels(printer.resolution()).y() ) marginY = ( - Preferences.getPrinter("TopMargin") * int(printer.resolution() / 2.54) + int(Preferences.getPrinter("TopMargin") * printer.resolution() / 2.54) - marginY ) width = ( printer.width() - marginX - - Preferences.getPrinter("RightMargin") * int(printer.resolution() / 2.54) + - int(Preferences.getPrinter("RightMargin") * printer.resolution() / 2.54) ) height = ( printer.height() - fontHeight - 4 - marginY - - Preferences.getPrinter("BottomMargin") * int(printer.resolution() / 2.54) + - int(Preferences.getPrinter("BottomMargin") * printer.resolution() / 2.54) ) # write a foot note
--- a/src/eric7/Graphics/UMLGraphicsView.py Thu Sep 05 17:07:25 2024 +0200 +++ b/src/eric7/Graphics/UMLGraphicsView.py Fri Sep 06 14:33:48 2024 +0200 @@ -393,7 +393,7 @@ if not res: return - success = super().saveImage(str(fpath), fpath.suffix.upper()) + success = super().saveImage(str(fpath), fpath.suffix.upper()[1:]) if not success: EricMessageBox.critical( self,