mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-08-13 18:14:13 +02:00
5ba08284f5
Bugtracker #308: the "current date" preset for a project's default title block doesn't persist. A later comment on the report pinpointed it exactly: the setting falls back to "No date" unless the folio tab remains active when saving settings, and the same happens in Project Properties. TitleBlockPropertiesWidget::properties() (and its near-duplicate sibling propertiesAutoNum(), copy-pasted with the same bug) reads the date radio buttons like this: else if (ui->m_current_date_rb->isVisible() && ui->m_current_date_rb->isChecked()) { prop.useDate = TitleBlockProperties::CurrentDate; ... Both the New Project settings page and Project Properties embed this widget as one page of a QTabWidget (NewDiagramPage, in configpage/configpages.cpp). QWidget::isVisible() depends on the whole ancestor chain being visible, not just the widget's own state -- switch to any other tab before clicking OK/Apply and this radio button's isVisible() goes false even though it's still checked underneath, silently falling through all three branches. The function returns a default-constructed TitleBlockProperties for the date fields (useDate = UseDateValue, date = QDate(), i.e. "no date"), matching exactly what was reported. Fix: use isHidden() instead, which reflects only this widget's own explicit state and mirrors the read side's own check in setProperties()/initDialog() just above it in the same file -- that side already uses isHidden(), not isVisible(), for the identical "is the current-date option even offered here" question. Verified directly: a standalone Qt program constructing the real NewDiagramPage, checking "current date", switching the tab widget away from Folio to Conducteur (reproducing the report's exact trigger), then calling applyConf() and reading back the QSettings value. Against the original code this saves date="null"; with the fix, date="now" -- the same scenario, same tab switch, only the one line differs. Also confirmed a full Release build (504/504, CMake/ Ninja, Qt 5.15.18) with no new warnings.