/* === This file is part of Calamares - === * * Copyright 2014, Teo Mrnjavac * * 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 "GreetingPage.h" #include "ui_GreetingPage.h" #include "AboutDialog.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 "Branding.h" GreetingPage::GreetingPage( QWidget* parent ) : QWidget( parent ) , ui( new Ui::GreetingPage ) { ui->setupUi( this ); QString defaultLocale = QLocale::system().name(); { 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 ); ui->languageWidget->item( ui->languageWidget->count() - 1 ) ->setData( Qt::UserRole, thisLocale ); if ( thisLocale.language() == QLocale( defaultLocale ).language() && thisLocale.country() == QLocale( defaultLocale ).country() ) ui->languageWidget->setCurrentRow( ui->languageWidget->count() - 1 ); } ui->languageWidget->sortItems(); connect( ui->languageWidget, &QListWidget::currentItemChanged, this, [ & ]( QListWidgetItem *current, QListWidgetItem *previous ) { QLocale selectedLocale = current->data( Qt::UserRole ).toLocale(); cDebug() << "Selected locale" << selectedLocale.name(); QLocale::setDefault( selectedLocale ); CalamaresUtils::installTranslator( selectedLocale.name(), qApp ); } ); connect( ui->languageWidget, &QListWidget::itemDoubleClicked, this, [] { Calamares::ViewManager::instance()->next(); } ); } 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->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 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 - " "technologies for a better world." ) .arg( CALAMARES_APPLICATION_NAME ) .arg( CALAMARES_VERSION ) .arg( Calamares::Branding::instance()->string( Calamares::Branding::VersionedName ) ) ); } ); } void GreetingPage::focusInEvent( QFocusEvent* e ) { if ( ui->languageWidget ) ui->languageWidget->setFocus(); e->accept(); }