Commit 1e1ed4a3 authored by Alexander Volkov's avatar Alexander Volkov
Browse files

Auto set print orientation

parent e1ae2ec1
Pipeline #98600 passed with stage
in 1 minute and 20 seconds
......@@ -368,6 +368,7 @@ private slots:
private:
void sendDocumentNameToPrinter (QPrinter *printer);
void setPrinterPageOrientation(QPrinter *printer);
void sendImageToPrinter(QPrinter *printer, bool showPrinterSetupDialog);
private slots:
......
......@@ -1159,6 +1159,14 @@ void kpMainWindow::sendDocumentNameToPrinter (QPrinter *printer)
//--------------------------------------------------------------------------------
void kpMainWindow::setPrinterPageOrientation(QPrinter *printer)
{
const bool isLandscape = d->document->width() > d->document->height();
printer->setPageOrientation(isLandscape ? QPageLayout::Landscape : QPageLayout::Portrait);
}
//--------------------------------------------------------------------------------
void kpMainWindow::sendPreviewToPrinter(QPrinter *printer)
{
sendImageToPrinter(printer, false);
......@@ -1367,6 +1375,7 @@ void kpMainWindow::slotPrint ()
toolEndShape ();
QPrinter printer;
setPrinterPageOrientation(&printer);
sendImageToPrinter (&printer, true/*showPrinterSetupDialog*/);
}
......@@ -1378,7 +1387,9 @@ void kpMainWindow::slotPrintPreview ()
{
toolEndShape ();
QPrintPreviewDialog printPreview(this);
QPrinter printer;
setPrinterPageOrientation(&printer);
QPrintPreviewDialog printPreview(&printer, this);
connect(&printPreview, &QPrintPreviewDialog::paintRequested, this, &kpMainWindow::sendPreviewToPrinter);
printPreview.exec ();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment