2017-12-20 14:39:09 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
2014-06-11 13:37:10 +02:00
|
|
|
*
|
2015-01-29 20:24:09 +01:00
|
|
|
* Copyright 2014-2015, Teo Mrnjavac <teo@kde.org>
|
2018-06-15 11:59:11 +02:00
|
|
|
* Copyright 2018, Adriaan de Groot <groot@kde.org>
|
2014-06-11 13:37:10 +02:00
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2015-05-13 12:44:11 +02:00
|
|
|
#include "WelcomeViewStep.h"
|
2014-06-11 13:37:10 +02:00
|
|
|
|
2015-05-13 12:44:11 +02:00
|
|
|
#include "WelcomePage.h"
|
2019-02-23 18:29:59 +01:00
|
|
|
#include "checker/GeneralRequirements.h"
|
2015-05-14 18:02:26 +02:00
|
|
|
|
2019-05-09 21:15:03 +02:00
|
|
|
#include "geoip/Handler.h"
|
2019-05-10 17:03:01 +02:00
|
|
|
#include "locale/Lookup.h"
|
2019-02-25 12:11:14 +01:00
|
|
|
#include "modulesystem/ModuleManager.h"
|
|
|
|
#include "utils/Logger.h"
|
2019-05-02 20:00:32 +02:00
|
|
|
#include "utils/Variant.h"
|
2014-06-27 13:58:53 +02:00
|
|
|
|
2019-05-09 21:15:03 +02:00
|
|
|
#include <QFutureWatcher>
|
2015-04-02 12:27:54 +02:00
|
|
|
#include <QVariant>
|
|
|
|
|
2015-09-09 18:46:13 +02:00
|
|
|
CALAMARES_PLUGIN_FACTORY_DEFINITION( WelcomeViewStepFactory, registerPlugin<WelcomeViewStep>(); )
|
|
|
|
|
2015-05-13 12:44:11 +02:00
|
|
|
WelcomeViewStep::WelcomeViewStep( QObject* parent )
|
2014-06-27 18:00:27 +02:00
|
|
|
: Calamares::ViewStep( parent )
|
2019-02-23 18:29:59 +01:00
|
|
|
, m_requirementsChecker( new GeneralRequirements( this ) )
|
2014-06-11 13:37:10 +02:00
|
|
|
{
|
2019-02-25 12:11:14 +01:00
|
|
|
connect( Calamares::ModuleManager::instance(), &Calamares::ModuleManager::requirementsComplete, this, &WelcomeViewStep::nextStatusChanged );
|
2017-12-02 15:56:03 +01:00
|
|
|
m_widget = new WelcomePage();
|
2014-06-27 18:00:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-13 12:44:11 +02:00
|
|
|
WelcomeViewStep::~WelcomeViewStep()
|
2014-06-27 18:00:27 +02:00
|
|
|
{
|
|
|
|
if ( m_widget && m_widget->parent() == nullptr )
|
|
|
|
m_widget->deleteLater();
|
2014-06-11 13:37:10 +02:00
|
|
|
}
|
2014-06-27 13:58:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
QString
|
2015-05-13 12:44:11 +02:00
|
|
|
WelcomeViewStep::prettyName() const
|
2014-06-27 13:58:53 +02:00
|
|
|
{
|
|
|
|
return tr( "Welcome" );
|
|
|
|
}
|
2014-06-27 18:00:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
QWidget*
|
2015-05-13 12:44:11 +02:00
|
|
|
WelcomeViewStep::widget()
|
2014-06-27 18:00:27 +02:00
|
|
|
{
|
|
|
|
return m_widget;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2015-05-13 12:44:11 +02:00
|
|
|
WelcomeViewStep::isNextEnabled() const
|
2014-06-27 18:00:27 +02:00
|
|
|
{
|
2017-12-02 15:56:03 +01:00
|
|
|
return m_widget->verdict();
|
2014-06-27 18:00:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-29 20:24:09 +01:00
|
|
|
bool
|
2015-05-13 12:44:11 +02:00
|
|
|
WelcomeViewStep::isBackEnabled() const
|
2015-01-29 20:24:09 +01:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-06-27 18:00:27 +02:00
|
|
|
bool
|
2015-05-13 12:44:11 +02:00
|
|
|
WelcomeViewStep::isAtBeginning() const
|
2014-06-27 18:00:27 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
2015-05-13 12:44:11 +02:00
|
|
|
WelcomeViewStep::isAtEnd() const
|
2014-06-27 18:00:27 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-07-08 14:02:21 +02:00
|
|
|
|
2019-02-25 13:05:12 +01:00
|
|
|
Calamares::JobList
|
2015-05-13 12:44:11 +02:00
|
|
|
WelcomeViewStep::jobs() const
|
2014-07-08 14:02:21 +02:00
|
|
|
{
|
2019-02-25 13:05:12 +01:00
|
|
|
return Calamares::JobList();
|
2014-07-08 14:02:21 +02:00
|
|
|
}
|
|
|
|
|
2015-04-02 12:27:54 +02:00
|
|
|
|
|
|
|
void
|
2015-05-13 12:44:11 +02:00
|
|
|
WelcomeViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
2015-04-02 12:27:54 +02:00
|
|
|
{
|
2019-05-02 20:00:32 +02:00
|
|
|
bool showSupportUrl = CalamaresUtils::getBool( configurationMap, "showSupportUrl", false );
|
|
|
|
bool showKnownIssuesUrl = CalamaresUtils::getBool( configurationMap, "showKnownIssuesUrl", false );
|
|
|
|
bool showReleaseNotesUrl = CalamaresUtils::getBool( configurationMap, "showReleaseNotesUrl", false );
|
2015-04-02 12:27:54 +02:00
|
|
|
|
|
|
|
m_widget->setUpLinks( showSupportUrl,
|
|
|
|
showKnownIssuesUrl,
|
|
|
|
showReleaseNotesUrl );
|
2015-05-14 18:02:26 +02:00
|
|
|
|
|
|
|
if ( configurationMap.contains( "requirements" ) &&
|
|
|
|
configurationMap.value( "requirements" ).type() == QVariant::Map )
|
|
|
|
m_requirementsChecker->setConfigurationMap( configurationMap.value( "requirements" ).toMap() );
|
2016-09-16 10:52:42 +02:00
|
|
|
else
|
2018-02-13 11:07:12 +01:00
|
|
|
cWarning() << "no valid requirements map found in welcome "
|
2016-09-16 10:52:42 +02:00
|
|
|
"module configuration.";
|
2019-05-09 21:15:03 +02:00
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
QVariantMap geoip = CalamaresUtils::getSubMap( configurationMap, "geoip", ok );
|
|
|
|
if ( ok )
|
|
|
|
{
|
|
|
|
using FWString = QFutureWatcher< QString >;
|
|
|
|
|
|
|
|
auto* handler = new CalamaresUtils::GeoIP::Handler(
|
|
|
|
CalamaresUtils::getString( geoip, "style" ),
|
|
|
|
CalamaresUtils::getString( geoip, "url" ),
|
|
|
|
CalamaresUtils::getString( geoip, "selector" ) );
|
|
|
|
auto* future = new FWString();
|
2019-05-10 13:53:44 +02:00
|
|
|
connect( future, &FWString::finished, [view=this, f=future, h=handler]()
|
2019-05-09 21:15:03 +02:00
|
|
|
{
|
2019-05-10 13:53:44 +02:00
|
|
|
QString countryResult = f->future().result();
|
|
|
|
cDebug() << "GeoIP result for welcome=" << countryResult;
|
|
|
|
view->setCountry( countryResult );
|
2019-05-09 21:15:03 +02:00
|
|
|
f->deleteLater();
|
|
|
|
delete h;
|
|
|
|
} );
|
|
|
|
future->setFuture( handler->queryRaw() );
|
|
|
|
}
|
2015-04-02 12:27:54 +02:00
|
|
|
}
|
|
|
|
|
2019-05-10 13:53:44 +02:00
|
|
|
Calamares::RequirementsList
|
|
|
|
WelcomeViewStep::checkRequirements()
|
2017-12-02 17:25:26 +01:00
|
|
|
{
|
2019-02-18 15:42:22 +01:00
|
|
|
return m_requirementsChecker->checkRequirements();
|
2017-12-02 17:25:26 +01:00
|
|
|
}
|
2019-05-10 13:53:44 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
WelcomeViewStep::setCountry( const QString& countryCode )
|
|
|
|
{
|
|
|
|
if ( countryCode.length() != 2 )
|
|
|
|
{
|
|
|
|
cDebug() << "Unusable country code" << countryCode;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-10 17:46:20 +02:00
|
|
|
auto c_l = CalamaresUtils::Locale::countryData( countryCode );
|
2019-05-10 17:03:01 +02:00
|
|
|
if ( c_l.first == QLocale::Country::AnyCountry )
|
|
|
|
{
|
|
|
|
cDebug() << "Unusable country code" << countryCode;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else
|
2019-05-10 21:02:12 +02:00
|
|
|
{
|
|
|
|
int r = CalamaresUtils::Locale::availableTranslations()->find( countryCode );
|
|
|
|
if ( r < 0 )
|
|
|
|
cDebug() << "Unusable country code" << countryCode << "(no suitable translation)";
|
|
|
|
if ( ( r >= 0 ) && m_widget )
|
|
|
|
m_widget->externallySelectedLanguage( r );
|
|
|
|
}
|
2019-05-10 13:53:44 +02:00
|
|
|
}
|