print: Use transient parent for native print dialog if provided
Change-Id: I6703784d57dab732e5d501cec0d1231b564a065e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit beeb531c3200b64cc46234e9fa4dcdac6eadae2c) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
9254bc610c
commit
3e3bb98eb6
@ -42,7 +42,7 @@ public:
|
|||||||
QWin32PrintEnginePrivate *ep;
|
QWin32PrintEnginePrivate *ep;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWidget *parent,
|
static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWindow *parentWindow,
|
||||||
QPrintDialog *pdlg,
|
QPrintDialog *pdlg,
|
||||||
QPrintDialogPrivate *d, HGLOBAL *tempDevNames)
|
QPrintDialogPrivate *d, HGLOBAL *tempDevNames)
|
||||||
{
|
{
|
||||||
@ -101,8 +101,6 @@ static void qt_win_setup_PRINTDLGEX(PRINTDLGEX *pd, QWidget *parent,
|
|||||||
|
|
||||||
if (d->ep->printToFile)
|
if (d->ep->printToFile)
|
||||||
pd->Flags |= PD_PRINTTOFILE;
|
pd->Flags |= PD_PRINTTOFILE;
|
||||||
Q_ASSERT(parent);
|
|
||||||
QWindow *parentWindow = parent->windowHandle();
|
|
||||||
pd->hwndOwner = parentWindow ? (HWND)QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", parentWindow) : 0;
|
pd->hwndOwner = parentWindow ? (HWND)QGuiApplication::platformNativeInterface()->nativeResourceForWindow("handle", parentWindow) : 0;
|
||||||
pd->lpPageRanges[0].nFromPage = qMax(pdlg->fromPage(), pdlg->minPage());
|
pd->lpPageRanges[0].nFromPage = qMax(pdlg->fromPage(), pdlg->minPage());
|
||||||
pd->lpPageRanges[0].nToPage = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1;
|
pd->lpPageRanges[0].nToPage = (pdlg->toPage() > 0) ? qMin(pdlg->toPage(), pdlg->maxPage()) : 1;
|
||||||
@ -182,15 +180,20 @@ int QPrintDialog::exec()
|
|||||||
int QPrintDialogPrivate::openWindowsPrintDialogModally()
|
int QPrintDialogPrivate::openWindowsPrintDialogModally()
|
||||||
{
|
{
|
||||||
Q_Q(QPrintDialog);
|
Q_Q(QPrintDialog);
|
||||||
QWidget *parent = q->parentWidget();
|
QWindow *parentWindow = q->windowHandle() ? q->windowHandle()->transientParent() : nullptr;
|
||||||
if (parent)
|
if (!parentWindow) {
|
||||||
parent = parent->window();
|
QWidget *parent = q->parentWidget();
|
||||||
else
|
if (parent)
|
||||||
parent = QApplication::activeWindow();
|
parent = parent->window();
|
||||||
|
else
|
||||||
|
parent = QApplication::activeWindow();
|
||||||
|
|
||||||
// If there is no window, fall back to the print dialog itself
|
// If there is no window, fall back to the print dialog itself
|
||||||
if (parent == 0)
|
if (!parent)
|
||||||
parent = q;
|
parent = q;
|
||||||
|
|
||||||
|
parentWindow = parent->windowHandle();
|
||||||
|
}
|
||||||
|
|
||||||
q->QDialog::setVisible(true);
|
q->QDialog::setVisible(true);
|
||||||
|
|
||||||
@ -205,7 +208,7 @@ int QPrintDialogPrivate::openWindowsPrintDialogModally()
|
|||||||
memset(&pd, 0, sizeof(PRINTDLGEX));
|
memset(&pd, 0, sizeof(PRINTDLGEX));
|
||||||
pd.lStructSize = sizeof(PRINTDLGEX);
|
pd.lStructSize = sizeof(PRINTDLGEX);
|
||||||
pd.lpPageRanges = &pageRange;
|
pd.lpPageRanges = &pageRange;
|
||||||
qt_win_setup_PRINTDLGEX(&pd, parent, q, this, tempDevNames);
|
qt_win_setup_PRINTDLGEX(&pd, parentWindow, q, this, tempDevNames);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
done = true;
|
done = true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user