mirror of
https://github.com/parchlinux/calamares.git
synced 2025-06-27 01:15:38 -04:00
[packagechooser] Rename internals
- pkgc -> packageChoice and similar for methods, variables - document that this is the convenience value for one-selection QML modules, not a full model - use std::optional to keep track of which one is being used.
This commit is contained in:
parent
47c504df5d
commit
c367731c42
2 changed files with 35 additions and 14 deletions
|
@ -100,8 +100,8 @@ Config::updateGlobalStorage( const QStringList& selected ) const
|
||||||
{
|
{
|
||||||
if ( m_method == PackageChooserMethod::Legacy )
|
if ( m_method == PackageChooserMethod::Legacy )
|
||||||
{
|
{
|
||||||
//QString value = selected.join( ',' );
|
QString value = selected.join( ',' );
|
||||||
QString value = ( m_pkgc );
|
// QString value = ( m_pkgc );
|
||||||
Calamares::JobQueue::instance()->globalStorage()->insert( m_id, value );
|
Calamares::JobQueue::instance()->globalStorage()->insert( m_id, value );
|
||||||
cDebug() << m_id << "selected" << value;
|
cDebug() << m_id << "selected" << value;
|
||||||
}
|
}
|
||||||
|
@ -119,16 +119,23 @@ Config::updateGlobalStorage( const QStringList& selected ) const
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::setPkgc( const QString& pkgc )
|
Config::setPackageChoice( const QString& packageChoice )
|
||||||
{
|
{
|
||||||
m_pkgc = pkgc;
|
if ( packageChoice.isEmpty() )
|
||||||
emit pkgcChanged( m_pkgc );
|
{
|
||||||
|
m_packageChoice.reset();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_packageChoice = packageChoice;
|
||||||
|
}
|
||||||
|
emit packageChoiceChanged( m_packageChoice.value_or( QString() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
QString
|
QString
|
||||||
Config::prettyStatus() const
|
Config::prettyStatus() const
|
||||||
{
|
{
|
||||||
return tr( "Install option: <strong>%1</strong>" ).arg( m_pkgc );
|
return tr( "Install option: <strong>%1</strong>" ).arg( m_packageChoice.value_or( tr( "None" ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -197,7 +204,7 @@ Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
PackageChooserMode::Required );
|
PackageChooserMode::Required );
|
||||||
m_method = PackageChooserMethodNames().find( CalamaresUtils::getString( configurationMap, "method" ),
|
m_method = PackageChooserMethodNames().find( CalamaresUtils::getString( configurationMap, "method" ),
|
||||||
PackageChooserMethod::Legacy );
|
PackageChooserMethod::Legacy );
|
||||||
m_pkgc = CalamaresUtils::getString( configurationMap, "pkgc" );
|
setPackageChoice( CalamaresUtils::getString( configurationMap, "pkgc" ) );
|
||||||
|
|
||||||
if ( m_method == PackageChooserMethod::Legacy )
|
if ( m_method == PackageChooserMethod::Legacy )
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include "modulesystem/InstanceKey.h"
|
#include "modulesystem/InstanceKey.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
enum class PackageChooserMode
|
enum class PackageChooserMode
|
||||||
{
|
{
|
||||||
|
@ -40,7 +41,16 @@ class Config : public Calamares::ModuleSystem::Config
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY( QString pkgc READ pkgc WRITE setPkgc NOTIFY pkgcChanged )
|
/** @brief This is the single-select package-choice
|
||||||
|
*
|
||||||
|
* For (QML) modules that support only a single selection and
|
||||||
|
* just want to do things in a straightforward pick-this-one
|
||||||
|
* way, the packageChoice property is a (the) way to go.
|
||||||
|
*
|
||||||
|
* Writing to this property means that any other form of package-
|
||||||
|
* choice or selection is ignored.
|
||||||
|
*/
|
||||||
|
Q_PROPERTY( QString packageChoice READ packageChoice WRITE setPackageChoice NOTIFY packageChoiceChanged )
|
||||||
Q_PROPERTY( QString prettyStatus READ prettyStatus NOTIFY prettyStatusChanged FINAL )
|
Q_PROPERTY( QString prettyStatus READ prettyStatus NOTIFY prettyStatusChanged FINAL )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -78,13 +88,13 @@ public:
|
||||||
/// As updateGlobalStorage() with an empty selection list
|
/// As updateGlobalStorage() with an empty selection list
|
||||||
void fillGSSecondaryConfiguration() const { updateGlobalStorage( QStringList() ); }
|
void fillGSSecondaryConfiguration() const { updateGlobalStorage( QStringList() ); }
|
||||||
|
|
||||||
QString pkgc() const { return m_pkgc; }
|
QString packageChoice() const { return m_packageChoice.value_or( QString() ); }
|
||||||
void setPkgc( const QString& pkgc );
|
void setPackageChoice( const QString& packageChoice );
|
||||||
|
|
||||||
QString prettyStatus() const;
|
QString prettyStatus() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void pkgcChanged( QString pkgc );
|
void packageChoiceChanged( QString packageChoice );
|
||||||
void prettyStatusChanged();
|
void prettyStatusChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -99,8 +109,12 @@ private:
|
||||||
QString m_id;
|
QString m_id;
|
||||||
/// Value to use for id if none is set in the config file
|
/// Value to use for id if none is set in the config file
|
||||||
Calamares::ModuleSystem::InstanceKey m_defaultId;
|
Calamares::ModuleSystem::InstanceKey m_defaultId;
|
||||||
/// QML selection
|
/** @brief QML selection (for single-selection approaches)
|
||||||
QString m_pkgc;
|
*
|
||||||
|
* If there is no value, then there has been no selection.
|
||||||
|
* Reading the property will return an empty QString.
|
||||||
|
*/
|
||||||
|
std::optional< QString > m_packageChoice;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue