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"
|
#include "printview.h"
|
||||||
|
|
||||||
#ifndef QT_NO_PRINTER
|
#if defined(QT_PRINTSUPPORT_LIB)
|
||||||
#include <QPrinter>
|
# include <QtPrintSupport/qtprintsupportglobal.h>
|
||||||
|
|
||||||
|
# if QT_CONFIG(printer)
|
||||||
|
# include <QPrinter>
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PrintView::PrintView()
|
PrintView::PrintView()
|
||||||
@ -62,9 +66,11 @@ PrintView::PrintView()
|
|||||||
|
|
||||||
void PrintView::print(QPrinter *printer)
|
void PrintView::print(QPrinter *printer)
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_PRINTER
|
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
||||||
resize(printer->width(), printer->height());
|
resize(printer->width(), printer->height());
|
||||||
render(printer);
|
render(printer);
|
||||||
|
#else
|
||||||
|
Q_UNUSED(printer)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,7 +638,7 @@ QString encode_pos(int row, int col)
|
|||||||
|
|
||||||
void SpreadSheet::print()
|
void SpreadSheet::print()
|
||||||
{
|
{
|
||||||
#if QT_CONFIG(printpreviewdialog)
|
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printpreviewdialog)
|
||||||
QPrinter printer(QPrinter::ScreenResolution);
|
QPrinter printer(QPrinter::ScreenResolution);
|
||||||
QPrintPreviewDialog dlg(&printer);
|
QPrintPreviewDialog dlg(&printer);
|
||||||
PrintView view;
|
PrintView view;
|
||||||
|
@ -197,7 +197,7 @@ void TextEdit::setupFileActions()
|
|||||||
a->setPriority(QAction::LowPriority);
|
a->setPriority(QAction::LowPriority);
|
||||||
menu->addSeparator();
|
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"));
|
const QIcon printIcon = QIcon::fromTheme("document-print", QIcon(rsrcPath + "/fileprint.png"));
|
||||||
a = menu->addAction(printIcon, tr("&Print..."), this, &TextEdit::filePrint);
|
a = menu->addAction(printIcon, tr("&Print..."), this, &TextEdit::filePrint);
|
||||||
a->setPriority(QAction::LowPriority);
|
a->setPriority(QAction::LowPriority);
|
||||||
@ -559,7 +559,7 @@ void TextEdit::filePrint()
|
|||||||
|
|
||||||
void TextEdit::filePrintPreview()
|
void TextEdit::filePrintPreview()
|
||||||
{
|
{
|
||||||
#if QT_CONFIG(printpreviewdialog)
|
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printpreviewdialog)
|
||||||
QPrinter printer(QPrinter::HighResolution);
|
QPrinter printer(QPrinter::HighResolution);
|
||||||
QPrintPreviewDialog preview(&printer, this);
|
QPrintPreviewDialog preview(&printer, this);
|
||||||
connect(&preview, &QPrintPreviewDialog::paintRequested, this, &TextEdit::printPreview);
|
connect(&preview, &QPrintPreviewDialog::paintRequested, this, &TextEdit::printPreview);
|
||||||
@ -569,17 +569,17 @@ void TextEdit::filePrintPreview()
|
|||||||
|
|
||||||
void TextEdit::printPreview(QPrinter *printer)
|
void TextEdit::printPreview(QPrinter *printer)
|
||||||
{
|
{
|
||||||
#ifdef QT_NO_PRINTER
|
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
||||||
Q_UNUSED(printer);
|
|
||||||
#else
|
|
||||||
textEdit->print(printer);
|
textEdit->print(printer);
|
||||||
|
#else
|
||||||
|
Q_UNUSED(printer)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TextEdit::filePrintPdf()
|
void TextEdit::filePrintPdf()
|
||||||
{
|
{
|
||||||
#ifndef QT_NO_PRINTER
|
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
||||||
//! [0]
|
//! [0]
|
||||||
QFileDialog fileDialog(this, tr("Export PDF"));
|
QFileDialog fileDialog(this, tr("Export PDF"));
|
||||||
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
|
fileDialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
TEMPLATE = app
|
TEMPLATE = app
|
||||||
TARGET = notepad
|
TARGET = notepad
|
||||||
|
|
||||||
|
QT += widgets
|
||||||
|
|
||||||
qtHaveModule(printsupport): QT += printsupport
|
qtHaveModule(printsupport): QT += printsupport
|
||||||
requires(qtConfig(fontdialog))
|
requires(qtConfig(fontdialog))
|
||||||
|
|
||||||
|
@ -69,10 +69,11 @@
|
|||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
|
|
||||||
#if defined(QT_PRINTSUPPORT_LIB)
|
#if defined(QT_PRINTSUPPORT_LIB)
|
||||||
#include <QtPrintSupport/qtprintsupportglobal.h>
|
# include <QtPrintSupport/qtprintsupportglobal.h>
|
||||||
#if QT_CONFIG(printdialog)
|
|
||||||
#include <QPrintDialog>
|
# if QT_CONFIG(printdialog)
|
||||||
#endif
|
# include <QPrintDialog>
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
|
@ -53,8 +53,12 @@
|
|||||||
|
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#ifndef QT_NO_PRINTER
|
#if defined(QT_PRINTSUPPORT_LIB)
|
||||||
#include <QPrinter>
|
# include <QtPrintSupport/qtprintsupportglobal.h>
|
||||||
|
|
||||||
|
# if QT_CONFIG(printer)
|
||||||
|
# include <QPrinter>
|
||||||
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -100,7 +104,7 @@ private:
|
|||||||
QScrollArea *scrollArea;
|
QScrollArea *scrollArea;
|
||||||
double scaleFactor = 1;
|
double scaleFactor = 1;
|
||||||
|
|
||||||
#ifndef QT_NO_PRINTER
|
#if defined(QT_PRINTSUPPORT_LIB) && QT_CONFIG(printer)
|
||||||
QPrinter printer;
|
QPrinter printer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user