[locale] Hook tz widget up to the Config's data
This commit is contained in:
parent
4d5ff6d5c4
commit
f0cac7d669
@ -139,17 +139,29 @@ loadLocales( const QString& localeGenPath )
|
|||||||
return localeGenLines;
|
return localeGenLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline const CalamaresUtils::Locale::CStringPairList&
|
||||||
|
timezoneData()
|
||||||
|
{
|
||||||
|
return CalamaresUtils::Locale::TZRegion::fromZoneTab();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Config::Config( QObject* parent )
|
Config::Config( QObject* parent )
|
||||||
: QObject( parent )
|
: QObject( parent )
|
||||||
, m_regionModel( std::make_unique< CalamaresUtils::Locale::CStringListModel >(
|
, m_regionModel( std::make_unique< CalamaresUtils::Locale::CStringListModel >( ::timezoneData() ) )
|
||||||
CalamaresUtils::Locale::TZRegion::fromZoneTab() ) )
|
|
||||||
, m_zonesModel( std::make_unique< CalamaresUtils::Locale::CStringListModel >() )
|
, m_zonesModel( std::make_unique< CalamaresUtils::Locale::CStringListModel >() )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Config::~Config() {}
|
Config::~Config() {}
|
||||||
|
|
||||||
|
const CalamaresUtils::Locale::CStringPairList&
|
||||||
|
Config::timezoneData() const
|
||||||
|
{
|
||||||
|
return ::timezoneData();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
Config::setConfigurationMap( const QVariantMap& configurationMap )
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,7 @@ class Config : public QObject
|
|||||||
Q_PROPERTY( const QStringList& supportedLocales READ supportedLocales CONSTANT FINAL )
|
Q_PROPERTY( const QStringList& supportedLocales READ supportedLocales CONSTANT FINAL )
|
||||||
Q_PROPERTY( CalamaresUtils::Locale::CStringListModel* zonesModel READ zonesModel CONSTANT FINAL )
|
Q_PROPERTY( CalamaresUtils::Locale::CStringListModel* zonesModel READ zonesModel CONSTANT FINAL )
|
||||||
Q_PROPERTY( CalamaresUtils::Locale::CStringListModel* regionModel READ regionModel CONSTANT FINAL )
|
Q_PROPERTY( CalamaresUtils::Locale::CStringListModel* regionModel READ regionModel CONSTANT FINAL )
|
||||||
|
Q_PROPERTY( const CalamaresUtils::Locale::CStringPairList& timezoneData READ timezoneData CONSTANT FINAL )
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Config( QObject* parent = nullptr );
|
Config( QObject* parent = nullptr );
|
||||||
@ -44,6 +45,8 @@ public Q_SLOTS:
|
|||||||
const QStringList& supportedLocales() const { return m_localeGenLines; }
|
const QStringList& supportedLocales() const { return m_localeGenLines; }
|
||||||
CalamaresUtils::Locale::CStringListModel* regionModel() const { return m_regionModel.get(); }
|
CalamaresUtils::Locale::CStringListModel* regionModel() const { return m_regionModel.get(); }
|
||||||
CalamaresUtils::Locale::CStringListModel* zonesModel() const { return m_zonesModel.get(); }
|
CalamaresUtils::Locale::CStringListModel* zonesModel() const { return m_zonesModel.get(); }
|
||||||
|
// Underlying data for the models
|
||||||
|
const CalamaresUtils::Locale::CStringPairList& timezoneData() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// A list of supported locale identifiers (e.g. "en_US.UTF-8")
|
/// A list of supported locale identifiers (e.g. "en_US.UTF-8")
|
||||||
|
@ -48,7 +48,7 @@ LocalePage::LocalePage( Config* config, QWidget* parent )
|
|||||||
QBoxLayout* mainLayout = new QVBoxLayout;
|
QBoxLayout* mainLayout = new QVBoxLayout;
|
||||||
|
|
||||||
QBoxLayout* tzwLayout = new QHBoxLayout;
|
QBoxLayout* tzwLayout = new QHBoxLayout;
|
||||||
m_tzWidget = new TimeZoneWidget( this );
|
m_tzWidget = new TimeZoneWidget( config->timezoneData(), this );
|
||||||
tzwLayout->addStretch();
|
tzwLayout->addStretch();
|
||||||
tzwLayout->addWidget( m_tzWidget );
|
tzwLayout->addWidget( m_tzWidget );
|
||||||
tzwLayout->addStretch();
|
tzwLayout->addStretch();
|
||||||
|
@ -41,9 +41,10 @@ getLocationPosition( const CalamaresUtils::Locale::TZZone* l )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TimeZoneWidget::TimeZoneWidget( QWidget* parent )
|
TimeZoneWidget::TimeZoneWidget( const CalamaresUtils::Locale::CStringPairList& zones, QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, timeZoneImages( TimeZoneImageList::fromQRC() )
|
, timeZoneImages( TimeZoneImageList::fromQRC() )
|
||||||
|
, m_zonesData( zones )
|
||||||
{
|
{
|
||||||
setMouseTracking( false );
|
setMouseTracking( false );
|
||||||
setCursor( Qt::PointingHandCursor );
|
setCursor( Qt::PointingHandCursor );
|
||||||
@ -67,8 +68,7 @@ void
|
|||||||
TimeZoneWidget::setCurrentLocation( QString regionName, QString zoneName )
|
TimeZoneWidget::setCurrentLocation( QString regionName, QString zoneName )
|
||||||
{
|
{
|
||||||
using namespace CalamaresUtils::Locale;
|
using namespace CalamaresUtils::Locale;
|
||||||
const auto& regions = TZRegion::fromZoneTab();
|
auto* region = m_zonesData.find< TZRegion >( regionName );
|
||||||
auto* region = regions.find< TZRegion >( regionName );
|
|
||||||
if ( !region )
|
if ( !region )
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -201,7 +201,7 @@ TimeZoneWidget::mousePressEvent( QMouseEvent* event )
|
|||||||
|
|
||||||
using namespace CalamaresUtils::Locale;
|
using namespace CalamaresUtils::Locale;
|
||||||
const TZZone* closest = nullptr;
|
const TZZone* closest = nullptr;
|
||||||
for ( const auto* region_p : TZRegion::fromZoneTab() )
|
for ( const auto* region_p : m_zonesData )
|
||||||
{
|
{
|
||||||
const auto* region = dynamic_cast< const TZRegion* >( region_p );
|
const auto* region = dynamic_cast< const TZRegion* >( region_p );
|
||||||
if ( region )
|
if ( region )
|
||||||
|
@ -53,7 +53,7 @@ class TimeZoneWidget : public QWidget
|
|||||||
public:
|
public:
|
||||||
using TZZone = CalamaresUtils::Locale::TZZone;
|
using TZZone = CalamaresUtils::Locale::TZZone;
|
||||||
|
|
||||||
explicit TimeZoneWidget( QWidget* parent = nullptr );
|
explicit TimeZoneWidget( const CalamaresUtils::Locale::CStringPairList& zones, QWidget* parent = nullptr );
|
||||||
|
|
||||||
/** @brief Sets a location by name
|
/** @brief Sets a location by name
|
||||||
*
|
*
|
||||||
@ -76,6 +76,8 @@ private:
|
|||||||
QFont font;
|
QFont font;
|
||||||
QImage background, pin, currentZoneImage;
|
QImage background, pin, currentZoneImage;
|
||||||
TimeZoneImageList timeZoneImages;
|
TimeZoneImageList timeZoneImages;
|
||||||
|
|
||||||
|
const CalamaresUtils::Locale::CStringPairList& m_zonesData;
|
||||||
const TZZone* m_currentLocation = nullptr; // Not owned by me
|
const TZZone* m_currentLocation = nullptr; // Not owned by me
|
||||||
|
|
||||||
void paintEvent( QPaintEvent* event );
|
void paintEvent( QPaintEvent* event );
|
||||||
|
Loading…
Reference in New Issue
Block a user