From fba7f28b701182f71a5fb604c9fb82f20ae5002b Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Wed, 24 May 2023 23:33:36 +0300 Subject: [PATCH] remove redundant QPaintDevice physical DPI getters return same values as the logical getters for anything but print devices which have their own resolution option (defaulting to the application DPI) Signed-off-by: Ivailo Monev --- package/archlinux/PKGBUILD | 2 +- src/gui/image/qimage.cpp | 6 ++--- src/gui/image/qpixmapdata.cpp | 6 ++--- src/gui/kernel/qwidget_x11.cpp | 2 -- src/gui/painting/qpaintdevice.h | 6 +---- src/gui/painting/qpaintdevice.qdoc | 52 +++--------------------------------- src/gui/painting/qpdf.cpp | 13 ++------- src/gui/painting/qpdf_p.h | 3 +-- src/gui/painting/qprintengine_ps.cpp | 8 +++--- src/gui/painting/qprintengine_ps_p.h | 4 +-- src/gui/painting/qprinter.cpp | 52 +++++++----------------------------- src/gui/painting/qprinter.h | 8 +++--- src/gui/painting/qprinter_p.h | 1 - 13 files changed, 31 insertions(+), 132 deletions(-) diff --git a/package/archlinux/PKGBUILD b/package/archlinux/PKGBUILD index a10601b02..9ea9906dc 100644 --- a/package/archlinux/PKGBUILD +++ b/package/archlinux/PKGBUILD @@ -3,7 +3,7 @@ # https://wiki.archlinux.org/index.php/Arch_package_guidelines pkgname=katie-git -pkgver=4.13.0.r7921.ea280c959 +pkgver=4.13.0.r7943.1ffa66d5c pkgrel=1 pkgdesc='C++ toolkit derived from the Qt 4.8 framework' arch=('i486' 'i686' 'pentium4' 'x86_64' 'arm') diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index b90c1712e..207ef317b 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -3201,12 +3201,10 @@ int QImage::metric(PaintDeviceMetric metric) const case QPaintDevice::PdmDepth: { return d->depth; } - case QPaintDevice::PdmDpiX: - case QPaintDevice::PdmPhysicalDpiX: { + case QPaintDevice::PdmDpiX: { return QX11Info::appDpiX(); } - case QPaintDevice::PdmDpiY: - case QPaintDevice::PdmPhysicalDpiY: { + case QPaintDevice::PdmDpiY: { return QX11Info::appDpiY(); } } diff --git a/src/gui/image/qpixmapdata.cpp b/src/gui/image/qpixmapdata.cpp index 0f6f94214..310ef6a37 100644 --- a/src/gui/image/qpixmapdata.cpp +++ b/src/gui/image/qpixmapdata.cpp @@ -239,11 +239,9 @@ int QPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const return 0; case QPaintDevice::PdmDepth: return depth(); - case QPaintDevice::PdmDpiX: // fall-through - case QPaintDevice::PdmPhysicalDpiX: + case QPaintDevice::PdmDpiX: return QX11Info::appDpiX(); - case QPaintDevice::PdmDpiY: // fall-through - case QPaintDevice::PdmPhysicalDpiY: + case QPaintDevice::PdmDpiY: return QX11Info::appDpiY(); } diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 3915d7a9d..1745eae32 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -2624,14 +2624,12 @@ int QWidget::metric(PaintDeviceMetric m) const int scr = d->xinfo.screen(); switch (m) { case PdmDpiX: - case PdmPhysicalDpiX: if (d->parent) val = static_cast(d->parent)->metric(m); else val = QX11Info::appDpiX(scr); break; case PdmDpiY: - case PdmPhysicalDpiY: if (d->parent) val = static_cast(d->parent)->metric(m); else diff --git a/src/gui/painting/qpaintdevice.h b/src/gui/painting/qpaintdevice.h index 7c3a19c32..31b9732ad 100644 --- a/src/gui/painting/qpaintdevice.h +++ b/src/gui/painting/qpaintdevice.h @@ -40,9 +40,7 @@ public: PdmNumColors, PdmDepth, PdmDpiX, - PdmDpiY, - PdmPhysicalDpiX, - PdmPhysicalDpiY + PdmDpiY }; virtual ~QPaintDevice(); @@ -59,8 +57,6 @@ public: int heightMM() const { return metric(PdmHeightMM); } int logicalDpiX() const { return metric(PdmDpiX); } int logicalDpiY() const { return metric(PdmDpiY); } - int physicalDpiX() const { return metric(PdmPhysicalDpiX); } - int physicalDpiY() const { return metric(PdmPhysicalDpiY); } int colorCount() const { return metric(PdmNumColors); } int depth() const { return metric(PdmDepth); } diff --git a/src/gui/painting/qpaintdevice.qdoc b/src/gui/painting/qpaintdevice.qdoc index 8cfd829b0..2062a4ddb 100644 --- a/src/gui/painting/qpaintdevice.qdoc +++ b/src/gui/painting/qpaintdevice.qdoc @@ -58,12 +58,8 @@ The logicalDpiX() and logicalDpiY() functions return the horizontal and vertical resolution of the device in dots per - inch. The physicalDpiX() and physicalDpiY() functions also return - the resolution of the device in dots per inch, but note that if - the logical and physical resolution differ, the corresponding - QPaintEngine must handle the mapping. Finally, the colorCount() - function returns the number of different colors available for the - paint device. + inch. Finally, the colorCount() function returns the number of + different colors available for the paint device. \sa QPaintEngine, QPainter, {Coordinate System}, {Paint System} */ @@ -99,12 +95,6 @@ \value PdmDpiY The vertical resolution of the device in dots per inch. See also logicalDpiY(). - \value PdmPhysicalDpiX The horizontal resolution of the device in - dots per inch. See also physicalDpiX(). - - \value PdmPhysicalDpiY The vertical resolution of the device in - dots per inch. See also physicalDpiY(). - \sa metric() */ @@ -217,10 +207,7 @@ which is used when computing font sizes. For X11, this is usually the same as could be computed from widthMM(). - Note that if the logicalDpiX() doesn't equal the physicalDpiX(), - the corresponding QPaintEngine must handle the resolution mapping. - - \sa logicalDpiY(), physicalDpiX() + \sa logicalDpiY() */ /*! @@ -230,36 +217,5 @@ which is used when computing font sizes. For X11, this is usually the same as could be computed from heightMM(). - Note that if the logicalDpiY() doesn't equal the physicalDpiY(), - the corresponding QPaintEngine must handle the resolution mapping. - - \sa logicalDpiX(), physicalDpiY() -*/ - -/*! - \fn int QPaintDevice::physicalDpiX() const - - Returns the horizontal resolution of the device in dots per inch. - For example, when printing, this resolution refers to the physical - printer's resolution. The logical DPI on the other hand, refers to - the resolution used by the actual paint engine. - - Note that if the physicalDpiX() doesn't equal the logicalDpiX(), - the corresponding QPaintEngine must handle the resolution mapping. - - \sa physicalDpiY(), logicalDpiX() -*/ - -/*! - \fn int QPaintDevice::physicalDpiY() const - - Returns the horizontal resolution of the device in dots per inch. - For example, when printing, this resolution refers to the physical - printer's resolution. The logical DPI on the other hand, refers to - the resolution used by the actual paint engine. - - Note that if the physicalDpiY() doesn't equal the logicalDpiY(), - the corresponding QPaintEngine must handle the resolution mapping. - - \sa physicalDpiX(), logicalDpiY() + \sa logicalDpiX() */ diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 035fcdf7f..665c419d8 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1160,10 +1160,6 @@ int QPdfBaseEngine::metric(QPaintDevice::PaintDeviceMetric metricType) const case QPaintDevice::PdmDpiY: val = d->resolution; break; - case QPaintDevice::PdmPhysicalDpiX: - case QPaintDevice::PdmPhysicalDpiY: - val = 1200; - break; case QPaintDevice::PdmWidthMM: val = qRound(r.width()*25.4/d->resolution); break; @@ -1376,7 +1372,7 @@ QVariant QPdfBaseEngine::property(PrintEnginePropertyKey key) const return ret; } -QPdfBaseEnginePrivate::QPdfBaseEnginePrivate(QPrinter::PrinterMode m) +QPdfBaseEnginePrivate::QPdfBaseEnginePrivate() : clipEnabled(false), allClipped(false), hasPen(true), hasBrush(false), simplePen(false), useAlphaEngine(false), outDevice(0), fd(-1), @@ -1386,12 +1382,7 @@ QPdfBaseEnginePrivate::QPdfBaseEnginePrivate(QPrinter::PrinterMode m) hasCustomPageMargins(false), leftMargin(0), topMargin(0), rightMargin(0), bottomMargin(0) { - resolution = 72; - if (m == QPrinter::HighResolution) - resolution = 1200; - else if (m == QPrinter::ScreenResolution) - resolution = QX11Info::appDpiY(); - + resolution = QX11Info::appDpiY(); postscript = false; currentObject = 1; currentPage = 0; diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index 6c47007a5..2651246a5 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -154,7 +154,6 @@ class QPdfBaseEngine : public QAlphaPaintEngine, public QPrintEngine Q_DECLARE_PRIVATE(QPdfBaseEngine) public: QPdfBaseEngine(QPdfBaseEnginePrivate &d, PaintEngineFeatures f); - ~QPdfBaseEngine() {} // reimplementations QPaintEngine bool begin(QPaintDevice *pdev); @@ -190,7 +189,7 @@ class QPdfBaseEnginePrivate : public QAlphaPaintEnginePrivate { Q_DECLARE_PUBLIC(QPdfBaseEngine) public: - QPdfBaseEnginePrivate(QPrinter::PrinterMode m); + QPdfBaseEnginePrivate(); ~QPdfBaseEnginePrivate(); bool openPrintDevice(); diff --git a/src/gui/painting/qprintengine_ps.cpp b/src/gui/painting/qprintengine_ps.cpp index e4b28bb0f..1351c905b 100644 --- a/src/gui/painting/qprintengine_ps.cpp +++ b/src/gui/painting/qprintengine_ps.cpp @@ -142,8 +142,8 @@ static QByteArray wrapDSC(const QByteArray &str) // ----------------------------- Internal class declarations ----------------------------- -QPSPrintEnginePrivate::QPSPrintEnginePrivate(QPrinter::PrinterMode m) - : QPdfBaseEnginePrivate(m), +QPSPrintEnginePrivate::QPSPrintEnginePrivate() + : QPdfBaseEnginePrivate(), printerState(QPrinter::Idle), hugeDocument(false), headerDone(false) { useAlphaEngine = false; @@ -562,8 +562,8 @@ void QPSPrintEnginePrivate::flushPage(bool last) // ================ PSPrinter class ======================== -QPSPrintEngine::QPSPrintEngine(QPrinter::PrinterMode m) - : QPdfBaseEngine(*(new QPSPrintEnginePrivate(m)), +QPSPrintEngine::QPSPrintEngine() + : QPdfBaseEngine(*(new QPSPrintEnginePrivate()), PatternTransform | PixmapTransform | PainterPaths diff --git a/src/gui/painting/qprintengine_ps_p.h b/src/gui/painting/qprintengine_ps_p.h index 5f74a02aa..3b33bcc7e 100644 --- a/src/gui/painting/qprintengine_ps_p.h +++ b/src/gui/painting/qprintengine_ps_p.h @@ -55,7 +55,7 @@ class QPSPrintEngine : public QPdfBaseEngine Q_DECLARE_PRIVATE(QPSPrintEngine) public: // QPrinter uses these - explicit QPSPrintEngine(QPrinter::PrinterMode m); + QPSPrintEngine(); ~QPSPrintEngine(); @@ -85,7 +85,7 @@ private: class QPSPrintEnginePrivate : public QPdfBaseEnginePrivate { public: - QPSPrintEnginePrivate(QPrinter::PrinterMode m); + QPSPrintEnginePrivate(); ~QPSPrintEnginePrivate(); void emitHeader(bool finished); diff --git a/src/gui/painting/qprinter.cpp b/src/gui/painting/qprinter.cpp index 33ab4fb5a..658a7b315 100644 --- a/src/gui/painting/qprinter.cpp +++ b/src/gui/painting/qprinter.cpp @@ -125,7 +125,7 @@ QSizeF qt_printerPaperSize(QPrinter::Orientation orientation, void QPrinterPrivate::createDefaultEngines() { - QPSPrintEngine *psEngine = new QPSPrintEngine(printerMode); + QPSPrintEngine *psEngine = new QPSPrintEngine(); paintEngine = psEngine; printEngine = psEngine; use_default_engine = true; @@ -250,39 +250,6 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke */ /*! - \enum QPrinter::PrinterMode - - This enum describes the mode the printer should work in. It - basically presets a certain resolution and working mode. - - \value ScreenResolution Sets the resolution of the print device to - the screen resolution. This has the big advantage that the results - obtained when painting on the printer will match more or less - exactly the visible output on the screen. It is the easiest to - use, as font metrics on the screen and on the printer are the - same. This is the default value. ScreenResolution will produce a - lower quality output than HighResolution and should only be used - for drafts. - - \value PrinterResolution This value is deprecated. Is is - equivalent to ScreenResolution on Unix and HighResolution on - Windows and Mac. Due do the difference between ScreenResolution - and HighResolution, use of this value may lead to non-portable - printer code. - - \value HighResolution On Windows, sets the printer resolution to that - defined for the printer in use. For PostScript printing, sets the - resolution of the PostScript driver to 1200 dpi. - - \note When rendering text on a QPrinter device, it is important - to realize that the size of text, when specified in points, is - independent of the resolution specified for the device itself. - Therefore, it may be useful to specify the font size in pixels - when combining text with graphics to ensure that their relative - sizes are what you expect. -*/ - -/*! \enum QPrinter::Orientation This enum type (not to be confused with \c Orientation) is used @@ -491,13 +458,13 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke */ /*! - Creates a new printer object with the given \a mode. + Creates a new printer object. */ -QPrinter::QPrinter(PrinterMode mode) +QPrinter::QPrinter() : QPaintDevice(), d_ptr(new QPrinterPrivate(this)) { - init(mode); + init(); QPrinterInfo defPrn(QPrinterInfo::defaultPrinter()); if (!defPrn.isNull()) { setPrinterName(defPrn.printerName()); @@ -507,17 +474,17 @@ QPrinter::QPrinter(PrinterMode mode) /*! \since 4.4 - Creates a new printer object with the given \a printer and \a mode. + Creates a new printer object with the given \a printer. */ -QPrinter::QPrinter(const QPrinterInfo& printer, PrinterMode mode) +QPrinter::QPrinter(const QPrinterInfo& printer) : QPaintDevice(), d_ptr(new QPrinterPrivate(this)) { - init(mode); + init(); setPrinterName(printer.printerName()); } -void QPrinter::init(PrinterMode mode) +void QPrinter::init() { if (Q_UNLIKELY(!qApp || QApplication::type() != QApplication::Gui)) { qFatal("QPrinter: Must construct a QApplication before a QPaintDevice"); @@ -525,7 +492,6 @@ void QPrinter::init(PrinterMode mode) } Q_D(QPrinter); - d->printerMode = mode; d->createDefaultEngines(); #ifndef QT_NO_PRINTPREVIEWWIDGET @@ -1428,7 +1394,7 @@ QPrintEngine *QPrinter::printEngine() const For X11 where all printing is directly to postscript, this function will always return a one item list containing only the - postscript resolution, i.e., 72 (72 dpi -- but see PrinterMode). + postscript resolution, i.e., 72 (72 dpi). */ QList QPrinter::supportedResolutions() const { diff --git a/src/gui/painting/qprinter.h b/src/gui/painting/qprinter.h index e4430548a..714c41ebf 100644 --- a/src/gui/painting/qprinter.h +++ b/src/gui/painting/qprinter.h @@ -46,10 +46,8 @@ class Q_GUI_EXPORT QPrinter : public QPaintDevice { Q_DECLARE_PRIVATE(QPrinter) public: - enum PrinterMode { ScreenResolution, PrinterResolution, HighResolution }; - - explicit QPrinter(PrinterMode mode = ScreenResolution); - explicit QPrinter(const QPrinterInfo& printer, PrinterMode mode = ScreenResolution); + QPrinter(); + explicit QPrinter(const QPrinterInfo& printer); ~QPrinter(); int devType() const; @@ -202,7 +200,7 @@ protected: void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine); private: - void init(PrinterMode mode); + void init(); Q_DISABLE_COPY(QPrinter) diff --git a/src/gui/painting/qprinter_p.h b/src/gui/painting/qprinter_p.h index 5f7daa627..746b6f3c9 100644 --- a/src/gui/painting/qprinter_p.h +++ b/src/gui/painting/qprinter_p.h @@ -85,7 +85,6 @@ public: void addToManualSetList(QPrintEngine::PrintEnginePropertyKey key); - QPrinter::PrinterMode printerMode; QPrintEngine *printEngine; QPaintEngine *paintEngine; -- 2.11.0