diff --git a/src/Mod/TechDraw/App/DrawTemplate.cpp b/src/Mod/TechDraw/App/DrawTemplate.cpp index 8964f10042..e36cba4373 100644 --- a/src/Mod/TechDraw/App/DrawTemplate.cpp +++ b/src/Mod/TechDraw/App/DrawTemplate.cpp @@ -37,6 +37,7 @@ #include "DrawTemplatePy.h" #include "DrawPage.h" #include "DrawUtil.h" +#include "Preferences.h" using namespace TechDraw; @@ -129,6 +130,7 @@ std::pair DrawTemplate::getPageNumbers() const //! get replacement values from document QString DrawTemplate::getAutofillValue(const QString &id) const { + constexpr int ISODATELENGTH {10}; auto doc = getDocument(); if (!doc) { return QString(); @@ -142,8 +144,14 @@ QString DrawTemplate::getAutofillValue(const QString &id) const } // date else if (id.compare(QString::fromUtf8(Autofill::Date)) == 0) { + auto timeLocale = std::setlocale(LC_TIME, nullptr); QDateTime date = QDateTime::currentDateTime(); - return date.toString(QLocale().dateFormat(QLocale::ShortFormat)); + if (Preferences::enforceISODate()) { + auto rawDate = date.toString(Qt::ISODate); + return rawDate.left(ISODATELENGTH); + } + auto qTimeLocale = QString::fromUtf8(timeLocale); + return date.toString(QLocale(qTimeLocale).dateFormat(QLocale::ShortFormat)); } // organization ( also organisation/owner/company ) else if (id.compare(QString::fromUtf8(Autofill::Organization)) == 0 || diff --git a/src/Mod/TechDraw/App/Preferences.cpp b/src/Mod/TechDraw/App/Preferences.cpp index 7962467cd0..9515e7b2d6 100644 --- a/src/Mod/TechDraw/App/Preferences.cpp +++ b/src/Mod/TechDraw/App/Preferences.cpp @@ -650,6 +650,11 @@ void Preferences::setBalloonDragModifiers(Qt::KeyboardModifiers newModifiers) getPreferenceGroup("General")->SetUnsigned("BalloonDragModifier", (uint)newModifiers); } +bool Preferences::enforceISODate() +{ + return getPreferenceGroup("Standards")->GetBool("EnforceISODate", false); +} + //! if true, shapes are validated before use and problematic ones are skipped. //! validating shape takes time, but can prevent crashes/bad results in occt. //! this would normally be set to false and set to true to aid in debugging/support. diff --git a/src/Mod/TechDraw/App/Preferences.h b/src/Mod/TechDraw/App/Preferences.h index b93889f1bd..2d1a99476f 100644 --- a/src/Mod/TechDraw/App/Preferences.h +++ b/src/Mod/TechDraw/App/Preferences.h @@ -151,6 +151,7 @@ public: static Qt::KeyboardModifiers balloonDragModifiers(); static void setBalloonDragModifiers(Qt::KeyboardModifiers newModifiers); + static bool enforceISODate(); static bool switchOnClick(); static bool checkShapesBeforeUse(); diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotation.ui b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotation.ui index 5f49c6a912..eb5d494323 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotation.ui +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotation.ui @@ -6,8 +6,8 @@ 0 0 - 580 - 795 + 835 + 956 @@ -28,231 +28,6 @@ - - - - - 0 - 0 - - - - Length of balloon leader line kink - - - 5.000000000000000 - - - BalloonKink - - - Mod/TechDraw/Dimensions - - - - - - - This checkbox controls whether or not to display a highlight around the detail area in the detail's source view. - - - Detail Source Show Highlight - - - true - - - ShowDetailHighlight - - - /Mod/TechDraw/General - - - - - - - - true - - - - Section Cut Surface - - - - - - - - 0 - 0 - - - - Style for balloon leader line ends - - - BalloonArrow - - - Mod/TechDraw/Decorations - - - - - - - - true - - - - Balloon Leader End - - - - - - - - true - - - - If checked, the cut line will be drawn on the Source view. If unchecked, only the change marks, arrows and symbols will be displayed. - - - Include Cut Line in Section Annotation - - - true - - - IncludeCutLine - - - Mod/TechDraw/Decorations - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - true - - - - Show or hide marks at direction changes on ComplexSection lines. - - - Complex Section Line Marks - - - true - - - SectionLineMarks - - - Mod/TechDraw/Decorations - - - - - - - This checkbox controls whether or not to display the outline around a detail view. - - - Detail View Show Matting - - - true - - - ShowDetailMatting - - - /Mod/TechDraw/General - - - - - - - - true - - - - If checked, the section annotation will be drawn on the Source view. If unchecked, no section line, arrows or symbol will be shown in the Source view. - - - Show Section Line in Source View - - - true - - - ShowSectionLine - - - Mod/TechDraw/Decorations - - - - - - - - false - - - - Detail View Outline Shape - - - - - - - - 0 - 0 - - - - Restrict Filled Triangle line end to vertical or horizontal directions - - - Balloon Orthogonal Triangle - - - true - - - PyramidOrtho - - - Mod/TechDraw/Decorations - - - @@ -275,36 +50,6 @@ - - - - - 0 - 0 - - - - - true - - - - Forces last leader line segment to be horizontal - - - Leader Line Auto Horizontal - - - true - - - AutoHorizontal - - - Mod/TechDraw/LeaderLine - - - @@ -335,15 +80,141 @@ - - + + + + + true + + + + If checked, the section annotation will be drawn on the Source view. If unchecked, no section line, arrows or symbol will be shown in the Source view. + + + Show Section Line in Source View + + + true + + + ShowSectionLine + + + Mod/TechDraw/Decorations + + + + + + + + 0 + 0 + + + + Shape of balloon annotations + + + BalloonShape + + + Mod/TechDraw/Decorations + + + + + + + + true + + + + If checked, the cut line will be drawn on the Source view. If unchecked, only the change marks, arrows and symbols will be displayed. + + + Include Cut Line in Section Annotation + + + true + + + IncludeCutLine + + + Mod/TechDraw/Decorations + + + + + + + + 0 + 0 + + + + Style for balloon leader line ends + + + BalloonArrow + + + Mod/TechDraw/Decorations + + + + + + + + true + + + + Length of horizontal portion of Balloon leader + + + Balloon Leader Kink Length + + + + + true - Balloon Shape + Broken View Break Type + + + + + + + + 0 + 0 + + + + Restrict Filled Triangle line end to vertical or horizontal directions + + + Balloon Orthogonal Triangle + + + true + + + PyramidOrtho + + + Mod/TechDraw/Decorations @@ -383,68 +254,108 @@ - - + + + + This checkbox controls whether or not to display the outline around a detail view. + + + Detail View Show Matting + + + true + + + ShowDetailMatting + + + /Mod/TechDraw/General + + + + + + + This checkbox controls whether or not to display a highlight around the detail area in the detail's source view. + + + Detail Source Show Highlight + + + true + + + ShowDetailHighlight + + + /Mod/TechDraw/General + + + + + + + + false + + + + Detail View Outline Shape + + + + + 0 0 - - Outline shape for detail views - - - MattingStyle - - - /Mod/TechDraw/Decorations - - - - - - - - 0 - 0 - - - - Shape of balloon annotations - - - BalloonShape - - - Mod/TechDraw/Decorations - - - - - true - Length of horizontal portion of Balloon leader + Forces last leader line segment to be horizontal - Balloon Leader Kink Length + Leader Line Auto Horizontal + + + true + + + AutoHorizontal + + + Mod/TechDraw/LeaderLine - - + + + + Qt::Orientation::Horizontal + + + + 40 + 20 + + + + + + true - Broken View Break Type + Balloon Leader End @@ -476,6 +387,111 @@ + + + + + true + + + + Balloon Shape + + + + + + + + true + + + + Section Cut Surface + + + + + + + + 0 + 0 + + + + Outline shape for detail views + + + MattingStyle + + + /Mod/TechDraw/Decorations + + + + + + + + true + + + + Show or hide marks at direction changes on ComplexSection lines. + + + Complex Section Line Marks + + + true + + + SectionLineMarks + + + Mod/TechDraw/Decorations + + + + + + + + 0 + 0 + + + + Length of balloon leader line kink + + + 5.000000000000000 + + + BalloonKink + + + Mod/TechDraw/Dimensions + + + + + + + If this box is checked, templates will auto fill date fields using ccyy-mm-dd format even if that is not the standard format for the current locale. + + + Enforce ISO 8601 Date Format + + + EnforceISODate + + + Mod/TechDraw/Standards + + + @@ -507,7 +523,7 @@ 6 - QComboBox::AdjustToContents + QComboBox::SizeAdjustPolicy::AdjustToContents @@ -775,7 +791,7 @@ if you are planning to use a drawing as a 1:1 cutting guide. - Qt::Horizontal + Qt::Orientation::Horizontal @@ -837,7 +853,7 @@ if you are planning to use a drawing as a 1:1 cutting guide. - Qt::Vertical + Qt::Orientation::Vertical @@ -871,8 +887,6 @@ if you are planning to use a drawing as a 1:1 cutting guide.
Gui/PrefWidgets.h
- - - + diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp index 551d20d45a..1affe1666a 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAnnotationImp.cpp @@ -127,6 +127,7 @@ void DlgPrefsTechDrawAnnotationImp::saveSettings() ui->pcbBreakType->onSave(); ui->pcbBreakStyle->onSave(); + ui->cbISODates->onSave(); } void DlgPrefsTechDrawAnnotationImp::loadSettings() @@ -186,6 +187,7 @@ void DlgPrefsTechDrawAnnotationImp::loadSettings() loadLineStyleBoxes(); ui->pcbBreakType->onRestore(); + ui->cbISODates->onRestore(); } /** diff --git a/src/Mod/TechDraw/Gui/TemplateTextField.cpp b/src/Mod/TechDraw/Gui/TemplateTextField.cpp index b0327184a2..dd22a49863 100644 --- a/src/Mod/TechDraw/Gui/TemplateTextField.cpp +++ b/src/Mod/TechDraw/Gui/TemplateTextField.cpp @@ -77,14 +77,21 @@ void TemplateTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) ui.setFieldName(fieldNameStr); ui.setFieldContent(tmplte->EditableTexts[fieldNameStr]); + + auto qName = QString::fromStdString(fieldNameStr); + auto svgTemplate = dynamic_cast(tmplte); + if (svgTemplate) { + // preset the autofill with the current value - something might have changed since this field was created + m_autofillString = svgTemplate->getAutofillByEditableName(qName); + } ui.setAutofillContent(m_autofillString.toStdString()); if (ui.exec() == QDialog::Accepted) { QString qsClean = ui.getFieldContent(); std::string utf8Content = qsClean.toUtf8().constData(); if (ui.getAutofillState()) { - auto svgTemplate = dynamic_cast(tmplte); if (svgTemplate) { + // unlikely, but something could have changed since we grabbed the autofill value QString fieldName = QString::fromStdString(fieldNameStr); QString autofillValue = svgTemplate->getAutofillByEditableName(fieldName); if (!autofillValue.isEmpty()) {