|
|
@ -43,7 +43,6 @@ LocaleViewStep::LocaleViewStep( QObject* parent )
|
|
|
|
, m_widget( new QWidget() )
|
|
|
|
, m_widget( new QWidget() )
|
|
|
|
, m_actualWidget( nullptr )
|
|
|
|
, m_actualWidget( nullptr )
|
|
|
|
, m_nextEnabled( false )
|
|
|
|
, m_nextEnabled( false )
|
|
|
|
, m_geoip( nullptr )
|
|
|
|
|
|
|
|
, m_config( std::make_unique< Config >() )
|
|
|
|
, m_config( std::make_unique< Config >() )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QBoxLayout* mainLayout = new QHBoxLayout;
|
|
|
|
QBoxLayout* mainLayout = new QHBoxLayout;
|
|
|
@ -66,11 +65,11 @@ LocaleViewStep::~LocaleViewStep()
|
|
|
|
void
|
|
|
|
void
|
|
|
|
LocaleViewStep::setUpPage()
|
|
|
|
LocaleViewStep::setUpPage()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
m_config->setCurrentLocation();
|
|
|
|
if ( !m_actualWidget )
|
|
|
|
if ( !m_actualWidget )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_actualWidget = new LocalePage( m_config.get() );
|
|
|
|
m_actualWidget = new LocalePage( m_config.get() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
m_config->setCurrentLocation( m_startingTimezone.first, m_startingTimezone.second );
|
|
|
|
|
|
|
|
m_widget->layout()->addWidget( m_actualWidget );
|
|
|
|
m_widget->layout()->addWidget( m_actualWidget );
|
|
|
|
|
|
|
|
|
|
|
|
ensureSize( m_actualWidget->sizeHint() );
|
|
|
|
ensureSize( m_actualWidget->sizeHint() );
|
|
|
@ -80,20 +79,6 @@ LocaleViewStep::setUpPage()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
LocaleViewStep::fetchGeoIpTimezone()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( m_geoip && m_geoip->isValid() )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_startingTimezone = m_geoip->get();
|
|
|
|
|
|
|
|
if ( !m_startingTimezone.isValid() )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cWarning() << "GeoIP lookup at" << m_geoip->url() << "failed.";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QString
|
|
|
|
QString
|
|
|
|
LocaleViewStep::prettyName() const
|
|
|
|
LocaleViewStep::prettyName() const
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -171,54 +156,5 @@ LocaleViewStep::onLeave()
|
|
|
|
void
|
|
|
|
void
|
|
|
|
LocaleViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|
|
|
LocaleViewStep::setConfigurationMap( const QVariantMap& configurationMap )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
QString region = CalamaresUtils::getString( configurationMap, "region" );
|
|
|
|
|
|
|
|
QString zone = CalamaresUtils::getString( configurationMap, "zone" );
|
|
|
|
|
|
|
|
if ( !region.isEmpty() && !zone.isEmpty() )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_startingTimezone = CalamaresUtils::GeoIP::RegionZonePair( region, zone );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
m_startingTimezone
|
|
|
|
|
|
|
|
= CalamaresUtils::GeoIP::RegionZonePair( QStringLiteral( "America" ), QStringLiteral( "New_York" ) );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
|
|
|
|
QVariantMap geoip = CalamaresUtils::getSubMap( configurationMap, "geoip", ok );
|
|
|
|
|
|
|
|
if ( ok )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
QString url = CalamaresUtils::getString( geoip, "url" );
|
|
|
|
|
|
|
|
QString style = CalamaresUtils::getString( geoip, "style" );
|
|
|
|
|
|
|
|
QString selector = CalamaresUtils::getString( geoip, "selector" );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_geoip = std::make_unique< CalamaresUtils::GeoIP::Handler >( style, url, selector );
|
|
|
|
|
|
|
|
if ( !m_geoip->isValid() )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cWarning() << "GeoIP Style" << style << "is not recognized.";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
m_config->setConfigurationMap( configurationMap );
|
|
|
|
m_config->setConfigurationMap( configurationMap );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Calamares::RequirementsList
|
|
|
|
|
|
|
|
LocaleViewStep::checkRequirements()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( m_geoip && m_geoip->isValid() )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
auto& network = CalamaresUtils::Network::Manager::instance();
|
|
|
|
|
|
|
|
if ( network.hasInternet() )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fetchGeoIpTimezone();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if ( network.synchronousPing( m_geoip->url() ) )
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fetchGeoIpTimezone();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return Calamares::RequirementsList();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|