/* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac * Copyright 2015, Anke Boersma * * Calamares is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Calamares is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Calamares. If not, see . */ #include "WelcomePage.h" #include "ui_WelcomePage.h" #include "CalamaresVersion.h" #include "utils/Logger.h" #include "utils/CalamaresUtilsGui.h" #include "utils/Retranslator.h" #include "ViewManager.h" #include #include #include #include #include #include #include #include "Branding.h" WelcomePage::WelcomePage( QWidget* parent ) : QWidget( parent ) , ui( new Ui::WelcomePage ) { ui->setupUi( this ); ui->languageWidget->setInsertPolicy( QComboBox::InsertAlphabetically ); QLocale defaultLocale = QLocale( QLocale::system().name() ); { bool isTranslationAvailable = false; foreach ( const QString& locale, QString( CALAMARES_TRANSLATION_LANGUAGES ).split( ';') ) { QLocale thisLocale = QLocale( locale ); QString lang = QLocale::languageToString( thisLocale.language() ); if ( QLocale::countriesForLanguage( thisLocale.language() ).count() > 2 ) lang.append( QString( " (%1)" ) .arg( QLocale::countryToString( thisLocale.country() ) ) ); ui->languageWidget->addItem( lang, thisLocale ); if ( thisLocale.language() == defaultLocale.language() && thisLocale.country() == defaultLocale.country() ) { isTranslationAvailable = true; ui->languageWidget->setCurrentIndex( ui->languageWidget->count() - 1 ); cDebug() << "Initial locale " << thisLocale.name(); CalamaresUtils::installTranslator( thisLocale.name(), Calamares::Branding::instance()->translationsPathPrefix(), qApp ); } } if ( !isTranslationAvailable ) { for (int i = 0; i < ui->languageWidget->count(); i++) { QLocale thisLocale = ui->languageWidget->itemData( i, Qt::UserRole ).toLocale(); if ( thisLocale.language() == defaultLocale.language() ) { isTranslationAvailable = true; ui->languageWidget->setCurrentIndex( i ); cDebug() << "Initial locale " << thisLocale.name(); CalamaresUtils::installTranslator( thisLocale.name(), Calamares::Branding::instance()->translationsPathPrefix(), qApp ); break; } } } if ( !isTranslationAvailable ) { for (int i = 0; i < ui->languageWidget->count(); i++) { QLocale thisLocale = ui->languageWidget->itemData( i, Qt::UserRole ).toLocale(); if ( thisLocale == QLocale( QLocale::English, QLocale::UnitedStates ) ) { ui->languageWidget->setCurrentIndex( i ); cDebug() << "Translation unavailable, so initial locale set to " << thisLocale.name(); QLocale::setDefault( thisLocale ); CalamaresUtils::installTranslator( thisLocale.name(), Calamares::Branding::instance()->translationsPathPrefix(), qApp ); break; } } } connect( ui->languageWidget, static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ), this, [ & ]( int newIndex ) { QLocale selectedLocale = ui->languageWidget->itemData( newIndex, Qt::UserRole ).toLocale(); cDebug() << "Selected locale" << selectedLocale.name(); QLocale::setDefault( selectedLocale ); CalamaresUtils::installTranslator( selectedLocale, Calamares::Branding::instance()->translationsPathPrefix(), qApp ); } ); } ui->mainText->setAlignment( Qt::AlignCenter ); ui->mainText->setWordWrap( true ); ui->mainText->setOpenExternalLinks( true ); CALAMARES_RETRANSLATE( ui->mainText->setText( tr( "

Welcome to the %1 installer.


" "This program will ask you some questions and " "set up %2 on your computer." ) .arg( Calamares::Branding::instance()-> string( Calamares::Branding::VersionedName ) ) .arg( Calamares::Branding::instance()-> string( Calamares::Branding::ProductName ) ) ); 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 ] { QMessageBox::about( this, tr( "About %1 installer" ) .arg( CALAMARES_APPLICATION_NAME ), tr( "

%1


" "%2
" "for %3


" "Copyright 2014-2015 Teo Mrnjavac <teo@kde.org>
" "Thanks to: Anke Boersma, Aurélien Gâteau, Kevin Kofler, Philip Müller, " "Pier Luigi Fiorini and Rohan Garg.

" "Calamares " "development is sponsored by
" "Blue Systems - " "Liberating Software." ) .arg( CALAMARES_APPLICATION_NAME ) .arg( CALAMARES_VERSION ) .arg( Calamares::Branding::instance()->string( Calamares::Branding::VersionedName ) ) ); } ); } void WelcomePage::setUpLinks( bool showSupportUrl, bool showKnownIssuesUrl, bool showReleaseNotesUrl ) { using namespace Calamares; Branding* b = Branding::instance(); if ( showSupportUrl && !b->string( Branding::SupportUrl ).isEmpty() ) { CALAMARES_RETRANSLATE( ui->supportButton->setText( tr( "%1 support" ) .arg( b->string( 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::instance()->string( Branding::SupportUrl ) ); } ); } else { ui->supportButton->hide(); } if ( showKnownIssuesUrl && !b->string( Branding::KnownIssuesUrl ).isEmpty() ) { ui->knownIssuesButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Bugs, CalamaresUtils::Original, 2*QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) ) ); connect( ui->knownIssuesButton, &QPushButton::clicked, [] { QDesktopServices::openUrl( Branding::instance()->string( Branding::KnownIssuesUrl ) ); } ); } else { ui->knownIssuesButton->hide(); } if ( showReleaseNotesUrl && !b->string( Branding::ReleaseNotesUrl ).isEmpty() ) { ui->releaseNotesButton->setIcon( CalamaresUtils::defaultPixmap( CalamaresUtils::Release, CalamaresUtils::Original, 2*QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() ) ) ); connect( ui->releaseNotesButton, &QPushButton::clicked, [] { QDesktopServices::openUrl( Branding::instance()->string( Branding::ReleaseNotesUrl ) ); } ); } else { ui->releaseNotesButton->hide(); } } void WelcomePage::focusInEvent( QFocusEvent* e ) { if ( ui->languageWidget ) ui->languageWidget->setFocus(); e->accept(); }