Set default printing color mode.

Known issue: program doesn't print in grayscale color mode.

--HG--
branch : develop
This commit is contained in:
Roman Telezhynskyi 2015-11-04 17:22:49 +02:00
parent 8d6c007217
commit 6b54c5bb7d
3 changed files with 29 additions and 9 deletions

View File

@ -705,7 +705,7 @@ void MainWindowsNoGUI::DxfFile(const QString &name, int i) const
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------
QVector<QImage> MainWindowsNoGUI::AllSheets() QVector<QImage> MainWindowsNoGUI::AllSheets() const
{ {
QVector<QImage> images; QVector<QImage> images;
for (int i=0; i < scenes.size(); ++i) for (int i=0; i < scenes.size(); ++i)
@ -867,7 +867,26 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer)
FromPixel(paper->rect().height(), Unit::Mm)), QPrinter::Millimeter ); FromPixel(paper->rect().height(), Unit::Mm)), QPrinter::Millimeter );
} }
printer->setOutputFileName(QDir::homePath() + QDir::separator() + FileName() + QLatin1Literal(".pdf"));
printer->setDocName(FileName()); printer->setDocName(FileName());
IsLayoutGrayscale() ? printer->setColorMode(QPrinter::GrayScale) : printer->setColorMode(QPrinter::Color);
}
//---------------------------------------------------------------------------------------------------------------------
bool MainWindowsNoGUI::IsLayoutGrayscale() const
{
const QVector<QImage> images = AllSheets();
for(int i=0; i < images.size(); ++i)
{
if (not images.at(i).isGrayscale())
{
return false;
}
}
return true;
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -104,7 +104,6 @@ private:
void CreateShadows(); void CreateShadows();
void CreateScenes(); void CreateScenes();
void SvgFile(const QString &name, int i)const; void SvgFile(const QString &name, int i)const;
void PngFile(const QString &name, int i)const; void PngFile(const QString &name, int i)const;
void PdfFile(const QString &name, int i)const; void PdfFile(const QString &name, int i)const;
@ -114,13 +113,14 @@ private:
void ObjFile(const QString &name, int i)const; void ObjFile(const QString &name, int i)const;
void DxfFile(const QString &name, int i)const; void DxfFile(const QString &name, int i)const;
QVector<QImage> AllSheets(); QVector<QImage> AllSheets() const;
void SaveLayoutAs(); void SaveLayoutAs();
void PrintPreview(); void PrintPreview();
void LayoutPrint(); void LayoutPrint();
void SetPrinterSettings(QPrinter *printer); void SetPrinterSettings(QPrinter *printer);
bool IsLayoutGrayscale() const;
bool isPagesUniform() const; bool isPagesUniform() const;
QString FileName() const; QString FileName() const;

View File

@ -33,6 +33,7 @@
#include "../ifc/ifcdef.h" #include "../ifc/ifcdef.h"
#include <QStringList> #include <QStringList>
#include <QMap>
class VMeasurementData; class VMeasurementData;
class VContainer; class VContainer;