Browse Source

plugins: revealer: fix following qt6 migration

follow-up https://github.com/spesmilo/electrum/issues/8007
master
SomberNight 1 year ago
parent
commit
4b6c7af9b0
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 15
      electrum/plugins/revealer/qt.py

15
electrum/plugins/revealer/qt.py

@ -25,7 +25,7 @@ import qrcode
from PyQt6.QtPrintSupport import QPrinter from PyQt6.QtPrintSupport import QPrinter
from PyQt6.QtCore import Qt, QRectF, QRect, QSizeF, QUrl, QPoint, QSize, QMarginsF from PyQt6.QtCore import Qt, QRectF, QRect, QSizeF, QUrl, QPoint, QSize, QMarginsF
from PyQt6.QtGui import (QPixmap, QImage, QBitmap, QPainter, QFontDatabase, QPen, QFont, from PyQt6.QtGui import (QPixmap, QImage, QBitmap, QPainter, QFontDatabase, QPen, QFont,
QColor, QDesktopServices, qRgba, QPainterPath, QPageSize) QColor, QDesktopServices, qRgba, QPainterPath, QPageSize, QPageLayout)
from PyQt6.QtWidgets import (QGridLayout, QVBoxLayout, QHBoxLayout, QLabel, from PyQt6.QtWidgets import (QGridLayout, QVBoxLayout, QHBoxLayout, QLabel,
QPushButton, QLineEdit) QPushButton, QLineEdit)
@ -495,7 +495,7 @@ class Plugin(RevealerPlugin):
img = img.convertToFormat(QImage.Format.Format_Mono) img = img.convertToFormat(QImage.Format.Format_Mono)
p = QPainter() p = QPainter()
p.begin(img) p.begin(img)
p.setCompositionMode(26) #xor p.setCompositionMode(QPainter.CompositionMode.RasterOp_SourceXorDestination) #xor
p.drawImage(0, 0, rawnoise) p.drawImage(0, 0, rawnoise)
p.end() p.end()
cypherseed = self.pixelcode_2x2(img) cypherseed = self.pixelcode_2x2(img)
@ -531,11 +531,11 @@ class Plugin(RevealerPlugin):
def toPdf(self, image): def toPdf(self, image):
printer = QPrinter() printer = QPrinter()
printer.setPageSize(QPageSize(QSizeF(210, 297), QPrinter.Unit.Millimeter)) printer.setPageSize(QPageSize(QSizeF(210, 297), QPageSize.Unit.Millimeter))
printer.setResolution(600) printer.setResolution(600)
printer.setOutputFormat(QPrinter.OutputFormat.PdfFormat) printer.setOutputFormat(QPrinter.OutputFormat.PdfFormat)
printer.setOutputFileName(self.get_path_to_revealer_file('.pdf')) printer.setOutputFileName(self.get_path_to_revealer_file('.pdf'))
printer.setPageMargins(QMarginsF(0, 0, 0, 0), QPrinter.Unit.DevicePixel) printer.setPageMargins(QMarginsF(0, 0, 0, 0), QPageLayout.Unit.Millimeter)
painter = QPainter() painter = QPainter()
painter.begin(printer) painter.begin(printer)
@ -556,11 +556,11 @@ class Plugin(RevealerPlugin):
def calibration_pdf(self, image): def calibration_pdf(self, image):
printer = QPrinter() printer = QPrinter()
printer.setPageSize(QPageSize(QSizeF(210, 297), QPrinter.Unit.Millimeter)) printer.setPageSize(QPageSize(QSizeF(210, 297), QPageSize.Unit.Millimeter))
printer.setResolution(600) printer.setResolution(600)
printer.setOutputFormat(QPrinter.OutputFormat.PdfFormat) printer.setOutputFormat(QPrinter.OutputFormat.PdfFormat)
printer.setOutputFileName(self.get_path_to_calibration_file()) printer.setOutputFileName(self.get_path_to_calibration_file())
printer.setPageMargins(QMarginsF(0, 0, 0, 0), QPrinter.Unit.DevicePixel) printer.setPageMargins(QMarginsF(0, 0, 0, 0), QPageLayout.Unit.Millimeter)
painter = QPainter() painter = QPainter()
painter.begin(printer) painter.begin(printer)
@ -609,6 +609,7 @@ class Plugin(RevealerPlugin):
img = QImage(img) img = QImage(img)
painter = QPainter() painter = QPainter()
painter.setRenderHint(QPainter.RenderHint.SmoothPixmapTransform)
painter.begin(base_img) painter.begin(base_img)
total_distance_h = round(base_img.width() / self.abstand_v) total_distance_h = round(base_img.width() / self.abstand_v)
@ -701,7 +702,7 @@ class Plugin(RevealerPlugin):
painter.drawLine(0, base_img.height()-dist_v, base_img.width(), base_img.height()-(dist_v)) painter.drawLine(0, base_img.height()-dist_v, base_img.width(), base_img.height()-(dist_v))
painter.drawLine(base_img.width()-(dist_h), 0, base_img.width()-(dist_h), base_img.height()) painter.drawLine(base_img.width()-(dist_h), 0, base_img.width()-(dist_h), base_img.height())
logo = QImage(internal_plugin_icon_path(self.name, 'revealer_c.png')).scaledToWidth(round(1.3*(total_distance_h))) logo = QImage(internal_plugin_icon_path(self.name, 'revealer_c.png')).scaledToWidth(round(1.3*(total_distance_h)))
painter.drawImage(int(total_distance_h+border_thick), int(total_distance_h+border_thick), logo, Qt.TransformationMode.SmoothTransformation) painter.drawImage(int(total_distance_h+border_thick), int(total_distance_h+border_thick), logo)
#frame around logo #frame around logo
painter.setPen(QPen(Qt.GlobalColor.black, border_thick)) painter.setPen(QPen(Qt.GlobalColor.black, border_thick))

Loading…
Cancel
Save