YAML list for uploadServer key

main
Anubhav Choudhary 4 years ago
parent 7057081bdf
commit 9738851261

@ -228,6 +228,7 @@ slideshowAPI: 2
# Takes string as input
# - port : Defines the port number to be used to send logs. Takes
# integer as input
uploadServer.type : "fiche"
uploadServer.url : "termbin.com"
uploadServer.port : 9999
uploadServer :
type : "fiche"
url : "termbin.com"
port : 9999

@ -87,6 +87,13 @@ const QStringList Branding::s_styleEntryStrings =
"sidebarTextSelect",
"sidebarTextHighlight"
};
const QStringList Branding::s_uploadServerStrings =
{
"type",
"url",
"port"
};
// clang-format on
// *INDENT-ON*
@ -219,6 +226,12 @@ Branding::Branding( const QString& brandingFilePath, QObject* parent )
return imageFi.absoluteFilePath();
} );
loadStrings( m_style, doc, "style", []( const QString& s ) -> QString { return s; } );
const QVariantMap temp = CalamaresUtils::yamlMapToVariant( doc[ "uploadServer" ] );
for ( auto it = temp.constBegin(); it != temp.constEnd(); ++it )
{
m_uploadServer.insert( it.key(), it.value().toString() );
}
}
catch ( YAML::Exception& e )
{
@ -279,6 +292,11 @@ Branding::imagePath( Branding::ImageEntry imageEntry ) const
return m_images.value( s_imageEntryStrings.value( imageEntry ) );
}
QString
Branding::uploadServer( Branding::UploadServerEntry uploadServerEntry ) const
{
return m_uploadServer.value( s_uploadServerStrings.value( uploadServerEntry ) );
}
QPixmap
Branding::image( Branding::ImageEntry imageEntry, const QSize& size ) const
@ -511,10 +529,6 @@ Branding::initSimpleSettings( const YAML::Node& doc )
{
m_windowHeight = WindowDimension( CalamaresUtils::windowPreferredHeight, WindowDimensionUnit::Pixies );
}
m_uploadServerURL = getString( doc, "uploadServer.url" );
m_uploadServerPort = doc[ "uploadServer.port" ].as< int >();
m_uploadServerType = getString( doc, "uploadServer.type" );
}
void

@ -83,6 +83,14 @@ public:
};
Q_ENUM( StyleEntry )
enum UploadServerEntry : short
{
Type,
URL,
Port
};
Q_ENUM( UploadServerEntry )
/** @brief Setting for how much the main window may expand. */
enum class WindowExpansion
{
@ -217,12 +225,6 @@ public:
*/
void setGlobals( GlobalStorage* globalStorage ) const;
//Paste functionality related
QString uploadServerType() { return m_uploadServerType; };
QUrl uploadServerURL() { return m_uploadServerURL; };
int uploadServerPort() { return m_uploadServerPort; };
public slots:
QString string( StringEntry stringEntry ) const;
QString versionedName() const { return string( VersionedName ); }
@ -232,6 +234,7 @@ public slots:
QString styleString( StyleEntry styleEntry ) const;
QString imagePath( ImageEntry imageEntry ) const;
QString uploadServer( UploadServerEntry uploadServerEntry ) const;
PanelSide sidebarSide() const { return m_sidebarSide; }
PanelSide navigationSide() const { return m_navigationSide; }
@ -242,12 +245,14 @@ private:
static const QStringList s_stringEntryStrings;
static const QStringList s_imageEntryStrings;
static const QStringList s_styleEntryStrings;
static const QStringList s_uploadServerStrings;
QString m_descriptorPath; // Path to descriptor (e.g. "/etc/calamares/default/branding.desc")
QString m_componentName; // Matches last part of full path to containing directory
QMap< QString, QString > m_strings;
QMap< QString, QString > m_images;
QMap< QString, QString > m_style;
QMap< QString, QString > m_uploadServer;
/* The slideshow can be done in one of two ways:
* - as a sequence of images
@ -270,10 +275,6 @@ private:
bool m_welcomeStyleCalamares;
bool m_welcomeExpandingLogo;
QString m_uploadServerType;
QUrl m_uploadServerURL;
int m_uploadServerPort;
WindowExpansion m_windowExpansion;
WindowDimension m_windowHeight, m_windowWidth;
WindowPlacement m_windowPlacement;

@ -141,7 +141,7 @@ ViewManager::insertViewStep( int before, ViewStep* step )
void
ViewManager::onInstallationFailed( const QString& message, const QString& details )
{
QString serverType = Calamares::Branding::instance()->uploadServerType();
QString serverType = Calamares::Branding::instance()->uploadServer( Calamares::Branding::Type );
bool shouldOfferWebPaste = CalamaresUtils::UploadServersList.contains( serverType );
cError() << "Installation failed:";
@ -186,7 +186,7 @@ ViewManager::onInstallationFailed( const QString& message, const QString& detail
if ( msgBox->buttonRole( button ) == QMessageBox::ButtonRole::YesRole )
{
QString pasteUrlMsg;
QString serverType = Calamares::Branding::instance()->uploadServerType();
QString serverType = Calamares::Branding::instance()->uploadServer( Calamares::Branding::Type );
if ( serverType == "fiche" )
{
pasteUrlMsg = CalamaresUtils::ficheLogUpload( msgBox );

@ -33,8 +33,8 @@ QString
ficheLogUpload( QObject* parent )
{
const QString& ficheHost = Calamares::Branding::instance()->uploadServerURL().toString();
quint16 fichePort = Calamares::Branding::instance()->uploadServerPort();
const QString& ficheHost = Calamares::Branding::instance()->uploadServer( Calamares::Branding::URL );
quint16 fichePort = Calamares::Branding::instance()->uploadServer( Calamares::Branding::Port ).toInt();
QString pasteUrlFmt = parent->tr( "Install log posted to\n\n%1\n\nLink copied to clipboard" );

Loading…
Cancel
Save