|
|
|
@ -20,8 +20,8 @@
|
|
|
|
|
|
|
|
|
|
#include "WelcomePage.h"
|
|
|
|
|
|
|
|
|
|
#include "ui_WelcomePage.h"
|
|
|
|
|
#include "checker/CheckerContainer.h"
|
|
|
|
|
#include "ui_WelcomePage.h"
|
|
|
|
|
|
|
|
|
|
#include "Branding.h"
|
|
|
|
|
#include "CalamaresVersion.h"
|
|
|
|
@ -48,9 +48,18 @@ WelcomePage::WelcomePage( QWidget* parent )
|
|
|
|
|
, m_checkingWidget( new CheckerContainer( this ) )
|
|
|
|
|
, m_languages( nullptr )
|
|
|
|
|
{
|
|
|
|
|
connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsResult, m_checkingWidget, &CheckerContainer::requirementsChecked );
|
|
|
|
|
connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsComplete, m_checkingWidget, &CheckerContainer::requirementsComplete );
|
|
|
|
|
connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsProgress, m_checkingWidget, &CheckerContainer::requirementsProgress );
|
|
|
|
|
connect( Calamares::ModuleManager::instance(),
|
|
|
|
|
&Calamares::ModuleManager::requirementsResult,
|
|
|
|
|
m_checkingWidget,
|
|
|
|
|
&CheckerContainer::requirementsChecked );
|
|
|
|
|
connect( Calamares::ModuleManager::instance(),
|
|
|
|
|
&Calamares::ModuleManager::requirementsComplete,
|
|
|
|
|
m_checkingWidget,
|
|
|
|
|
&CheckerContainer::requirementsComplete );
|
|
|
|
|
connect( Calamares::ModuleManager::instance(),
|
|
|
|
|
&Calamares::ModuleManager::requirementsProgress,
|
|
|
|
|
m_checkingWidget,
|
|
|
|
|
&CheckerContainer::requirementsProgress );
|
|
|
|
|
ui->setupUi( this );
|
|
|
|
|
|
|
|
|
|
ui->verticalLayout->insertSpacing( 1, CalamaresUtils::defaultFontHeight() * 2 );
|
|
|
|
@ -61,38 +70,31 @@ WelcomePage::WelcomePage( QWidget* parent )
|
|
|
|
|
ui->mainText->setOpenExternalLinks( true );
|
|
|
|
|
|
|
|
|
|
cDebug() << "Welcome string" << Calamares::Branding::instance()->welcomeStyleCalamares()
|
|
|
|
|
<< *Calamares::Branding::VersionedName;
|
|
|
|
|
|
|
|
|
|
CALAMARES_RETRANSLATE(
|
|
|
|
|
QString message;
|
|
|
|
|
|
|
|
|
|
if ( Calamares::Settings::instance()->isSetupMode() )
|
|
|
|
|
message = Calamares::Branding::instance()->welcomeStyleCalamares()
|
|
|
|
|
? tr( "<h1>Welcome to the Calamares setup program for %1.</h1>" )
|
|
|
|
|
: tr( "<h1>Welcome to %1 setup.</h1>" );
|
|
|
|
|
else
|
|
|
|
|
message = Calamares::Branding::instance()->welcomeStyleCalamares()
|
|
|
|
|
? tr( "<h1>Welcome to the Calamares installer for %1.</h1>" )
|
|
|
|
|
: tr( "<h1>Welcome to the %1 installer.</h1>" );
|
|
|
|
|
|
|
|
|
|
ui->mainText->setText( message.arg( *Calamares::Branding::VersionedName ) );
|
|
|
|
|
ui->retranslateUi( this );
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
ui->aboutButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Information,
|
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
|
2*QSize( CalamaresUtils::defaultFontHeight(),
|
|
|
|
|
CalamaresUtils::defaultFontHeight() ) ) );
|
|
|
|
|
connect( ui->aboutButton, &QPushButton::clicked,
|
|
|
|
|
this, [ this ]
|
|
|
|
|
{
|
|
|
|
|
QString title = Calamares::Settings::instance()->isSetupMode()
|
|
|
|
|
? tr( "About %1 setup" )
|
|
|
|
|
: tr( "About %1 installer" );
|
|
|
|
|
<< *Calamares::Branding::VersionedName;
|
|
|
|
|
|
|
|
|
|
CALAMARES_RETRANSLATE( QString message;
|
|
|
|
|
|
|
|
|
|
if ( Calamares::Settings::instance()->isSetupMode() ) message
|
|
|
|
|
= Calamares::Branding::instance()->welcomeStyleCalamares()
|
|
|
|
|
? tr( "<h1>Welcome to the Calamares setup program for %1.</h1>" )
|
|
|
|
|
: tr( "<h1>Welcome to %1 setup.</h1>" );
|
|
|
|
|
else message = Calamares::Branding::instance()->welcomeStyleCalamares()
|
|
|
|
|
? tr( "<h1>Welcome to the Calamares installer for %1.</h1>" )
|
|
|
|
|
: tr( "<h1>Welcome to the %1 installer.</h1>" );
|
|
|
|
|
|
|
|
|
|
ui->mainText->setText( message.arg( *Calamares::Branding::VersionedName ) );
|
|
|
|
|
ui->retranslateUi( this ); )
|
|
|
|
|
|
|
|
|
|
ui->aboutButton->setIcon( CalamaresUtils::defaultPixmap(
|
|
|
|
|
CalamaresUtils::Information,
|
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
|
2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) ) );
|
|
|
|
|
connect( ui->aboutButton, &QPushButton::clicked, this, [this] {
|
|
|
|
|
QString title
|
|
|
|
|
= Calamares::Settings::instance()->isSetupMode() ? tr( "About %1 setup" ) : tr( "About %1 installer" );
|
|
|
|
|
QMessageBox mb( QMessageBox::Information,
|
|
|
|
|
title.arg( CALAMARES_APPLICATION_NAME ),
|
|
|
|
|
tr(
|
|
|
|
|
"<h1>%1</h1><br/>"
|
|
|
|
|
tr( "<h1>%1</h1><br/>"
|
|
|
|
|
"<strong>%2<br/>"
|
|
|
|
|
"for %3</strong><br/><br/>"
|
|
|
|
|
"Copyright 2014-2017 Teo Mrnjavac <teo@kde.org><br/>"
|
|
|
|
@ -103,24 +105,23 @@ WelcomePage::WelcomePage( QWidget* parent )
|
|
|
|
|
"<a href=\"https://calamares.io/\">Calamares</a> "
|
|
|
|
|
"development is sponsored by <br/>"
|
|
|
|
|
"<a href=\"http://www.blue-systems.com/\">Blue Systems</a> - "
|
|
|
|
|
"Liberating Software."
|
|
|
|
|
)
|
|
|
|
|
.arg( CALAMARES_APPLICATION_NAME )
|
|
|
|
|
.arg( CALAMARES_VERSION )
|
|
|
|
|
.arg( *Calamares::Branding::VersionedName ),
|
|
|
|
|
"Liberating Software." )
|
|
|
|
|
.arg( CALAMARES_APPLICATION_NAME )
|
|
|
|
|
.arg( CALAMARES_VERSION )
|
|
|
|
|
.arg( *Calamares::Branding::VersionedName ),
|
|
|
|
|
QMessageBox::Ok,
|
|
|
|
|
this );
|
|
|
|
|
mb.setIconPixmap( CalamaresUtils::defaultPixmap( CalamaresUtils::Squid,
|
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
|
QSize( CalamaresUtils::defaultFontHeight() * 6,
|
|
|
|
|
CalamaresUtils::defaultFontHeight() * 6 ) ) );
|
|
|
|
|
QGridLayout* layout = reinterpret_cast<QGridLayout *>( mb.layout() );
|
|
|
|
|
mb.setIconPixmap( CalamaresUtils::defaultPixmap(
|
|
|
|
|
CalamaresUtils::Squid,
|
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
|
QSize( CalamaresUtils::defaultFontHeight() * 6, CalamaresUtils::defaultFontHeight() * 6 ) ) );
|
|
|
|
|
QGridLayout* layout = reinterpret_cast< QGridLayout* >( mb.layout() );
|
|
|
|
|
if ( layout )
|
|
|
|
|
layout->setColumnMinimumWidth( 2, CalamaresUtils::defaultFontHeight() * 24 );
|
|
|
|
|
mb.exec();
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
ui->verticalLayout->insertWidget( 3, m_checkingWidget);
|
|
|
|
|
ui->verticalLayout->insertWidget( 3, m_checkingWidget );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -139,15 +140,16 @@ WelcomePage::initLanguages()
|
|
|
|
|
QLocale defaultLocale = QLocale( QLocale::system().name() );
|
|
|
|
|
|
|
|
|
|
cDebug() << "Matching locale" << defaultLocale;
|
|
|
|
|
int matchedLocaleIndex = m_languages->find(
|
|
|
|
|
[&](const QLocale& x){ return x.language() == defaultLocale.language() && x.country() == defaultLocale.country(); } );
|
|
|
|
|
int matchedLocaleIndex = m_languages->find( [&]( const QLocale& x ) {
|
|
|
|
|
return x.language() == defaultLocale.language() && x.country() == defaultLocale.country();
|
|
|
|
|
} );
|
|
|
|
|
|
|
|
|
|
if ( matchedLocaleIndex < 0 )
|
|
|
|
|
{
|
|
|
|
|
cDebug() << Logger::SubEntry << "Matching approximate locale" << defaultLocale.language();
|
|
|
|
|
|
|
|
|
|
matchedLocaleIndex = m_languages->find(
|
|
|
|
|
[&](const QLocale& x){ return x.language() == defaultLocale.language(); } );
|
|
|
|
|
matchedLocaleIndex
|
|
|
|
|
= m_languages->find( [&]( const QLocale& x ) { return x.language() == defaultLocale.language(); } );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( matchedLocaleIndex < 0 )
|
|
|
|
@ -159,7 +161,9 @@ WelcomePage::initLanguages()
|
|
|
|
|
|
|
|
|
|
// Now, if it matched, because we didn't match the system locale, switch to the one found
|
|
|
|
|
if ( matchedLocaleIndex >= 0 )
|
|
|
|
|
{
|
|
|
|
|
QLocale::setDefault( m_languages->locale( matchedLocaleIndex ).locale() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( matchedLocaleIndex >= 0 )
|
|
|
|
@ -171,44 +175,36 @@ WelcomePage::initLanguages()
|
|
|
|
|
ui->languageWidget->setCurrentIndex( matchedLocaleIndex );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
cWarning() << "No available translation matched" << defaultLocale;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connect( ui->languageWidget,
|
|
|
|
|
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
|
|
|
|
|
this,
|
|
|
|
|
[&]( int newIndex )
|
|
|
|
|
{
|
|
|
|
|
[&]( int newIndex ) {
|
|
|
|
|
const auto& selectedLocale = m_languages->locale( newIndex ).locale();
|
|
|
|
|
cDebug() << "Selected locale" << selectedLocale;
|
|
|
|
|
|
|
|
|
|
QLocale::setDefault( selectedLocale );
|
|
|
|
|
CalamaresUtils::installTranslator( selectedLocale,
|
|
|
|
|
Calamares::Branding::instance()->translationsDirectory(),
|
|
|
|
|
qApp );
|
|
|
|
|
CalamaresUtils::installTranslator(
|
|
|
|
|
selectedLocale, Calamares::Branding::instance()->translationsDirectory(), qApp );
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
WelcomePage::setUpLinks( bool showSupportUrl,
|
|
|
|
|
bool showKnownIssuesUrl,
|
|
|
|
|
bool showReleaseNotesUrl )
|
|
|
|
|
WelcomePage::setUpLinks( bool showSupportUrl, bool showKnownIssuesUrl, bool showReleaseNotesUrl )
|
|
|
|
|
{
|
|
|
|
|
using namespace Calamares;
|
|
|
|
|
if ( showSupportUrl && !( *Branding::SupportUrl ).isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
CALAMARES_RETRANSLATE(
|
|
|
|
|
ui->supportButton->setText( tr( "%1 support" )
|
|
|
|
|
.arg( *Branding::ShortProductName ) );
|
|
|
|
|
)
|
|
|
|
|
ui->supportButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Help,
|
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
|
2*QSize( CalamaresUtils::defaultFontHeight(),
|
|
|
|
|
CalamaresUtils::defaultFontHeight() ) ) );
|
|
|
|
|
connect( ui->supportButton, &QPushButton::clicked, []
|
|
|
|
|
{
|
|
|
|
|
QDesktopServices::openUrl( *Branding::SupportUrl );
|
|
|
|
|
} );
|
|
|
|
|
CALAMARES_RETRANSLATE( ui->supportButton->setText( tr( "%1 support" ).arg( *Branding::ShortProductName ) ); )
|
|
|
|
|
ui->supportButton->setIcon( CalamaresUtils::defaultPixmap(
|
|
|
|
|
CalamaresUtils::Help,
|
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
|
2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) ) );
|
|
|
|
|
connect( ui->supportButton, &QPushButton::clicked, [] { QDesktopServices::openUrl( *Branding::SupportUrl ); } );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
@ -217,12 +213,11 @@ WelcomePage::setUpLinks( bool showSupportUrl,
|
|
|
|
|
|
|
|
|
|
if ( showKnownIssuesUrl && !( *Branding::KnownIssuesUrl ).isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
ui->knownIssuesButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Bugs,
|
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
|
2*QSize( CalamaresUtils::defaultFontHeight(),
|
|
|
|
|
CalamaresUtils::defaultFontHeight() ) ) );
|
|
|
|
|
connect( ui->knownIssuesButton, &QPushButton::clicked, []
|
|
|
|
|
{
|
|
|
|
|
ui->knownIssuesButton->setIcon( CalamaresUtils::defaultPixmap(
|
|
|
|
|
CalamaresUtils::Bugs,
|
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
|
2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) ) );
|
|
|
|
|
connect( ui->knownIssuesButton, &QPushButton::clicked, [] {
|
|
|
|
|
QDesktopServices::openUrl( *Branding::KnownIssuesUrl );
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
@ -233,12 +228,11 @@ WelcomePage::setUpLinks( bool showSupportUrl,
|
|
|
|
|
|
|
|
|
|
if ( showReleaseNotesUrl && !( *Branding::ReleaseNotesUrl ).isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
ui->releaseNotesButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Release,
|
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
|
2*QSize( CalamaresUtils::defaultFontHeight(),
|
|
|
|
|
CalamaresUtils::defaultFontHeight() ) ) );
|
|
|
|
|
connect( ui->releaseNotesButton, &QPushButton::clicked, []
|
|
|
|
|
{
|
|
|
|
|
ui->releaseNotesButton->setIcon( CalamaresUtils::defaultPixmap(
|
|
|
|
|
CalamaresUtils::Release,
|
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
|
2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) ) );
|
|
|
|
|
connect( ui->releaseNotesButton, &QPushButton::clicked, [] {
|
|
|
|
|
QDesktopServices::openUrl( *Branding::ReleaseNotesUrl );
|
|
|
|
|
} );
|
|
|
|
|
}
|
|
|
|
@ -249,11 +243,38 @@ WelcomePage::setUpLinks( bool showSupportUrl,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
WelcomePage::setupDonateButton( const QString& url )
|
|
|
|
|
{
|
|
|
|
|
if ( url.isEmpty() )
|
|
|
|
|
{
|
|
|
|
|
ui->donateButton->hide();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QUrl u( url );
|
|
|
|
|
if ( u.isValid() )
|
|
|
|
|
{
|
|
|
|
|
ui->donateButton->setIcon( CalamaresUtils::defaultPixmap(
|
|
|
|
|
CalamaresUtils::Donate,
|
|
|
|
|
CalamaresUtils::Original,
|
|
|
|
|
2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) ) );
|
|
|
|
|
connect( ui->donateButton, &QPushButton::clicked, [u]() { QDesktopServices::openUrl( u ); } );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
qWarning() << "Donate URL" << url << "is invalid.";
|
|
|
|
|
ui->donateButton->hide();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
WelcomePage::focusInEvent( QFocusEvent* e )
|
|
|
|
|
{
|
|
|
|
|
if ( ui->languageWidget )
|
|
|
|
|
{
|
|
|
|
|
ui->languageWidget->setFocus();
|
|
|
|
|
}
|
|
|
|
|
e->accept();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -267,7 +288,9 @@ void
|
|
|
|
|
WelcomePage::externallySelectedLanguage( int row )
|
|
|
|
|
{
|
|
|
|
|
if ( ( row >= 0 ) && ( row < ui->languageWidget->count() ) )
|
|
|
|
|
{
|
|
|
|
|
ui->languageWidget->setCurrentIndex( row );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
@ -278,8 +301,14 @@ WelcomePage::setLanguageIcon( QPixmap i )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
LocaleTwoColumnDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
|
|
|
|
LocaleTwoColumnDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
|
|
|
|
{
|
|
|
|
|
QStyledItemDelegate::paint( painter, option, index );
|
|
|
|
|
option.widget->style()->drawItemText( painter, option.rect, Qt::AlignRight | Qt::AlignVCenter, option.palette, false, index.data( CalamaresUtils::Locale::LabelModel::EnglishLabelRole ).toString() );
|
|
|
|
|
option.widget->style()->drawItemText(
|
|
|
|
|
painter,
|
|
|
|
|
option.rect,
|
|
|
|
|
Qt::AlignRight | Qt::AlignVCenter,
|
|
|
|
|
option.palette,
|
|
|
|
|
false,
|
|
|
|
|
index.data( CalamaresUtils::Locale::LabelModel::EnglishLabelRole ).toString() );
|
|
|
|
|
}
|
|
|
|
|