[welcome] Apply coding style

This commit is contained in:
Adriaan de Groot 2020-03-25 11:41:39 +01:00
parent ff74113675
commit 1ede7003c0
6 changed files with 224 additions and 228 deletions

View File

@ -17,10 +17,10 @@
*/ */
#include "Config.h" #include "Config.h"
#include "utils/Logger.h"
#include "utils/Retranslator.h"
#include "Branding.h" #include "Branding.h"
#include "Settings.h" #include "Settings.h"
#include "utils/Logger.h"
#include "utils/Retranslator.h"
#include <QApplication> #include <QApplication>
@ -83,7 +83,8 @@ RequirementsModel::roleNames() const
return roles; return roles;
} }
Config::Config( QObject* parent ) : QObject( parent ) Config::Config( QObject* parent )
: QObject( parent )
, m_requirementsModel( new RequirementsModel( this ) ) , m_requirementsModel( new RequirementsModel( this ) )
, m_languages( CalamaresUtils::Locale::availableTranslations() ) , m_languages( CalamaresUtils::Locale::availableTranslations() )
{ {
@ -180,8 +181,11 @@ Config::setLanguageIcon(const QString &languageIcon )
void void
Config::setLocaleIndex( const int& index ) Config::setLocaleIndex( const int& index )
{ {
if(index == m_localeIndex || index > CalamaresUtils::Locale::availableTranslations()->rowCount(QModelIndex()) || index < 0) if ( index == m_localeIndex || index > CalamaresUtils::Locale::availableTranslations()->rowCount( QModelIndex() )
|| index < 0 )
{
return; return;
}
m_localeIndex = index; m_localeIndex = index;
@ -189,8 +193,7 @@ Config::setLocaleIndex(const int& index)
cDebug() << "Selected locale" << selectedLocale; cDebug() << "Selected locale" << selectedLocale;
QLocale::setDefault( selectedLocale ); QLocale::setDefault( selectedLocale );
CalamaresUtils::installTranslator( CalamaresUtils::installTranslator( selectedLocale, Calamares::Branding::instance()->translationsDirectory(), qApp );
selectedLocale, Calamares::Branding::instance()->translationsDirectory(), qApp );
emit localeIndexChanged( m_localeIndex ); emit localeIndexChanged( m_localeIndex );
} }
@ -278,8 +281,8 @@ RequirementsModel::retranslate()
"requirements for installing %1.<br/>" "requirements for installing %1.<br/>"
"Installation cannot continue. " "Installation cannot continue. "
"<a href=\"#details\">Details...</a>" ); "<a href=\"#details\">Details...</a>" );
}
}else else
{ {
message = setup ? tr( "This computer does not satisfy some of the " message = setup ? tr( "This computer does not satisfy some of the "
"recommended requirements for setting up %1.<br/>" "recommended requirements for setting up %1.<br/>"
@ -292,7 +295,8 @@ RequirementsModel::retranslate()
} }
m_warningMessage = message.arg( *Calamares::Branding::ShortVersionedName ); m_warningMessage = message.arg( *Calamares::Branding::ShortVersionedName );
}else }
else
{ {
m_warningMessage = tr( "This program will ask you some questions and " m_warningMessage = tr( "This program will ask you some questions and "
"set up %2 on your computer." ) "set up %2 on your computer." )
@ -322,4 +326,3 @@ Config::genericWelcomeMessage()
return message; return message;
} }

View File

