mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-22 00:06:12 -05:00
Make QtPrinter support non-mandatory
This commit is contained in:
parent
779155f634
commit
185724f892
@ -496,11 +496,18 @@ if(WITH_CORE)
|
||||
if (BUILD_WITH_QT6)
|
||||
find_package(${QT_VERSION_BASE} COMPONENTS Core5Compat REQUIRED)
|
||||
endif()
|
||||
|
||||
if (NOT IOS)
|
||||
find_package(${QT_VERSION_BASE} COMPONENTS PrintSupport REQUIRED)
|
||||
else()
|
||||
add_definitions(-DQT_NO_PRINTER)
|
||||
set (DEFAULT_WITH_QTPRINTER TRUE)
|
||||
else ()
|
||||
set (DEFAULT_WITH_QTPRINTER FALSE)
|
||||
endif()
|
||||
set (WITH_QTPRINTER ${DEFAULT_WITH_QTPRINTER} CACHE BOOL "Enable QtPrinter support")
|
||||
if (WITH_QTPRINTER)
|
||||
find_package(${QT_VERSION_BASE} COMPONENTS PrintSupport REQUIRED)
|
||||
set (HAVE_QTPRINTER TRUE)
|
||||
endif()
|
||||
|
||||
if (WITH_QTWEBKIT)
|
||||
if(BUILD_WITH_QT6)
|
||||
message(FATAL_ERROR "Qt WebKit support cannot be enabled on Qt 6 builds")
|
||||
|
@ -98,6 +98,8 @@
|
||||
|
||||
#cmakedefine HAVE_QTGAMEPAD
|
||||
|
||||
#cmakedefine HAVE_QTPRINTER
|
||||
|
||||
#cmakedefine HAVE_STATIC_PROVIDERS
|
||||
|
||||
#cmakedefine HAVE_EPT
|
||||
|
@ -170,6 +170,10 @@ if(NOT WITH_QTSERIALPORT)
|
||||
set(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_QTSERIALPORT)
|
||||
endif()
|
||||
|
||||
if(NOT WITH_QTPRINTER)
|
||||
set(SIP_DISABLE_FEATURES ${SIP_DISABLE_FEATURES} HAVE_QTPRINTER)
|
||||
endif()
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/core/project.py.in ${CMAKE_CURRENT_BINARY_DIR}/core/project.py @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/core/pyproject.toml.in ${CMAKE_CURRENT_BINARY_DIR}/core/pyproject.toml @ONLY)
|
||||
GENERATE_SIP_PYTHON_MODULE_CODE(qgis._core core/core.sip "${sip_files_core}" cpp_files)
|
||||
|
@ -272,6 +272,7 @@ Constructor for PrintExportSettings
|
||||
|
||||
};
|
||||
|
||||
%If (HAVE_QTPRINTER)
|
||||
|
||||
ExportResult print( QPrinter &printer, const QgsLayoutExporter::PrintExportSettings &settings );
|
||||
%Docstring
|
||||
@ -290,6 +291,8 @@ Exports a layout ``iterator`` to a ``printer``, with the specified export ``sett
|
||||
Returns a result code indicating whether the export was successful or an
|
||||
error was encountered. If an error was obtained then ``error`` will be set
|
||||
to the error description.
|
||||
%End
|
||||
|
||||
%End
|
||||
|
||||
struct SvgExportSettings
|
||||
|
@ -101,6 +101,7 @@ done:
|
||||
|
||||
%Feature HAVE_GUI
|
||||
%Feature HAVE_QTSERIALPORT
|
||||
%Feature HAVE_QTPRINTER
|
||||
%Feature ANDROID
|
||||
%Feature VECTOR_MAPPED_TYPE
|
||||
%Feature PYQT6
|
||||
|
@ -272,6 +272,7 @@ Constructor for PrintExportSettings
|
||||
|
||||
};
|
||||
|
||||
%If (HAVE_QTPRINTER)
|
||||
|
||||
ExportResult print( QPrinter &printer, const QgsLayoutExporter::PrintExportSettings &settings );
|
||||
%Docstring
|
||||
@ -290,6 +291,8 @@ Exports a layout ``iterator`` to a ``printer``, with the specified export ``sett
|
||||
Returns a result code indicating whether the export was successful or an
|
||||
error was encountered. If an error was obtained then ``error`` will be set
|
||||
to the error description.
|
||||
%End
|
||||
|
||||
%End
|
||||
|
||||
struct SvgExportSettings
|
||||
|
@ -101,6 +101,7 @@ done:
|
||||
|
||||
%Feature HAVE_GUI
|
||||
%Feature HAVE_QTSERIALPORT
|
||||
%Feature HAVE_QTPRINTER
|
||||
%Feature ANDROID
|
||||
%Feature VECTOR_MAPPED_TYPE
|
||||
|
||||
|
@ -115,12 +115,10 @@
|
||||
#include "qgsalgorithmintersection.h"
|
||||
#include "qgsalgorithmkeepnbiggestparts.h"
|
||||
#include "qgsalgorithmkmeansclustering.h"
|
||||
#ifndef QT_NO_PRINTER
|
||||
#include "qgsalgorithmlayoutatlastoimage.h"
|
||||
#include "qgsalgorithmlayoutatlastopdf.h"
|
||||
#include "qgsalgorithmlayouttoimage.h"
|
||||
#include "qgsalgorithmlayouttopdf.h"
|
||||
#endif
|
||||
#include "qgsalgorithmlinedensity.h"
|
||||
#include "qgsalgorithmlineintersection.h"
|
||||
#include "qgsalgorithmlinesubstring.h"
|
||||
@ -398,13 +396,11 @@ void QgsNativeAlgorithms::loadAlgorithms()
|
||||
addAlgorithm( new QgsKMeansClusteringAlgorithm() );
|
||||
addAlgorithm( new QgsLayerToBookmarksAlgorithm() );
|
||||
addAlgorithm( new QgsLayoutMapExtentToLayerAlgorithm() );
|
||||
#ifndef QT_NO_PRINTER
|
||||
addAlgorithm( new QgsLayoutAtlasToImageAlgorithm() );
|
||||
addAlgorithm( new QgsLayoutAtlasToPdfAlgorithm() );
|
||||
addAlgorithm( new QgsLayoutAtlasToMultiplePdfAlgorithm() );
|
||||
addAlgorithm( new QgsLayoutToImageAlgorithm() );
|
||||
addAlgorithm( new QgsLayoutToPdfAlgorithm() );
|
||||
#endif
|
||||
addAlgorithm( new QgsLineDensityAlgorithm() );
|
||||
addAlgorithm( new QgsLineIntersectionAlgorithm() );
|
||||
addAlgorithm( new QgsLineSubstringAlgorithm() );
|
||||
|
@ -2242,7 +2242,6 @@ target_include_directories(qgis_core SYSTEM PUBLIC
|
||||
${${QT_VERSION_BASE}Xml_INCLUDE_DIRS}
|
||||
${${QT_VERSION_BASE}Widgets_INCLUDE_DIRS}
|
||||
${${QT_VERSION_BASE}Svg_INCLUDE_DIRS}
|
||||
${${QT_VERSION_BASE}PrintSupport_INCLUDE_DIRS}
|
||||
${${QT_VERSION_BASE}Network_INCLUDE_DIRS}
|
||||
${${QT_VERSION_BASE}Sql_INCLUDE_DIRS}
|
||||
${${QT_VERSION_BASE}Concurrent_INCLUDE_DIRS}
|
||||
@ -2425,12 +2424,13 @@ target_link_libraries(qgis_core
|
||||
PROJ::proj
|
||||
)
|
||||
|
||||
if (WITH_DRACO)
|
||||
target_link_libraries(qgis_core ${DRACO_LIBRARY})
|
||||
if (WITH_QTPRINTER)
|
||||
target_link_libraries(qgis_core ${QT_VERSION_BASE}::PrintSupport)
|
||||
target_include_directories(qgis_core SYSTEM PUBLIC ${${QT_VERSION_BASE}PrintSupport_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
if (NOT IOS)
|
||||
target_link_libraries(qgis_core ${QT_VERSION_BASE}::PrintSupport)
|
||||
if (WITH_DRACO)
|
||||
target_link_libraries(qgis_core ${DRACO_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (WITH_SPATIALITE)
|
||||
|
@ -868,7 +868,7 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToPdfs( QgsAbstractLayo
|
||||
return Success;
|
||||
}
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if defined( HAVE_QTPRINTER )
|
||||
QgsLayoutExporter::ExportResult QgsLayoutExporter::print( QPrinter &printer, const QgsLayoutExporter::PrintExportSettings &s )
|
||||
{
|
||||
if ( !mLayout )
|
||||
@ -988,7 +988,7 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::print( QgsAbstractLayoutItera
|
||||
iterator->endRender();
|
||||
return Success;
|
||||
}
|
||||
#endif // QT_NO_PRINTER
|
||||
#endif // HAVE_QTPRINTER
|
||||
|
||||
QgsLayoutExporter::ExportResult QgsLayoutExporter::exportToSvg( const QString &filePath, const QgsLayoutExporter::SvgExportSettings &s )
|
||||
{
|
||||
@ -1255,7 +1255,7 @@ void QgsLayoutExporter::preparePrint( QgsLayout *layout, QPagedPaintDevice *devi
|
||||
{
|
||||
pdf->setResolution( static_cast< int>( std::round( layout->renderContext().dpi() ) ) );
|
||||
}
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if defined( HAVE_QTPRINTER )
|
||||
else if ( QPrinter *printer = dynamic_cast<QPrinter *>( device ) )
|
||||
{
|
||||
printer->setFullPage( true );
|
||||
@ -1295,7 +1295,7 @@ QgsLayoutExporter::ExportResult QgsLayoutExporter::printPrivate( QPagedPaintDevi
|
||||
int fromPage = 0;
|
||||
int toPage = mLayout->pageCollection()->pageCount() - 1;
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if defined( HAVE_QTPRINTER )
|
||||
if ( QPrinter *printer = dynamic_cast<QPrinter *>( device ) )
|
||||
{
|
||||
if ( printer->fromPage() >= 1 )
|
||||
@ -1368,7 +1368,7 @@ void QgsLayoutExporter::updatePrinterPageSize( QgsLayout *layout, QPagedPaintDev
|
||||
device->setPageLayout( pageLayout );
|
||||
device->setPageMargins( QMarginsF( 0, 0, 0, 0 ) );
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if defined( HAVE_QTPRINTER )
|
||||
if ( QPrinter *printer = dynamic_cast<QPrinter *>( device ) )
|
||||
{
|
||||
printer->setFullPage( true );
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define QGSLAYOUTEXPORTER_H
|
||||
|
||||
#include "qgis_core.h"
|
||||
#include "qgsconfig.h"
|
||||
#include "qgsmargins.h"
|
||||
#include "qgslayoutrendercontext.h"
|
||||
#include "qgslayoutreportcontext.h"
|
||||
@ -29,7 +30,7 @@
|
||||
#include <QVector>
|
||||
#include <functional>
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if defined( HAVE_QTPRINTER )
|
||||
#include <QPrinter>
|
||||
#endif
|
||||
|
||||
@ -471,7 +472,8 @@ class CORE_EXPORT QgsLayoutExporter
|
||||
|
||||
};
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if defined( HAVE_QTPRINTER )
|
||||
SIP_IF_FEATURE( HAVE_QTPRINTER )
|
||||
|
||||
/**
|
||||
* Prints the layout to a \a printer, using the specified export \a settings.
|
||||
@ -491,6 +493,8 @@ class CORE_EXPORT QgsLayoutExporter
|
||||
static ExportResult print( QgsAbstractLayoutIterator *iterator, QPrinter &printer,
|
||||
const QgsLayoutExporter::PrintExportSettings &settings,
|
||||
QString &error SIP_OUT, QgsFeedback *feedback = nullptr );
|
||||
|
||||
SIP_END
|
||||
#endif
|
||||
|
||||
//! Contains settings relating to exporting layouts to SVG
|
||||
|
@ -33,11 +33,12 @@
|
||||
#include "qgsxmlutils.h"
|
||||
#include "qgssymbollayerreference.h"
|
||||
#include "qgssymbollayerutils.h"
|
||||
#include "qgsconfig.h"
|
||||
|
||||
#include <QTextStream>
|
||||
#include <QDomDocument>
|
||||
#include <QRegularExpression>
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if defined( HAVE_QTPRINTER )
|
||||
#include <QPrinter> //to find out screen resolution
|
||||
#endif
|
||||
#include <cstdlib>
|
||||
@ -304,7 +305,7 @@ void transform0100to0110( QgsProjectFileTransform *pft )
|
||||
{
|
||||
if ( ! pft->dom().isNull() )
|
||||
{
|
||||
#ifndef QT_NO_PRINTER
|
||||
#if defined( HAVE_QTPRINTER )
|
||||
//Change 'outlinewidth' in QgsSymbol
|
||||
const QPrinter myPrinter( QPrinter::ScreenResolution );
|
||||
const int screenDpi = myPrinter.resolution();
|
||||
|
@ -266,9 +266,6 @@ QgsLayoutChecker::QgsLayoutChecker( const QString &testName, QgsLayout *layout )
|
||||
|
||||
bool QgsLayoutChecker::testLayout( QString &checkedReport, int page, int pixelDiff, bool createReferenceImage )
|
||||
{
|
||||
#ifdef QT_NO_PRINTER
|
||||
return false;
|
||||
#else
|
||||
if ( !mLayout )
|
||||
{
|
||||
return false;
|
||||
@ -322,9 +319,7 @@ bool QgsLayoutChecker::testLayout( QString &checkedReport, int page, int pixelDi
|
||||
checkedReport += report();
|
||||
|
||||
return testResult;
|
||||
#endif // QT_NO_PRINTER
|
||||
}
|
||||
|
||||
|
||||
|
||||
///@endcond
|
||||
|
@ -25,9 +25,7 @@
|
||||
#include "qgsrendercontext.h"
|
||||
#include <QImage>
|
||||
#include <QPainter>
|
||||
#ifndef QT_NO_PRINTER
|
||||
#include <QPrinter>
|
||||
#endif
|
||||
#include <QPdfWriter>
|
||||
|
||||
QgsRasterDrawer::QgsRasterDrawer( QgsRasterIterator *iterator, double dpiTarget )
|
||||
: mIterator( iterator )
|
||||
@ -94,11 +92,10 @@ void QgsRasterDrawer::draw( QPainter *p, QgsRasterViewPort *viewPort, const QgsM
|
||||
|
||||
QImage img = block->image();
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
// Because of bug in Acrobat Reader we must use "white" transparent color instead
|
||||
// of "black" for PDF. See #9101.
|
||||
QPrinter *printer = dynamic_cast<QPrinter *>( p->device() );
|
||||
if ( printer && printer->outputFormat() == QPrinter::PdfFormat )
|
||||
QPdfWriter *pdfWriter = dynamic_cast<QPdfWriter *>( p->device() );
|
||||
if ( pdfWriter )
|
||||
{
|
||||
QgsDebugMsgLevel( QStringLiteral( "PdfFormat" ), 4 );
|
||||
|
||||
@ -116,7 +113,6 @@ void QgsRasterDrawer::draw( QPainter *p, QgsRasterViewPort *viewPort, const QgsM
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( feedback && feedback->renderPartialOutput() )
|
||||
{
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "qgscolorutils.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPagedPaintDevice>
|
||||
#include <QFile>
|
||||
#include <QSvgRenderer>
|
||||
#include <QDomDocument>
|
||||
@ -48,9 +49,6 @@
|
||||
#include <QtMath>
|
||||
#include <random>
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
#include <QPrinter>
|
||||
#endif
|
||||
|
||||
QgsSimpleFillSymbolLayer::QgsSimpleFillSymbolLayer( const QColor &color, Qt::BrushStyle style, const QColor &strokeColor, Qt::PenStyle strokeStyle, double strokeWidth,
|
||||
Qt::PenJoinStyle penJoinStyle )
|
||||
@ -328,15 +326,12 @@ void QgsSimpleFillSymbolLayer::renderPolygon( const QPolygonF &points, const QVe
|
||||
|
||||
const bool useSelectedColor = shouldRenderUsingSelectionColor( context );
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
if ( mBrush.style() == Qt::SolidPattern || mBrush.style() == Qt::NoBrush || !dynamic_cast<QPrinter *>( p->device() ) )
|
||||
#endif
|
||||
if ( mBrush.style() == Qt::SolidPattern || mBrush.style() == Qt::NoBrush || !dynamic_cast<QPagedPaintDevice *>( p->device() ) )
|
||||
{
|
||||
p->setPen( useSelectedColor ? mSelPen : mPen );
|
||||
p->setBrush( useSelectedColor ? mSelBrush : mBrush );
|
||||
_renderPolygon( p, points, rings, context );
|
||||
}
|
||||
#ifndef QT_NO_PRINTER
|
||||
else
|
||||
{
|
||||
// workaround upstream issue https://github.com/qgis/QGIS/issues/36580
|
||||
@ -350,7 +345,6 @@ void QgsSimpleFillSymbolLayer::renderPolygon( const QPolygonF &points, const QVe
|
||||
p->setBrush( Qt::NoBrush );
|
||||
_renderPolygon( p, points, rings, context );
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( !offset.isNull() )
|
||||
{
|
||||
|
@ -63,13 +63,11 @@ class TestQgsProcessingAlgsPt2: public QgsTest
|
||||
void init() {} // will be called before each testfunction is executed.
|
||||
void cleanup() {} // will be called after every testfunction.
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
void exportLayoutPdf();
|
||||
void exportLayoutPng();
|
||||
void exportAtlasLayoutPdf();
|
||||
void exportAtlasLayoutPdfMultiple();
|
||||
void exportAtlasLayoutPng();
|
||||
#endif
|
||||
|
||||
void tinMeshCreation();
|
||||
void exportMeshVertices();
|
||||
@ -220,7 +218,6 @@ QVariantMap pkgAlg( const QStringList &layers, const QString &outputGpkg, bool o
|
||||
return package->run( parameters, *context, &feedback, ok );
|
||||
}
|
||||
|
||||
#ifndef QT_NO_PRINTER
|
||||
void TestQgsProcessingAlgsPt2::exportLayoutPdf()
|
||||
{
|
||||
QgsProject p;
|
||||
@ -464,7 +461,6 @@ void TestQgsProcessingAlgsPt2::exportAtlasLayoutPng()
|
||||
QVERIFY( QFile::exists( QDir::tempPath() + "/my_atlas/custom_10.png" ) );
|
||||
QGSVERIFYIMAGECHECK( "export_atlas_custom_layers", "export_atlas_custom_layers", QDir::tempPath() + "/my_atlas/custom_1.png", QString(), 500, QSize( 3, 3 ) );
|
||||
}
|
||||
#endif
|
||||
|
||||
void TestQgsProcessingAlgsPt2::tinMeshCreation()
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user