1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
7 ** This file is part of the QtGui module of the Qt Toolkit. |
8 ** |
8 ** |
205 QAction *overviewModeAction; |
205 QAction *overviewModeAction; |
206 |
206 |
207 QActionGroup *printerGroup; |
207 QActionGroup *printerGroup; |
208 QAction *printAction; |
208 QAction *printAction; |
209 QAction *pageSetupAction; |
209 QAction *pageSetupAction; |
|
210 #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) |
|
211 QAction *closeAction; |
|
212 #endif |
210 |
213 |
211 QPointer<QObject> receiverToDisconnectOnClose; |
214 QPointer<QObject> receiverToDisconnectOnClose; |
212 QByteArray memberToDisconnectOnClose; |
215 QByteArray memberToDisconnectOnClose; |
213 }; |
216 }; |
214 |
217 |
268 // aligned in all styles - the extra QVBoxLayout is a workaround |
271 // aligned in all styles - the extra QVBoxLayout is a workaround |
269 // for bug in QFormLayout |
272 // for bug in QFormLayout |
270 QWidget *pageEdit = new QWidget(toolbar); |
273 QWidget *pageEdit = new QWidget(toolbar); |
271 QVBoxLayout *vboxLayout = new QVBoxLayout; |
274 QVBoxLayout *vboxLayout = new QVBoxLayout; |
272 vboxLayout->setContentsMargins(0, 0, 0, 0); |
275 vboxLayout->setContentsMargins(0, 0, 0, 0); |
|
276 #ifdef Q_WS_MAC |
|
277 // We query the widgets about their size and then we fix the size. |
|
278 // This should do the trick for the laying out part... |
|
279 QSize pageNumEditSize, pageNumLabelSize; |
|
280 pageNumEditSize = pageNumEdit->minimumSizeHint(); |
|
281 pageNumLabelSize = pageNumLabel->minimumSizeHint(); |
|
282 pageNumEdit->resize(pageNumEditSize); |
|
283 pageNumLabel->resize(pageNumLabelSize); |
|
284 #endif |
273 QFormLayout *formLayout = new QFormLayout; |
285 QFormLayout *formLayout = new QFormLayout; |
|
286 #ifdef Q_WS_MAC |
|
287 // We have to change the growth policy in Mac. |
|
288 formLayout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); |
|
289 #endif |
274 formLayout->setWidget(0, QFormLayout::LabelRole, pageNumEdit); |
290 formLayout->setWidget(0, QFormLayout::LabelRole, pageNumEdit); |
275 formLayout->setWidget(0, QFormLayout::FieldRole, pageNumLabel); |
291 formLayout->setWidget(0, QFormLayout::FieldRole, pageNumLabel); |
276 vboxLayout->addLayout(formLayout); |
292 vboxLayout->addLayout(formLayout); |
277 vboxLayout->setAlignment(Qt::AlignVCenter); |
293 vboxLayout->setAlignment(Qt::AlignVCenter); |
278 pageEdit->setLayout(vboxLayout); |
294 pageEdit->setLayout(vboxLayout); |
285 toolbar->addAction(facingModeAction); |
301 toolbar->addAction(facingModeAction); |
286 toolbar->addAction(overviewModeAction); |
302 toolbar->addAction(overviewModeAction); |
287 toolbar->addSeparator(); |
303 toolbar->addSeparator(); |
288 toolbar->addAction(pageSetupAction); |
304 toolbar->addAction(pageSetupAction); |
289 toolbar->addAction(printAction); |
305 toolbar->addAction(printAction); |
|
306 #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) |
|
307 toolbar->addAction(closeAction); |
|
308 #endif |
290 |
309 |
291 // Cannot use the actions' triggered signal here, since it doesn't autorepeat |
310 // Cannot use the actions' triggered signal here, since it doesn't autorepeat |
292 QToolButton *zoomInButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomInAction)); |
311 QToolButton *zoomInButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomInAction)); |
293 QToolButton *zoomOutButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomOutAction)); |
312 QToolButton *zoomOutButton = static_cast<QToolButton *>(toolbar->widgetForAction(zoomOutAction)); |
294 zoomInButton->setAutoRepeat(true); |
313 zoomInButton->setAutoRepeat(true); |
404 pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup")); |
423 pageSetupAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Page setup")); |
405 qt_setupActionIcon(printAction, QLatin1String("print")); |
424 qt_setupActionIcon(printAction, QLatin1String("print")); |
406 qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup")); |
425 qt_setupActionIcon(pageSetupAction, QLatin1String("page-setup")); |
407 QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print())); |
426 QObject::connect(printAction, SIGNAL(triggered(bool)), q, SLOT(_q_print())); |
408 QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup())); |
427 QObject::connect(pageSetupAction, SIGNAL(triggered(bool)), q, SLOT(_q_pageSetup())); |
|
428 #if defined(Q_WS_MAC) && !defined(QT_MAC_USE_COCOA) |
|
429 closeAction = printerGroup->addAction(QCoreApplication::translate("QPrintPreviewDialog", "Close")); |
|
430 QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(reject())); |
|
431 #endif |
409 |
432 |
410 // Initial state: |
433 // Initial state: |
411 fitPageAction->setChecked(true); |
434 fitPageAction->setChecked(true); |
412 singleModeAction->setChecked(true); |
435 singleModeAction->setChecked(true); |
413 if (preview->orientation() == QPrinter::Portrait) |
436 if (preview->orientation() == QPrinter::Portrait) |