From 54b899f44877d87f6118b1bab02fb67c35d738e8 Mon Sep 17 00:00:00 2001 From: John Layt Date: Sun, 20 May 2012 22:38:28 +0100 Subject: SIC: QtPrintSupport - Remove QAbstractPageSetupDialog QAbstractPageSetupDialog is a completely unnecessary base class that is not really abstract and is used nowhere else. This changes merges its methods into the QPageSetupDialog main class. While technically SIC no-one else uses this so no apps should be affected. Change-Id: I59b1739f1c453c34c25d1664d5d042e7918db316 Reviewed-by: Lars Knoll --- src/printsupport/dialogs/dialogs.pri | 4 +- .../dialogs/qabstractpagesetupdialog.cpp | 138 --------------------- .../dialogs/qabstractpagesetupdialog.h | 82 ------------ .../dialogs/qabstractpagesetupdialog_p.h | 88 ------------- src/printsupport/dialogs/qpagesetupdialog.cpp | 76 +++++++++++- src/printsupport/dialogs/qpagesetupdialog.h | 11 +- src/printsupport/dialogs/qpagesetupdialog_mac.mm | 32 ++--- src/printsupport/dialogs/qpagesetupdialog_p.h | 89 +++++++++++++ src/printsupport/dialogs/qpagesetupdialog_unix.cpp | 38 +++--- src/printsupport/dialogs/qpagesetupdialog_win.cpp | 12 +- 10 files changed, 213 insertions(+), 357 deletions(-) delete mode 100644 src/printsupport/dialogs/qabstractpagesetupdialog.cpp delete mode 100644 src/printsupport/dialogs/qabstractpagesetupdialog.h delete mode 100644 src/printsupport/dialogs/qabstractpagesetupdialog_p.h create mode 100644 src/printsupport/dialogs/qpagesetupdialog_p.h (limited to 'src/printsupport/dialogs') diff --git a/src/printsupport/dialogs/dialogs.pri b/src/printsupport/dialogs/dialogs.pri index c9acae7767..9db975e202 100644 --- a/src/printsupport/dialogs/dialogs.pri +++ b/src/printsupport/dialogs/dialogs.pri @@ -3,8 +3,7 @@ HEADERS += \ dialogs/qabstractprintdialog.h \ dialogs/qabstractprintdialog_p.h \ - dialogs/qabstractpagesetupdialog.h \ - dialogs/qabstractpagesetupdialog_p.h \ + dialogs/qpagesetupdialog_p.h \ dialogs/qpagesetupdialog.h \ dialogs/qprintdialog.h \ dialogs/qprintpreviewdialog.h @@ -34,7 +33,6 @@ INCLUDEPATH += $$PWD SOURCES += \ dialogs/qabstractprintdialog.cpp \ - dialogs/qabstractpagesetupdialog.cpp \ dialogs/qpagesetupdialog.cpp \ dialogs/qprintpreviewdialog.cpp diff --git a/src/printsupport/dialogs/qabstractpagesetupdialog.cpp b/src/printsupport/dialogs/qabstractpagesetupdialog.cpp deleted file mode 100644 index 783d0dc5fc..0000000000 --- a/src/printsupport/dialogs/qabstractpagesetupdialog.cpp +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qabstractpagesetupdialog.h" -#include "qabstractpagesetupdialog_p.h" - -#ifndef QT_NO_PRINTDIALOG - -#include -#include - -QT_BEGIN_NAMESPACE - -/*! - \internal - \class QAbstractPageSetupDialog - - \brief The QAbstractPageSetupDialog class provides a base for - implementations of page setup dialogs. -*/ - -/*! - Constructs the page setup dialog for the printer \a printer with - \a parent as parent widget. -*/ -QAbstractPageSetupDialog::QAbstractPageSetupDialog(QPrinter *printer, QWidget *parent) - : QDialog(*(new QAbstractPageSetupDialogPrivate), parent) -{ - Q_D(QAbstractPageSetupDialog); - setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup")); - d->setPrinter(printer); -} - -/*! - \internal -*/ -QAbstractPageSetupDialog::QAbstractPageSetupDialog(QAbstractPageSetupDialogPrivate &ptr, - QPrinter *printer, QWidget *parent) - : QDialog(ptr, parent) -{ - Q_D(QAbstractPageSetupDialog); - setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup")); - d->setPrinter(printer); -} - -QAbstractPageSetupDialog::~QAbstractPageSetupDialog() -{ - Q_D(QAbstractPageSetupDialog); - if (d->ownsPrinter) - delete d->printer; -} - -/*! - Returns the printer that this page setup dialog is operating on. -*/ -QPrinter *QAbstractPageSetupDialog::printer() -{ - Q_D(QAbstractPageSetupDialog); - return d->printer; -} - -void QAbstractPageSetupDialogPrivate::setPrinter(QPrinter *newPrinter) -{ - if (newPrinter) { - printer = newPrinter; - ownsPrinter = false; - } else { - printer = new QPrinter; - ownsPrinter = true; - } - if (printer->outputFormat() != QPrinter::NativeFormat && QGuiApplication::platformName() == QLatin1String("xcb")) - qWarning("QPageSetupDialog: Cannot be used on non-native printers"); -} - -/*! - \fn int QAbstractPageSetupDialog::exec() - - This virtual function is called to pop up the dialog. It must be - reimplemented in subclasses. -*/ - -/*! - \reimp -*/ -void QAbstractPageSetupDialog::done(int result) -{ - Q_D(QAbstractPageSetupDialog); - QDialog::done(result); - if (d->receiverToDisconnectOnClose) { - disconnect(this, SIGNAL(accepted()), - d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); - d->receiverToDisconnectOnClose = 0; - } - d->memberToDisconnectOnClose.clear(); - -} - -QT_END_NAMESPACE - -#endif // QT_NO_PRINTDIALOG diff --git a/src/printsupport/dialogs/qabstractpagesetupdialog.h b/src/printsupport/dialogs/qabstractpagesetupdialog.h deleted file mode 100644 index 6805db0e17..0000000000 --- a/src/printsupport/dialogs/qabstractpagesetupdialog.h +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTPAGESETUPDIALOG_H -#define QABSTRACTPAGESETUPDIALOG_H - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - - -#ifndef QT_NO_PRINTDIALOG - -class QAbstractPageSetupDialogPrivate; -class QPrinter; - -// ### QtPrintNG: merge this class with QPageSetupDialog -class Q_PRINTSUPPORT_EXPORT QAbstractPageSetupDialog : public QDialog -{ - Q_DECLARE_PRIVATE(QAbstractPageSetupDialog) - Q_OBJECT - -public: - explicit QAbstractPageSetupDialog(QPrinter *printer, QWidget *parent = 0); - QAbstractPageSetupDialog(QAbstractPageSetupDialogPrivate &ptr, - QPrinter *printer, QWidget *parent = 0); - ~QAbstractPageSetupDialog(); - - virtual int exec() = 0; - void done(int result); - - QPrinter *printer(); -}; - -#endif // QT_NO_PRINTDIALOG - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QABSTRACTPAGESETUPDIALOG_H diff --git a/src/printsupport/dialogs/qabstractpagesetupdialog_p.h b/src/printsupport/dialogs/qabstractpagesetupdialog_p.h deleted file mode 100644 index 565b03185e..0000000000 --- a/src/printsupport/dialogs/qabstractpagesetupdialog_p.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QABSTRACTPAGESETUPDIALOG_P_H -#define QABSTRACTPAGESETUPDIALOG_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// to version without notice, or even be removed. -// -// We mean it. -// -// - -#include "private/qdialog_p.h" - -#ifndef QT_NO_PRINTDIALOG - -#include "qbytearray.h" -#include "qpagesetupdialog.h" -#include "qpointer.h" - -QT_BEGIN_NAMESPACE - -class QPrinter; - -class QAbstractPageSetupDialogPrivate : public QDialogPrivate -{ - Q_DECLARE_PUBLIC(QAbstractPageSetupDialog) - -public: - QAbstractPageSetupDialogPrivate() : printer(0), ownsPrinter(false) {} - - void setPrinter(QPrinter *newPrinter); - - QPrinter *printer; - bool ownsPrinter; - QPointer receiverToDisconnectOnClose; - QByteArray memberToDisconnectOnClose; -}; - -QT_END_NAMESPACE - -#endif // QT_NO_PRINTDIALOG - -#endif // QABSTRACTPAGESETUPDIALOG_P_H diff --git a/src/printsupport/dialogs/qpagesetupdialog.cpp b/src/printsupport/dialogs/qpagesetupdialog.cpp index 404d5d9ec2..8488255872 100644 --- a/src/printsupport/dialogs/qpagesetupdialog.cpp +++ b/src/printsupport/dialogs/qpagesetupdialog.cpp @@ -39,7 +39,10 @@ ** ****************************************************************************/ -#include +#include "qpagesetupdialog.h" +#include + +#include #ifndef QT_NO_PRINTDIALOG @@ -74,6 +77,12 @@ QT_BEGIN_NAMESPACE parent as the parent widget. */ +/*! + \fn QPageSetupDialog::~QPageSetupDialog() + + Destroys the page setup dialog. +*/ + /*! \since 4.5 @@ -92,10 +101,33 @@ QT_BEGIN_NAMESPACE constructor. */ -// hack -class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate +QPageSetupDialogPrivate::QPageSetupDialogPrivate(QPrinter *prntr) : printer(0), ownsPrinter(false) { -}; + setPrinter(prntr); + init(); +} + +void QPageSetupDialogPrivate::init() +{ +} + +void QPageSetupDialogPrivate::setPrinter(QPrinter *newPrinter) +{ + if (printer && ownsPrinter) + delete printer; + + if (newPrinter) { + printer = newPrinter; + ownsPrinter = false; + } else { + printer = new QPrinter; + ownsPrinter = true; + } +#ifndef Q_WS_X11 + if (printer->outputFormat() != QPrinter::NativeFormat) + qWarning("QPageSetupDialog: Cannot be used on non-native printers"); +#endif +} /*! \overload @@ -121,6 +153,42 @@ void QPageSetupDialog::open(QObject *receiver, const char *member) */ #endif +QPageSetupDialog::~QPageSetupDialog() +{ + Q_D(QPageSetupDialog); + if (d->ownsPrinter) + delete d->printer; +} + +QPrinter *QPageSetupDialog::printer() +{ + Q_D(QPageSetupDialog); + return d->printer; +} + +/*! + \fn int QPageSetupDialog::exec() + + This virtual function is called to pop up the dialog. It must be + reimplemented in subclasses. +*/ + +/*! + \reimp +*/ +void QPageSetupDialog::done(int result) +{ + Q_D(QPageSetupDialog); + QDialog::done(result); + if (d->receiverToDisconnectOnClose) { + disconnect(this, SIGNAL(accepted()), + d->receiverToDisconnectOnClose, d->memberToDisconnectOnClose); + d->receiverToDisconnectOnClose = 0; + } + d->memberToDisconnectOnClose.clear(); + +} + QT_END_NAMESPACE #endif diff --git a/src/printsupport/dialogs/qpagesetupdialog.h b/src/printsupport/dialogs/qpagesetupdialog.h index c17008150f..1360a8df3d 100644 --- a/src/printsupport/dialogs/qpagesetupdialog.h +++ b/src/printsupport/dialogs/qpagesetupdialog.h @@ -42,7 +42,8 @@ #ifndef QPAGESETUPDIALOG_H #define QPAGESETUPDIALOG_H -#include +#include +#include QT_BEGIN_HEADER @@ -51,9 +52,10 @@ QT_BEGIN_NAMESPACE #ifndef QT_NO_PRINTDIALOG +class QPrinter; class QPageSetupDialogPrivate; -class Q_PRINTSUPPORT_EXPORT QPageSetupDialog : public QAbstractPageSetupDialog +class Q_PRINTSUPPORT_EXPORT QPageSetupDialog : public QDialog { Q_OBJECT Q_DECLARE_PRIVATE(QPageSetupDialog) @@ -61,6 +63,7 @@ class Q_PRINTSUPPORT_EXPORT QPageSetupDialog : public QAbstractPageSetupDialog public: explicit QPageSetupDialog(QPrinter *printer, QWidget *parent = 0); explicit QPageSetupDialog(QWidget *parent = 0); + virtual ~QPageSetupDialog(); #if defined(Q_OS_MAC) || defined(Q_OS_WIN) virtual void setVisible(bool visible); @@ -76,9 +79,9 @@ public: #endif void open(QObject *receiver, const char *member); -#ifdef qdoc + void done(int result); + QPrinter *printer(); -#endif }; #endif // QT_NO_PRINTDIALOG diff --git a/src/printsupport/dialogs/qpagesetupdialog_mac.mm b/src/printsupport/dialogs/qpagesetupdialog_mac.mm index 3e84423fd8..eafe7b2db9 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_mac.mm +++ b/src/printsupport/dialogs/qpagesetupdialog_mac.mm @@ -44,7 +44,7 @@ #include #include "qpagesetupdialog.h" -#include "qabstractpagesetupdialog_p.h" +#include "qpagesetupdialog_p.h" #include #include @@ -93,16 +93,16 @@ QT_USE_NAMESPACE QT_BEGIN_NAMESPACE -class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate +class QMacPageSetupDialogPrivate : public QPageSetupDialogPrivate { Q_DECLARE_PUBLIC(QPageSetupDialog) public: - QPageSetupDialogPrivate() - : printInfo(0), pageLayout(0) + QMacPageSetupDialogPrivate(QPrinter *printer) + : QPageSetupDialogPrivate(printer), printInfo(0), pageLayout(0) { } - ~QPageSetupDialogPrivate() { + ~QMacPageSetupDialogPrivate() { } void openCocoaPageLayout(Qt::WindowModality modality); @@ -112,7 +112,7 @@ public: NSPageLayout *pageLayout; }; -void QPageSetupDialogPrivate::openCocoaPageLayout(Qt::WindowModality modality) +void QMacPageSetupDialogPrivate::openCocoaPageLayout(Qt::WindowModality modality) { Q_Q(QPageSetupDialog); @@ -145,7 +145,7 @@ void QPageSetupDialogPrivate::openCocoaPageLayout(Qt::WindowModality modality) } } -void QPageSetupDialogPrivate::closeCocoaPageLayout() +void QMacPageSetupDialogPrivate::closeCocoaPageLayout() { [printInfo release]; printInfo = 0; @@ -154,14 +154,16 @@ void QPageSetupDialogPrivate::closeCocoaPageLayout() } QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent) - : QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), printer, parent) + : QDialog(*(new QMacPageSetupDialogPrivate(printer)), parent) { + setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup")); setAttribute(Qt::WA_DontShowOnScreen); } QPageSetupDialog::QPageSetupDialog(QWidget *parent) - : QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), 0, parent) + : QDialog(*(new QMacPageSetupDialogPrivate(0)), parent) { + setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup")); setAttribute(Qt::WA_DontShowOnScreen); } @@ -172,7 +174,7 @@ void QPageSetupDialog::setVisible(bool visible) if (d->printer->outputFormat() != QPrinter::NativeFormat) return; - bool isCurrentlyVisible = (d->pageLayout != 0); + bool isCurrentlyVisible = (static_cast (d)->pageLayout != 0); if (!visible == !isCurrentlyVisible) return; @@ -184,11 +186,11 @@ void QPageSetupDialog::setVisible(bool visible) // NSPrintPanels can only be modal, so we must pick a type modality = parentWidget() ? Qt::WindowModal : Qt::ApplicationModal; } - d->openCocoaPageLayout(modality); + static_cast (d)->openCocoaPageLayout(modality); return; } else { - if (d->pageLayout) { - d->closeCocoaPageLayout(); + if (static_cast (d)->pageLayout) { + static_cast (d)->closeCocoaPageLayout(); return; } } @@ -204,8 +206,8 @@ int QPageSetupDialog::exec() QDialog::setVisible(true); NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - d->openCocoaPageLayout(Qt::ApplicationModal); - d->closeCocoaPageLayout(); + static_cast (d)->openCocoaPageLayout(Qt::ApplicationModal); + static_cast (d)->closeCocoaPageLayout(); [pool release]; QDialog::setVisible(false); diff --git a/src/printsupport/dialogs/qpagesetupdialog_p.h b/src/printsupport/dialogs/qpagesetupdialog_p.h new file mode 100644 index 0000000000..9783fae97f --- /dev/null +++ b/src/printsupport/dialogs/qpagesetupdialog_p.h @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QPAGESETUPDIALOG_P_H +#define QPAGESETUPDIALOG_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// to version without notice, or even be removed. +// +// We mean it. +// +// + +#include "private/qdialog_p.h" + +#ifndef QT_NO_PRINTDIALOG + +#include "qbytearray.h" +#include "qpagesetupdialog.h" +#include "qpointer.h" + +QT_BEGIN_NAMESPACE + +class QPrinter; + +class QPageSetupDialogPrivate : public QDialogPrivate +{ + Q_DECLARE_PUBLIC(QPageSetupDialog) + +public: + QPageSetupDialogPrivate(QPrinter *printer); + + virtual void init(); + void setPrinter(QPrinter *newPrinter); + + QPrinter *printer; + bool ownsPrinter; + QPointer receiverToDisconnectOnClose; + QByteArray memberToDisconnectOnClose; +}; + +QT_END_NAMESPACE + +#endif // QT_NO_PRINTDIALOG + +#endif // QPAGESETUPDIALOG_P_H diff --git a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp index ac8338b739..fabade2d25 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_unix.cpp +++ b/src/printsupport/dialogs/qpagesetupdialog_unix.cpp @@ -50,7 +50,7 @@ #include #include -#include +#include #include #include @@ -214,12 +214,13 @@ private: }; -class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate +class QUnixPageSetupDialogPrivate : public QPageSetupDialogPrivate { Q_DECLARE_PUBLIC(QPageSetupDialog) public: - ~QPageSetupDialogPrivate(); + QUnixPageSetupDialogPrivate(QPrinter *printer); + ~QUnixPageSetupDialogPrivate(); void init(); QPageSetupWidget *widget; @@ -228,14 +229,24 @@ public: #endif }; -QPageSetupDialogPrivate::~QPageSetupDialogPrivate() +QUnixPageSetupDialogPrivate::QUnixPageSetupDialogPrivate(QPrinter *printer) : QPageSetupDialogPrivate(printer) +#if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) + , cups(0) +#endif +{ +} + +QUnixPageSetupDialogPrivate::~QUnixPageSetupDialogPrivate() { #if !defined(QT_NO_CUPS) && !defined(QT_NO_LIBRARY) - delete cups; + if (cups) { + delete cups; + cups = 0; + } #endif } -void QPageSetupDialogPrivate::init() +void QUnixPageSetupDialogPrivate::init() { Q_Q(QPageSetupDialog); @@ -584,30 +595,25 @@ void QPageSetupWidget::setRightMargin(double newValue) QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent) - : QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), printer, parent) + : QDialog(*(new QUnixPageSetupDialogPrivate(printer)), parent) { - Q_D(QPageSetupDialog); - d->init(); + setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup")); } QPageSetupDialog::QPageSetupDialog(QWidget *parent) - : QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), 0, parent) + : QDialog(*(new QUnixPageSetupDialogPrivate(0)), parent) { - Q_D(QPageSetupDialog); - d->init(); + setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup")); } -/*! - \internal -*/ int QPageSetupDialog::exec() { Q_D(QPageSetupDialog); int ret = QDialog::exec(); if (ret == Accepted) - d->widget->setupPrinter(); + static_cast (d)->widget->setupPrinter(); return ret; } diff --git a/src/printsupport/dialogs/qpagesetupdialog_win.cpp b/src/printsupport/dialogs/qpagesetupdialog_win.cpp index a10dc1ccd4..a36ebf06c5 100644 --- a/src/printsupport/dialogs/qpagesetupdialog_win.cpp +++ b/src/printsupport/dialogs/qpagesetupdialog_win.cpp @@ -45,25 +45,23 @@ #include #include "../kernel/qprintengine_win_p.h" -#include "qabstractpagesetupdialog_p.h" +#include "qpagesetupdialog_p.h" #include "qprinter.h" #include QT_BEGIN_NAMESPACE -class QPageSetupDialogPrivate : public QAbstractPageSetupDialogPrivate -{ -}; - QPageSetupDialog::QPageSetupDialog(QPrinter *printer, QWidget *parent) - : QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), printer, parent) + : QDialog(*(new QPageSetupDialogPrivate(printer)), parent) { + setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup")); setAttribute(Qt::WA_DontShowOnScreen); } QPageSetupDialog::QPageSetupDialog(QWidget *parent) - : QAbstractPageSetupDialog(*(new QPageSetupDialogPrivate), 0, parent) + : QDialog(*(new QPageSetupDialogPrivate(0)), parent) { + setWindowTitle(QCoreApplication::translate("QPrintPreviewDialog", "Page Setup")); setAttribute(Qt::WA_DontShowOnScreen); } -- cgit v1.2.3