[packagechooser] Massage API
- use updateGlobalStorage() for both single-selection and model-based approaches, although the model-based one needs extra parameters. - complain about inconsistent settings and API calls (e.g. setting a model and single-selection at the same time)
This commit is contained in:
parent
8a49fde016
commit
33e7e8da58
@ -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.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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 );
|
||||
|
@ -74,7 +74,7 @@ PackageChooserQmlViewStep::jobs() const
|
||||
void
|
||||
PackageChooserQmlViewStep::onLeave()
|
||||
{
|
||||
m_config->fillGSSecondaryConfiguration();
|
||||
m_config->updateGlobalStorage();
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user