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 <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-05-24 23:33:36 +03:00
parent 1ffa66d5c7
commit fba7f28b70
13 changed files with 31 additions and 132 deletions

View file

@ -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')

View file

@ -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();
}
}

View file

@ -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();
}

View file

@ -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<QWidget *>(d->parent)->metric(m);
else
val = QX11Info::appDpiX(scr);
break;
case PdmDpiY:
case PdmPhysicalDpiY:
if (d->parent)
val = static_cast<QWidget *>(d->parent)->metric(m);
else

View file

@ -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); }

View file

@ -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()
*/

View file

@ -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;

View file

@ -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();

View file

@ -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

View file

@ -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);

View file

@ -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;
@ -249,39 +249,6 @@ void QPrinterPrivate::addToManualSetList(QPrintEngine::PrintEnginePropertyKey ke
\value Error
*/
/*!
\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
@ -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<int> QPrinter::supportedResolutions() const
{

View file

@ -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)

View file

@ -85,7 +85,6 @@ public:
void addToManualSetList(QPrintEngine::PrintEnginePropertyKey key);
QPrinter::PrinterMode printerMode;
QPrintEngine *printEngine;
QPaintEngine *paintEngine;