8#include <private/qprintengine_win_p.h>
11#include <qpa/qplatformnativeinterface.h>
40 memset(&psd, 0,
sizeof(PAGESETUPDLG));
41 psd.lStructSize =
sizeof(PAGESETUPDLG);
44 HGLOBAL hDevMode =
nullptr;
46 if (!
engine->globalDevMode()) {
47 devModeSize =
sizeof(DEVMODE) + ep->
devMode->dmDriverExtra;
48 hDevMode = GlobalAlloc(GHND, devModeSize);
50 void *dest = GlobalLock(hDevMode);
51 memcpy(dest, ep->
devMode, devModeSize);
52 GlobalUnlock(hDevMode);
54 psd.hDevMode = hDevMode;
56 psd.hDevMode =
engine->globalDevMode();
59 HGLOBAL *tempDevNames =
engine->createGlobalDevNames();
60 psd.hDevNames = tempDevNames;
67 psd.hwndOwner = parentWindow
70 psd.Flags = PSD_MARGINS;
84 qreal multiplier = 1.0;
86 psd.Flags |= PSD_INHUNDREDTHSOFMILLIMETERS;
89 psd.Flags |= PSD_INTHOUSANDTHSOFINCHES;
92 psd.rtMargin.left =
layout.margins().left() * multiplier;
93 psd.rtMargin.top =
layout.margins().top() * multiplier;
94 psd.rtMargin.right =
layout.margins().right() * multiplier;
95 psd.rtMargin.bottom =
layout.margins().bottom() * multiplier;
98 bool result = PageSetupDlg(&psd);
101 engine->setGlobalDevMode(psd.hDevNames, psd.hDevMode);
105 DEVMODE *rDevmode =
reinterpret_cast<DEVMODE*
>(GlobalLock(psd.hDevMode));
106 if (rDevmode->dmFields & DM_ORIENTATION) {
107 layout.setOrientation(rDevmode->dmOrientation == DMORIENT_PORTRAIT
110 if (rDevmode->dmFields & DM_PAPERSIZE)
112 GlobalUnlock(rDevmode);
116 QSizeF unitSize(psd.ptPaperSize.x / multiplier, psd.ptPaperSize.y / multiplier);
117 if (unitSize.width() > unitSize.height()) {
119 unitSize.transpose();
128 const QMarginsF margins(psd.rtMargin.left, psd.rtMargin.top, psd.rtMargin.right, psd.rtMargin.bottom);
130 d->printer->setPageLayout(
layout);
133 if (!
engine->globalDevMode() && hDevMode) {
137 ep->
devMode =
reinterpret_cast<DEVMODE *
>(malloc(devModeSize));
142 void *
src = GlobalLock(hDevMode);
144 GlobalUnlock(hDevMode);
148 if (!
engine->globalDevMode() && hDevMode)
149 GlobalFree(hDevMode);
150 GlobalFree(tempDevNames);
static QWidget * activeWindow()
Returns the application top-level window that has the keyboard input focus, or \nullptr if no applica...
static QString translate(const char *context, const char *key, const char *disambiguation=nullptr, int n=-1)
\threadsafe
The QDialog class is the base class of dialog windows.
int result() const
In general returns the modal dialog's result code, Accepted or Rejected.
void setVisible(bool visible) override
\reimp
static QPlatformNativeInterface * platformNativeInterface()
static QLocale system()
Returns a QLocale object initialized to the system locale.
QObject * parent() const
Returns a pointer to the parent object.
QScopedPointer< QObjectData > d_ptr
The QPageSetupDialog class provides a configuration dialog for the page-related options on a printer.
QPageSetupDialog(QPrinter *printer, QWidget *parent=nullptr)
Constructs a page setup dialog that configures printer with parent as the parent widget.
int exec() override
This virtual function is called to pop up the dialog.
bool isValid() const
Returns true if this page size is valid.
PageSizeId id() const
Returns the standard QPageSize::PageSizeId of the page, or QPageSize::Custom.
T * data() const noexcept
Returns the value of the pointer referenced by this object.
static void initializeDevMode(DEVMODE *)
Combined button and popup list for selecting options.
app setAttribute(Qt::AA_DontShowIconsInMenus)