Refactoring.
This commit is contained in:
parent
abb4397901
commit
510a5ab6a7
|
@ -312,14 +312,6 @@ void VPrintLayout::PrintPreview()
|
|||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VPrintLayout::PrintPages(QPrinter *printer)
|
||||
{
|
||||
// Here we try understand difference between printer's dpi and our.
|
||||
// Get printer rect acording to our dpi.
|
||||
const QRectF printerPageRect(0, 0, ToPixel(printer->pageRect(QPrinter::Millimeter).width(), Unit::Mm),
|
||||
ToPixel(printer->pageRect(QPrinter::Millimeter).height(), Unit::Mm));
|
||||
const QRect pageRect = printer->pageLayout().paintRectPixels(printer->resolution());
|
||||
const double xscale = pageRect.width() / printerPageRect.width();
|
||||
const double yscale = pageRect.height() / printerPageRect.height();
|
||||
|
||||
QPainter painter;
|
||||
if (not painter.begin(printer))
|
||||
{ // failed to open file
|
||||
|
@ -391,29 +383,15 @@ void VPrintLayout::PrintPages(QPrinter *printer)
|
|||
copyCount = printer->copyCount();
|
||||
}
|
||||
|
||||
VWatermarkData data;
|
||||
if (not m_watermarkPath.isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
VWatermarkConverter converter(m_watermarkPath);
|
||||
VWatermark watermark;
|
||||
watermark.setXMLContent(converter.Convert());
|
||||
data = watermark.GetWatermark();
|
||||
VWatermarkData data = WatermarkData();
|
||||
|
||||
if (not data.path.isEmpty())
|
||||
{
|
||||
// Clean previous cache
|
||||
QPixmapCache::remove(AbsoluteMPath(m_watermarkPath, data.path));
|
||||
}
|
||||
}
|
||||
catch (VException &e)
|
||||
{
|
||||
const QString errorMsg = tr("File error.\n\n%1\n\n%2").arg(e.ErrorMessage(), e.DetailedInformation());
|
||||
qApp->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
}
|
||||
}
|
||||
// Here we try understand difference between printer's dpi and our.
|
||||
// Get printer rect acording to our dpi.
|
||||
const QRectF printerPageRect(0, 0, ToPixel(printer->pageRect(QPrinter::Millimeter).width(), Unit::Mm),
|
||||
ToPixel(printer->pageRect(QPrinter::Millimeter).height(), Unit::Mm));
|
||||
const QRect pageRect = printer->pageLayout().paintRectPixels(printer->resolution());
|
||||
const double xscale = pageRect.width() / printerPageRect.width();
|
||||
const double yscale = pageRect.height() / printerPageRect.height();
|
||||
|
||||
for (int i = 0; i < copyCount; ++i)
|
||||
{
|
||||
|
@ -736,6 +714,36 @@ auto VPrintLayout::IsPagesFit(QSizeF printPaper) const -> bool
|
|||
return pSize.height() <= printPaper.height() && pSize.width() <= printPaper.width();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPrintLayout::WatermarkData() const -> VWatermarkData
|
||||
{
|
||||
VWatermarkData data;
|
||||
if (m_isTiled && not m_watermarkPath.isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
VWatermarkConverter converter(m_watermarkPath);
|
||||
VWatermark watermark;
|
||||
watermark.setXMLContent(converter.Convert());
|
||||
data = watermark.GetWatermark();
|
||||
|
||||
if (not data.path.isEmpty())
|
||||
{
|
||||
// Clean previous cache
|
||||
QPixmapCache::remove(AbsoluteMPath(m_watermarkPath, data.path));
|
||||
}
|
||||
}
|
||||
catch (VException &e)
|
||||
{
|
||||
const QString errorMsg = tr("File error.\n\n%1\n\n%2").arg(e.ErrorMessage(), e.DetailedInformation());
|
||||
qApp->IsPedantic() ? throw VException(errorMsg) :
|
||||
qWarning() << VAbstractValApplication::warningMessageSignature + errorMsg;
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
auto VPrintLayout::ContinueIfLayoutStale(QWidget *parent) -> int
|
||||
{
|
||||
|
|
|
@ -38,6 +38,7 @@ enum class PrintType : qint8 {PrintPDF, PrintPreview, PrintNative};
|
|||
|
||||
class QPrinter;
|
||||
class QGraphicsScene;
|
||||
struct VWatermarkData;
|
||||
|
||||
class VPrintLayout : public QObject
|
||||
{
|
||||
|
@ -168,6 +169,8 @@ private:
|
|||
|
||||
bool IsPagesUniform() const;
|
||||
bool IsPagesFit(QSizeF printPaper) const;
|
||||
|
||||
auto WatermarkData() const -> VWatermarkData;
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user