From 003eda2cb8d304eb86cd55ff686417c7d2c7987c Mon Sep 17 00:00:00 2001 From: ispyisail Date: Fri, 2 Oct 2026 21:04:53 +1300 Subject: [PATCH] Fix Project properties saving the Page Num placeholder as a numbering name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In Projet > Propriétés du projet > Nouveau folio, the Page Num box shows a "Créer un Folio Numérotation Auto" entry when the project has no folio auto-numbering. Pressing OK, even without touching anything, returned that entry's text as the numbering's name: it was saved in the project as auto_page_num (in the interface's language), and since it differed from the stored empty value the project was marked modified. When the project has numberings, an empty stored value cannot be shown at all, so the first numbering came back instead. Return the stored value unless the user picks an entry (activated() is only emitted for a user's choice), and never return the placeholder. Checked in the GUI on grafcet, schema_indus and Projet_vierge: after OK with no edit and Ctrl+S, master saves auto_page_num="Créer un Folio Numérotation Auto"; this branch keeps auto_page_num="". An edited field on the same page (default author) is still saved. Co-Authored-By: Claude Opus 5.5 (1M context) --- sources/ui/titleblockpropertieswidget.cpp | 13 ++++++++++++- sources/ui/titleblockpropertieswidget.h | 4 ++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/sources/ui/titleblockpropertieswidget.cpp b/sources/ui/titleblockpropertieswidget.cpp index 929b557c2..f0d99a61a 100644 --- a/sources/ui/titleblockpropertieswidget.cpp +++ b/sources/ui/titleblockpropertieswidget.cpp @@ -123,6 +123,8 @@ void TitleBlockPropertiesWidget::setProperties( ui -> m_folio_le -> setText (properties.folio); ui -> m_display_at_cb -> setCurrentIndex(properties.display_at == Qt::BottomEdge ? 0 : 1); ui->auto_page_cb->setCurrentText(properties.auto_page_num); + m_auto_page_num = properties.auto_page_num; + m_auto_page_num_picked = false; //About date ui -> m_date_now_pb -> setDisabled(true); @@ -216,7 +218,13 @@ TitleBlockProperties TitleBlockPropertiesWidget::properties() const prop.context = m_dcw -> context(); - prop.auto_page_num = ui->auto_page_cb->currentText(); + //The combo box cannot show "no folio numbering": it shows its + //placeholder entry, or the project's first numbering. Return what + //was set unless the user picked something else. + if (!m_auto_page_num_picked) + prop.auto_page_num = m_auto_page_num; + else if (ui->auto_page_cb->currentText() != tr("Créer un Folio Numérotation Auto")) + prop.auto_page_num = ui->auto_page_cb->currentText(); return prop; } @@ -376,6 +384,9 @@ void TitleBlockPropertiesWidget::initDialog( foreach (QString str, keys_2) { ui -> auto_page_cb -> addItem(str); } if (ui->auto_page_cb->currentText()==nullptr) ui->auto_page_cb->addItem(tr("Créer un Folio Numérotation Auto")); + //activated() is only emitted for a choice the user makes + connect(ui->auto_page_cb, qOverload(&QComboBox::activated), + this, [this]() { m_auto_page_num_picked = true; }); } else{ ui->auto_page_cb->hide(); diff --git a/sources/ui/titleblockpropertieswidget.h b/sources/ui/titleblockpropertieswidget.h index 0622da8a5..6736bfcdf 100644 --- a/sources/ui/titleblockpropertieswidget.h +++ b/sources/ui/titleblockpropertieswidget.h @@ -105,6 +105,10 @@ class TitleBlockPropertiesWidget : public QWidget QList m_tbt_collection_list; QList m_map_index_to_collection_type; QList keys_2; + /// auto_page_num as given to setProperties(), returned + /// unchanged unless the user picks another folio numbering + QString m_auto_page_num; + bool m_auto_page_num_picked = false; }; #endif // TITLEBLOCKPROPERTIESWIDGET_H