diff --git a/src/modules/packagechooser/Config.cpp b/src/modules/packagechooser/Config.cpp index 11288bde6..0001d9fc6 100644 --- a/src/modules/packagechooser/Config.cpp +++ b/src/modules/packagechooser/Config.cpp @@ -98,10 +98,13 @@ Config::introductionPackage() const void Config::updateGlobalStorage( const QStringList& selected ) const { + if ( m_packageChoice.has_value() ) + { + cWarning() << "Inconsistent package choices -- both model and single-selection QML"; + } if ( m_method == PackageChooserMethod::Legacy ) { QString value = selected.join( ',' ); - // QString value = ( m_pkgc ); Calamares::JobQueue::instance()->globalStorage()->insert( m_id, value ); cDebug() << m_id << "selected" << value; } @@ -118,6 +121,36 @@ Config::updateGlobalStorage( const QStringList& selected ) const } } +void +Config::updateGlobalStorage() const +{ + if ( m_model->packageCount() > 0 ) + { + cWarning() << "Inconsistent package choices -- both model and single-selection QML"; + } + if ( m_method == PackageChooserMethod::Legacy ) + { + auto* gs = Calamares::JobQueue::instance()->globalStorage(); + if ( m_packageChoice.has_value() ) + { + gs->insert( m_id, m_packageChoice.value() ); + } + else + { + gs->remove( m_id ); + } + } + else if ( m_method == PackageChooserMethod::Packages ) + { + cWarning() << "Unsupported single-selection packagechooser method 'Packages'"; + } + else + { + cWarning() << "Unknown packagechooser method" << smash( m_method ); + } +} + + void Config::setPackageChoice( const QString& packageChoice ) { @@ -252,5 +285,9 @@ Config::setConfigurationMap( const QVariantMap& configurationMap ) else { setPackageChoice( CalamaresUtils::getString( configurationMap, "packageChoice" ) ); + if ( m_method != PackageChooserMethod::Legacy ) + { + cWarning() << "Single-selection QML module must use 'Legacy' method."; + } } } diff --git a/src/modules/packagechooser/Config.h b/src/modules/packagechooser/Config.h index 75ff0d0c6..85b8de83f 100644 --- a/src/modules/packagechooser/Config.h +++ b/src/modules/packagechooser/Config.h @@ -85,8 +85,13 @@ public: * (and only) the packages in @p selected as selected. */ void updateGlobalStorage( const QStringList& selected ) const; - /// As updateGlobalStorage() with an empty selection list - void fillGSSecondaryConfiguration() const { updateGlobalStorage( QStringList() ); } + /** @brief Write selection to global storage + * + * Updates the GS keys for this packagechooser, marking **only** + * the package choice as selected. This assumes that the single- + * selection QML code is in use. + */ + void updateGlobalStorage() const; QString packageChoice() const { return m_packageChoice.value_or( QString() ); } void setPackageChoice( const QString& packageChoice ); diff --git a/src/modules/packagechooserq/PackageChooserQmlViewStep.cpp b/src/modules/packagechooserq/PackageChooserQmlViewStep.cpp index 109260ca9..543c9771d 100644 --- a/src/modules/packagechooserq/PackageChooserQmlViewStep.cpp +++ b/src/modules/packagechooserq/PackageChooserQmlViewStep.cpp @@ -74,7 +74,7 @@ PackageChooserQmlViewStep::jobs() const void PackageChooserQmlViewStep::onLeave() { - m_config->fillGSSecondaryConfiguration(); + m_config->updateGlobalStorage(); } void