[netinstall] Make status an enum
- Since we might change translations after loading, display the message based on the status enum, rather than setting it once at load-time.
This commit is contained in:
parent
f5b4e5d5e1
commit
1a74a713b6
@ -29,17 +29,38 @@
|
|||||||
|
|
||||||
Config::Config( QObject* parent )
|
Config::Config( QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
|
, m_status( Status::Ok )
|
||||||
, m_model( new PackageModel( this ) )
|
, m_model( new PackageModel( this ) )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::~Config() {}
|
Config::~Config() {}
|
||||||
|
|
||||||
|
QString
|
||||||
|
Config::status() const
|
||||||
|
{
|
||||||
|
switch ( m_status )
|
||||||
|
{
|
||||||
|
case Status::Ok:
|
||||||
|
return QString();
|
||||||
|
case Status::FailedBadConfiguration:
|
||||||
|
return tr( "Network Installation. (Disabled: Incorrect configuration)" );
|
||||||
|
case Status::FailedBadData:
|
||||||
|
return tr( "Network Installation. (Disabled: Received invalid groups data)" );
|
||||||
|
case Status::FailedInternalError:
|
||||||
|
return tr( "Network Installation. (Disabled: internal error)" );
|
||||||
|
case Status::FailedNetworkError:
|
||||||
|
return tr( "Network Installation. (Disabled: Unable to fetch package lists, check your network connection)" );
|
||||||
|
}
|
||||||
|
NOTREACHED return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::setStatus( const QString& s )
|
Config::setStatus( Status s )
|
||||||
{
|
{
|
||||||
m_status = s;
|
m_status = s;
|
||||||
emit statusChanged( m_status );
|
emit statusChanged( status() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -53,7 +74,7 @@ Config::loadGroupList( const QUrl& url )
|
|||||||
{
|
{
|
||||||
if ( !url.isValid() )
|
if ( !url.isValid() )
|
||||||
{
|
{
|
||||||
setStatus( tr( "Network Installation. (Disabled: Incorrect configuration)" ) );
|
setStatus( Status::FailedBadConfiguration );
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace CalamaresUtils::Network;
|
using namespace CalamaresUtils::Network;
|
||||||
@ -66,7 +87,7 @@ Config::loadGroupList( const QUrl& url )
|
|||||||
if ( !reply )
|
if ( !reply )
|
||||||
{
|
{
|
||||||
cDebug() << Logger::Continuation << "request failed immediately.";
|
cDebug() << Logger::Continuation << "request failed immediately.";
|
||||||
setStatus( tr( "Network Installation. (Disabled: Incorrect configuration)" ) );
|
setStatus( Status::FailedBadConfiguration );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -96,7 +117,7 @@ Config::receivedGroupData()
|
|||||||
if ( !m_reply || !m_reply->isFinished() )
|
if ( !m_reply || !m_reply->isFinished() )
|
||||||
{
|
{
|
||||||
cWarning() << "NetInstall data called too early.";
|
cWarning() << "NetInstall data called too early.";
|
||||||
setStatus( tr( "Network Installation. (Disabled: internal error)" ) );
|
setStatus( Status::FailedInternalError );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +133,7 @@ Config::receivedGroupData()
|
|||||||
cDebug() << Logger::SubEntry << "Netinstall reply error: " << m_reply->error();
|
cDebug() << Logger::SubEntry << "Netinstall reply error: " << m_reply->error();
|
||||||
cDebug() << Logger::SubEntry << "Request for url: " << m_reply->url().toString()
|
cDebug() << Logger::SubEntry << "Request for url: " << m_reply->url().toString()
|
||||||
<< " failed with: " << m_reply->errorString();
|
<< " failed with: " << m_reply->errorString();
|
||||||
setStatus( tr( "Network Installation. (Disabled: Unable to fetch package lists, check your network connection)" ) );
|
setStatus( Status::FailedNetworkError );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,6 +151,6 @@ Config::receivedGroupData()
|
|||||||
catch ( YAML::Exception& e )
|
catch ( YAML::Exception& e )
|
||||||
{
|
{
|
||||||
CalamaresUtils::explainYamlException( e, yamlData, "netinstall groups data" );
|
CalamaresUtils::explainYamlException( e, yamlData, "netinstall groups data" );
|
||||||
setStatus( tr( "Network Installation. (Disabled: Received invalid groups data)" ) );
|
setStatus( Status::FailedBadData );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,15 +33,23 @@ class Config : public QObject
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
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 WRITE setStatus NOTIFY statusChanged FINAL )
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Config( QObject* parent = nullptr );
|
Config( QObject* parent = nullptr );
|
||||||
virtual ~Config();
|
virtual ~Config();
|
||||||
|
|
||||||
QString status() const { return m_status; }
|
enum class Status
|
||||||
void setStatus( const QString& s );
|
{
|
||||||
|
Ok,
|
||||||
|
FailedBadConfiguration,
|
||||||
|
FailedInternalError,
|
||||||
|
FailedNetworkError,
|
||||||
|
FailedBadData
|
||||||
|
};
|
||||||
|
|
||||||
|
QString status() const;
|
||||||
|
void setStatus( Status s );
|
||||||
|
|
||||||
/** @brief Retrieves the groups, with name, description and packages
|
/** @brief Retrieves the groups, with name, description and packages
|
||||||
*
|
*
|
||||||
@ -64,7 +72,7 @@ private slots:
|
|||||||
void receivedGroupData(); ///< From async-loading group data
|
void receivedGroupData(); ///< From async-loading group data
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_status;
|
Status m_status;
|
||||||
PackageModel* m_model;
|
PackageModel* m_model;
|
||||||
QNetworkReply* m_reply = nullptr; // For fetching data
|
QNetworkReply* m_reply = nullptr; // For fetching data
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user