2020-08-25 16:05:56 +02:00
|
|
|
/* === This file is part of Calamares - <https://calamares.io> ===
|
2014-06-11 13:37:10 +02:00
|
|
|
*
|
2020-08-22 01:19:58 +02:00
|
|
|
* SPDX-FileCopyrightText: 2014-2015 Teo Mrnjavac <teo@kde.org>
|
|
|
|
* SPDX-FileCopyrightText: 2015 Anke Boersma <demm@kaosx.us>
|
|
|
|
* SPDX-FileCopyrightText: 2017-2019 Adriaan de Groot <groot@kde.org>
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
2014-06-11 13:37:10 +02:00
|
|
|
*
|
2020-08-25 16:05:56 +02:00
|
|
|
* Calamares is Free Software: see the License-Identifier above.
|
2014-06-11 13:37:10 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-05-13 12:44:11 +02:00
|
|
|
#include "WelcomePage.h"
|
2014-06-11 13:37:10 +02:00
|
|
|
|
2017-12-02 15:56:03 +01:00
|
|
|
#include "checker/CheckerContainer.h"
|
2019-08-13 22:29:01 +02:00
|
|
|
#include "ui_WelcomePage.h"
|
2017-12-02 15:56:03 +01:00
|
|
|
|
2019-04-18 23:17:49 +02:00
|
|
|
#include "Branding.h"
|
|
|
|
#include "CalamaresVersion.h"
|
2020-03-25 11:41:39 +01:00
|
|
|
#include "Config.h"
|
2019-04-01 11:54:35 +02:00
|
|
|
#include "Settings.h"
|
2014-11-10 12:40:00 +01:00
|
|
|
#include "ViewManager.h"
|
2019-05-10 17:46:20 +02:00
|
|
|
|
|
|
|
#include "locale/LabelModel.h"
|
2019-04-18 23:17:49 +02:00
|
|
|
#include "modulesystem/ModuleManager.h"
|
2020-05-12 17:07:15 +02:00
|
|
|
#include "modulesystem/RequirementsModel.h"
|
2019-04-18 23:17:49 +02:00
|
|
|
#include "utils/CalamaresUtilsGui.h"
|
2019-04-19 10:10:36 +02:00
|
|
|
#include "utils/Logger.h"
|
2019-08-13 22:43:11 +02:00
|
|
|
#include "utils/NamedEnum.h"
|
2019-04-18 23:17:49 +02:00
|
|
|
#include "utils/Retranslator.h"
|
2014-11-10 12:40:00 +01:00
|
|
|
|
|
|
|
#include <QApplication>
|
2014-06-27 18:00:27 +02:00
|
|
|
#include <QBoxLayout>
|
2019-04-19 13:34:25 +02:00
|
|
|
#include <QComboBox>
|
2015-04-02 12:28:40 +02:00
|
|
|
#include <QDesktopServices>
|
2014-11-10 12:40:00 +01:00
|
|
|
#include <QFocusEvent>
|
2014-06-27 18:00:27 +02:00
|
|
|
#include <QLabel>
|
2014-11-20 09:40:55 +01:00
|
|
|
#include <QMessageBox>
|
2014-06-27 18:00:27 +02:00
|
|
|
|
2020-03-25 11:41:39 +01:00
|
|
|
WelcomePage::WelcomePage( Config* conf, QWidget* parent )
|
2014-11-20 09:40:55 +01:00
|
|
|
: QWidget( parent )
|
2015-05-13 12:44:11 +02:00
|
|
|
, ui( new Ui::WelcomePage )
|
2020-08-25 23:44:08 +02:00
|
|
|
, m_checkingWidget( new CheckerContainer( *( conf->requirementsModel() ), this ) )
|
2019-04-18 23:17:49 +02:00
|
|
|
, m_languages( nullptr )
|
2020-03-10 22:44:48 +01:00
|
|
|
, m_conf( conf )
|
2014-06-11 13:37:10 +02:00
|
|
|
{
|
2020-04-22 14:36:09 +02:00
|
|
|
using Branding = Calamares::Branding;
|
|
|
|
|
2020-04-18 04:24:33 +02:00
|
|
|
const int defaultFontHeight = CalamaresUtils::defaultFontHeight();
|
2020-04-22 11:01:50 +02:00
|
|
|
ui->setupUi( this );
|
2019-08-13 22:29:01 +02:00
|
|
|
ui->aboutButton->setIcon( CalamaresUtils::defaultPixmap(
|
2020-05-04 12:51:28 +02:00
|
|
|
CalamaresUtils::Information, CalamaresUtils::Original, 2 * QSize( defaultFontHeight, defaultFontHeight ) ) );
|
2015-05-14 18:02:26 +02:00
|
|
|
|
2020-04-18 04:24:33 +02:00
|
|
|
// insert system-check widget below welcome text
|
|
|
|
const int welcome_text_idx = ui->verticalLayout->indexOf( ui->mainText );
|
2019-08-28 08:47:24 +02:00
|
|
|
ui->verticalLayout->insertWidget( welcome_text_idx + 1, m_checkingWidget );
|
2020-04-18 04:24:33 +02:00
|
|
|
|
|
|
|
// insert optional logo banner image above welcome text
|
2020-04-22 14:36:09 +02:00
|
|
|
QString bannerPath = Branding::instance()->imagePath( Branding::ProductBanner );
|
|
|
|
if ( !bannerPath.isEmpty() )
|
2020-04-18 04:24:33 +02:00
|
|
|
{
|
2020-04-22 14:36:09 +02:00
|
|
|
// If the name is not empty, the file exists -- Branding checks that at startup
|
2020-04-18 04:24:33 +02:00
|
|
|
QPixmap bannerPixmap = QPixmap( bannerPath );
|
|
|
|
if ( !bannerPixmap.isNull() )
|
|
|
|
{
|
|
|
|
QLabel* bannerLabel = new QLabel;
|
|
|
|
bannerLabel->setPixmap( bannerPixmap );
|
|
|
|
bannerLabel->setMinimumHeight( 64 );
|
|
|
|
bannerLabel->setAlignment( Qt::AlignCenter );
|
2020-04-22 14:36:09 +02:00
|
|
|
ui->aboveTextSpacer->changeSize( 20, defaultFontHeight ); // Shrink it down
|
|
|
|
ui->aboveTextSpacer->invalidate();
|
2020-04-18 04:24:33 +02:00
|
|
|
ui->verticalLayout->insertSpacing( welcome_text_idx, defaultFontHeight );
|
|
|
|
ui->verticalLayout->insertWidget( welcome_text_idx, bannerLabel );
|
|
|
|
}
|
|
|
|
}
|
2020-04-22 11:01:50 +02:00
|
|
|
|
|
|
|
initLanguages();
|
|
|
|
|
|
|
|
CALAMARES_RETRANSLATE_SLOT( &WelcomePage::retranslate )
|
|
|
|
|
|
|
|
connect( ui->aboutButton, &QPushButton::clicked, this, &WelcomePage::showAboutBox );
|
|
|
|
connect( Calamares::ModuleManager::instance(),
|
|
|
|
&Calamares::ModuleManager::requirementsComplete,
|
|
|
|
m_checkingWidget,
|
|
|
|
&CheckerContainer::requirementsComplete );
|
2020-05-12 17:07:15 +02:00
|
|
|
connect( Calamares::ModuleManager::instance()->requirementsModel(),
|
|
|
|
&Calamares::RequirementsModel::progressMessageChanged,
|
2020-04-22 11:01:50 +02:00
|
|
|
m_checkingWidget,
|
|
|
|
&CheckerContainer::requirementsProgress );
|
2015-05-14 18:02:26 +02:00
|
|
|
}
|
|
|
|
|
2020-03-25 11:41:39 +01:00
|
|
|
void
|
|
|
|
WelcomePage::init()
|
2020-03-10 22:44:48 +01:00
|
|
|
{
|
|
|
|
//setup the url buttons
|
2020-03-25 11:41:39 +01:00
|
|
|
setupButton( WelcomePage::Button::Support, m_conf->supportUrl() );
|
2020-03-10 22:44:48 +01:00
|
|
|
setupButton( WelcomePage::Button::KnownIssues, m_conf->knownIssuesUrl() );
|
|
|
|
setupButton( WelcomePage::Button::ReleaseNotes, m_conf->releaseNotesUrl() );
|
2020-03-25 11:41:39 +01:00
|
|
|
setupButton( WelcomePage::Button::Donate, m_conf->donateUrl() );
|
2020-03-10 22:44:48 +01:00
|
|
|
|
|
|
|
//language icon
|
|
|
|
auto icon = Calamares::Branding::instance()->image( m_conf->languageIcon(), QSize( 48, 48 ) );
|
|
|
|
if ( !icon.isNull() )
|
|
|
|
{
|
|
|
|
setLanguageIcon( icon );
|
|
|
|
}
|
|
|
|
}
|
2015-05-14 18:02:26 +02:00
|
|
|
|
2018-04-19 00:18:00 +02:00
|
|
|
void
|
|
|
|
WelcomePage::initLanguages()
|
|
|
|
{
|
2018-04-18 16:42:58 +02:00
|
|
|
// Fill the list of translations
|
2018-04-19 00:18:00 +02:00
|
|
|
ui->languageWidget->clear();
|
|
|
|
ui->languageWidget->setInsertPolicy( QComboBox::InsertAtBottom );
|
|
|
|
|
2020-03-10 22:44:48 +01:00
|
|
|
ui->languageWidget->setModel( m_conf->languagesModel() );
|
2019-04-19 13:34:25 +02:00
|
|
|
ui->languageWidget->setItemDelegate( new LocaleTwoColumnDelegate( ui->languageWidget ) );
|
2014-11-10 12:40:00 +01:00
|
|
|
|
2020-03-10 22:44:48 +01:00
|
|
|
ui->languageWidget->setCurrentIndex( m_conf->localeIndex() );
|
2018-04-18 16:42:58 +02:00
|
|
|
|
|
|
|
connect( ui->languageWidget,
|
2020-03-25 11:41:39 +01:00
|
|
|
static_cast< void ( QComboBox::* )( int ) >( &QComboBox::currentIndexChanged ),
|
|
|
|
m_conf,
|
|
|
|
&Config::setLocaleIndex );
|
2014-11-10 12:40:00 +01:00
|
|
|
}
|
|
|
|
|
2019-08-13 22:29:01 +02:00
|
|
|
void
|
2019-08-13 22:43:11 +02:00
|
|
|
WelcomePage::setupButton( Button role, const QString& url )
|
2019-08-13 22:29:01 +02:00
|
|
|
{
|
2019-08-13 22:43:11 +02:00
|
|
|
QPushButton* button = nullptr;
|
|
|
|
CalamaresUtils::ImageType icon = CalamaresUtils::Information;
|
|
|
|
|
|
|
|
switch ( role )
|
|
|
|
{
|
|
|
|
case Button::Donate:
|
|
|
|
button = ui->donateButton;
|
|
|
|
icon = CalamaresUtils::Donate;
|
|
|
|
break;
|
|
|
|
case Button::KnownIssues:
|
|
|
|
button = ui->knownIssuesButton;
|
|
|
|
icon = CalamaresUtils::Bugs;
|
|
|
|
break;
|
|
|
|
case Button::ReleaseNotes:
|
|
|
|
button = ui->releaseNotesButton;
|
|
|
|
icon = CalamaresUtils::Release;
|
|
|
|
break;
|
|
|
|
case Button::Support:
|
|
|
|
button = ui->supportButton;
|
|
|
|
icon = CalamaresUtils::Help;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ( !button )
|
|
|
|
{
|
|
|
|
qWarning() << "Unknown button role" << smash( role );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-08-13 22:29:01 +02:00
|
|
|
if ( url.isEmpty() )
|
|
|
|
{
|
2019-08-13 22:43:11 +02:00
|
|
|
button->hide();
|
2019-08-13 22:29:01 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QUrl u( url );
|
|
|
|
if ( u.isValid() )
|
|
|
|
{
|
2019-08-13 22:57:33 +02:00
|
|
|
auto size = 2 * QSize( CalamaresUtils::defaultFontHeight(), CalamaresUtils::defaultFontHeight() );
|
|
|
|
button->setIcon( CalamaresUtils::defaultPixmap( icon, CalamaresUtils::Original, size ) );
|
2020-05-06 15:52:56 +02:00
|
|
|
connect( button, &QPushButton::clicked, [u]() { QDesktopServices::openUrl( u ); } );
|
2019-08-13 22:29:01 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-13 22:43:11 +02:00
|
|
|
qWarning() << "Welcome button" << smash( role ) << "URL" << url << "is invalid.";
|
|
|
|
button->hide();
|
2019-08-13 22:29:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-11-10 12:40:00 +01:00
|
|
|
void
|
2015-05-13 12:44:11 +02:00
|
|
|
WelcomePage::focusInEvent( QFocusEvent* e )
|
2014-11-10 12:40:00 +01:00
|
|
|
{
|
2014-11-20 09:40:55 +01:00
|
|
|
if ( ui->languageWidget )
|
2019-08-13 22:29:01 +02:00
|
|
|
{
|
2014-11-20 09:40:55 +01:00
|
|
|
ui->languageWidget->setFocus();
|
2019-08-13 22:29:01 +02:00
|
|
|
}
|
2014-11-10 12:40:00 +01:00
|
|
|
e->accept();
|
|
|
|
}
|
2014-11-10 14:36:18 +01:00
|
|
|
|
2019-05-10 21:02:12 +02:00
|
|
|
bool
|
|
|
|
WelcomePage::verdict() const
|
2017-12-02 15:56:03 +01:00
|
|
|
{
|
|
|
|
return m_checkingWidget->verdict();
|
|
|
|
}
|
2019-05-10 17:46:20 +02:00
|
|
|
|
2019-05-10 21:02:12 +02:00
|
|
|
void
|
|
|
|
WelcomePage::externallySelectedLanguage( int row )
|
|
|
|
{
|
|
|
|
if ( ( row >= 0 ) && ( row < ui->languageWidget->count() ) )
|
2019-08-13 22:29:01 +02:00
|
|
|
{
|
2019-05-10 21:02:12 +02:00
|
|
|
ui->languageWidget->setCurrentIndex( row );
|
2019-08-13 22:29:01 +02:00
|
|
|
}
|
2019-05-10 21:02:12 +02:00
|
|
|
}
|
|
|
|
|
2019-05-31 16:59:38 +02:00
|
|
|
void
|
2019-05-31 17:26:30 +02:00
|
|
|
WelcomePage::setLanguageIcon( QPixmap i )
|
2019-05-31 16:59:38 +02:00
|
|
|
{
|
2019-05-31 17:26:30 +02:00
|
|
|
ui->languageIcon->setPixmap( i );
|
2019-05-31 16:59:38 +02:00
|
|
|
}
|
|
|
|
|
2019-08-29 11:06:55 +02:00
|
|
|
void
|
|
|
|
WelcomePage::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>" );
|
|
|
|
}
|
|
|
|
|
2020-05-04 12:51:28 +02:00
|
|
|
ui->mainText->setText( message.arg( Calamares::Branding::instance()->versionedName() ) );
|
2019-08-29 11:06:55 +02:00
|
|
|
ui->retranslateUi( this );
|
2020-05-04 12:51:28 +02:00
|
|
|
ui->supportButton->setText( tr( "%1 support" ).arg( Calamares::Branding::instance()->shortProductName() ) );
|
2019-08-29 11:06:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
WelcomePage::showAboutBox()
|
|
|
|
{
|
|
|
|
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/>"
|
|
|
|
"<strong>%2<br/>"
|
|
|
|
"for %3</strong><br/><br/>"
|
|
|
|
"Copyright 2014-2017 Teo Mrnjavac <teo@kde.org><br/>"
|
2020-03-25 13:54:54 +01:00
|
|
|
"Copyright 2017-2020 Adriaan de Groot <groot@kde.org><br/>"
|
2019-08-29 11:06:55 +02:00
|
|
|
"Thanks to <a href=\"https://calamares.io/team/\">the Calamares team</a> "
|
|
|
|
"and the <a href=\"https://www.transifex.com/calamares/calamares/\">Calamares "
|
|
|
|
"translators team</a>.<br/><br/>"
|
|
|
|
"<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 )
|
2020-05-04 12:51:28 +02:00
|
|
|
.arg( Calamares::Branding::instance()->versionedName() ),
|
2019-08-29 11:06:55 +02:00
|
|
|
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() );
|
|
|
|
if ( layout )
|
|
|
|
{
|
|
|
|
layout->setColumnMinimumWidth( 2, CalamaresUtils::defaultFontHeight() * 24 );
|
|
|
|
}
|
|
|
|
mb.exec();
|
|
|
|
}
|
|
|
|
|
2019-05-10 17:46:20 +02:00
|
|
|
|
|
|
|
void
|
2019-08-13 22:29:01 +02:00
|
|
|
LocaleTwoColumnDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
2019-05-10 17:46:20 +02:00
|
|
|
{
|
|
|
|
QStyledItemDelegate::paint( painter, option, index );
|
2019-08-13 22:29:01 +02:00
|
|
|
option.widget->style()->drawItemText(
|
|
|
|
painter,
|
|
|
|
option.rect,
|
|
|
|
Qt::AlignRight | Qt::AlignVCenter,
|
|
|
|
option.palette,
|
|
|
|
false,
|
|
|
|
index.data( CalamaresUtils::Locale::LabelModel::EnglishLabelRole ).toString() );
|
2019-05-10 17:46:20 +02:00
|
|
|
}
|