diff --git a/src/modules/locale/CMakeLists.txt b/src/modules/locale/CMakeLists.txt index 2643ff548..cc34658dd 100644 --- a/src/modules/locale/CMakeLists.txt +++ b/src/modules/locale/CMakeLists.txt @@ -20,7 +20,6 @@ calamares_add_plugin( locale LocaleViewStep.cpp SetTimezoneJob.cpp timezonewidget/timezonewidget.cpp - timezonewidget/localeglobal.cpp UI RESOURCES locale.qrc diff --git a/src/modules/locale/Config.cpp b/src/modules/locale/Config.cpp index 47e7b7fcf..baa904c60 100644 --- a/src/modules/locale/Config.cpp +++ b/src/modules/locale/Config.cpp @@ -209,7 +209,13 @@ Config::updateGlobalStorage() const auto* location = currentLocation(); bool locationChanged = ( location->region() != gs->value( "locationRegion" ) ) || ( location->zone() != gs->value( "locationZone" ) ); - +#ifdef DEBUG_TIMEZONES + if ( locationChanged ) + { + cDebug() << "Location changed" << gs->value( "locationRegion" ) << ',' << gs->value( "locationZone" ) << "to" + << location->region() << ',' << location->zone(); + } +#endif gs->insert( "locationRegion", location->region() ); gs->insert( "locationZone", location->zone() ); diff --git a/src/modules/locale/Config.h b/src/modules/locale/Config.h index 9105cb071..cfbed7bae 100644 --- a/src/modules/locale/Config.h +++ b/src/modules/locale/Config.h @@ -21,7 +21,6 @@ #define LOCALE_CONFIG_H #include "LocaleConfiguration.h" -#include "timezonewidget/localeglobal.h" #include "Job.h" #include "locale/TimeZone.h" diff --git a/src/modules/locale/LocalePage.h b/src/modules/locale/LocalePage.h index d6aaa6de8..f31d81fb6 100644 --- a/src/modules/locale/LocalePage.h +++ b/src/modules/locale/LocalePage.h @@ -21,7 +21,6 @@ #define LOCALEPAGE_H #include "LocaleConfiguration.h" -#include "timezonewidget/localeglobal.h" #include "Job.h" #include "locale/TimeZone.h" diff --git a/src/modules/locale/LocaleViewStep.cpp b/src/modules/locale/LocaleViewStep.cpp index 4fa219065..6a2c17816 100644 --- a/src/modules/locale/LocaleViewStep.cpp +++ b/src/modules/locale/LocaleViewStep.cpp @@ -20,7 +20,6 @@ #include "LocaleViewStep.h" #include "LocalePage.h" -#include "timezonewidget/localeglobal.h" #include "widgets/WaitingWidget.h" #include "GlobalStorage.h" @@ -225,7 +224,6 @@ LocaleViewStep::setConfigurationMap( const QVariantMap& configurationMap ) Calamares::RequirementsList LocaleViewStep::checkRequirements() { - LocaleGlobal::init(); if ( m_geoip && m_geoip->isValid() ) { auto& network = CalamaresUtils::Network::Manager::instance(); diff --git a/src/modules/locale/timezonewidget/localeglobal.cpp b/src/modules/locale/timezonewidget/localeglobal.cpp deleted file mode 100644 index d0e889148..000000000 --- a/src/modules/locale/timezonewidget/localeglobal.cpp +++ /dev/null @@ -1,126 +0,0 @@ -/* === This file is part of Calamares - === - * - * Copyright 2014-2016, Teo Mrnjavac - * - * Originally from the Manjaro Installation Framework - * by Roland Singer - * Copyright (C) 2007 Free Software Foundation, Inc. - * - * 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 . - */ - -#include "localeglobal.h" - -#include "locale/TimeZone.h" - -#include - -//### -//### Private variables -//### - -QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > LocaleGlobal::locales; - - -//### -//### Public methods -//### - - -void -LocaleGlobal::init() -{ - // TODO: Error handling - initLocales(); -} - - -QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > -LocaleGlobal::getLocales() -{ - return locales; -} - - -//### -//### Private methods -//### - - -void -LocaleGlobal::initLocales() -{ - static const char LOCALESDIR[] = "/usr/share/i18n/locales"; - - locales.clear(); - - QStringList files = QDir( LOCALESDIR ).entryList( QDir::Files, QDir::Name ); - - for ( int i = 0; i < files.size(); ++i ) - { - QString filename = files.at( i ); - QFile file( QString( LOCALESDIR ) + "/" + filename ); - if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) - { - continue; - } - - QTextStream in( &file ); - QString commentChar = "%"; - Locale locale; - QString lang, territory; - - locale.locale = filename; - - while ( !in.atEnd() ) - { - QString line = in.readLine().trimmed(); - QStringList split = line.split( commentChar, QString::KeepEmptyParts ) - .first() - .split( QRegExp( " (?=[^\"]*(\"[^\"]*\"[^\"]*)*$)" ), QString::SkipEmptyParts ); - - if ( split.size() < 2 ) - { - continue; - } - - QString sub1 = QString( split.at( 0 ) ).remove( "\"" ); - QString sub2 = QString( split.at( 1 ) ).remove( "\"" ); - - if ( sub1 == "comment_char" ) - { - commentChar = sub2; - } - else if ( sub1 == "title" ) - { - locale.description = sub2; - } - else if ( sub1 == "territory" ) - { - territory = sub2; - } - else if ( sub1 == "language" ) - { - lang = sub2; - } - } - - if ( lang.isEmpty() || territory.isEmpty() ) - { - continue; - } - - locales[ lang ][ territory ].append( locale ); - } -} diff --git a/src/modules/locale/timezonewidget/localeglobal.h b/src/modules/locale/timezonewidget/localeglobal.h deleted file mode 100644 index 1dc9548d0..000000000 --- a/src/modules/locale/timezonewidget/localeglobal.h +++ /dev/null @@ -1,63 +0,0 @@ -/* === This file is part of Calamares - === - * - * Copyright 2014-2016, Teo Mrnjavac - * Copyright 2019, Adriaan de Groot - * - * Originally from the Manjaro Installation Framework - * by Roland Singer - * Copyright (C) 2007 Free Software Foundation, Inc. - * - * 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 . - */ - -#ifndef LOCALEGLOBAL_H -#define LOCALEGLOBAL_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace CalamaresUtils -{ -namespace Locale -{ -class TZZone; -} -} // namespace CalamaresUtils - -class LocaleGlobal -{ -public: - struct Locale - { - QString description, locale; - }; - - static void init(); - static QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > getLocales(); - -private: - static QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > locales; - - static void initLocales(); -}; - -#endif // LOCALEGLOBAL_H diff --git a/src/modules/locale/timezonewidget/timezonewidget.h b/src/modules/locale/timezonewidget/timezonewidget.h index d91c5cf27..81d2a618e 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.h +++ b/src/modules/locale/timezonewidget/timezonewidget.h @@ -24,8 +24,6 @@ #ifndef TIMEZONEWIDGET_H #define TIMEZONEWIDGET_H -#include "localeglobal.h" - #include "locale/TimeZone.h" #include diff --git a/src/modules/localeq/CMakeLists.txt b/src/modules/localeq/CMakeLists.txt index 458f44bfb..ff5292f3a 100644 --- a/src/modules/localeq/CMakeLists.txt +++ b/src/modules/localeq/CMakeLists.txt @@ -19,7 +19,6 @@ calamares_add_plugin( localeq ${_locale}/LocaleConfiguration.cpp ${_locale}/Config.cpp ${_locale}/SetTimezoneJob.cpp - ${_locale}/timezonewidget/localeglobal.cpp RESOURCES localeq.qrc LINK_PRIVATE_LIBRARIES diff --git a/src/modules/localeq/LocaleQmlViewStep.cpp b/src/modules/localeq/LocaleQmlViewStep.cpp index 13fbeaacc..fd5e72734 100644 --- a/src/modules/localeq/LocaleQmlViewStep.cpp +++ b/src/modules/localeq/LocaleQmlViewStep.cpp @@ -29,8 +29,6 @@ #include "utils/Variant.h" #include "utils/Yaml.h" -#include "timezonewidget/localeglobal.h" - #include "Branding.h" #include "modulesystem/ModuleManager.h" #include @@ -72,7 +70,6 @@ LocaleQmlViewStep::fetchGeoIpTimezone() Calamares::RequirementsList LocaleQmlViewStep::checkRequirements() { - LocaleGlobal::init(); if ( m_geoip && m_geoip->isValid() ) { auto& network = CalamaresUtils::Network::Manager::instance();