Fix bug with landscape oriention.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2019-06-18 12:35:43 +03:00
parent 0deb90af92
commit d2396820c5
3 changed files with 20 additions and 4 deletions

View File

@ -319,6 +319,7 @@ bool MainWindowsNoGUI::GenerateLayout(VLayoutGenerator& lGenerator)
details = lGenerator.GetAllDetailsItems();// All details items
detailsOnLayout = lGenerator.GetAllDetails();// All details items
shadows = CreateShadows(papers);
isLayoutPortrait = lGenerator.IsPortrait();
scenes = CreateScenes(papers, shadows, details);
//Uncomment to debug, shows global contour
// gcontours = lGenerator.GetGlobalContours(); // uncomment for debugging
@ -1522,7 +1523,7 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr
printer->setCreator(QGuiApplication::applicationDisplayName()+QChar(QChar::Space)+
QCoreApplication::applicationVersion());
printer->setOrientation(QPrinter::Portrait);
printer->setOrientation(isLayoutPortrait ? QPrinter::Portrait : QPrinter::Landscape);
if (not isTiled)
{
@ -1532,11 +1533,24 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr
auto *paper = qgraphicsitem_cast<QGraphicsRectItem *>(papers.at(0));
if (paper)
{
size = QSizeF(FromPixel(paperSize.width(), Unit::Mm),
FromPixel(paper->rect().height() + margins.top() + margins.bottom(), Unit::Mm));
if (isLayoutPortrait)
{
size = QSizeF(FromPixel(paperSize.width(), Unit::Mm),
FromPixel(paper->rect().height() + margins.top() + margins.bottom(), Unit::Mm));
}
else
{
size = QSizeF(FromPixel(paper->rect().width() + margins.left() + margins.right(), Unit::Mm),
FromPixel(paperSize.height(), Unit::Mm));
}
}
}
if (not isLayoutPortrait)
{
size.transpose(); // QPrinter reverse this for landscape orientation
}
const QPageSize::PageSizeId pSZ = FindPageSizeId(size);
if (pSZ == QPageSize::Custom)
{

View File

@ -114,6 +114,7 @@ protected:
bool isLayoutStale;
bool isNeedAutosave;
bool ignorePrinterFields;
bool isLayoutPortrait{true};
QMarginsF margins;
QSizeF paperSize;

View File

@ -122,6 +122,8 @@ public:
bool IsRotationNeeded() const;
bool IsPortrait() const;
public slots:
void Abort();
void Timeout();
@ -152,7 +154,6 @@ private:
int PageHeight() const;
int PageWidth() const;
bool IsPortrait() const;
void GatherPages();
void UnitePages();