take orientation into account for export

This commit is contained in:
Ronan Le Tiec 2021-05-15 13:02:21 +02:00
parent 43fbdbf83c
commit ee9bce8632

View file

@ -1360,13 +1360,17 @@ void VPMainWindow::on_pushButtonSheetExport_clicked()
{ {
m_graphicsView->PrepareForExport(); m_graphicsView->PrepareForExport();
const QSizeF s = m_layout->GetFocusedSheet()->GetSheetSize(); QSizeF size = QSizeF(m_layout->GetFocusedSheet()->GetSheetSize());
const QRectF r = QRectF(0, 0, s.width(), s.height()); if(m_layout->GetFocusedSheet()->GetOrientation() == PageOrientation::Landscape)
{
size.transpose();
}
const QRectF rect = QRectF(0, 0, size.width(), size.height());
QSvgGenerator generator; QSvgGenerator generator;
generator.setFileName(fileName); generator.setFileName(fileName);
generator.setSize(QSize(qFloor(s.width()),qFloor(s.height()))); generator.setSize(QSize(qFloor(size.width()),qFloor(size.height())));
generator.setViewBox(r); generator.setViewBox(rect);
generator.setTitle(m_layout->GetFocusedSheet()->GetName()); generator.setTitle(m_layout->GetFocusedSheet()->GetName());
generator.setDescription(m_layout->GetDescription().toHtmlEscaped()); generator.setDescription(m_layout->GetDescription().toHtmlEscaped());
generator.setResolution(static_cast<int>(PrintDPI)); generator.setResolution(static_cast<int>(PrintDPI));
@ -1376,12 +1380,11 @@ void VPMainWindow::on_pushButtonSheetExport_clicked()
painter.setRenderHint(QPainter::Antialiasing, true); painter.setRenderHint(QPainter::Antialiasing, true);
painter.setPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); painter.setPen(QPen(Qt::black, qApp->Settings()->WidthHairLine(), Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin));
painter.setBrush ( QBrush ( Qt::NoBrush ) ); painter.setBrush ( QBrush ( Qt::NoBrush ) );
m_graphicsView->GetScene()->render(&painter, r, r, Qt::IgnoreAspectRatio); m_graphicsView->GetScene()->render(&painter, rect, rect, Qt::IgnoreAspectRatio);
painter.end(); painter.end();
m_graphicsView->CleanAfterExport(); m_graphicsView->CleanAfterExport();
} }
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------