2017-12-20 14:39:09 +01:00
|
|
|
/* === This file is part of Calamares - <https://github.com/calamares> ===
|
2014-07-02 17:59:24 +02:00
|
|
|
*
|
2016-05-27 17:14:17 +02:00
|
|
|
* Copyright 2014-2016, Teo Mrnjavac <teo@kde.org>
|
2019-01-08 22:30:12 +01:00
|
|
|
* Copyright 2017-2019, Adriaan de Groot <groot@kde.org>
|
2014-07-02 17:59:24 +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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "LocalePage.h"
|
|
|
|
|
2020-07-20 12:58:35 +02:00
|
|
|
#include "Config.h"
|
2014-08-01 16:29:19 +02:00
|
|
|
#include "SetTimezoneJob.h"
|
2019-04-19 10:10:36 +02:00
|
|
|
#include "timezonewidget/timezonewidget.h"
|
|
|
|
|
2014-11-25 17:41:27 +01:00
|
|
|
#include "GlobalStorage.h"
|
|
|
|
#include "JobQueue.h"
|
|
|
|
#include "LCLocaleDialog.h"
|
2016-08-26 17:20:48 +02:00
|
|
|
#include "Settings.h"
|
2019-05-10 17:46:20 +02:00
|
|
|
#include "locale/Label.h"
|
2019-12-10 10:30:48 +01:00
|
|
|
#include "locale/TimeZone.h"
|
2019-04-19 10:10:36 +02:00
|
|
|
#include "utils/CalamaresUtilsGui.h"
|
|
|
|
#include "utils/Logger.h"
|
|
|
|
#include "utils/Retranslator.h"
|
|
|
|
|
2014-07-02 17:59:24 +02:00
|
|
|
#include <QBoxLayout>
|
|
|
|
#include <QComboBox>
|
2020-04-15 11:45:27 +02:00
|
|
|
#include <QFile>
|
2014-07-02 17:59:24 +02:00
|
|
|
#include <QLabel>
|
2014-11-25 20:03:37 +01:00
|
|
|
#include <QProcess>
|
2019-09-07 15:48:22 +02:00
|
|
|
#include <QPushButton>
|
2014-07-02 17:59:24 +02:00
|
|
|
|
2020-07-20 12:58:35 +02:00
|
|
|
LocalePage::LocalePage( Config* config, QWidget* parent )
|
2016-07-27 13:35:03 +02:00
|
|
|
: QWidget( parent )
|
2020-07-20 12:58:35 +02:00
|
|
|
, m_config( config )
|
2019-12-10 16:31:56 +01:00
|
|
|
, m_regionList( CalamaresUtils::Locale::TZRegion::fromZoneTab() )
|
|
|
|
, m_regionModel( std::make_unique< CalamaresUtils::Locale::CStringListModel >( m_regionList ) )
|
2020-01-07 10:46:26 +01:00
|
|
|
, m_blockTzWidgetSet( false )
|
2014-07-02 17:59:24 +02:00
|
|
|
{
|
2014-07-02 18:12:20 +02:00
|
|
|
QBoxLayout* mainLayout = new QVBoxLayout;
|
2014-07-02 17:59:24 +02:00
|
|
|
|
2014-07-02 18:12:20 +02:00
|
|
|
QBoxLayout* tzwLayout = new QHBoxLayout;
|
2014-07-02 17:59:24 +02:00
|
|
|
m_tzWidget = new TimeZoneWidget( this );
|
2014-07-02 18:12:20 +02:00
|
|
|
tzwLayout->addStretch();
|
|
|
|
tzwLayout->addWidget( m_tzWidget );
|
|
|
|
tzwLayout->addStretch();
|
2020-04-17 10:19:41 +02:00
|
|
|
// Adjust for margins and spacing in this page
|
|
|
|
m_tzWidget->setMinimumHeight( m_tzWidget->minimumHeight() + 12 ); // 2 * spacing
|
2014-07-02 17:59:24 +02:00
|
|
|
|
2020-04-17 10:19:41 +02:00
|
|
|
QBoxLayout* zoneAndRegionLayout = new QHBoxLayout;
|
2014-11-25 17:41:27 +01:00
|
|
|
m_regionLabel = new QLabel( this );
|
2020-04-17 10:19:41 +02:00
|
|
|
zoneAndRegionLayout->addWidget( m_regionLabel );
|
2014-07-02 17:59:24 +02:00
|
|
|
|
|
|
|
m_regionCombo = new QComboBox( this );
|
2020-04-17 10:19:41 +02:00
|
|
|
zoneAndRegionLayout->addWidget( m_regionCombo );
|
2014-07-02 17:59:24 +02:00
|
|
|
m_regionCombo->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
2014-11-25 17:41:27 +01:00
|
|
|
m_regionLabel->setBuddy( m_regionCombo );
|
2014-07-02 17:59:24 +02:00
|
|
|
|
2020-04-17 10:19:41 +02:00
|
|
|
zoneAndRegionLayout->addSpacing( 20 );
|
2014-07-02 17:59:24 +02:00
|
|
|
|
2014-11-25 17:41:27 +01:00
|
|
|
m_zoneLabel = new QLabel( this );
|
2020-04-17 10:19:41 +02:00
|
|
|
zoneAndRegionLayout->addWidget( m_zoneLabel );
|
2014-07-02 17:59:24 +02:00
|
|
|
|
2014-11-25 17:41:27 +01:00
|
|
|
m_zoneCombo = new QComboBox( this );
|
|
|
|
m_zoneCombo->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
2020-04-17 10:19:41 +02:00
|
|
|
zoneAndRegionLayout->addWidget( m_zoneCombo );
|
2014-11-25 17:41:27 +01:00
|
|
|
m_zoneLabel->setBuddy( m_zoneCombo );
|
2014-07-02 17:59:24 +02:00
|
|
|
|
|
|
|
|
2014-11-25 17:41:27 +01:00
|
|
|
QBoxLayout* localeLayout = new QHBoxLayout;
|
|
|
|
m_localeLabel = new QLabel( this );
|
|
|
|
m_localeLabel->setWordWrap( true );
|
|
|
|
m_localeLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
|
|
|
localeLayout->addWidget( m_localeLabel );
|
|
|
|
|
|
|
|
m_localeChangeButton = new QPushButton( this );
|
|
|
|
m_localeChangeButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
|
|
|
|
localeLayout->addWidget( m_localeChangeButton );
|
|
|
|
|
2016-08-10 11:45:22 +02:00
|
|
|
QBoxLayout* formatsLayout = new QHBoxLayout;
|
|
|
|
m_formatsLabel = new QLabel( this );
|
|
|
|
m_formatsLabel->setWordWrap( true );
|
|
|
|
m_formatsLabel->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Preferred );
|
|
|
|
formatsLayout->addWidget( m_formatsLabel );
|
|
|
|
|
|
|
|
m_formatsChangeButton = new QPushButton( this );
|
|
|
|
m_formatsChangeButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
|
|
|
|
formatsLayout->addWidget( m_formatsChangeButton );
|
|
|
|
|
2020-04-17 10:19:41 +02:00
|
|
|
mainLayout->addLayout( tzwLayout );
|
|
|
|
mainLayout->addStretch();
|
|
|
|
mainLayout->addLayout( zoneAndRegionLayout );
|
|
|
|
mainLayout->addStretch();
|
|
|
|
mainLayout->addLayout( localeLayout );
|
|
|
|
mainLayout->addLayout( formatsLayout );
|
|
|
|
setMinimumWidth( m_tzWidget->width() );
|
2014-07-02 17:59:24 +02:00
|
|
|
setLayout( mainLayout );
|
|
|
|
|
2019-09-07 15:18:58 +02:00
|
|
|
connect( m_regionCombo, QOverload< int >::of( &QComboBox::currentIndexChanged ), this, &LocalePage::regionChanged );
|
|
|
|
connect( m_zoneCombo, QOverload< int >::of( &QComboBox::currentIndexChanged ), this, &LocalePage::zoneChanged );
|
2019-09-07 15:47:12 +02:00
|
|
|
connect( m_tzWidget, &TimeZoneWidget::locationChanged, this, &LocalePage::locationChanged );
|
|
|
|
connect( m_localeChangeButton, &QPushButton::clicked, this, &LocalePage::changeLocale );
|
|
|
|
connect( m_formatsChangeButton, &QPushButton::clicked, this, &LocalePage::changeFormats );
|
2016-08-10 11:45:22 +02:00
|
|
|
|
2019-09-07 12:38:49 +02:00
|
|
|
CALAMARES_RETRANSLATE_SLOT( &LocalePage::updateLocaleLabels )
|
2014-07-02 17:59:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-10 12:45:56 +01:00
|
|
|
LocalePage::~LocalePage()
|
|
|
|
{
|
|
|
|
qDeleteAll( m_regionList );
|
|
|
|
}
|
2014-11-25 17:41:27 +01:00
|
|
|
|
|
|
|
|
2016-08-10 11:45:22 +02:00
|
|
|
void
|
|
|
|
LocalePage::updateLocaleLabels()
|
|
|
|
{
|
2019-09-07 12:38:49 +02:00
|
|
|
m_regionLabel->setText( tr( "Region:" ) );
|
|
|
|
m_zoneLabel->setText( tr( "Zone:" ) );
|
|
|
|
m_localeChangeButton->setText( tr( "&Change..." ) );
|
|
|
|
m_formatsChangeButton->setText( tr( "&Change..." ) );
|
|
|
|
|
2019-09-07 15:48:22 +02:00
|
|
|
LocaleConfiguration lc
|
|
|
|
= m_selectedLocaleConfiguration.isEmpty() ? guessLocaleConfiguration() : m_selectedLocaleConfiguration;
|
2017-08-08 14:59:44 +02:00
|
|
|
auto labels = prettyLocaleStatus( lc );
|
|
|
|
m_localeLabel->setText( labels.first );
|
|
|
|
m_formatsLabel->setText( labels.second );
|
2016-08-10 11:45:22 +02:00
|
|
|
}
|
|
|
|
|
2014-07-02 17:59:24 +02:00
|
|
|
void
|
2020-07-20 13:22:38 +02:00
|
|
|
LocalePage::init( const QString& initialRegion, const QString& initialZone )
|
2014-07-02 17:59:24 +02:00
|
|
|
{
|
2019-12-10 15:54:43 +01:00
|
|
|
using namespace CalamaresUtils::Locale;
|
|
|
|
|
2019-12-10 10:30:48 +01:00
|
|
|
m_regionCombo->setModel( m_regionModel.get() );
|
2015-02-20 16:09:43 +01:00
|
|
|
m_regionCombo->currentIndexChanged( m_regionCombo->currentIndex() );
|
2014-07-02 18:12:20 +02:00
|
|
|
|
2019-12-10 15:54:43 +01:00
|
|
|
auto* region = m_regionList.find< TZRegion >( initialRegion );
|
|
|
|
if ( region && region->zones().find< TZZone >( initialZone ) )
|
2014-07-15 11:35:05 +02:00
|
|
|
{
|
|
|
|
m_tzWidget->setCurrentLocation( initialRegion, initialZone );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-09-10 23:33:25 +02:00
|
|
|
m_tzWidget->setCurrentLocation( "America", "New_York" );
|
2014-07-15 11:35:05 +02:00
|
|
|
}
|
2014-11-25 17:41:27 +01:00
|
|
|
|
2020-01-28 15:46:28 +01:00
|
|
|
|
2016-08-18 16:18:24 +02:00
|
|
|
updateGlobalStorage();
|
2014-07-02 17:59:24 +02:00
|
|
|
}
|
|
|
|
|
2019-09-07 15:48:22 +02:00
|
|
|
std::pair< QString, QString >
|
|
|
|
LocalePage::prettyLocaleStatus( const LocaleConfiguration& lc ) const
|
2017-08-08 14:59:44 +02:00
|
|
|
{
|
2019-05-10 17:46:20 +02:00
|
|
|
using CalamaresUtils::Locale::Label;
|
2018-12-14 13:27:32 +01:00
|
|
|
|
2019-05-10 17:46:20 +02:00
|
|
|
Label lang( lc.language(), Label::LabelFormat::AlwaysWithCountry );
|
|
|
|
Label num( lc.lc_numeric, Label::LabelFormat::AlwaysWithCountry );
|
2018-12-14 13:27:32 +01:00
|
|
|
|
2017-08-08 14:59:44 +02:00
|
|
|
return std::make_pair< QString, QString >(
|
2018-12-14 13:27:32 +01:00
|
|
|
tr( "The system language will be set to %1." ).arg( lang.label() ),
|
|
|
|
tr( "The numbers and dates locale will be set to %1." ).arg( num.label() ) );
|
2017-08-08 14:59:44 +02:00
|
|
|
}
|
2014-07-08 18:25:54 +02:00
|
|
|
|
|
|
|
QString
|
|
|
|
LocalePage::prettyStatus() const
|
|
|
|
{
|
|
|
|
QString status;
|
2019-09-07 15:48:22 +02:00
|
|
|
status += tr( "Set timezone to %1/%2.<br/>" ).arg( m_regionCombo->currentText() ).arg( m_zoneCombo->currentText() );
|
|
|
|
|
|
|
|
LocaleConfiguration lc
|
|
|
|
= m_selectedLocaleConfiguration.isEmpty() ? guessLocaleConfiguration() : m_selectedLocaleConfiguration;
|
|
|
|
auto labels = prettyLocaleStatus( lc );
|
2017-08-08 14:59:44 +02:00
|
|
|
status += labels.first + "<br/>";
|
|
|
|
status += labels.second + "<br/>";
|
|
|
|
|
2014-07-08 18:25:54 +02:00
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2014-08-01 16:29:19 +02:00
|
|
|
|
2019-11-25 10:52:22 +01:00
|
|
|
Calamares::JobList
|
2014-08-01 16:29:19 +02:00
|
|
|
LocalePage::createJobs()
|
|
|
|
{
|
|
|
|
QList< Calamares::job_ptr > list;
|
2019-12-11 14:36:23 +01:00
|
|
|
const CalamaresUtils::Locale::TZZone* location = m_tzWidget->currentLocation();
|
2014-08-01 16:29:19 +02:00
|
|
|
|
2019-12-11 14:36:23 +01:00
|
|
|
Calamares::Job* j = new SetTimezoneJob( location->region(), location->zone() );
|
2014-08-01 16:29:19 +02:00
|
|
|
list.append( Calamares::job_ptr( j ) );
|
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
2014-11-10 14:56:29 +01:00
|
|
|
|
2014-11-25 17:41:27 +01:00
|
|
|
|
2016-08-10 11:45:22 +02:00
|
|
|
QMap< QString, QString >
|
|
|
|
LocalePage::localesMap()
|
2014-11-25 17:41:27 +01:00
|
|
|
{
|
2019-09-07 15:48:22 +02:00
|
|
|
return m_selectedLocaleConfiguration.isEmpty() ? guessLocaleConfiguration().toMap()
|
|
|
|
: m_selectedLocaleConfiguration.toMap();
|
2014-11-25 17:41:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-11-26 18:52:44 +01:00
|
|
|
void
|
|
|
|
LocalePage::onActivate()
|
|
|
|
{
|
|
|
|
m_regionCombo->setFocus();
|
2019-09-07 15:48:22 +02:00
|
|
|
if ( m_selectedLocaleConfiguration.isEmpty() || !m_selectedLocaleConfiguration.explicit_lang )
|
2017-06-06 23:52:44 +02:00
|
|
|
{
|
|
|
|
auto newLocale = guessLocaleConfiguration();
|
2019-01-08 18:09:34 +01:00
|
|
|
m_selectedLocaleConfiguration.setLanguage( newLocale.language() );
|
2019-01-07 18:49:08 +01:00
|
|
|
updateGlobalLocale();
|
2017-06-06 23:52:44 +02:00
|
|
|
updateLocaleLabels();
|
|
|
|
}
|
2014-11-26 18:52:44 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-10 11:45:22 +02:00
|
|
|
LocaleConfiguration
|
2017-08-08 14:59:44 +02:00
|
|
|
LocalePage::guessLocaleConfiguration() const
|
2014-11-25 17:41:27 +01:00
|
|
|
{
|
2019-09-07 15:48:22 +02:00
|
|
|
return LocaleConfiguration::fromLanguageAndLocation(
|
2020-07-20 13:22:38 +02:00
|
|
|
QLocale().name(), m_config->supportedLocales(), m_tzWidget->currentLocation()->country() );
|
2014-11-25 17:41:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-01-07 17:29:54 +01:00
|
|
|
void
|
|
|
|
LocalePage::updateGlobalLocale()
|
|
|
|
{
|
2019-09-07 15:48:22 +02:00
|
|
|
auto* gs = Calamares::JobQueue::instance()->globalStorage();
|
2019-01-07 17:29:54 +01:00
|
|
|
const QString bcp47 = m_selectedLocaleConfiguration.toBcp47();
|
|
|
|
gs->insert( "locale", bcp47 );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-07-15 17:48:59 +02:00
|
|
|
void
|
|
|
|
LocalePage::updateGlobalStorage()
|
|
|
|
{
|
2019-09-07 15:48:22 +02:00
|
|
|
auto* gs = Calamares::JobQueue::instance()->globalStorage();
|
2019-01-07 15:16:37 +01:00
|
|
|
|
2019-12-11 14:36:23 +01:00
|
|
|
const auto* location = m_tzWidget->currentLocation();
|
|
|
|
bool locationChanged = ( location->region() != gs->value( "locationRegion" ) )
|
|
|
|
|| ( location->zone() != gs->value( "locationZone" ) );
|
2018-04-03 18:10:05 +02:00
|
|
|
|
2019-12-11 14:36:23 +01:00
|
|
|
gs->insert( "locationRegion", location->region() );
|
|
|
|
gs->insert( "locationZone", location->zone() );
|
2018-04-03 18:10:05 +02:00
|
|
|
|
2019-01-07 17:29:54 +01:00
|
|
|
updateGlobalLocale();
|
2016-08-10 11:45:22 +02:00
|
|
|
|
2016-08-26 17:20:48 +02:00
|
|
|
// If we're in chroot mode (normal install mode), then we immediately set the
|
2018-05-29 09:45:14 +02:00
|
|
|
// timezone on the live system. When debugging timezones, don't bother.
|
|
|
|
#ifndef DEBUG_TIMEZONES
|
2019-01-07 15:16:37 +01:00
|
|
|
if ( locationChanged && Calamares::Settings::instance()->doChroot() )
|
2016-08-26 17:20:48 +02:00
|
|
|
{
|
2018-06-15 10:46:53 +02:00
|
|
|
QProcess::execute( "timedatectl", // depends on systemd
|
2019-12-11 14:36:23 +01:00
|
|
|
{ "set-timezone", location->region() + '/' + location->zone() } );
|
2016-08-26 17:20:48 +02:00
|
|
|
}
|
2018-05-29 09:45:14 +02:00
|
|
|
#endif
|
2016-08-26 17:20:48 +02:00
|
|
|
|
2017-06-06 16:45:35 +02:00
|
|
|
// Preserve those settings that have been made explicit.
|
|
|
|
auto newLocale = guessLocaleConfiguration();
|
2019-09-07 15:48:22 +02:00
|
|
|
if ( !m_selectedLocaleConfiguration.isEmpty() && m_selectedLocaleConfiguration.explicit_lang )
|
|
|
|
{
|
2019-01-08 18:09:34 +01:00
|
|
|
newLocale.setLanguage( m_selectedLocaleConfiguration.language() );
|
2019-09-07 15:48:22 +02:00
|
|
|
}
|
|
|
|
if ( !m_selectedLocaleConfiguration.isEmpty() && m_selectedLocaleConfiguration.explicit_lc )
|
2017-06-06 16:45:35 +02:00
|
|
|
{
|
|
|
|
newLocale.lc_numeric = m_selectedLocaleConfiguration.lc_numeric;
|
|
|
|
newLocale.lc_time = m_selectedLocaleConfiguration.lc_time;
|
|
|
|
newLocale.lc_monetary = m_selectedLocaleConfiguration.lc_monetary;
|
|
|
|
newLocale.lc_paper = m_selectedLocaleConfiguration.lc_paper;
|
|
|
|
newLocale.lc_name = m_selectedLocaleConfiguration.lc_name;
|
|
|
|
newLocale.lc_address = m_selectedLocaleConfiguration.lc_address;
|
|
|
|
newLocale.lc_telephone = m_selectedLocaleConfiguration.lc_telephone;
|
|
|
|
newLocale.lc_measurement = m_selectedLocaleConfiguration.lc_measurement;
|
|
|
|
newLocale.lc_identification = m_selectedLocaleConfiguration.lc_identification;
|
|
|
|
}
|
|
|
|
newLocale.explicit_lang = m_selectedLocaleConfiguration.explicit_lang;
|
|
|
|
newLocale.explicit_lc = m_selectedLocaleConfiguration.explicit_lc;
|
|
|
|
|
|
|
|
m_selectedLocaleConfiguration = newLocale;
|
2016-08-10 11:45:22 +02:00
|
|
|
updateLocaleLabels();
|
2015-07-15 17:48:59 +02:00
|
|
|
}
|
2019-09-07 15:18:58 +02:00
|
|
|
|
|
|
|
void
|
|
|
|
LocalePage::regionChanged( int currentIndex )
|
|
|
|
{
|
2019-12-10 16:04:09 +01:00
|
|
|
using namespace CalamaresUtils::Locale;
|
|
|
|
|
2019-09-07 15:18:58 +02:00
|
|
|
Q_UNUSED( currentIndex )
|
2019-12-10 10:30:48 +01:00
|
|
|
QString selectedRegion = m_regionCombo->currentData().toString();
|
|
|
|
|
2019-12-10 16:04:09 +01:00
|
|
|
TZRegion* region = m_regionList.find< TZRegion >( selectedRegion );
|
|
|
|
if ( !region )
|
2019-09-07 15:18:58 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_zoneCombo->blockSignals( true );
|
2019-12-10 16:04:09 +01:00
|
|
|
m_zoneCombo->setModel( new CStringListModel( region->zones() ) );
|
2019-09-07 15:18:58 +02:00
|
|
|
m_zoneCombo->blockSignals( false );
|
|
|
|
m_zoneCombo->currentIndexChanged( m_zoneCombo->currentIndex() );
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LocalePage::zoneChanged( int currentIndex )
|
|
|
|
{
|
|
|
|
Q_UNUSED( currentIndex )
|
|
|
|
if ( !m_blockTzWidgetSet )
|
|
|
|
m_tzWidget->setCurrentLocation( m_regionCombo->currentData().toString(),
|
|
|
|
m_zoneCombo->currentData().toString() );
|
|
|
|
|
|
|
|
updateGlobalStorage();
|
|
|
|
}
|
2019-09-07 15:47:12 +02:00
|
|
|
|
|
|
|
void
|
2019-12-11 14:36:23 +01:00
|
|
|
LocalePage::locationChanged( const CalamaresUtils::Locale::TZZone* location )
|
2019-09-07 15:47:12 +02:00
|
|
|
{
|
|
|
|
m_blockTzWidgetSet = true;
|
|
|
|
|
|
|
|
// Set region index
|
2019-12-11 14:36:23 +01:00
|
|
|
int index = m_regionCombo->findData( location->region() );
|
2019-09-07 15:47:12 +02:00
|
|
|
if ( index < 0 )
|
2019-09-07 15:48:22 +02:00
|
|
|
{
|
2019-09-07 15:47:12 +02:00
|
|
|
return;
|
2019-09-07 15:48:22 +02:00
|
|
|
}
|
2019-09-07 15:47:12 +02:00
|
|
|
|
|
|
|
m_regionCombo->setCurrentIndex( index );
|
|
|
|
|
|
|
|
// Set zone index
|
2019-12-11 14:36:23 +01:00
|
|
|
index = m_zoneCombo->findData( location->zone() );
|
2019-09-07 15:47:12 +02:00
|
|
|
if ( index < 0 )
|
2019-09-07 15:48:22 +02:00
|
|
|
{
|
2019-09-07 15:47:12 +02:00
|
|
|
return;
|
2019-09-07 15:48:22 +02:00
|
|
|
}
|
2019-09-07 15:47:12 +02:00
|
|
|
|
|
|
|
m_zoneCombo->setCurrentIndex( index );
|
|
|
|
|
|
|
|
m_blockTzWidgetSet = false;
|
|
|
|
|
|
|
|
updateGlobalStorage();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
LocalePage::changeLocale()
|
|
|
|
{
|
2019-09-07 15:48:22 +02:00
|
|
|
LCLocaleDialog* dlg
|
|
|
|
= new LCLocaleDialog( m_selectedLocaleConfiguration.isEmpty() ? guessLocaleConfiguration().language()
|
|
|
|
: m_selectedLocaleConfiguration.language(),
|
2020-07-20 13:22:38 +02:00
|
|
|
m_config->supportedLocales(),
|
2019-09-07 15:48:22 +02:00
|
|
|
this );
|
2019-09-07 15:47:12 +02:00
|
|
|
dlg->exec();
|
2019-09-07 15:48:22 +02:00
|
|
|
if ( dlg->result() == QDialog::Accepted && !dlg->selectedLCLocale().isEmpty() )
|
2019-09-07 15:47:12 +02:00
|
|
|
{
|
|
|
|
m_selectedLocaleConfiguration.setLanguage( dlg->selectedLCLocale() );
|
|
|
|
m_selectedLocaleConfiguration.explicit_lang = true;
|
|
|
|
this->updateGlobalLocale();
|
|
|
|
this->updateLocaleLabels();
|
|
|
|
}
|
|
|
|
|
|
|
|
dlg->deleteLater();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
LocalePage::changeFormats()
|
|
|
|
{
|
2019-09-07 15:48:22 +02:00
|
|
|
LCLocaleDialog* dlg
|
|
|
|
= new LCLocaleDialog( m_selectedLocaleConfiguration.isEmpty() ? guessLocaleConfiguration().lc_numeric
|
|
|
|
: m_selectedLocaleConfiguration.lc_numeric,
|
2020-07-20 13:22:38 +02:00
|
|
|
m_config->supportedLocales(),
|
2019-09-07 15:48:22 +02:00
|
|
|
this );
|
2019-09-07 15:47:12 +02:00
|
|
|
dlg->exec();
|
2019-09-07 15:48:22 +02:00
|
|
|
if ( dlg->result() == QDialog::Accepted && !dlg->selectedLCLocale().isEmpty() )
|
2019-09-07 15:47:12 +02:00
|
|
|
{
|
|
|
|
// TODO: improve the granularity of this setting.
|
|
|
|
m_selectedLocaleConfiguration.lc_numeric = dlg->selectedLCLocale();
|
|
|
|
m_selectedLocaleConfiguration.lc_time = dlg->selectedLCLocale();
|
|
|
|
m_selectedLocaleConfiguration.lc_monetary = dlg->selectedLCLocale();
|
|
|
|
m_selectedLocaleConfiguration.lc_paper = dlg->selectedLCLocale();
|
|
|
|
m_selectedLocaleConfiguration.lc_name = dlg->selectedLCLocale();
|
|
|
|
m_selectedLocaleConfiguration.lc_address = dlg->selectedLCLocale();
|
|
|
|
m_selectedLocaleConfiguration.lc_telephone = dlg->selectedLCLocale();
|
|
|
|
m_selectedLocaleConfiguration.lc_measurement = dlg->selectedLCLocale();
|
|
|
|
m_selectedLocaleConfiguration.lc_identification = dlg->selectedLCLocale();
|
|
|
|
m_selectedLocaleConfiguration.explicit_lc = true;
|
|
|
|
|
|
|
|
this->updateLocaleLabels();
|
|
|
|
}
|
|
|
|
|
|
|
|
dlg->deleteLater();
|
|
|
|
}
|