parent
9da0b5cab5
commit
27767e46e2
|
@ -583,8 +583,8 @@ void DialogLayoutSettings::DialogAccepted()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const QMarginsF minFields = RoundMargins(MinPrinterFields());
|
const QMarginsF minFields = MinPrinterFields();
|
||||||
const QMarginsF fields = RoundMargins(GetFields());
|
const QMarginsF fields = GetFields();
|
||||||
if (fields.left() < minFields.left() || fields.right() < minFields.right() ||
|
if (fields.left() < minFields.left() || fields.right() < minFields.right() ||
|
||||||
fields.top() < minFields.top() || fields.bottom() < minFields.bottom())
|
fields.top() < minFields.top() || fields.bottom() < minFields.bottom())
|
||||||
{
|
{
|
||||||
|
@ -594,25 +594,24 @@ void DialogLayoutSettings::DialogAccepted()
|
||||||
QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
|
QMessageBox::Yes|QMessageBox::No, QMessageBox::No);
|
||||||
if (answer == QMessageBox::No)
|
if (answer == QMessageBox::No)
|
||||||
{
|
{
|
||||||
const QMarginsF defFields = RoundMargins(GetDefPrinterFields());
|
if (fields.left() < minFields.left())
|
||||||
if (fields.left() < defFields.left())
|
|
||||||
{
|
{
|
||||||
ui->doubleSpinBoxLeftField->setValue(UnitConvertor(defFields.left(), Unit::Px, LayoutUnit()));
|
ui->doubleSpinBoxLeftField->setValue(UnitConvertor(minFields.left(), Unit::Px, LayoutUnit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fields.right() < defFields.right())
|
if (fields.right() < minFields.right())
|
||||||
{
|
{
|
||||||
ui->doubleSpinBoxRightField->setValue(UnitConvertor(defFields.right(), Unit::Px, LayoutUnit()));
|
ui->doubleSpinBoxRightField->setValue(UnitConvertor(minFields.right(), Unit::Px, LayoutUnit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fields.top() < defFields.top())
|
if (fields.top() < minFields.top())
|
||||||
{
|
{
|
||||||
ui->doubleSpinBoxTopField->setValue(UnitConvertor(defFields.top(), Unit::Px, LayoutUnit()));
|
ui->doubleSpinBoxTopField->setValue(UnitConvertor(minFields.top(), Unit::Px, LayoutUnit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fields.bottom() < defFields.bottom())
|
if (fields.bottom() < minFields.bottom())
|
||||||
{
|
{
|
||||||
ui->doubleSpinBoxBottomField->setValue(UnitConvertor(defFields.bottom(), Unit::Px,
|
ui->doubleSpinBoxBottomField->setValue(UnitConvertor(minFields.bottom(), Unit::Px,
|
||||||
LayoutUnit()));
|
LayoutUnit()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -947,17 +946,6 @@ QSizeF DialogLayoutSettings::RoundTemplateSize(qreal width, qreal height) const
|
||||||
return QSizeF(width, height);
|
return QSizeF(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
|
||||||
QMarginsF DialogLayoutSettings::RoundMargins(const QMarginsF &margins) const
|
|
||||||
{
|
|
||||||
QMarginsF newMargins;
|
|
||||||
newMargins.setLeft(qRound(margins.left() * 100.0) / 100.0);
|
|
||||||
newMargins.setRight(qRound(margins.right() * 100.0) / 100.0);
|
|
||||||
newMargins.setTop(qRound(margins.top() * 100.0) / 100.0);
|
|
||||||
newMargins.setBottom(qRound(margins.bottom() * 100.0) / 100.0);
|
|
||||||
return newMargins;
|
|
||||||
}
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
QMarginsF DialogLayoutSettings::MinPrinterFields() const
|
QMarginsF DialogLayoutSettings::MinPrinterFields() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -158,7 +158,6 @@ private:
|
||||||
QSizeF Template();
|
QSizeF Template();
|
||||||
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 MinPrinterFields() const;
|
QMarginsF MinPrinterFields() const;
|
||||||
QMarginsF GetDefPrinterFields() const;
|
QMarginsF GetDefPrinterFields() const;
|
||||||
|
|
||||||
|
|
|
@ -964,7 +964,12 @@ void MainWindowsNoGUI::SetPrinterSettings(QPrinter *printer, const PrintType &pr
|
||||||
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);
|
||||||
const qreal bottom = FromPixel(margins.bottom(), Unit::Mm);
|
const qreal bottom = FromPixel(margins.bottom(), Unit::Mm);
|
||||||
printer->setPageMargins(left, top, right, bottom, QPrinter::Millimeter);
|
const bool success = printer->setPageMargins(left, top, right, bottom, QPrinter::Millimeter);
|
||||||
|
|
||||||
|
if (not success)
|
||||||
|
{
|
||||||
|
qWarning() << tr("Cannot set printer margins");
|
||||||
|
}
|
||||||
|
|
||||||
switch(printType)
|
switch(printType)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user