Fix rounding problem when search a size template.

This commit is contained in:
Roman Telezhynskyi 2024-02-27 20:35:22 +02:00
parent eb22f19fea
commit 21b8401466
4 changed files with 7 additions and 4 deletions

View File

@ -690,7 +690,8 @@ void PuzzlePreferencesLayoutPage::FindTemplate(QComboBox *box, qreal width, qrea
{
const QSizeF tmplSize =
VAbstractLayoutDialog::GetTemplateSize(static_cast<VAbstractLayoutDialog::PaperSizeTemplate>(i), paperUnit);
if (QSizeF(width, height) == tmplSize || QSizeF(height, width) == tmplSize)
if (VAbstractLayoutDialog::RoundTemplateSize(width, height, paperUnit) == tmplSize ||
VAbstractLayoutDialog::RoundTemplateSize(height, width, paperUnit) == tmplSize)
{
box->blockSignals(true);
const int index = box->findData(i);

View File

@ -2144,7 +2144,8 @@ void VPMainWindow::FindTemplate(QComboBox *box, qreal width, qreal height)
{
const QSizeF tmplSize =
VAbstractLayoutDialog::GetTemplateSize(static_cast<VAbstractLayoutDialog::PaperSizeTemplate>(i), paperUnit);
if (QSizeF(width, height) == tmplSize || QSizeF(height, width) == tmplSize)
if (VAbstractLayoutDialog::RoundTemplateSize(width, height, paperUnit) == tmplSize ||
VAbstractLayoutDialog::RoundTemplateSize(height, width, paperUnit) == tmplSize)
{
box->blockSignals(true);
const int index = box->findData(i);

View File

@ -760,7 +760,8 @@ void DialogSaveLayout::ReadSettings()
ui->doubleSpinBoxBottomField->setSuffix(UnitsToStr(unit, true));
// read Template
const QSizeF size = QSizeF(settings->GetTiledPDFPaperWidth(Unit::Mm), settings->GetTiledPDFPaperHeight(Unit::Mm));
const QSizeF size = VAbstractLayoutDialog::RoundTemplateSize(settings->GetTiledPDFPaperWidth(Unit::Mm),
settings->GetTiledPDFPaperHeight(Unit::Mm), Unit::Mm);
const int max = static_cast<int>(PaperSizeTemplate::Custom);
for (int i = 0; i < max; ++i)

View File

@ -61,6 +61,7 @@ public:
explicit VAbstractLayoutDialog(QWidget *parent = nullptr);
static auto GetTemplateSize(PaperSizeTemplate tmpl, Unit unit) -> QSizeF;
static auto RoundTemplateSize(qreal width, qreal height, Unit unit) -> QSizeF;
static void InitTemplates(QComboBox *comboBoxTemplates);
static void InitTileTemplates(QComboBox *comboBoxTemplates, bool keepCustom = false);
@ -70,7 +71,6 @@ protected:
using VIndexType = int;
static auto PageFormatNames() -> const FormatsVector &;
static auto RoundTemplateSize(qreal width, qreal height, Unit unit) -> QSizeF;
private:
Q_DISABLE_COPY_MOVE(VAbstractLayoutDialog) // NOLINT