6#include <private/qprinter_p.h>
9#include <QtGui/qaction.h>
10#include <QtGui/qactiongroup.h>
11#include <QtWidgets/qboxlayout.h>
12#include <QtWidgets/qcombobox.h>
13#include <QtWidgets/qlineedit.h>
14#include <QtPrintSupport/qpagesetupdialog.h>
15#include <QtPrintSupport/qprinter.h>
16#include <QtWidgets/qstyle.h>
17#include <QtWidgets/qtoolbutton.h>
18#include <QtGui/qvalidator.h>
19#if QT_CONFIG(filedialog)
20#include <QtWidgets/qfiledialog.h>
22#include <QtWidgets/qmainwindow.h>
23#include <QtWidgets/qtoolbar.h>
24#include <QtCore/QCoreApplication>
26#include "private/qdialog_p.h"
28#include <QtWidgets/qformlayout.h>
29#include <QtWidgets/qlabel.h>
31#include <QtCore/qpointer.h>
35 static bool resourcesInitialized =
false;
36 if (!resourcesInitialized) {
38 resourcesInitialized =
true;
51 QMenu *createPopupMenu()
override {
return nullptr; }
57 ZoomFactorValidator(
QObject* parent)
64 bool replacePercent =
false;
65 if (
input.endsWith(u
'%')) {
67 replacePercent =
true;
72 const int num_size = 4;
73 if (
state == Intermediate) {
75 if ((
i == -1 &&
input.size() > num_size)
76 || (
i != -1 &&
i > num_size))
87 LineEdit(
QWidget* parent =
nullptr)
91 connect(
this, &LineEdit::returnPressed,
this, &LineEdit::handleReturnPressed);
103 if (isModified() && !hasAcceptableInput())
109 void handleReturnPressed()
221 LineEdit *zoomEditor =
new LineEdit;
222 zoomEditor->setValidator(
new ZoomFactorValidator(1, 1000, 1, zoomEditor));
224 static const short factorsX2[] = { 25, 50, 100, 200, 250, 300, 400, 800, 1600 };
225 for (
auto factorX2 : factorsX2)
232 QPrintPreviewMainWindow *mw =
new QPrintPreviewMainWindow(
q);
256 QSize pageNumEditSize, pageNumLabelSize;
271 pageEdit->setLayout(vboxLayout);
288 zoomInButton->setAutoRepeatInterval(200);
289 zoomInButton->setAutoRepeatDelay(200);
290 zoomOutButton->setAutoRepeat(
true);
291 zoomOutButton->setAutoRepeatInterval(200);
292 zoomOutButton->setAutoRepeatDelay(200);
296 mw->addToolBar(toolbar);
304 topLayout->setContentsMargins(0, 0, 0, 0);
305 q->setLayout(topLayout);
310 q->setWindowTitle(caption);
313#
if defined(Q_OS_WIN) || defined(Q_OS_MAC)
323 const auto imagePrefix =
":/qt-project.org/dialogs/qprintpreviewdialog/images/"_L1;
457 int cyphersWidth =
q->fontMetrics().horizontalAdvance(
QString().
fill(u
'8', maxChars));
542#if defined(Q_OS_WIN) || defined(Q_OS_MAC)
547#if QT_CONFIG(filedialog)
686 delete d->printDialog;
687 delete d->pageSetupDialog;
698 d->preview->updatePreview();
699 d->initialized =
true;
711 if (
d->receiverToDisconnectOnClose) {
713 d->receiverToDisconnectOnClose,
d->memberToDisconnectOnClose);
714 d->receiverToDisconnectOnClose =
nullptr;
716 d->memberToDisconnectOnClose.clear();
734 d->receiverToDisconnectOnClose = receiver;
735 d->memberToDisconnectOnClose = member;
763#include "moc_qprintpreviewdialog.cpp"
764#include "qprintpreviewdialog.moc"
The QActionGroup class groups actions together.
QAction * checkedAction() const
Returns the currently checked action in the group, or \nullptr if none are checked.
void removeAction(QAction *a)
Removes the action from this group.
bool isExclusive() const
Returns true if the group is exclusive.
void setExclusive(bool)
Enable or disable the group exclusion checking.
QAction * addAction(QAction *a)
Adds the action to this group, and returns it.
The QAction class provides an abstraction for user commands that can be added to different user inter...
void setIcon(const QIcon &icon)
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
The QComboBox widget combines a button with a dropdown list.
void setInsertPolicy(InsertPolicy policy)
QLineEdit * lineEdit() const
Returns the line edit used to edit items in the combobox, or \nullptr if there is no line edit.
void setMinimumContentsLength(int characters)
void addItem(const QString &text, const QVariant &userData=QVariant())
Adds an item to the combobox with the given text, and containing the specified userData (stored in th...
void setEditText(const QString &text)
Sets the text in the combobox's text edit.
void setLineEdit(QLineEdit *edit)
Sets the line edit to use instead of the current line edit widget.
void setEditable(bool editable)
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.
void finished(int result)
virtual void done(int)
Closes the dialog and sets its result code to r.
void setVisible(bool visible) override
\reimp
The QDoubleValidator class provides range checking of floating-point numbers.
QValidator::State validate(QString &, int &) const override
Returns \l Acceptable if the string input is in the correct format and contains a double within the v...
static QString getSaveFileName(QWidget *parent=nullptr, const QString &caption=QString(), const QString &dir=QString(), const QString &filter=QString(), QString *selectedFilter=nullptr, Options options=Options())
This is a convenience static function that returns a file name selected by the user.
The QFocusEvent class contains event parameters for widget focus events.
The QIcon class provides scalable icons in different modes and states.
void addFile(const QString &fileName, const QSize &size=QSize(), Mode mode=Normal, State state=Off)
Adds an image from the file with the given fileName to the icon, as a specialization for size,...
static QIcon fromTheme(const QString &name)
The QIntValidator class provides a validator that ensures a string contains a valid integer within a ...
The QLabel widget provides a text or image display.
void setText(const QString &)
QSize minimumSizeHint() const override
\reimp
void setContentsMargins(int left, int top, int right, int bottom)
The QLineEdit widget is a one-line text editor.
QSize minimumSizeHint() const override
Returns a minimum size for the line edit.
void setValidator(const QValidator *)
Sets the validator for values of line edit to v.
void setAlignment(Qt::Alignment flag)
void focusOutEvent(QFocusEvent *) override
\reimp
void setText(const QString &)
QString text
The line edit's text.
void focusInEvent(QFocusEvent *) override
\reimp
static QLocale system()
Returns a QLocale object initialized to the system locale.
The QMainWindow class provides a main application window.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
The QPageSetupDialog class provides a configuration dialog for the page-related options on a printer.
int exec() override
This virtual function is called to pop up the dialog.
The QPrintDialog class provides a dialog for specifying the printer's configuration.
int exec() override
\reimp
void init(QPrinter *printer=nullptr)
QAction * facingModeAction
QByteArray memberToDisconnectOnClose
QPageSetupDialog * pageSetupDialog
QAction * pageSetupAction
void _q_fit(QAction *action)
void _q_navigate(QAction *action)
QAction * landscapeAction
void _q_zoomFactorChanged()
QPrintPreviewWidget * preview
QPointer< QObject > receiverToDisconnectOnClose
QPrintDialog * printDialog
QAction * overviewModeAction
QAction * firstPageAction
QActionGroup * orientationGroup
void _q_setMode(QAction *action)
QActionGroup * printerGroup
QAction * singleModeAction
QPrintPreviewDialogPrivate()
void updatePageNumLabel()
The QPrintPreviewDialog class provides a dialog for previewing and configuring page layouts for print...
~QPrintPreviewDialog()
Destroys the QPrintPreviewDialog.
QPrinter * printer()
Returns a pointer to the QPrinter object this dialog is currently operating on.
void done(int result) override
\reimp
QPrintPreviewDialog(QWidget *parent=nullptr, Qt::WindowFlags flags=Qt::WindowFlags())
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setVisible(bool visible) override
\reimp
QString docName() const
Returns the document name.
QString outputFileName() const
Returns the name of the output file.
void setOutputFileName(const QString &)
Sets the name of the output file to fileName.
OutputFormat outputFormat() const
The QSizePolicy class is a layout attribute describing horizontal and vertical resizing policy.
constexpr int width() const noexcept
Returns the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
int toInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an int using base base, which is 10 by default and must be between 2 ...
static QString fromLatin1(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
float toFloat(bool *ok=nullptr) const
Returns the string converted to a float value.
static QString number(int, int base=10)
This is an overloaded member function, provided for convenience. It differs from the above function o...
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
static QString static QString asprintf(const char *format,...) Q_ATTRIBUTE_FORMAT_PRINTF(1
The QVBoxLayout class lines up widgets vertically.
Combined button and popup list for selecting options.
constexpr const T & qMin(const T &a, const T &b)
constexpr const T & qMax(const T &a, const T &b)
GLdouble GLdouble GLdouble GLdouble top
GLdouble GLdouble GLdouble GLdouble q
GLenum GLenum GLenum input
static void _q_ppd_initResources()
static void qt_setupActionIcon(QAction *action, QLatin1StringView name)
#define Q_INIT_RESOURCE(name)
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
myObject disconnect()
[26]
insertRed setText("insert red text")