[libcalamaresui] Use meaningful type for Upload info
- use a struct with named fields instead of a tuple - offer an operator bool() for the logic of does-it-make-sense-to-upload
This commit is contained in:
parent
3234de5753
commit
b07c9bb4af
@ -162,14 +162,15 @@ uploadServerFromMap( const QVariantMap& map )
|
||||
|
||||
if ( typestring.isEmpty() || urlstring.isEmpty() )
|
||||
{
|
||||
return Branding::UploadServerInfo( Branding::UploadServerType::None, QUrl(), 0 );
|
||||
return Branding::UploadServerInfo { Branding::UploadServerType::None, QUrl(), 0 };
|
||||
}
|
||||
|
||||
bool bogus = false; // we don't care about type-name lookup success here
|
||||
return Branding::UploadServerInfo(
|
||||
return Branding::UploadServerInfo {
|
||||
names.find( typestring, bogus ),
|
||||
QUrl( urlstring, QUrl::ParsingMode::StrictMode ),
|
||||
sizeLimitKiB >= 0 ? CalamaresUtils::KiBtoBytes( static_cast< unsigned long long >( sizeLimitKiB ) ) : -1 );
|
||||
sizeLimitKiB >= 0 ? CalamaresUtils::KiBtoBytes( static_cast< unsigned long long >( sizeLimitKiB ) ) : -1
|
||||
};
|
||||
}
|
||||
|
||||
/** @brief Load the @p map with strings from @p config
|
||||
|
@ -227,7 +227,14 @@ public:
|
||||
* is irrelevant and usually empty), the URL for the upload and the size limit of upload
|
||||
* in bytes (for configuration value < 0, it serves -1, which stands for having no limit).
|
||||
*/
|
||||
using UploadServerInfo = std::tuple< UploadServerType, QUrl, qint64 >;
|
||||
struct UploadServerInfo
|
||||
{
|
||||
UploadServerType type;
|
||||
QUrl url;
|
||||
qint64 size;
|
||||
|
||||
operator bool() const { return type != Calamares::Branding::UploadServerType::None && size != 0; }
|
||||
};
|
||||
UploadServerInfo uploadServer() const { return m_uploadServer; }
|
||||
|
||||
/**
|
||||
|
@ -152,9 +152,7 @@ ViewManager::insertViewStep( int before, ViewStep* step )
|
||||
void
|
||||
ViewManager::onInstallationFailed( const QString& message, const QString& details )
|
||||
{
|
||||
const auto webPaste = Calamares::Branding::instance()->uploadServer();
|
||||
bool shouldOfferWebPaste
|
||||
= std::get< 0 >( webPaste ) != Calamares::Branding::UploadServerType::None and std::get< 2 >( webPaste ) != 0;
|
||||
bool shouldOfferWebPaste = bool( Calamares::Branding::instance()->uploadServer() );
|
||||
|
||||
cError() << "Installation failed:" << message;
|
||||
cDebug() << Logger::SubEntry << "- message:" << message;
|
||||
|
Loading…
Reference in New Issue
Block a user