@ -19,9 +19,9 @@
#ifndef WELCOME_CONFIG_H #ifndef WELCOME_CONFIG_H
#define WELCOME_CONFIG_H #define WELCOME_CONFIG_H
#include "modulesystem/Requirement.h"
#include <QObject> #include <QObject>
#include <QUrl> #include <QUrl>
#include "modulesystem/Requirement.h"
#include "locale/LabelModel.h" #include "locale/LabelModel.h"
@ -45,37 +45,26 @@ public:
HasDetails HasDetails
}; };
bool satisfiedRequirements() const bool satisfiedRequirements() const { return m_satisfiedRequirements; }
{
return m_satisfiedRequirements;
}
bool satisfiedMandatory() const bool satisfiedMandatory() const { return m_satisfiedMandatory; }
{
return m_satisfiedMandatory;
}
const Calamares::RequirementEntry& getEntry( const int& index ) const const Calamares::RequirementEntry& getEntry( const int& index ) const
{ {
if ( index > count() || index < 0 ) if ( index > count() || index < 0 )
{
return *( new Calamares::RequirementEntry() ); return *( new Calamares::RequirementEntry() );
}
return m_requirements.at( index ); return m_requirements.at( index );
} }
void setRequirementsList( const Calamares::RequirementsList& requirements ); void setRequirementsList( const Calamares::RequirementsList& requirements );
int rowCount( const QModelIndex& ) const override; int rowCount( const QModelIndex& ) const override;
int count() const int count() const { return m_requirements.count(); }
{
return m_requirements.count();
}
QString warningMessage() const QString warningMessage() const { return m_warningMessage; }
{
return m_warningMessage;
}
void retranslate(); void retranslate();
@ -175,7 +164,6 @@ signals:
void knownIssuesUrlChanged(); void knownIssuesUrlChanged();
void releaseNotesUrlChanged(); void releaseNotesUrlChanged();
void donateUrlChanged(); void donateUrlChanged();
}; };
#endif #endif

View File

@ -25,9 +25,9 @@
#include "Branding.h" #include "Branding.h"
#include "CalamaresVersion.h" #include "CalamaresVersion.h"
#include "Config.h"
#include "Settings.h" #include "Settings.h"
#include "ViewManager.h" #include "ViewManager.h"
#include "Config.h"
#include "locale/LabelModel.h" #include "locale/LabelModel.h"
#include "modulesystem/ModuleManager.h" #include "modulesystem/ModuleManager.h"
@ -84,7 +84,8 @@ WelcomePage::WelcomePage( Config *conf, QWidget* parent )
ui->verticalLayout->insertWidget( welcome_text_idx + 1, m_checkingWidget ); ui->verticalLayout->insertWidget( welcome_text_idx + 1, m_checkingWidget );
} }
void WelcomePage::init() void
WelcomePage::init()
{ {
//setup the url buttons //setup the url buttons
setupButton( WelcomePage::Button::Support, m_conf->supportUrl() ); setupButton( WelcomePage::Button::Support, m_conf->supportUrl() );
@ -113,7 +114,9 @@ WelcomePage::initLanguages()
ui->languageWidget->setCurrentIndex( m_conf->localeIndex() ); ui->languageWidget->setCurrentIndex( m_conf->localeIndex() );
connect( ui->languageWidget, connect( ui->languageWidget,
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ), m_conf, &Config::setLocaleIndex ); static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
m_conf,
&Config::setLocaleIndex );
} }
void void

View File

@ -145,8 +145,10 @@ WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
using Calamares::Branding; using Calamares::Branding;
m_conf->setSupportUrl( jobOrBrandingSetting( Branding::SupportUrl, configurationMap, "showSupportUrl" ) ); m_conf->setSupportUrl( jobOrBrandingSetting( Branding::SupportUrl, configurationMap, "showSupportUrl" ) );
m_conf->setKnownIssuesUrl( jobOrBrandingSetting( Branding::KnownIssuesUrl, configurationMap, "showKnownIssuesUrl" ) ); m_conf->setKnownIssuesUrl(
m_conf->setReleaseNotesUrl( jobOrBrandingSetting( Branding::ReleaseNotesUrl, configurationMap, "showReleaseNotesUrl" ) ); jobOrBrandingSetting( Branding::KnownIssuesUrl, configurationMap, "showKnownIssuesUrl" ) );
m_conf->setReleaseNotesUrl(
jobOrBrandingSetting( Branding::ReleaseNotesUrl, configurationMap, "showReleaseNotesUrl" ) );
m_conf->setDonateUrl( CalamaresUtils::getString( configurationMap, "showDonateUrl" ) ); m_conf->setDonateUrl( CalamaresUtils::getString( configurationMap, "showDonateUrl" ) );
if ( configurationMap.contains( "requirements" ) if ( configurationMap.contains( "requirements" )