examples: Fix build for configurations that do not have printsupport
printsupport features are only available if the module is available for the configuration. Every printer feature check has to be coupled with a check for the module itself. Change-Id: Id2ca84e71d5d74463d0ff35e8b18b252a779a883 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
This commit is contained in:
parent
d678827f11
commit
7c7bd44669
@ -50,8 +50,12 @@
|
||||
|
||||
#include "printview.h"
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
#include <QPrinter>
|
||||
#if defined(QT_PRINTSUPPORT_LIB)
|
||||
# include <QtPrintSupport/qtprintsupportglobal.h>
|
||||
|
||||
# if QT_CONFIG(printer)
|
||||
# include <QPrinter>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
PrintView::PrintView()
|
||||
@ -62,9 +66,11 @@ PrintView::PrintView()
|
||||
|
||||
void PrintView::print(QPrinter *printer)
|
||||
{
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
||||
resize(printer->width(), printer->height());
|
||||
render(printer);
|
||||
#else
|
||||
Q_UNUSED(printer)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -638,7 +638,7 @@ QString encode_pos(int row, int col)
|
||||
|
||||
void SpreadSheet::print()
|
||||
{
|
||||
#if QT_CONFIG(printpreviewdialog)
|
||||
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printpreviewdialog)
|
||||
QPrinter printer(QPrinter::ScreenResolution);
|
||||
QPrintPreviewDialog dlg(&printer);
|
||||
PrintView view;
|
||||
|
@ -197,7 +197,7 @@ void TextEdit::setupFileActions()
|
||||
a->setPriority(QAction::LowPriority);
|
||||
menu->addSeparator();
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
||||
const QIcon printIcon = QIcon::fromTheme("document-print", QIcon(rsrcPath + "/fileprint.png"));
|
||||
a = menu->addAction(printIcon, tr("&Print..."), this, &TextEdit::filePrint);
|
||||
a->setPriority(QAction::LowPriority);
|
||||
@ -559,7 +559,7 @@ void TextEdit::filePrint()
|
||||
|
||||
void TextEdit::filePrintPreview()
|
||||
{
|
||||
#if QT_CONFIG(printpreviewdialog)
|
||||
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printpreviewdialog)
|
||||
QPrinter printer(QPrinter::HighResolution);
|
||||
QPrintPreviewDialog preview(&printer, this);
|
||||
connect(&preview, &QPrintPreviewDialog::paintRequested, this, &TextEdit::printPreview);
|
||||
@ -569,17 +569,17 @@ void TextEdit::filePrintPreview()
|
||||
|
||||
void TextEdit::printPreview(QPrinter *printer)
|
||||
{
|
||||
#ifdef QT_NO_PRINTER
|
||||
Q_UNUSED(printer);
|
||||
#else
|
||||
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
||||
textEdit->print(printer);
|
||||
#else
|
||||
Q_UNUSED(printer)
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void TextEdit::filePrintPdf()
|
||||
{
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
||||
//! [0]
|
||||
QFileDialog fileDialog(this, tr("Export PDF"));
|
||||
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
|
@ -1,6 +1,8 @@
|
||||
TEMPLATE = app
|
||||
TARGET = notepad
|
||||
|
||||
QT += widgets
|
||||
|
||||
qtHaveModule(printsupport): QT += printsupport
|
||||
requires(qtConfig(fontdialog))
|
||||
|
||||
|
@ -69,10 +69,11 @@
|
||||
#include <QStatusBar>
|
||||
|
||||
#if defined(QT_PRINTSUPPORT_LIB)
|
||||
#include <QtPrintSupport/qtprintsupportglobal.h>
|
||||
#if QT_CONFIG(printdialog)
|
||||
#include <QPrintDialog>
|
||||
#endif
|
||||
# include <QtPrintSupport/qtprintsupportglobal.h>
|
||||
|
||||
# if QT_CONFIG(printdialog)
|
||||
# include <QPrintDialog>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//! [0]
|
||||
|
@ -53,8 +53,12 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QImage>
|
||||
#ifndef QT_NO_PRINTER
|
||||
#include <QPrinter>
|
||||
#if defined(QT_PRINTSUPPORT_LIB)
|
||||
# include <QtPrintSupport/qtprintsupportglobal.h>
|
||||
|
||||
# if QT_CONFIG(printer)
|
||||
# include <QPrinter>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
@ -100,7 +104,7 @@ private:
|
||||
QScrollArea *scrollArea;
|
||||
double scaleFactor = 1;
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
||||
QPrinter printer;
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user