printing: Make sure window modality works with native print dialogs
Make the native QPrintDialogs and QPageSetupDialogs participate in the Qt modality system. Even though we are overriding QDialog::setVisible() and exec() to show the native dialgos, we want to still call into QDialog::setVisible() so that modality state and events are properly handled. We do this by setting the WA_DontShowOnScreen attribute on QPrintDialog and QPageSetupDialog, and call QDialog::setVisible() at the appropriate places. Change-Id: I7d800790c40ba1f467c3315e29abb79a7fa0eb34 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>bb10
parent
3867641d78
commit
f7674d8122
|
|
@ -155,11 +155,15 @@ void QPageSetupDialogPrivate::closeCocoaPageLayout()
|
|||
|
||||
QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent)
|
||||
: QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), printer, parent)
|
||||
{ }
|
||||
{
|
||||
setAttribute(Qt::WA_DontShowOnScreen);
|
||||
}
|
||||
|
||||
QPageSetupDialog::QPageSetupDialog(QWidget *parent)
|
||||
: QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), 0, parent)
|
||||
{ }
|
||||
{
|
||||
setAttribute(Qt::WA_DontShowOnScreen);
|
||||
}
|
||||
|
||||
void QPageSetupDialog::setVisible(bool visible)
|
||||
{
|
||||
|
|
@ -172,6 +176,8 @@ void QPageSetupDialog::setVisible(bool visible)
|
|||
if (!visible == !isCurrentlyVisible)
|
||||
return;
|
||||
|
||||
QDialog::setVisible(visible);
|
||||
|
||||
if (visible) {
|
||||
d->openCocoaPageLayout(parentWidget() ? Qt::WindowModal
|
||||
: Qt::ApplicationModal);
|
||||
|
|
@ -191,10 +197,15 @@ int QPageSetupDialog::exec()
|
|||
if (d->printer->outputFormat() != QPrinter::NativeFormat)
|
||||
return Rejected;
|
||||
|
||||
QDialog::setVisible(true);
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
d->openCocoaPageLayout(Qt::ApplicationModal);
|
||||
d->closeCocoaPageLayout();
|
||||
[pool release];
|
||||
|
||||
QDialog::setVisible(false);
|
||||
|
||||
return result();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -58,11 +58,13 @@ class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate
|
|||
QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent)
|
||||
: QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), printer, parent)
|
||||
{
|
||||
setAttribute(Qt::WA_DontShowOnScreen);
|
||||
}
|
||||
|
||||
QPageSetupDialog::QPageSetupDialog(QWidget *parent)
|
||||
: QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), 0, parent)
|
||||
{
|
||||
setAttribute(Qt::WA_DontShowOnScreen);
|
||||
}
|
||||
|
||||
int QPageSetupDialog::exec()
|
||||
|
|
@ -124,7 +126,9 @@ int QPageSetupDialog::exec()
|
|||
psd.rtMargin.right = marginRect.width() / multiplier;;
|
||||
psd.rtMargin.bottom = marginRect.height() / multiplier;;
|
||||
|
||||
QDialog::setVisible(true);
|
||||
bool result = PageSetupDlg(&psd);
|
||||
QDialog::setVisible(false);
|
||||
if (result) {
|
||||
ep->readDevnames(psd.hDevNames);
|
||||
ep->readDevmode(psd.hDevMode);
|
||||
|
|
|
|||
|
|
@ -243,6 +243,7 @@ QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)
|
|||
Q_D(QPrintDialog);
|
||||
if (!warnIfNotNative(d->printer))
|
||||
return;
|
||||
setAttribute(Qt::WA_DontShowOnScreen);
|
||||
}
|
||||
|
||||
QPrintDialog::QPrintDialog(QWidget *parent)
|
||||
|
|
@ -251,6 +252,7 @@ QPrintDialog::QPrintDialog(QWidget *parent)
|
|||
Q_D(QPrintDialog);
|
||||
if (!warnIfNotNative(d->printer))
|
||||
return;
|
||||
setAttribute(Qt::WA_DontShowOnScreen);
|
||||
}
|
||||
|
||||
QPrintDialog::~QPrintDialog()
|
||||
|
|
@ -263,10 +265,15 @@ int QPrintDialog::exec()
|
|||
if (!warnIfNotNative(d->printer))
|
||||
return QDialog::Rejected;
|
||||
|
||||
QDialog::setVisible(true);
|
||||
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
d->openCocoaPrintPanel(Qt::ApplicationModal);
|
||||
d->closeCocoaPrintPanel();
|
||||
[pool release];
|
||||
|
||||
QDialog::setVisible(false);
|
||||
|
||||
return result();
|
||||
}
|
||||
|
||||
|
|
@ -286,6 +293,8 @@ void QPrintDialog::setVisible(bool visible)
|
|||
if (d->printer->outputFormat() != QPrinter::NativeFormat)
|
||||
return;
|
||||
|
||||
QDialog::setVisible(visible);
|
||||
|
||||
if (visible) {
|
||||
d->openCocoaPrintPanel(parentWidget() ? Qt::WindowModal
|
||||
: Qt::ApplicationModal);
|
||||
|
|
|
|||
|
|
@ -193,6 +193,7 @@ QPrintDialog::QPrintDialog(QPrinter *printer, QWidget *parent)
|
|||
if (!warnIfNotNative(d->printer))
|
||||
return;
|
||||
d->ep = static_cast<QWin32PrintEngine *>(d->printer->paintEngine())->d_func();
|
||||
setAttribute(Qt::WA_DontShowOnScreen);
|
||||
}
|
||||
|
||||
QPrintDialog::QPrintDialog(QWidget *parent)
|
||||
|
|
@ -202,6 +203,7 @@ QPrintDialog::QPrintDialog(QWidget *parent)
|
|||
if (!warnIfNotNative(d->printer))
|
||||
return;
|
||||
d->ep = static_cast<QWin32PrintEngine *>(d->printer->paintEngine())->d_func();
|
||||
setAttribute(Qt::WA_DontShowOnScreen);
|
||||
}
|
||||
|
||||
QPrintDialog::~QPrintDialog()
|
||||
|
|
@ -230,10 +232,7 @@ int QPrintDialogPrivate::openWindowsPrintDialogModally()
|
|||
if (parent == 0)
|
||||
parent = q;
|
||||
|
||||
QWidget modal_widget;
|
||||
modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true);
|
||||
modal_widget.setParent(parent, Qt::Window);
|
||||
QApplicationPrivate::enterModal(&modal_widget);
|
||||
q->QDialog::setVisible(true);
|
||||
|
||||
HGLOBAL *tempDevNames = ep->createDevNames();
|
||||
|
||||
|
|
@ -274,7 +273,7 @@ int QPrintDialogPrivate::openWindowsPrintDialogModally()
|
|||
}
|
||||
} while (!done);
|
||||
|
||||
QApplicationPrivate::leaveModal(&modal_widget);
|
||||
q->QDialog::setVisible(false);
|
||||
|
||||
// qt_win_eatMouseMove();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue