[netinstall] Continue moving settings to the Config object
This commit is contained in:
parent
dd8b893ee8
commit
cf7391696e
@ -12,9 +12,12 @@
|
|||||||
|
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
|
#include "GlobalStorage.h"
|
||||||
|
#include "JobQueue.h"
|
||||||
#include "network/Manager.h"
|
#include "network/Manager.h"
|
||||||
#include "utils/Logger.h"
|
#include "utils/Logger.h"
|
||||||
#include "utils/RAII.h"
|
#include "utils/RAII.h"
|
||||||
|
#include "utils/Variant.h"
|
||||||
#include "utils/Yaml.h"
|
#include "utils/Yaml.h"
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
@ -54,6 +57,19 @@ Config::setStatus( Status s )
|
|||||||
emit statusChanged( status() );
|
emit statusChanged( status() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
Config::sidebarLabel() const
|
||||||
|
{
|
||||||
|
return m_sidebarLabel ? m_sidebarLabel->get() : tr( "Package selection" );
|
||||||
|
}
|
||||||
|
|
||||||
|
QString
|
||||||
|
Config::titleLabel() const
|
||||||
|
{
|
||||||
|
return m_titleLabel ? m_titleLabel->get() : QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::loadGroupList( const QVariantList& groupData )
|
Config::loadGroupList( const QVariantList& groupData )
|
||||||
{
|
{
|
||||||
@ -143,3 +159,36 @@ Config::receivedGroupData()
|
|||||||
setStatus( Status::FailedBadData );
|
setStatus( Status::FailedBadData );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
|
{
|
||||||
|
setRequired( CalamaresUtils::getBool( configurationMap, "required", false ) );
|
||||||
|
|
||||||
|
// Get the translations, if any
|
||||||
|
bool bogus = false;
|
||||||
|
auto label = CalamaresUtils::getSubMap( configurationMap, "label", bogus );
|
||||||
|
|
||||||
|
if ( label.contains( "sidebar" ) )
|
||||||
|
{
|
||||||
|
m_sidebarLabel = new CalamaresUtils::Locale::TranslatedString( label, "sidebar", metaObject()->className() );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lastly, load the groups data
|
||||||
|
QString groupsUrl = CalamaresUtils::getString( configurationMap, "groupsUrl" );
|
||||||
|
if ( !groupsUrl.isEmpty() )
|
||||||
|
{
|
||||||
|
// Keep putting groupsUrl into the global storage,
|
||||||
|
// even though it's no longer used for in-module data-passing.
|
||||||
|
Calamares::JobQueue::instance()->globalStorage()->insert( "groupsUrl", groupsUrl );
|
||||||
|
if ( groupsUrl == QStringLiteral( "local" ) )
|
||||||
|
{
|
||||||
|
QVariantList l = configurationMap.value( "groups" ).toList();
|
||||||
|
loadGroupList( l );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
loadGroupList( groupsUrl );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -14,8 +14,11 @@
|
|||||||
|
|
||||||
#include "PackageModel.h"
|
#include "PackageModel.h"
|
||||||
|
|
||||||
|
#include "locale/TranslatableConfiguration.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
#include <QVariantMap>
|
||||||
|
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
|
|
||||||
@ -26,10 +29,16 @@ class Config : public QObject
|
|||||||
Q_PROPERTY( PackageModel* packageModel MEMBER m_model FINAL )
|
Q_PROPERTY( PackageModel* packageModel MEMBER m_model FINAL )
|
||||||
Q_PROPERTY( QString status READ status NOTIFY statusChanged FINAL )
|
Q_PROPERTY( QString status READ status NOTIFY statusChanged FINAL )
|
||||||
|
|
||||||
|
// Translations, of the module name (for sidebar) and above the list
|
||||||
|
Q_PROPERTY( QString sidebarLabel READ sidebarLabel NOTIFY sidebarLabelChanged FINAL )
|
||||||
|
Q_PROPERTY( QString titleLabel READ titleLabel NOTIFY titleLabelChanged FINAL )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Config( QObject* parent = nullptr );
|
Config( QObject* parent = nullptr );
|
||||||
~Config() override;
|
~Config() override;
|
||||||
|
|
||||||
|
void setConfigurationMap( const QVariantMap& configurationMap );
|
||||||
|
|
||||||
enum class Status
|
enum class Status
|
||||||
{
|
{
|
||||||
Ok,
|
Ok,
|
||||||
@ -45,6 +54,11 @@ public:
|
|||||||
bool required() const { return m_required; }
|
bool required() const { return m_required; }
|
||||||
void setRequired( bool r ) { m_required = r; }
|
void setRequired( bool r ) { m_required = r; }
|
||||||
|
|
||||||
|
PackageModel* model() const { return m_model; }
|
||||||
|
|
||||||
|
QString sidebarLabel() const;
|
||||||
|
QString titleLabel() const;
|
||||||
|
|
||||||
/** @brief Retrieves the groups, with name, description and packages
|
/** @brief Retrieves the groups, with name, description and packages
|
||||||
*
|
*
|
||||||
* Loads data from the given URL. Once done, the data is parsed
|
* Loads data from the given URL. Once done, the data is parsed
|
||||||
@ -59,16 +73,19 @@ public:
|
|||||||
*/
|
*/
|
||||||
void loadGroupList( const QVariantList& groupData );
|
void loadGroupList( const QVariantList& groupData );
|
||||||
|
|
||||||
PackageModel* model() const { return m_model; }
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void statusChanged( QString status ); ///< Something changed
|
void statusChanged( QString status ); ///< Something changed
|
||||||
|
void sidebarLabelChanged( QString label );
|
||||||
|
void titleLabelChanged( QString label );
|
||||||
void statusReady(); ///< Loading groups is complete
|
void statusReady(); ///< Loading groups is complete
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void receivedGroupData(); ///< From async-loading group data
|
void receivedGroupData(); ///< From async-loading group data
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
CalamaresUtils::Locale::TranslatedString* m_sidebarLabel = nullptr; // As it appears in the sidebar
|
||||||
|
CalamaresUtils::Locale::TranslatedString* m_titleLabel = nullptr;
|
||||||
PackageModel* m_model = nullptr;
|
PackageModel* m_model = nullptr;
|
||||||
QNetworkReply* m_reply = nullptr; // For fetching data
|
QNetworkReply* m_reply = nullptr; // For fetching data
|
||||||
Status m_status = Status::Ok;
|
Status m_status = Status::Ok;
|
||||||
|
@ -24,7 +24,6 @@ CALAMARES_PLUGIN_FACTORY_DEFINITION( NetInstallViewStepFactory, registerPlugin<
|
|||||||
NetInstallViewStep::NetInstallViewStep( QObject* parent )
|
NetInstallViewStep::NetInstallViewStep( QObject* parent )
|
||||||
: Calamares::ViewStep( parent )
|
: Calamares::ViewStep( parent )
|
||||||
, m_widget( new NetInstallPage( &m_config ) )
|
, m_widget( new NetInstallPage( &m_config ) )
|
||||||
, m_sidebarLabel( nullptr )
|
|
||||||
, m_nextEnabled( false )
|
, m_nextEnabled( false )
|
||||||
{
|
{
|
||||||
connect( &m_config, &Config::statusReady, this, &NetInstallViewStep::nextIsReady );
|
connect( &m_config, &Config::statusReady, this, &NetInstallViewStep::nextIsReady );
|
||||||
@ -37,14 +36,13 @@ NetInstallViewStep::~NetInstallViewStep()
|
|||||||
{
|
{
|
||||||
m_widget->deleteLater();
|
m_widget->deleteLater();
|
||||||
}
|
}
|
||||||
delete m_sidebarLabel;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString
|
QString
|
||||||
NetInstallViewStep::prettyName() const
|
NetInstallViewStep::prettyName() const
|
||||||
{
|
{
|
||||||
return m_sidebarLabel ? m_sidebarLabel->get() : tr( "Package selection" );
|
return m_config.sidebarLabel();
|
||||||
|
|
||||||
#if defined( TABLE_OF_TRANSLATIONS )
|
#if defined( TABLE_OF_TRANSLATIONS )
|
||||||
__builtin_unreachable();
|
__builtin_unreachable();
|
||||||
@ -201,32 +199,11 @@ NetInstallViewStep::nextIsReady()
|
|||||||
void
|
void
|
||||||
NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
NetInstallViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
m_config.setRequired( CalamaresUtils::getBool( configurationMap, "required", false ) );
|
m_config.setConfigurationMap( configurationMap );
|
||||||
|
|
||||||
QString groupsUrl = CalamaresUtils::getString( configurationMap, "groupsUrl" );
|
|
||||||
if ( !groupsUrl.isEmpty() )
|
|
||||||
{
|
|
||||||
// Keep putting groupsUrl into the global storage,
|
|
||||||
// even though it's no longer used for in-module data-passing.
|
|
||||||
Calamares::JobQueue::instance()->globalStorage()->insert( "groupsUrl", groupsUrl );
|
|
||||||
if ( groupsUrl == QStringLiteral( "local" ) )
|
|
||||||
{
|
|
||||||
QVariantList l = configurationMap.value( "groups" ).toList();
|
|
||||||
m_config.loadGroupList( l );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
m_config.loadGroupList( groupsUrl );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bogus = false;
|
bool bogus = false;
|
||||||
auto label = CalamaresUtils::getSubMap( configurationMap, "label", bogus );
|
auto label = CalamaresUtils::getSubMap( configurationMap, "label", bogus );
|
||||||
|
|
||||||
if ( label.contains( "sidebar" ) )
|
|
||||||
{
|
|
||||||
m_sidebarLabel = new CalamaresUtils::Locale::TranslatedString( label, "sidebar", metaObject()->className() );
|
|
||||||
}
|
|
||||||
if ( label.contains( "title" ) )
|
if ( label.contains( "title" ) )
|
||||||
{
|
{
|
||||||
m_widget->setPageTitle(
|
m_widget->setPageTitle(
|
||||||
|
@ -14,7 +14,6 @@
|
|||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
#include "locale/TranslatableConfiguration.h"
|
|
||||||
#include "utils/PluginFactory.h"
|
#include "utils/PluginFactory.h"
|
||||||
#include "viewpages/ViewStep.h"
|
#include "viewpages/ViewStep.h"
|
||||||
|
|
||||||
@ -56,7 +55,6 @@ private:
|
|||||||
Config m_config;
|
Config m_config;
|
||||||
|
|
||||||
NetInstallPage* m_widget;
|
NetInstallPage* m_widget;
|
||||||
CalamaresUtils::Locale::TranslatedString* m_sidebarLabel; // As it appears in the sidebar
|
|
||||||
bool m_nextEnabled = false;
|
bool m_nextEnabled = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user