Show message "Pages will be cropped because they do not fit printer paper size."
--HG-- branch : develop
This commit is contained in:
parent
6c6edf3728
commit
342095408a
|
@ -341,6 +341,9 @@ void MainWindowsNoGUI::PrintPages(QPrinter *printer)
|
||||||
copyCount = printer->copyCount();
|
copyCount = printer->copyCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
qreal left, top, right, bottom;
|
||||||
|
printer->getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter);
|
||||||
|
|
||||||
for (int i = 0; i < copyCount; ++i)
|
for (int i = 0; i < copyCount; ++i)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < numPages; ++j)
|
for (int j = 0; j < numPages; ++j)
|
||||||
|
@ -362,7 +365,7 @@ void MainWindowsNoGUI::PrintPages(QPrinter *printer)
|
||||||
{
|
{
|
||||||
index = lastPage - j;
|
index = lastPage - j;
|
||||||
}
|
}
|
||||||
painter.drawImage(QPointF(margins.left(), margins.top()), poster.at(index));
|
painter.drawImage(QPointF(left, top), poster.at(index));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,6 +796,12 @@ void MainWindowsNoGUI::SaveLayoutAs()
|
||||||
QPrinter printer;
|
QPrinter printer;
|
||||||
SetPrinterSettings(&printer, PrintType::PrintPDF);
|
SetPrinterSettings(&printer, PrintType::PrintPDF);
|
||||||
|
|
||||||
|
// Call IsPagesFit after setting a printer settings and check if pages is not bigger than printer's paper size
|
||||||
|
if (not isTiled && not IsPagesFit(printer.paperRect().size()))
|
||||||
|
{
|
||||||
|
qWarning()<<tr("Pages will be cropped because they do not fit printer paper size.");
|
||||||
|
}
|
||||||
|
|
||||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Print to pdf"),
|
QString fileName = QFileDialog::getSaveFileName(this, tr("Print to pdf"),
|
||||||
qApp->ValentinaSettings()->GetPathLayout()+"/"+FileName()+".pdf",
|
qApp->ValentinaSettings()->GetPathLayout()+"/"+FileName()+".pdf",
|
||||||
tr("PDF file (*.pdf)"));
|
tr("PDF file (*.pdf)"));
|
||||||
|
@ -831,6 +840,7 @@ void MainWindowsNoGUI::PrintPreview()
|
||||||
}
|
}
|
||||||
|
|
||||||
SetPrinterSettings(printer.data(), PrintType::PrintPreview);
|
SetPrinterSettings(printer.data(), PrintType::PrintPreview);
|
||||||
|
printer->setResolution(static_cast<int>(PrintDPI));
|
||||||
// display print preview dialog
|
// display print preview dialog
|
||||||
QPrintPreviewDialog preview(printer.data());
|
QPrintPreviewDialog preview(printer.data());
|
||||||
connect(&preview, &QPrintPreviewDialog::paintRequested, this, &MainWindowsNoGUI::PrintPages);
|
connect(&preview, &QPrintPreviewDialog::paintRequested, this, &MainWindowsNoGUI::PrintPages);
|
||||||
|
@ -1023,6 +1033,22 @@ bool MainWindowsNoGUI::isPagesUniform() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
bool MainWindowsNoGUI::IsPagesFit(const QSizeF &printPaper) const
|
||||||
|
{
|
||||||
|
// On previous stage already was checked if pages have uniform size
|
||||||
|
// Enough will be to check only one page
|
||||||
|
QGraphicsRectItem *p = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(0));
|
||||||
|
SCASSERT(p != nullptr);
|
||||||
|
const QSizeF pSize = p->rect().size();
|
||||||
|
if (pSize.height() <= printPaper.height() && pSize.width() <= printPaper.width())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QString MainWindowsNoGUI::FileName() const
|
QString MainWindowsNoGUI::FileName() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -130,6 +130,7 @@ private:
|
||||||
QPrinter::PaperSize FindTemplate(const QSizeF &size) const;
|
QPrinter::PaperSize FindTemplate(const QSizeF &size) const;
|
||||||
|
|
||||||
bool isPagesUniform() const;
|
bool isPagesUniform() const;
|
||||||
|
bool IsPagesFit(const QSizeF &printPaper) const;
|
||||||
QString FileName() const;
|
QString FileName() const;
|
||||||
|
|
||||||
int ContinueIfLayoutStale();
|
int ContinueIfLayoutStale();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user