1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-28 05:34:47 +01:00

Fixed margins operators + print margins now in cm

This commit is contained in:
Martin Tůma 2020-10-06 22:02:26 +02:00
parent 789f314ae8
commit 378da395fb
3 changed files with 6 additions and 5 deletions

View File

@ -20,13 +20,13 @@ private:
qreal _left, _top, _right, _bottom; qreal _left, _top, _right, _bottom;
}; };
inline MarginsF operator*(const MarginsF &margins, int factor) inline MarginsF operator*(const MarginsF &margins, qreal factor)
{ {
return MarginsF(margins.left() * factor, margins.top() * factor, return MarginsF(margins.left() * factor, margins.top() * factor,
margins.right() * factor, margins.bottom() * factor); margins.right() * factor, margins.bottom() * factor);
} }
inline MarginsF operator/(const MarginsF &margins, int factor) inline MarginsF operator/(const MarginsF &margins, qreal factor)
{ {
return MarginsF(margins.left() / factor, margins.top() / factor, return MarginsF(margins.left() / factor, margins.top() / factor,
margins.right() / factor, margins.bottom() / factor); margins.right() / factor, margins.bottom() / factor);

View File

@ -59,10 +59,10 @@ PDFExportDialog::PDFExportDialog(PDFExport &exp, Units units, QWidget *parent)
_landscape->setChecked(true); _landscape->setChecked(true);
_margins = new MarginsFWidget(); _margins = new MarginsFWidget();
_margins->setUnits((units == Metric) ? tr("mm") : tr("in")); _margins->setUnits((units == Metric) ? tr("cm") : tr("in"));
_margins->setSingleStep(0.1); _margins->setSingleStep(0.1);
_margins->setValue((units == Metric) _margins->setValue((units == Metric)
? _export.margins : _export.margins * MM2IN); ? _export.margins * MM2CM : _export.margins * MM2IN);
#ifndef Q_OS_MAC #ifndef Q_OS_MAC
QGroupBox *pageSetupBox = new QGroupBox(tr("Page Setup")); QGroupBox *pageSetupBox = new QGroupBox(tr("Page Setup"));
@ -129,7 +129,7 @@ void PDFExportDialog::accept()
_export.resolution = resolution; _export.resolution = resolution;
_export.orientation = orientation; _export.orientation = orientation;
_export.margins = (_units == Imperial) _export.margins = (_units == Imperial)
? _margins->value() / MM2IN : _margins->value(); ? _margins->value() / MM2IN : _margins->value() / MM2CM;
QDialog::accept(); QDialog::accept();
} }

View File

@ -16,6 +16,7 @@ enum Units {
#define MS2KN 1.943844490000 // m/s -> kn #define MS2KN 1.943844490000 // m/s -> kn
#define FT2MI 0.000189393939 // ft -> mi #define FT2MI 0.000189393939 // ft -> mi
#define MM2IN 0.039370100000 // mm -> in #define MM2IN 0.039370100000 // mm -> in
#define MM2CM 0.100000000000 // mm -> cm
#define H2S 0.000277777778 // h -> s #define H2S 0.000277777778 // h -> s
#define MIN2S 0.016666666667 // min -> s #define MIN2S 0.016666666667 // min -> s