Resolved issue #570. Error: Tiled PDF : field values not taken into account if
one of them is smaller than 0,3. --HG-- branch : develop
This commit is contained in:
parent
bf1e4aeb0c
commit
723d68b245
|
@ -572,44 +572,58 @@ void DialogLayoutSettings::DialogAccepted()
|
||||||
|
|
||||||
if (IsIgnoreAllFields())
|
if (IsIgnoreAllFields())
|
||||||
{
|
{
|
||||||
generator->SetFields(QMarginsF());
|
generator->SetPrinterFields(false, QMarginsF());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const QMarginsF minFields = RoundMargins(VSettings::GetDefFields());
|
QPrinterInfo printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText());
|
||||||
const QMarginsF fields = RoundMargins(GetFields());
|
if (printer.isNull())
|
||||||
if (fields.left() < minFields.left() || fields.right() < minFields.right() ||
|
|
||||||
fields.top() < minFields.top() || fields.bottom() < minFields.bottom())
|
|
||||||
{
|
{
|
||||||
QMessageBox::StandardButton answer;
|
generator->SetPrinterFields(true, GetFields());
|
||||||
answer = QMessageBox::question(this, tr("Wrong fields."),
|
}
|
||||||
tr("Fields go beyond printing. \n\nApply settings anyway?"),
|
else
|
||||||
QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
|
{
|
||||||
if (answer == QMessageBox::No)
|
const QMarginsF minFields = RoundMargins(GetMinPrinterFields());
|
||||||
|
const QMarginsF fields = RoundMargins(GetFields());
|
||||||
|
if (fields.left() < minFields.left() || fields.right() < minFields.right() ||
|
||||||
|
fields.top() < minFields.top() || fields.bottom() < minFields.bottom())
|
||||||
{
|
{
|
||||||
if (fields.left() < minFields.left())
|
QMessageBox::StandardButton answer;
|
||||||
|
answer = QMessageBox::question(this, tr("Wrong fields."),
|
||||||
|
tr("Fields go beyond printing. \n\nApply settings anyway?"),
|
||||||
|
QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
|
||||||
|
if (answer == QMessageBox::No)
|
||||||
{
|
{
|
||||||
ui->doubleSpinBoxLeftField->setValue(UnitConvertor(minFields.left(), Unit::Px, LayoutUnit()));
|
const QMarginsF defFields = RoundMargins(GetDefPrinterFields());
|
||||||
}
|
if (fields.left() < defFields.left())
|
||||||
|
{
|
||||||
|
ui->doubleSpinBoxLeftField->setValue(UnitConvertor(defFields.left(), Unit::Px, LayoutUnit()));
|
||||||
|
}
|
||||||
|
|
||||||
if (fields.right() < minFields.right())
|
if (fields.right() < defFields.right())
|
||||||
{
|
{
|
||||||
ui->doubleSpinBoxRightField->setValue(UnitConvertor(minFields.right(), Unit::Px, LayoutUnit()));
|
ui->doubleSpinBoxRightField->setValue(UnitConvertor(defFields.right(), Unit::Px, LayoutUnit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fields.top() < minFields.top())
|
if (fields.top() < defFields.top())
|
||||||
{
|
{
|
||||||
ui->doubleSpinBoxTopField->setValue(UnitConvertor(minFields.top(), Unit::Px, LayoutUnit()));
|
ui->doubleSpinBoxTopField->setValue(UnitConvertor(defFields.top(), Unit::Px, LayoutUnit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fields.bottom() < minFields.bottom())
|
if (fields.bottom() < defFields.bottom())
|
||||||
|
{
|
||||||
|
ui->doubleSpinBoxBottomField->setValue(UnitConvertor(defFields.bottom(), Unit::Px,
|
||||||
|
LayoutUnit()));
|
||||||
|
}
|
||||||
|
|
||||||
|
generator->SetPrinterFields(true, GetFields());
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
ui->doubleSpinBoxBottomField->setValue(UnitConvertor(minFields.bottom(), Unit::Px, LayoutUnit()));
|
generator->SetPrinterFields(false, GetFields());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
generator->SetFields(GetFields());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//don't want to break visual settings when cmd used
|
//don't want to break visual settings when cmd used
|
||||||
|
@ -637,7 +651,7 @@ void DialogLayoutSettings::RestoreDefaults()
|
||||||
SetGroup(VSettings::GetDefLayoutGroup());
|
SetGroup(VSettings::GetDefLayoutGroup());
|
||||||
SetRotate(VSettings::GetDefLayoutRotate());
|
SetRotate(VSettings::GetDefLayoutRotate());
|
||||||
SetIncrease(VSettings::GetDefLayoutRotationIncrease());
|
SetIncrease(VSettings::GetDefLayoutRotationIncrease());
|
||||||
SetFields(VSettings::GetDefFields());
|
SetFields(GetDefPrinterFields());
|
||||||
SetIgnoreAllFields(VSettings::GetDefIgnoreAllFields());
|
SetIgnoreAllFields(VSettings::GetDefIgnoreAllFields());
|
||||||
SetMultiplier(VSettings::GetDefMultiplier());
|
SetMultiplier(VSettings::GetDefMultiplier());
|
||||||
|
|
||||||
|
@ -651,7 +665,11 @@ void DialogLayoutSettings::PrinterMargins()
|
||||||
QPrinterInfo printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText());
|
QPrinterInfo printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText());
|
||||||
if (not printer.isNull())
|
if (not printer.isNull())
|
||||||
{
|
{
|
||||||
SetFields(VSettings::GetPrinterFields(QSharedPointer<QPrinter>(new QPrinter(printer))));
|
SetFields(GetPrinterFields(QSharedPointer<QPrinter>(new QPrinter(printer))));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetFields(QMarginsF());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -940,6 +958,50 @@ QMarginsF DialogLayoutSettings::RoundMargins(const QMarginsF &margins) const
|
||||||
return newMargins;
|
return newMargins;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QMarginsF DialogLayoutSettings::GetMinPrinterFields() const
|
||||||
|
{
|
||||||
|
QPrinterInfo printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText());
|
||||||
|
if (not printer.isNull())
|
||||||
|
{
|
||||||
|
QSharedPointer<QPrinter> pr = QSharedPointer<QPrinter>(new QPrinter(printer));
|
||||||
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)
|
||||||
|
QPageLayout layout = pr->pageLayout();
|
||||||
|
layout.setUnits(QPageLayout::Millimeter);
|
||||||
|
const QMarginsF minMargins = layout.minimumMargins();
|
||||||
|
|
||||||
|
QMarginsF min;
|
||||||
|
min.setLeft(UnitConvertor(minMargins.left(), Unit::Mm, Unit::Px));
|
||||||
|
min.setRight(UnitConvertor(minMargins.right(), Unit::Mm, Unit::Px));
|
||||||
|
min.setTop(UnitConvertor(minMargins.top(), Unit::Mm, Unit::Px));
|
||||||
|
min.setBottom(UnitConvertor(minMargins.bottom(), Unit::Mm, Unit::Px));
|
||||||
|
return min;
|
||||||
|
#else
|
||||||
|
pr->setFullPage(false);
|
||||||
|
pr->setPageMargins(0, 0, 0, 0, QPrinter::Millimeter);
|
||||||
|
return GetPrinterFields(QSharedPointer<QPrinter>(new QPrinter(printer)));
|
||||||
|
#endif //QT_VERSION >= QT_VERSION_CHECK(5, 3, 0)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QMarginsF();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QMarginsF DialogLayoutSettings::GetDefPrinterFields() const
|
||||||
|
{
|
||||||
|
QPrinterInfo printer = QPrinterInfo::printerInfo(ui->comboBoxPrinter->currentText());
|
||||||
|
if (not printer.isNull())
|
||||||
|
{
|
||||||
|
return GetPrinterFields(QSharedPointer<QPrinter>(new QPrinter(printer)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return QMarginsF();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
Unit DialogLayoutSettings::PaperUnit() const
|
Unit DialogLayoutSettings::PaperUnit() const
|
||||||
{
|
{
|
||||||
|
@ -1043,7 +1105,7 @@ void DialogLayoutSettings::ReadSettings()
|
||||||
SetAutoCrop(settings->GetLayoutAutoCrop());
|
SetAutoCrop(settings->GetLayoutAutoCrop());
|
||||||
SetSaveLength(settings->GetLayoutSaveLength());
|
SetSaveLength(settings->GetLayoutSaveLength());
|
||||||
SetUnitePages(settings->GetLayoutUnitePages());
|
SetUnitePages(settings->GetLayoutUnitePages());
|
||||||
SetFields(settings->GetFields());
|
SetFields(settings->GetFields(GetDefPrinterFields()));
|
||||||
SetIgnoreAllFields(settings->GetIgnoreAllFields());
|
SetIgnoreAllFields(settings->GetIgnoreAllFields());
|
||||||
SetStripOptimization(settings->GetStripOptimization());
|
SetStripOptimization(settings->GetStripOptimization());
|
||||||
SetMultiplier(settings->GetMultiplier());
|
SetMultiplier(settings->GetMultiplier());
|
||||||
|
@ -1096,3 +1158,25 @@ void DialogLayoutSettings::SetAdditionalOptions(bool value)
|
||||||
SetUnitePages(value);
|
SetUnitePages(value);
|
||||||
SetStripOptimization(value);
|
SetStripOptimization(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QMarginsF DialogLayoutSettings::GetPrinterFields(const QSharedPointer<QPrinter> &printer)
|
||||||
|
{
|
||||||
|
if (printer.isNull())
|
||||||
|
{
|
||||||
|
return QMarginsF();
|
||||||
|
}
|
||||||
|
|
||||||
|
qreal left = 0;
|
||||||
|
qreal top = 0;
|
||||||
|
qreal right = 0;
|
||||||
|
qreal bottom = 0;
|
||||||
|
printer->getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter);
|
||||||
|
// We can't use Unit::Px because our dpi in most cases is different
|
||||||
|
QMarginsF def;
|
||||||
|
def.setLeft(UnitConvertor(left, Unit::Mm, Unit::Px));
|
||||||
|
def.setRight(UnitConvertor(right, Unit::Mm, Unit::Px));
|
||||||
|
def.setTop(UnitConvertor(top, Unit::Mm, Unit::Px));
|
||||||
|
def.setBottom(UnitConvertor(bottom, Unit::Mm, Unit::Px));
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
|
|
@ -159,6 +159,8 @@ private:
|
||||||
QSizeF TemplateSize(const PaperSizeTemplate &tmpl) const;
|
QSizeF TemplateSize(const PaperSizeTemplate &tmpl) const;
|
||||||
QSizeF RoundTemplateSize(qreal width, qreal height) const;
|
QSizeF RoundTemplateSize(qreal width, qreal height) const;
|
||||||
QMarginsF RoundMargins(const QMarginsF &margins) const;
|
QMarginsF RoundMargins(const QMarginsF &margins) const;
|
||||||
|
QMarginsF GetMinPrinterFields() const;
|
||||||
|
QMarginsF GetDefPrinterFields() const;
|
||||||
|
|
||||||
Unit PaperUnit() const;
|
Unit PaperUnit() const;
|
||||||
Unit LayoutUnit() const;
|
Unit LayoutUnit() const;
|
||||||
|
@ -174,6 +176,8 @@ private:
|
||||||
|
|
||||||
void SheetSize(const QSizeF &size);
|
void SheetSize(const QSizeF &size);
|
||||||
void SetAdditionalOptions(bool value);
|
void SetAdditionalOptions(bool value);
|
||||||
|
|
||||||
|
static QMarginsF GetPrinterFields(const QSharedPointer<QPrinter> &printer);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // DIALOGLAYOUTSETTINGS_H
|
#endif // DIALOGLAYOUTSETTINGS_H
|
||||||
|
|
|
@ -205,6 +205,12 @@
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_6">
|
<widget class="QLabel" name="label_6">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Printer:</string>
|
<string>Printer:</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -292,7 +298,7 @@
|
||||||
<item>
|
<item>
|
||||||
<widget class="QCheckBox" name="checkBoxIgnoreFileds">
|
<widget class="QCheckBox" name="checkBoxIgnoreFileds">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
|
@ -726,7 +732,7 @@
|
||||||
</connection>
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<buttongroups>
|
<buttongroups>
|
||||||
<buttongroup name="buttonGroupPrinciple"/>
|
|
||||||
<buttongroup name="buttonGroup"/>
|
<buttongroup name="buttonGroup"/>
|
||||||
|
<buttongroup name="buttonGroupPrinciple"/>
|
||||||
</buttongroups>
|
</buttongroups>
|
||||||
</ui>
|
</ui>
|
||||||
|
|
|
@ -65,6 +65,7 @@ MainWindowsNoGUI::MainWindowsNoGUI(QWidget *parent)
|
||||||
undoAction(nullptr), redoAction(nullptr), actionDockWidgetToolOptions(nullptr), actionDockWidgetGroups(nullptr),
|
undoAction(nullptr), redoAction(nullptr), actionDockWidgetToolOptions(nullptr), actionDockWidgetGroups(nullptr),
|
||||||
curFile(QString()),
|
curFile(QString()),
|
||||||
isLayoutStale(true),
|
isLayoutStale(true),
|
||||||
|
ignorePrinterFields(false),
|
||||||
margins(),
|
margins(),
|
||||||
paperSize(),
|
paperSize(),
|
||||||
isTiled(false),
|
isTiled(false),
|
||||||
|
@ -137,7 +138,8 @@ bool MainWindowsNoGUI::LayoutSettings(VLayoutGenerator& lGenerator)
|
||||||
CreateShadows();
|
CreateShadows();
|
||||||
CreateScenes();
|
CreateScenes();
|
||||||
PrepareSceneList();
|
PrepareSceneList();
|
||||||
margins = lGenerator.GetFields();
|
ignorePrinterFields = not lGenerator.IsUsePrinterFields();
|
||||||
|
margins = lGenerator.GetPrinterFields();
|
||||||
paperSize = QSizeF(lGenerator.GetPaperWidth(), lGenerator.GetPaperHeight());
|
paperSize = QSizeF(lGenerator.GetPaperWidth(), lGenerator.GetPaperHeight());
|
||||||
isAutoCrop = lGenerator.GetAutoCrop();
|
isAutoCrop = lGenerator.GetAutoCrop();
|
||||||
isUnitePages = lGenerator.IsUnitePages();
|
isUnitePages = lGenerator.IsUnitePages();
|
||||||
|
@ -647,6 +649,7 @@ void MainWindowsNoGUI::PdfFile(const QString &name, int i) const
|
||||||
{
|
{
|
||||||
printer.setOrientation(QPrinter::Landscape);
|
printer.setOrientation(QPrinter::Landscape);
|
||||||
}
|
}
|
||||||
|
printer.setFullPage(ignorePrinterFields);
|
||||||
printer.setPaperSize ( QSizeF(FromPixel(r.width() + margins.left() + margins.right(), Unit::Mm),
|
printer.setPaperSize ( QSizeF(FromPixel(r.width() + margins.left() + margins.right(), Unit::Mm),
|
||||||
FromPixel(r.height() + margins.top() + margins.bottom(), Unit::Mm)),
|
FromPixel(r.height() + margins.top() + margins.bottom(), Unit::Mm)),
|
||||||
QPrinter::Millimeter );
|
QPrinter::Millimeter );
|
||||||
|
@ -955,6 +958,8 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printer->setFullPage(ignorePrinterFields);
|
||||||
|
|
||||||
const qreal left = FromPixel(margins.left(), Unit::Mm);
|
const qreal left = FromPixel(margins.left(), Unit::Mm);
|
||||||
const qreal top = FromPixel(margins.top(), Unit::Mm);
|
const qreal top = FromPixel(margins.top(), Unit::Mm);
|
||||||
const qreal right = FromPixel(margins.right(), Unit::Mm);
|
const qreal right = FromPixel(margins.right(), Unit::Mm);
|
||||||
|
|
|
@ -86,6 +86,7 @@ protected:
|
||||||
QString curFile;
|
QString curFile;
|
||||||
|
|
||||||
bool isLayoutStale;
|
bool isLayoutStale;
|
||||||
|
bool ignorePrinterFields;
|
||||||
QMarginsF margins;
|
QMarginsF margins;
|
||||||
QSizeF paperSize;
|
QSizeF paperSize;
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,9 @@ class QMarginsF;
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
VLayoutGenerator::VLayoutGenerator(QObject *parent)
|
VLayoutGenerator::VLayoutGenerator(QObject *parent)
|
||||||
:QObject(parent), papers(QVector<VLayoutPaper>()), bank(new VBank()), paperHeight(0), paperWidth(0), margins(),
|
:QObject(parent), papers(QVector<VLayoutPaper>()), bank(new VBank()), paperHeight(0), paperWidth(0), margins(),
|
||||||
stopGeneration(false), state(LayoutErrors::NoError), shift(0), rotate(true), rotationIncrease(180),
|
usePrinterFields(true),stopGeneration(false), state(LayoutErrors::NoError), shift(0), rotate(true),
|
||||||
autoCrop(false), saveLength(false), unitePages(false), stripOptimizationEnabled(false), multiplier(1),
|
rotationIncrease(180), autoCrop(false), saveLength(false), unitePages(false), stripOptimizationEnabled(false),
|
||||||
stripOptimization(false)
|
multiplier(1), stripOptimization(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -499,14 +499,21 @@ void VLayoutGenerator::SetPaperWidth(qreal value)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QMarginsF VLayoutGenerator::GetFields() const
|
bool VLayoutGenerator::IsUsePrinterFields() const
|
||||||
|
{
|
||||||
|
return usePrinterFields;
|
||||||
|
}
|
||||||
|
|
||||||
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
QMarginsF VLayoutGenerator::GetPrinterFields() const
|
||||||
{
|
{
|
||||||
return margins;
|
return margins;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VLayoutGenerator::SetFields(const QMarginsF &value)
|
void VLayoutGenerator::SetPrinterFields(bool usePrinterFields, const QMarginsF &value)
|
||||||
{
|
{
|
||||||
|
this->usePrinterFields = usePrinterFields;
|
||||||
margins = value;
|
margins = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,8 +71,9 @@ public:
|
||||||
qreal GetPaperWidth() const;
|
qreal GetPaperWidth() const;
|
||||||
void SetPaperWidth(qreal value);
|
void SetPaperWidth(qreal value);
|
||||||
|
|
||||||
QMarginsF GetFields() const;
|
bool IsUsePrinterFields() const;
|
||||||
void SetFields(const QMarginsF &value);
|
QMarginsF GetPrinterFields() const;
|
||||||
|
void SetPrinterFields(bool usePrinterFields, const QMarginsF &value);
|
||||||
|
|
||||||
quint32 GetShift() const;
|
quint32 GetShift() const;
|
||||||
void SetShift(quint32 shift);
|
void SetShift(quint32 shift);
|
||||||
|
@ -121,6 +122,7 @@ private:
|
||||||
qreal paperHeight;
|
qreal paperHeight;
|
||||||
qreal paperWidth;
|
qreal paperWidth;
|
||||||
QMarginsF margins;
|
QMarginsF margins;
|
||||||
|
bool usePrinterFields;
|
||||||
volatile bool stopGeneration;
|
volatile bool stopGeneration;
|
||||||
LayoutErrors state;
|
LayoutErrors state;
|
||||||
quint32 shift;
|
quint32 shift;
|
||||||
|
|
|
@ -362,9 +362,8 @@ void VSettings::SetLayoutWidth(qreal value)
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QMarginsF VSettings::GetFields() const
|
QMarginsF VSettings::GetFields(const QMarginsF &def) const
|
||||||
{
|
{
|
||||||
const QMarginsF def = GetDefFields();
|
|
||||||
const QVariant val = value(SettingFields, QVariant::fromValue(def));
|
const QVariant val = value(SettingFields, QVariant::fromValue(def));
|
||||||
if (val.canConvert<QMarginsF>())
|
if (val.canConvert<QMarginsF>())
|
||||||
{
|
{
|
||||||
|
@ -373,34 +372,6 @@ QMarginsF VSettings::GetFields() const
|
||||||
return def;
|
return def;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QMarginsF VSettings::GetDefFields()
|
|
||||||
{
|
|
||||||
return GetPrinterFields(PreparePrinter(QPrinterInfo::defaultPrinter()));
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QMarginsF VSettings::GetPrinterFields(const QSharedPointer<QPrinter> &printer)
|
|
||||||
{
|
|
||||||
if (printer.isNull())
|
|
||||||
{
|
|
||||||
return QMarginsF();
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal left = 0;
|
|
||||||
qreal top = 0;
|
|
||||||
qreal right = 0;
|
|
||||||
qreal bottom = 0;
|
|
||||||
printer->getPageMargins(&left, &top, &right, &bottom, QPrinter::Millimeter);
|
|
||||||
// We can't use Unit::Px because our dpi in most cases is different
|
|
||||||
QMarginsF def;
|
|
||||||
def.setLeft(UnitConvertor(left, Unit::Mm, Unit::Px));
|
|
||||||
def.setRight(UnitConvertor(right, Unit::Mm, Unit::Px));
|
|
||||||
def.setTop(UnitConvertor(top, Unit::Mm, Unit::Px));
|
|
||||||
def.setBottom(UnitConvertor(bottom, Unit::Mm, Unit::Px));
|
|
||||||
return def;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
void VSettings::SetFields(const QMarginsF &value)
|
void VSettings::SetFields(const QMarginsF &value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -112,9 +112,7 @@ public:
|
||||||
static qreal GetDefLayoutWidth();
|
static qreal GetDefLayoutWidth();
|
||||||
void SetLayoutWidth(qreal value);
|
void SetLayoutWidth(qreal value);
|
||||||
|
|
||||||
QMarginsF GetFields() const;
|
QMarginsF GetFields(const QMarginsF &def = QMarginsF()) const;
|
||||||
static QMarginsF GetDefFields();
|
|
||||||
static QMarginsF GetPrinterFields(const QSharedPointer<QPrinter> &printer);
|
|
||||||
void SetFields(const QMarginsF &value);
|
void SetFields(const QMarginsF &value);
|
||||||
|
|
||||||
Cases GetLayoutGroup() const;
|
Cases GetLayoutGroup() const;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user