[packagechooser] Read packages model from config
- add key *items* which will be used to fill up the model for software products. TODO: needs translation support
This commit is contained in:
parent
adb939b2e8
commit
791f9cbccb
@ -177,6 +177,15 @@ PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap
|
||||
m_id = moduleInstanceKey().split( '@' ).last();
|
||||
}
|
||||
|
||||
bool first_time = !m_model;
|
||||
|
||||
ok = false;
|
||||
QVariantMap items = CalamaresUtils::getSubMap( configurationMap, "items", ok );
|
||||
if ( ok )
|
||||
{
|
||||
fillModel( items );
|
||||
}
|
||||
|
||||
// TODO: replace this hard-coded model
|
||||
if ( !m_model )
|
||||
{
|
||||
@ -192,12 +201,54 @@ PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap
|
||||
m_model->addPackage( PackageItem { "kde", "kde", "Plasma", "Plasma Desktop", ":/images/kde.png" } );
|
||||
m_model->addPackage( PackageItem {
|
||||
"gnome", "gnome", "GNOME", "GNU Networked Object Modeling Environment Desktop", ":/images/gnome.png" } );
|
||||
}
|
||||
|
||||
if ( first_time && m_widget && m_model )
|
||||
{
|
||||
hookupModel();
|
||||
}
|
||||
}
|
||||
|
||||
if ( m_widget )
|
||||
void
|
||||
PackageChooserViewStep::fillModel( const QVariantMap& items )
|
||||
{
|
||||
if ( !m_model )
|
||||
{
|
||||
m_model = new PackageListModel( nullptr );
|
||||
}
|
||||
|
||||
cDebug() << "Loading PackageChooser model items from config";
|
||||
for ( auto item_it = items.constKeyValueBegin(); item_it != items.constKeyValueEnd(); ++item_it )
|
||||
{
|
||||
QString id = ( *item_it ).first;
|
||||
|
||||
QVariantMap item_map = ( *item_it ).second.toMap();
|
||||
if ( item_map.isEmpty() )
|
||||
{
|
||||
hookupModel();
|
||||
cWarning() << "PackageChooser item" << id << "is not valid.";
|
||||
continue;
|
||||
}
|
||||
|
||||
QString package = CalamaresUtils::getString( item_map, "package" );
|
||||
QString name = CalamaresUtils::getString( item_map, "name" );
|
||||
QString description = CalamaresUtils::getString( item_map, "description" );
|
||||
QString screenshot = CalamaresUtils::getString( item_map, "screenshot" );
|
||||
|
||||
if ( name.isEmpty() )
|
||||
{
|
||||
cWarning() << "PackageChooser item" << id << "has an empty name.";
|
||||
continue;
|
||||
}
|
||||
if ( description.isEmpty() )
|
||||
{
|
||||
description = tr( "No description provided." );
|
||||
}
|
||||
if ( screenshot.isEmpty() )
|
||||
{
|
||||
screenshot = QStringLiteral( ":/images/no-selection.png" );
|
||||
}
|
||||
|
||||
m_model->addPackage( PackageItem { id, package, name, description, screenshot } );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@ public:
|
||||
void setConfigurationMap( const QVariantMap& configurationMap ) override;
|
||||
|
||||
private:
|
||||
void fillModel( const QVariantMap& items );
|
||||
void hookupModel();
|
||||
|
||||
PackageChooserPage* m_widget;
|
||||
|
@ -19,3 +19,38 @@
|
||||
# or "optionalmultiple", "requiredmultiple" (for zero-or-more
|
||||
# or one-or-more).
|
||||
mode: required
|
||||
|
||||
# Items to display in the chooser. In general, this should be a
|
||||
# pretty short list to avoid overwhelming the UI.
|
||||
#
|
||||
# Each item has a key, which is used as its ID (used in setting
|
||||
# the value of *packagechooser_<module-id>*). The following fields
|
||||
# are mandatory:
|
||||
#
|
||||
# - *package* Package name for the product. While mandatory, this is
|
||||
# not actually used anywhere.
|
||||
# - *name* Human-readable, but untranslated, name of the product.
|
||||
# - *description* Human-readable, but untranslated, description.
|
||||
# - *screenshot* Path to a single screenshot of the product. May be
|
||||
# a filesystem path or a QRC path (e.g. ":/images/no-selection.png").
|
||||
#
|
||||
# Use the empty string "" as ID / key for the "no selection" item if
|
||||
# you want to customize the display of that item as well.
|
||||
items:
|
||||
"":
|
||||
package: ""
|
||||
name: "No Desktop"
|
||||
description: "Please pick a desktop environment from the list. If you don't want to install a desktop, that's fine, your system will start up in text-only mode and you can install a desktop environment later."
|
||||
screenshot: ":/images/no-selection.png"
|
||||
kde:
|
||||
package: kde
|
||||
name: Plasma Desktop
|
||||
description: "KDE Plasma Desktop, simple by default, a clean work area for real-world usage which intends to stay out of your way. Plasma is powerful when needed, enabling the user to create the workflow that makes them more effective to complete their tasks."
|
||||
screenshot: ":/images/kde.png"
|
||||
gnome:
|
||||
package: gnome
|
||||
name: GNOME
|
||||
description: GNU Networked Object Modeling Environment Desktop
|
||||
screenshot: ":/images/gnome.png"
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user