From 96828c1df0fafbcc2ef97e2d91bdffbb908d8189 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 29 Apr 2019 09:03:10 -0400 Subject: [PATCH] [oemid] Handle substitution in config-string --- src/modules/oemid/OEMViewStep.cpp | 31 ++++++++++++++++++++++++++++++- src/modules/oemid/OEMViewStep.h | 7 ++++++- src/modules/oemid/oemid.conf | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/modules/oemid/OEMViewStep.cpp b/src/modules/oemid/OEMViewStep.cpp index 8e038e7ff..b91dceed9 100644 --- a/src/modules/oemid/OEMViewStep.cpp +++ b/src/modules/oemid/OEMViewStep.cpp @@ -20,11 +20,13 @@ #include "utils/Variant.h" +#include #include OEMViewStep::OEMViewStep(QObject* parent) : Calamares::ViewStep( parent ) , m_widget( nullptr ) + , m_visited( false ) { } @@ -52,6 +54,33 @@ bool OEMViewStep::isAtEnd() const return true; } +static QString substitute( QString s ) +{ + QString t_date = QStringLiteral( "@@DATE@@" ); + if ( s.contains( t_date ) ) + { + auto date = QDate::currentDate(); + s = s.replace( t_date, date.toString( Qt::ISODate )); + } + + return s; +} + +void OEMViewStep::onActivate() +{ + if ( !m_visited && m_user_batchIdentifier.isEmpty() ) + { + m_user_batchIdentifier = substitute( m_conf_batchIdentifier ); + // m_widget->setIdentifier( m_user_batchIdentifier ); + } + m_visited = true; +} + +void OEMViewStep::onLeave() +{ + // m_user_batchIdentifier = m_widget->identifier(); +} + QString OEMViewStep::prettyName() const { return tr( "OEM Configuration" ); @@ -69,7 +98,7 @@ Calamares::JobList OEMViewStep::jobs() const void OEMViewStep::setConfigurationMap(const QVariantMap& configurationMap) { - m_batch = CalamaresUtils::getString( configurationMap, "batch-identifier" ); + m_conf_batchIdentifier = CalamaresUtils::getString( configurationMap, "batch-identifier" ); } CALAMARES_PLUGIN_FACTORY_DEFINITION( OEMViewStepFactory, registerPlugin(); ) diff --git a/src/modules/oemid/OEMViewStep.h b/src/modules/oemid/OEMViewStep.h index 137047b11..a4d917278 100644 --- a/src/modules/oemid/OEMViewStep.h +++ b/src/modules/oemid/OEMViewStep.h @@ -46,13 +46,18 @@ public: bool isAtBeginning() const override; bool isAtEnd() const override; + void onActivate() override; + void onLeave() override; + Calamares::JobList jobs() const override; void setConfigurationMap( const QVariantMap& configurationMap ) override; private: - QString m_batch; + QString m_conf_batchIdentifier; + QString m_user_batchIdentifier; OEMPage* m_widget; + bool m_visited; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( OEMViewStepFactory ) diff --git a/src/modules/oemid/oemid.conf b/src/modules/oemid/oemid.conf index 90587faae..36233858c 100644 --- a/src/modules/oemid/oemid.conf +++ b/src/modules/oemid/oemid.conf @@ -3,5 +3,5 @@ # The batch-identifier is written to /var/log/installer/oem-id. # This value is put into the text box as the **suggested** # OEM ID. If @@DATE@@ is included in the identifier, then -# that is replaced by the current date in YYYYMMDD (ISO) format. +# that is replaced by the current date in yyyy-MM-dd (ISO) format. batch-identifier: neon-@@DATE@@