From 3ee384f36c02499a507ed4cb878f69934733c2bc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Nov 2019 17:57:54 +0100 Subject: [PATCH 01/57] [libcalamares] Extract zone.tab data for translations --- src/libcalamares/locale/zone-extractor.py | 105 ++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/libcalamares/locale/zone-extractor.py diff --git a/src/libcalamares/locale/zone-extractor.py b/src/libcalamares/locale/zone-extractor.py new file mode 100644 index 000000000..3622534da --- /dev/null +++ b/src/libcalamares/locale/zone-extractor.py @@ -0,0 +1,105 @@ +#! /usr/bin/env python3 +# +# === This file is part of Calamares - === +# +# Python3 script to scrape some data out of zoneinfo/zone.tab. +# +### BEGIN LICENSES +# +# Copyright 2019 Adriaan de Groot +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +### END LICENSES + +### BEGIN USAGE +# +""" +Python3 script to scrape some data out of zoneinfo/zone.tab. + +To use this script, you must have a zone.tab in a standard location. +FreeBSD uses /usr/share/zoneinfo/zone.tab, so that's where it looks. + +Prints out a few tables of zone names for use in translations. +""" + +def scrape_file(file, regionset, zoneset): + for line in file.readlines(): + if line.startswith("#"): + continue + parts = line.split("\t") + if len(parts) < 3: + continue + + zoneid = parts[2] + if not "/" in zoneid: + continue + + region, zone = zoneid.split("/", 1) + + zone = zone.strip().replace("_", " ") + + regionset.add(region) + assert(zone not in zoneset) + zoneset.add(zone) + +def write_set(file, label, set): + file.write("/* This returns a reference to local, which is a terrible idea.\n * Good thing it's not meant to be compiled.\n */\n") + # Note {{ is an escaped { for Python string formatting + file.write("static const QStringList& {!s}_table()\n{{\n\treturn QStringList {{\n".format(label)) + for x in set: + file.write("""\t\tQObject::tr("{!s}", "{!s}"),\n""".format(x, label)) + file.write("\t\tQString()\n\t};\n}\n\n") + +cpp_header_comment = """/* GENERATED FILE DO NOT EDIT +* +* === This file is part of Calamares - === +* +* This file is derived from zone.tab, which has its own copyright statement: +* +* This file is in the public domain, so clarified as of +* 2009-05-17 by Arthur David Olson. +* +* From Paul Eggert (2018-06-27): +* This file is intended as a backward-compatibility aid for older programs. +* New programs should use zone1970.tab. This file is like zone1970.tab (see +* zone1970.tab's comments), but with the following additional restrictions: +* +* 1. This file contains only ASCII characters. +* 2. The first data column contains exactly one country code. +* +*/ + +/** THIS FILE EXISTS ONLY FOR TRANSLATIONS PURPOSES **/ +""" + +if __name__ == "__main__": + regions=set() + zones=set() + with open("/usr/share/zoneinfo/zone.tab", "r") as f: + scrape_file(f, regions, zones) + with open("ZoneData_p.cpp", "w") as f: + f.write(cpp_header_comment) + write_set(f, "tz_regions", regions) + write_set(f, "tz_names", zones) + From 5fbae8213db2a0e1897d11d35405a9e6ddacad60 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Nov 2019 18:02:02 +0100 Subject: [PATCH 02/57] CI: fix Qt version-selection for FreeBSD when calling lupdate --- ci/txpush.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/txpush.sh b/ci/txpush.sh index 84166fac6..f3442f0e5 100755 --- a/ci/txpush.sh +++ b/ci/txpush.sh @@ -39,6 +39,9 @@ fi # sources, then push to Transifex export QT_SELECT=5 +lupdate -version > /dev/null 2>&1 || export QT_SELECT=qt5 +lupdate -version > /dev/null 2>&1 || { echo "! No working lupdate" ; lupdate -version ; exit 1 ; } + # Don't pull branding translations in, # those are done separately. _srcdirs="src/calamares src/libcalamares src/libcalamaresui src/modules src/qml" From 2034dd62a4da779fe8166dedffaea499c0a7877e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 19 Nov 2019 18:06:00 +0100 Subject: [PATCH 03/57] [libcalamares]: Timezone information for translation/extraction SEE #1259 --- src/libcalamares/locale/ZoneData_p.cpp | 475 +++++++++++++++++++++++++ 1 file changed, 475 insertions(+) create mode 100644 src/libcalamares/locale/ZoneData_p.cpp diff --git a/src/libcalamares/locale/ZoneData_p.cpp b/src/libcalamares/locale/ZoneData_p.cpp new file mode 100644 index 000000000..cb798963d --- /dev/null +++ b/src/libcalamares/locale/ZoneData_p.cpp @@ -0,0 +1,475 @@ +/* GENERATED FILE DO NOT EDIT +* +* === This file is part of Calamares - === +* +* This file is derived from zone.tab, which has its own copyright statement: +* +* This file is in the public domain, so clarified as of +* 2009-05-17 by Arthur David Olson. +* +* From Paul Eggert (2018-06-27): +* This file is intended as a backward-compatibility aid for older programs. +* New programs should use zone1970.tab. This file is like zone1970.tab (see +* zone1970.tab's comments), but with the following additional restrictions: +* +* 1. This file contains only ASCII characters. +* 2. The first data column contains exactly one country code. +* +*/ + +/** THIS FILE EXISTS ONLY FOR TRANSLATIONS PURPOSES **/ +/* This returns a reference to local, which is a terrible idea. + * Good thing it's not meant to be compiled. + */ +static const QStringList& tz_regions_table() +{ + return QStringList { + QObject::tr("Arctic", "tz_regions"), + QObject::tr("Pacific", "tz_regions"), + QObject::tr("Asia", "tz_regions"), + QObject::tr("Antarctica", "tz_regions"), + QObject::tr("America", "tz_regions"), + QObject::tr("Europe", "tz_regions"), + QObject::tr("Australia", "tz_regions"), + QObject::tr("Africa", "tz_regions"), + QObject::tr("Atlantic", "tz_regions"), + QObject::tr("Indian", "tz_regions"), + QString() + }; +} + +/* This returns a reference to local, which is a terrible idea. + * Good thing it's not meant to be compiled. + */ +static const QStringList& tz_names_table() +{ + return QStringList { + QObject::tr("Dhaka", "tz_names"), + QObject::tr("Palau", "tz_names"), + QObject::tr("Havana", "tz_names"), + QObject::tr("Busingen", "tz_names"), + QObject::tr("Tbilisi", "tz_names"), + QObject::tr("Guam", "tz_names"), + QObject::tr("Indiana/Winamac", "tz_names"), + QObject::tr("Indiana/Petersburg", "tz_names"), + QObject::tr("Macquarie", "tz_names"), + QObject::tr("Antigua", "tz_names"), + QObject::tr("Windhoek", "tz_names"), + QObject::tr("Barnaul", "tz_names"), + QObject::tr("Sarajevo", "tz_names"), + QObject::tr("Porto-Novo", "tz_names"), + QObject::tr("Ceuta", "tz_names"), + QObject::tr("Cambridge Bay", "tz_names"), + QObject::tr("Belize", "tz_names"), + QObject::tr("Port-au-Prince", "tz_names"), + QObject::tr("Baku", "tz_names"), + QObject::tr("Amsterdam", "tz_names"), + QObject::tr("Detroit", "tz_names"), + QObject::tr("Accra", "tz_names"), + QObject::tr("Indiana/Marengo", "tz_names"), + QObject::tr("Panama", "tz_names"), + QObject::tr("Argentina/Tucuman", "tz_names"), + QObject::tr("Reunion", "tz_names"), + QObject::tr("Beirut", "tz_names"), + QObject::tr("Dawson", "tz_names"), + QObject::tr("Bangui", "tz_names"), + QObject::tr("Punta Arenas", "tz_names"), + QObject::tr("Maldives", "tz_names"), + QObject::tr("Khartoum", "tz_names"), + QObject::tr("Argentina/La Rioja", "tz_names"), + QObject::tr("Porto Velho", "tz_names"), + QObject::tr("Wake", "tz_names"), + QObject::tr("Stockholm", "tz_names"), + QObject::tr("New York", "tz_names"), + QObject::tr("Chicago", "tz_names"), + QObject::tr("Madeira", "tz_names"), + QObject::tr("Vladivostok", "tz_names"), + QObject::tr("Argentina/Rio Gallegos", "tz_names"), + QObject::tr("Kirov", "tz_names"), + QObject::tr("Guernsey", "tz_names"), + QObject::tr("Cayenne", "tz_names"), + QObject::tr("Niamey", "tz_names"), + QObject::tr("Managua", "tz_names"), + QObject::tr("Ashgabat", "tz_names"), + QObject::tr("Addis Ababa", "tz_names"), + QObject::tr("Nauru", "tz_names"), + QObject::tr("Guyana", "tz_names"), + QObject::tr("Damascus", "tz_names"), + QObject::tr("Volgograd", "tz_names"), + QObject::tr("Kerguelen", "tz_names"), + QObject::tr("Fort Nelson", "tz_names"), + QObject::tr("Bahia Banderas", "tz_names"), + QObject::tr("Cayman", "tz_names"), + QObject::tr("Astrakhan", "tz_names"), + QObject::tr("Wallis", "tz_names"), + QObject::tr("Anadyr", "tz_names"), + QObject::tr("Fortaleza", "tz_names"), + QObject::tr("Thule", "tz_names"), + QObject::tr("Palmer", "tz_names"), + QObject::tr("Harare", "tz_names"), + QObject::tr("Araguaina", "tz_names"), + QObject::tr("Chagos", "tz_names"), + QObject::tr("Reykjavik", "tz_names"), + QObject::tr("Auckland", "tz_names"), + QObject::tr("Melbourne", "tz_names"), + QObject::tr("Mawson", "tz_names"), + QObject::tr("Miquelon", "tz_names"), + QObject::tr("Eirunepe", "tz_names"), + QObject::tr("Argentina/Salta", "tz_names"), + QObject::tr("Ndjamena", "tz_names"), + QObject::tr("Warsaw", "tz_names"), + QObject::tr("Brussels", "tz_names"), + QObject::tr("Hobart", "tz_names"), + QObject::tr("Kampala", "tz_names"), + QObject::tr("Jerusalem", "tz_names"), + QObject::tr("Vatican", "tz_names"), + QObject::tr("Kolkata", "tz_names"), + QObject::tr("Dakar", "tz_names"), + QObject::tr("Merida", "tz_names"), + QObject::tr("Moncton", "tz_names"), + QObject::tr("Riyadh", "tz_names"), + QObject::tr("Pohnpei", "tz_names"), + QObject::tr("Funafuti", "tz_names"), + QObject::tr("Krasnoyarsk", "tz_names"), + QObject::tr("Belem", "tz_names"), + QObject::tr("Rome", "tz_names"), + QObject::tr("Oral", "tz_names"), + QObject::tr("Sakhalin", "tz_names"), + QObject::tr("Moscow", "tz_names"), + QObject::tr("Anchorage", "tz_names"), + QObject::tr("Argentina/Cordoba", "tz_names"), + QObject::tr("Bucharest", "tz_names"), + QObject::tr("Nome", "tz_names"), + QObject::tr("La Paz", "tz_names"), + QObject::tr("Scoresbysund", "tz_names"), + QObject::tr("Adelaide", "tz_names"), + QObject::tr("Barbados", "tz_names"), + QObject::tr("Casey", "tz_names"), + QObject::tr("Seoul", "tz_names"), + QObject::tr("Tarawa", "tz_names"), + QObject::tr("Chatham", "tz_names"), + QObject::tr("Vostok", "tz_names"), + QObject::tr("Bishkek", "tz_names"), + QObject::tr("Inuvik", "tz_names"), + QObject::tr("Baghdad", "tz_names"), + QObject::tr("Whitehorse", "tz_names"), + QObject::tr("Resolute", "tz_names"), + QObject::tr("Syowa", "tz_names"), + QObject::tr("Regina", "tz_names"), + QObject::tr("Saratov", "tz_names"), + QObject::tr("North Dakota/Beulah", "tz_names"), + QObject::tr("Santo Domingo", "tz_names"), + QObject::tr("Lindeman", "tz_names"), + QObject::tr("Magadan", "tz_names"), + QObject::tr("Efate", "tz_names"), + QObject::tr("Bermuda", "tz_names"), + QObject::tr("Maceio", "tz_names"), + QObject::tr("Tashkent", "tz_names"), + QObject::tr("Qyzylorda", "tz_names"), + QObject::tr("Madrid", "tz_names"), + QObject::tr("Costa Rica", "tz_names"), + QObject::tr("Antananarivo", "tz_names"), + QObject::tr("Lima", "tz_names"), + QObject::tr("Kigali", "tz_names"), + QObject::tr("Marquesas", "tz_names"), + QObject::tr("Halifax", "tz_names"), + QObject::tr("Copenhagen", "tz_names"), + QObject::tr("Comoro", "tz_names"), + QObject::tr("Anguilla", "tz_names"), + QObject::tr("Kralendijk", "tz_names"), + QObject::tr("Sydney", "tz_names"), + QObject::tr("Yakutat", "tz_names"), + QObject::tr("Aqtau", "tz_names"), + QObject::tr("Brunei", "tz_names"), + QObject::tr("Vientiane", "tz_names"), + QObject::tr("Rainy River", "tz_names"), + QObject::tr("Bogota", "tz_names"), + QObject::tr("Port of Spain", "tz_names"), + QObject::tr("Rankin Inlet", "tz_names"), + QObject::tr("Pyongyang", "tz_names"), + QObject::tr("Bamako", "tz_names"), + QObject::tr("Samarkand", "tz_names"), + QObject::tr("Srednekolymsk", "tz_names"), + QObject::tr("Nicosia", "tz_names"), + QObject::tr("Iqaluit", "tz_names"), + QObject::tr("Yakutsk", "tz_names"), + QObject::tr("Cape Verde", "tz_names"), + QObject::tr("Zagreb", "tz_names"), + QObject::tr("Indiana/Knox", "tz_names"), + QObject::tr("Djibouti", "tz_names"), + QObject::tr("Grand Turk", "tz_names"), + QObject::tr("Hong Kong", "tz_names"), + QObject::tr("Monrovia", "tz_names"), + QObject::tr("Pitcairn", "tz_names"), + QObject::tr("El Aaiun", "tz_names"), + QObject::tr("Kuala Lumpur", "tz_names"), + QObject::tr("Kuwait", "tz_names"), + QObject::tr("Christmas", "tz_names"), + QObject::tr("Stanley", "tz_names"), + QObject::tr("Gambier", "tz_names"), + QObject::tr("Phnom Penh", "tz_names"), + QObject::tr("Sofia", "tz_names"), + QObject::tr("Longyearbyen", "tz_names"), + QObject::tr("St Helena", "tz_names"), + QObject::tr("Singapore", "tz_names"), + QObject::tr("Nipigon", "tz_names"), + QObject::tr("Zaporozhye", "tz_names"), + QObject::tr("Adak", "tz_names"), + QObject::tr("El Salvador", "tz_names"), + QObject::tr("Fakaofo", "tz_names"), + QObject::tr("Samara", "tz_names"), + QObject::tr("Makassar", "tz_names"), + QObject::tr("St Johns", "tz_names"), + QObject::tr("Tehran", "tz_names"), + QObject::tr("Almaty", "tz_names"), + QObject::tr("Hovd", "tz_names"), + QObject::tr("Tortola", "tz_names"), + QObject::tr("Bangkok", "tz_names"), + QObject::tr("Nassau", "tz_names"), + QObject::tr("Tunis", "tz_names"), + QObject::tr("Omsk", "tz_names"), + QObject::tr("Tokyo", "tz_names"), + QObject::tr("Casablanca", "tz_names"), + QObject::tr("Karachi", "tz_names"), + QObject::tr("McMurdo", "tz_names"), + QObject::tr("Tallinn", "tz_names"), + QObject::tr("Marigot", "tz_names"), + QObject::tr("Macau", "tz_names"), + QObject::tr("San Marino", "tz_names"), + QObject::tr("Denver", "tz_names"), + QObject::tr("Darwin", "tz_names"), + QObject::tr("Pangnirtung", "tz_names"), + QObject::tr("Chita", "tz_names"), + QObject::tr("Zurich", "tz_names"), + QObject::tr("Ulyanovsk", "tz_names"), + QObject::tr("Bissau", "tz_names"), + QObject::tr("Lagos", "tz_names"), + QObject::tr("Kuching", "tz_names"), + QObject::tr("Monaco", "tz_names"), + QObject::tr("Davis", "tz_names"), + QObject::tr("Argentina/Jujuy", "tz_names"), + QObject::tr("Recife", "tz_names"), + QObject::tr("Colombo", "tz_names"), + QObject::tr("Banjul", "tz_names"), + QObject::tr("Mauritius", "tz_names"), + QObject::tr("Creston", "tz_names"), + QObject::tr("Malta", "tz_names"), + QObject::tr("Argentina/Buenos Aires", "tz_names"), + QObject::tr("Vienna", "tz_names"), + QObject::tr("Skopje", "tz_names"), + QObject::tr("Swift Current", "tz_names"), + QObject::tr("Urumqi", "tz_names"), + QObject::tr("Guatemala", "tz_names"), + QObject::tr("Argentina/Mendoza", "tz_names"), + QObject::tr("Phoenix", "tz_names"), + QObject::tr("Asmara", "tz_names"), + QObject::tr("Noumea", "tz_names"), + QObject::tr("Boise", "tz_names"), + QObject::tr("Novokuznetsk", "tz_names"), + QObject::tr("Brazzaville", "tz_names"), + QObject::tr("Isle of Man", "tz_names"), + QObject::tr("Tegucigalpa", "tz_names"), + QObject::tr("Troll", "tz_names"), + QObject::tr("Glace Bay", "tz_names"), + QObject::tr("Yangon", "tz_names"), + QObject::tr("Conakry", "tz_names"), + QObject::tr("Aden", "tz_names"), + QObject::tr("Mayotte", "tz_names"), + QObject::tr("Grenada", "tz_names"), + QObject::tr("Mogadishu", "tz_names"), + QObject::tr("Sitka", "tz_names"), + QObject::tr("Kwajalein", "tz_names"), + QObject::tr("Pontianak", "tz_names"), + QObject::tr("Uzhgorod", "tz_names"), + QObject::tr("Ust-Nera", "tz_names"), + QObject::tr("Nairobi", "tz_names"), + QObject::tr("Saipan", "tz_names"), + QObject::tr("Sao Paulo", "tz_names"), + QObject::tr("Gaza", "tz_names"), + QObject::tr("Jakarta", "tz_names"), + QObject::tr("Godthab", "tz_names"), + QObject::tr("Choibalsan", "tz_names"), + QObject::tr("Jersey", "tz_names"), + QObject::tr("Tripoli", "tz_names"), + QObject::tr("Blantyre", "tz_names"), + QObject::tr("Freetown", "tz_names"), + QObject::tr("Andorra", "tz_names"), + QObject::tr("Danmarkshavn", "tz_names"), + QObject::tr("Los Angeles", "tz_names"), + QObject::tr("Caracas", "tz_names"), + QObject::tr("Oslo", "tz_names"), + QObject::tr("Rothera", "tz_names"), + QObject::tr("Budapest", "tz_names"), + QObject::tr("St Lucia", "tz_names"), + QObject::tr("Indiana/Indianapolis", "tz_names"), + QObject::tr("Paris", "tz_names"), + QObject::tr("Yerevan", "tz_names"), + QObject::tr("St Barthelemy", "tz_names"), + QObject::tr("Cuiaba", "tz_names"), + QObject::tr("Asuncion", "tz_names"), + QObject::tr("Manila", "tz_names"), + QObject::tr("Edmonton", "tz_names"), + QObject::tr("Vancouver", "tz_names"), + QObject::tr("Tongatapu", "tz_names"), + QObject::tr("Bahrain", "tz_names"), + QObject::tr("Kinshasa", "tz_names"), + QObject::tr("Mariehamn", "tz_names"), + QObject::tr("Kosrae", "tz_names"), + QObject::tr("Luanda", "tz_names"), + QObject::tr("Tirane", "tz_names"), + QObject::tr("Manaus", "tz_names"), + QObject::tr("Helsinki", "tz_names"), + QObject::tr("Chihuahua", "tz_names"), + QObject::tr("Khandyga", "tz_names"), + QObject::tr("Mexico City", "tz_names"), + QObject::tr("Prague", "tz_names"), + QObject::tr("Atyrau", "tz_names"), + QObject::tr("Jayapura", "tz_names"), + QObject::tr("Novosibirsk", "tz_names"), + QObject::tr("Eucla", "tz_names"), + QObject::tr("Vilnius", "tz_names"), + QObject::tr("Dublin", "tz_names"), + QObject::tr("Luxembourg", "tz_names"), + QObject::tr("Johannesburg", "tz_names"), + QObject::tr("Yellowknife", "tz_names"), + QObject::tr("Norfolk", "tz_names"), + QObject::tr("Menominee", "tz_names"), + QObject::tr("Dushanbe", "tz_names"), + QObject::tr("Noronha", "tz_names"), + QObject::tr("Kathmandu", "tz_names"), + QObject::tr("Shanghai", "tz_names"), + QObject::tr("Goose Bay", "tz_names"), + QObject::tr("Amman", "tz_names"), + QObject::tr("Santiago", "tz_names"), + QObject::tr("Campo Grande", "tz_names"), + QObject::tr("Dili", "tz_names"), + QObject::tr("Nouakchott", "tz_names"), + QObject::tr("Bahia", "tz_names"), + QObject::tr("Guadalcanal", "tz_names"), + QObject::tr("Simferopol", "tz_names"), + QObject::tr("Douala", "tz_names"), + QObject::tr("Dar es Salaam", "tz_names"), + QObject::tr("Bratislava", "tz_names"), + QObject::tr("Minsk", "tz_names"), + QObject::tr("Indiana/Vevay", "tz_names"), + QObject::tr("Cairo", "tz_names"), + QObject::tr("Winnipeg", "tz_names"), + QObject::tr("Kiev", "tz_names"), + QObject::tr("Broken Hill", "tz_names"), + QObject::tr("Montserrat", "tz_names"), + QObject::tr("Perth", "tz_names"), + QObject::tr("Ljubljana", "tz_names"), + QObject::tr("Lisbon", "tz_names"), + QObject::tr("Majuro", "tz_names"), + QObject::tr("North Dakota/Center", "tz_names"), + QObject::tr("Lome", "tz_names"), + QObject::tr("DumontDUrville", "tz_names"), + QObject::tr("Argentina/Ushuaia", "tz_names"), + QObject::tr("Atikokan", "tz_names"), + QObject::tr("Lubumbashi", "tz_names"), + QObject::tr("Santarem", "tz_names"), + QObject::tr("Riga", "tz_names"), + QObject::tr("Kamchatka", "tz_names"), + QObject::tr("Aruba", "tz_names"), + QObject::tr("Azores", "tz_names"), + QObject::tr("Maseru", "tz_names"), + QObject::tr("Faroe", "tz_names"), + QObject::tr("Niue", "tz_names"), + QObject::tr("Gaborone", "tz_names"), + QObject::tr("Port Moresby", "tz_names"), + QObject::tr("Cocos", "tz_names"), + QObject::tr("Blanc-Sablon", "tz_names"), + QObject::tr("Argentina/San Luis", "tz_names"), + QObject::tr("Mahe", "tz_names"), + QObject::tr("Kentucky/Monticello", "tz_names"), + QObject::tr("Galapagos", "tz_names"), + QObject::tr("South Georgia", "tz_names"), + QObject::tr("Ho Chi Minh", "tz_names"), + QObject::tr("Kiritimati", "tz_names"), + QObject::tr("Mazatlan", "tz_names"), + QObject::tr("Argentina/Catamarca", "tz_names"), + QObject::tr("St Kitts", "tz_names"), + QObject::tr("Kentucky/Louisville", "tz_names"), + QObject::tr("Bougainville", "tz_names"), + QObject::tr("Lower Princes", "tz_names"), + QObject::tr("Pago Pago", "tz_names"), + QObject::tr("Curacao", "tz_names"), + QObject::tr("Tahiti", "tz_names"), + QObject::tr("Irkutsk", "tz_names"), + QObject::tr("Thunder Bay", "tz_names"), + QObject::tr("Rio Branco", "tz_names"), + QObject::tr("Argentina/San Juan", "tz_names"), + QObject::tr("Paramaribo", "tz_names"), + QObject::tr("Libreville", "tz_names"), + QObject::tr("Lusaka", "tz_names"), + QObject::tr("Hebron", "tz_names"), + QObject::tr("Algiers", "tz_names"), + QObject::tr("Ojinaga", "tz_names"), + QObject::tr("Rarotonga", "tz_names"), + QObject::tr("Maputo", "tz_names"), + QObject::tr("Honolulu", "tz_names"), + QObject::tr("Brisbane", "tz_names"), + QObject::tr("Ulaanbaatar", "tz_names"), + QObject::tr("Chuuk", "tz_names"), + QObject::tr("Aqtobe", "tz_names"), + QObject::tr("Guayaquil", "tz_names"), + QObject::tr("Canary", "tz_names"), + QObject::tr("Mbabane", "tz_names"), + QObject::tr("Abidjan", "tz_names"), + QObject::tr("Muscat", "tz_names"), + QObject::tr("Apia", "tz_names"), + QObject::tr("North Dakota/New Salem", "tz_names"), + QObject::tr("Istanbul", "tz_names"), + QObject::tr("Belgrade", "tz_names"), + QObject::tr("Juba", "tz_names"), + QObject::tr("Midway", "tz_names"), + QObject::tr("Berlin", "tz_names"), + QObject::tr("Martinique", "tz_names"), + QObject::tr("Indiana/Vincennes", "tz_names"), + QObject::tr("Athens", "tz_names"), + QObject::tr("Ouagadougou", "tz_names"), + QObject::tr("Podgorica", "tz_names"), + QObject::tr("Sao Tome", "tz_names"), + QObject::tr("Vaduz", "tz_names"), + QObject::tr("Qatar", "tz_names"), + QObject::tr("Cancun", "tz_names"), + QObject::tr("Taipei", "tz_names"), + QObject::tr("Puerto Rico", "tz_names"), + QObject::tr("Metlakatla", "tz_names"), + QObject::tr("Jamaica", "tz_names"), + QObject::tr("Kaliningrad", "tz_names"), + QObject::tr("Enderbury", "tz_names"), + QObject::tr("Currie", "tz_names"), + QObject::tr("Thimphu", "tz_names"), + QObject::tr("Matamoros", "tz_names"), + QObject::tr("Montevideo", "tz_names"), + QObject::tr("Gibraltar", "tz_names"), + QObject::tr("Tijuana", "tz_names"), + QObject::tr("St Thomas", "tz_names"), + QObject::tr("London", "tz_names"), + QObject::tr("Yekaterinburg", "tz_names"), + QObject::tr("Easter", "tz_names"), + QObject::tr("Boa Vista", "tz_names"), + QObject::tr("Dawson Creek", "tz_names"), + QObject::tr("Hermosillo", "tz_names"), + QObject::tr("Famagusta", "tz_names"), + QObject::tr("Monterrey", "tz_names"), + QObject::tr("Dominica", "tz_names"), + QObject::tr("Guadeloupe", "tz_names"), + QObject::tr("Indiana/Tell City", "tz_names"), + QObject::tr("Dubai", "tz_names"), + QObject::tr("Malabo", "tz_names"), + QObject::tr("Bujumbura", "tz_names"), + QObject::tr("Fiji", "tz_names"), + QObject::tr("St Vincent", "tz_names"), + QObject::tr("Qostanay", "tz_names"), + QObject::tr("Tomsk", "tz_names"), + QObject::tr("Juneau", "tz_names"), + QObject::tr("Chisinau", "tz_names"), + QObject::tr("Lord Howe", "tz_names"), + QObject::tr("Kabul", "tz_names"), + QObject::tr("Toronto", "tz_names"), + QString() + }; +} + From 1df6454cfea949c15cab807605e81b7393e7a60f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 25 Nov 2019 10:52:22 +0100 Subject: [PATCH 04/57] [locale] Tidy up types - use JobList typedef where possible - remove unused forward type definitions --- src/modules/locale/LocalePage.cpp | 2 +- src/modules/locale/LocaleViewStep.cpp | 8 +++----- src/modules/locale/LocaleViewStep.h | 5 ++--- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index 7720a840c..fc715e3f3 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -301,7 +301,7 @@ LocalePage::prettyStatus() const } -QList< Calamares::job_ptr > +Calamares::JobList LocalePage::createJobs() { QList< Calamares::job_ptr > list; diff --git a/src/modules/locale/LocaleViewStep.cpp b/src/modules/locale/LocaleViewStep.cpp index 4acfcb2de..4fa219065 100644 --- a/src/modules/locale/LocaleViewStep.cpp +++ b/src/modules/locale/LocaleViewStep.cpp @@ -142,7 +142,7 @@ LocaleViewStep::isAtEnd() const } -QList< Calamares::job_ptr > +Calamares::JobList LocaleViewStep::jobs() const { return m_jobs; @@ -163,12 +163,9 @@ LocaleViewStep::onActivate() void LocaleViewStep::onLeave() { - m_jobs.clear(); - if ( m_actualWidget ) { - m_jobs.append( m_actualWidget->createJobs() ); - + m_jobs = m_actualWidget->createJobs(); m_prettyStatus = m_actualWidget->prettyStatus(); auto map = m_actualWidget->localesMap(); @@ -182,6 +179,7 @@ LocaleViewStep::onLeave() } else { + m_jobs.clear(); Calamares::JobQueue::instance()->globalStorage()->remove( "localeConf" ); } } diff --git a/src/modules/locale/LocaleViewStep.h b/src/modules/locale/LocaleViewStep.h index ca8ecc3fa..eb8d64177 100644 --- a/src/modules/locale/LocaleViewStep.h +++ b/src/modules/locale/LocaleViewStep.h @@ -33,7 +33,6 @@ #include class LocalePage; -class WaitingWidget; class PLUGINDLLEXPORT LocaleViewStep : public Calamares::ViewStep { @@ -54,7 +53,7 @@ public: bool isAtBeginning() const override; bool isAtEnd() const override; - QList< Calamares::job_ptr > jobs() const override; + Calamares::JobList jobs() const override; void onActivate() override; void onLeave() override; @@ -78,7 +77,7 @@ private: CalamaresUtils::GeoIP::RegionZonePair m_startingTimezone; QString m_localeGenPath; - QList< Calamares::job_ptr > m_jobs; + Calamares::JobList m_jobs; std::unique_ptr< CalamaresUtils::GeoIP::Handler > m_geoip; }; From 906aeec5d3f98ee485e2f534b75e1a54d438c5d7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 25 Nov 2019 11:49:41 +0100 Subject: [PATCH 05/57] [locale] Replace #define with a static const - TZ_DATA_FILE is only used in one place --- src/modules/locale/timezonewidget/localeconst.h | 1 - src/modules/locale/timezonewidget/localeglobal.cpp | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/modules/locale/timezonewidget/localeconst.h b/src/modules/locale/timezonewidget/localeconst.h index 3bac6adde..2de1b0dac 100644 --- a/src/modules/locale/timezonewidget/localeconst.h +++ b/src/modules/locale/timezonewidget/localeconst.h @@ -25,7 +25,6 @@ #define LOCALESDIR "/usr/share/i18n/locales" -#define TZ_DATA_FILE "/usr/share/zoneinfo/zone.tab" #define USER_IMAGES_PATH "/usr/share/pixmaps/faces" diff --git a/src/modules/locale/timezonewidget/localeglobal.cpp b/src/modules/locale/timezonewidget/localeglobal.cpp index 6303ffdcb..683b2bebc 100644 --- a/src/modules/locale/timezonewidget/localeglobal.cpp +++ b/src/modules/locale/timezonewidget/localeglobal.cpp @@ -131,6 +131,8 @@ LocaleGlobal::initLocales() { void LocaleGlobal::initLocations() { + static const char TZ_DATA_FILE[] = "/usr/share/zoneinfo/zone.tab"; + locations.clear(); QFile file(TZ_DATA_FILE); From c3fdb3809786b2bfff8faf16f926ea752c3a139b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 25 Nov 2019 20:51:45 +0100 Subject: [PATCH 06/57] [libcalamares] Stub of class for TimeZone model management - Intent is to move out of locale module --- src/libcalamares/locale/TimeZone.h | 69 ++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 src/libcalamares/locale/TimeZone.h diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h new file mode 100644 index 000000000..b9102dff9 --- /dev/null +++ b/src/libcalamares/locale/TimeZone.h @@ -0,0 +1,69 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019, Adriaan de Groot + * + * 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 LOCALE_TIMEZONE_H +#define LOCALE_TIMEZONE_H + +#include + +namespace CalamaresUtils +{ +namespace Locale +{ + +/** @brief A pair of strings, one human-readable, one a key + * + * Given an identifier-like string (e.g. "New_York"), makes + * a human-readable version of that and keeps a copy of the + * identifier itself. + * + * This explicitly uses const char* instead of just being + * QPair because there is API that needs + * C-style strings. + */ +class CStringPair +{ +public: + explicit CStringPair(const char *s1); + CStringPair(CStringPair&& t); + CStringPair(const CStringPair&) = delete; + ~CStringPair(); + +private: + const char* m_human = nullptr; + const char* m_key = nullptr; +}; + +/// @brief A pair of strings for timezone regions (e.g. "America") +class TZRegion : public CStringPair +{ +public: + using CStringPair::CStringPair; +}; + +/// @brief A pair of strings for specific timezone names (e.g. "New_York") +class TZZone : public CStringPair +{ +public: + using CStringPair::CStringPair; +}; + +} +} + +#endif // LOCALE_TIMEZONE_H From 733fb43b5ec57eb32120d8013dfe95bcd5b04664 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Nov 2019 10:45:36 +0100 Subject: [PATCH 07/57] [libcalamares] Sort the dummy zone names --- src/libcalamares/locale/ZoneData_p.cpp | 848 +++++++++++----------- src/libcalamares/locale/zone-extractor.py | 6 +- 2 files changed, 427 insertions(+), 427 deletions(-) diff --git a/src/libcalamares/locale/ZoneData_p.cpp b/src/libcalamares/locale/ZoneData_p.cpp index cb798963d..f0b92f33f 100644 --- a/src/libcalamares/locale/ZoneData_p.cpp +++ b/src/libcalamares/locale/ZoneData_p.cpp @@ -24,16 +24,16 @@ static const QStringList& tz_regions_table() { return QStringList { - QObject::tr("Arctic", "tz_regions"), - QObject::tr("Pacific", "tz_regions"), - QObject::tr("Asia", "tz_regions"), - QObject::tr("Antarctica", "tz_regions"), - QObject::tr("America", "tz_regions"), - QObject::tr("Europe", "tz_regions"), - QObject::tr("Australia", "tz_regions"), QObject::tr("Africa", "tz_regions"), + QObject::tr("America", "tz_regions"), + QObject::tr("Antarctica", "tz_regions"), + QObject::tr("Arctic", "tz_regions"), + QObject::tr("Asia", "tz_regions"), QObject::tr("Atlantic", "tz_regions"), + QObject::tr("Australia", "tz_regions"), + QObject::tr("Europe", "tz_regions"), QObject::tr("Indian", "tz_regions"), + QObject::tr("Pacific", "tz_regions"), QString() }; } @@ -44,431 +44,431 @@ static const QStringList& tz_regions_table() static const QStringList& tz_names_table() { return QStringList { - QObject::tr("Dhaka", "tz_names"), - QObject::tr("Palau", "tz_names"), - QObject::tr("Havana", "tz_names"), - QObject::tr("Busingen", "tz_names"), - QObject::tr("Tbilisi", "tz_names"), - QObject::tr("Guam", "tz_names"), - QObject::tr("Indiana/Winamac", "tz_names"), - QObject::tr("Indiana/Petersburg", "tz_names"), - QObject::tr("Macquarie", "tz_names"), - QObject::tr("Antigua", "tz_names"), - QObject::tr("Windhoek", "tz_names"), - QObject::tr("Barnaul", "tz_names"), - QObject::tr("Sarajevo", "tz_names"), - QObject::tr("Porto-Novo", "tz_names"), - QObject::tr("Ceuta", "tz_names"), - QObject::tr("Cambridge Bay", "tz_names"), - QObject::tr("Belize", "tz_names"), - QObject::tr("Port-au-Prince", "tz_names"), - QObject::tr("Baku", "tz_names"), - QObject::tr("Amsterdam", "tz_names"), - QObject::tr("Detroit", "tz_names"), - QObject::tr("Accra", "tz_names"), - QObject::tr("Indiana/Marengo", "tz_names"), - QObject::tr("Panama", "tz_names"), - QObject::tr("Argentina/Tucuman", "tz_names"), - QObject::tr("Reunion", "tz_names"), - QObject::tr("Beirut", "tz_names"), - QObject::tr("Dawson", "tz_names"), - QObject::tr("Bangui", "tz_names"), - QObject::tr("Punta Arenas", "tz_names"), - QObject::tr("Maldives", "tz_names"), - QObject::tr("Khartoum", "tz_names"), - QObject::tr("Argentina/La Rioja", "tz_names"), - QObject::tr("Porto Velho", "tz_names"), - QObject::tr("Wake", "tz_names"), - QObject::tr("Stockholm", "tz_names"), - QObject::tr("New York", "tz_names"), - QObject::tr("Chicago", "tz_names"), - QObject::tr("Madeira", "tz_names"), - QObject::tr("Vladivostok", "tz_names"), - QObject::tr("Argentina/Rio Gallegos", "tz_names"), - QObject::tr("Kirov", "tz_names"), - QObject::tr("Guernsey", "tz_names"), - QObject::tr("Cayenne", "tz_names"), - QObject::tr("Niamey", "tz_names"), - QObject::tr("Managua", "tz_names"), - QObject::tr("Ashgabat", "tz_names"), - QObject::tr("Addis Ababa", "tz_names"), - QObject::tr("Nauru", "tz_names"), - QObject::tr("Guyana", "tz_names"), - QObject::tr("Damascus", "tz_names"), - QObject::tr("Volgograd", "tz_names"), - QObject::tr("Kerguelen", "tz_names"), - QObject::tr("Fort Nelson", "tz_names"), - QObject::tr("Bahia Banderas", "tz_names"), - QObject::tr("Cayman", "tz_names"), - QObject::tr("Astrakhan", "tz_names"), - QObject::tr("Wallis", "tz_names"), - QObject::tr("Anadyr", "tz_names"), - QObject::tr("Fortaleza", "tz_names"), - QObject::tr("Thule", "tz_names"), - QObject::tr("Palmer", "tz_names"), - QObject::tr("Harare", "tz_names"), - QObject::tr("Araguaina", "tz_names"), - QObject::tr("Chagos", "tz_names"), - QObject::tr("Reykjavik", "tz_names"), - QObject::tr("Auckland", "tz_names"), - QObject::tr("Melbourne", "tz_names"), - QObject::tr("Mawson", "tz_names"), - QObject::tr("Miquelon", "tz_names"), - QObject::tr("Eirunepe", "tz_names"), - QObject::tr("Argentina/Salta", "tz_names"), - QObject::tr("Ndjamena", "tz_names"), - QObject::tr("Warsaw", "tz_names"), - QObject::tr("Brussels", "tz_names"), - QObject::tr("Hobart", "tz_names"), - QObject::tr("Kampala", "tz_names"), - QObject::tr("Jerusalem", "tz_names"), - QObject::tr("Vatican", "tz_names"), - QObject::tr("Kolkata", "tz_names"), - QObject::tr("Dakar", "tz_names"), - QObject::tr("Merida", "tz_names"), - QObject::tr("Moncton", "tz_names"), - QObject::tr("Riyadh", "tz_names"), - QObject::tr("Pohnpei", "tz_names"), - QObject::tr("Funafuti", "tz_names"), - QObject::tr("Krasnoyarsk", "tz_names"), - QObject::tr("Belem", "tz_names"), - QObject::tr("Rome", "tz_names"), - QObject::tr("Oral", "tz_names"), - QObject::tr("Sakhalin", "tz_names"), - QObject::tr("Moscow", "tz_names"), - QObject::tr("Anchorage", "tz_names"), - QObject::tr("Argentina/Cordoba", "tz_names"), - QObject::tr("Bucharest", "tz_names"), - QObject::tr("Nome", "tz_names"), - QObject::tr("La Paz", "tz_names"), - QObject::tr("Scoresbysund", "tz_names"), - QObject::tr("Adelaide", "tz_names"), - QObject::tr("Barbados", "tz_names"), - QObject::tr("Casey", "tz_names"), - QObject::tr("Seoul", "tz_names"), - QObject::tr("Tarawa", "tz_names"), - QObject::tr("Chatham", "tz_names"), - QObject::tr("Vostok", "tz_names"), - QObject::tr("Bishkek", "tz_names"), - QObject::tr("Inuvik", "tz_names"), - QObject::tr("Baghdad", "tz_names"), - QObject::tr("Whitehorse", "tz_names"), - QObject::tr("Resolute", "tz_names"), - QObject::tr("Syowa", "tz_names"), - QObject::tr("Regina", "tz_names"), - QObject::tr("Saratov", "tz_names"), - QObject::tr("North Dakota/Beulah", "tz_names"), - QObject::tr("Santo Domingo", "tz_names"), - QObject::tr("Lindeman", "tz_names"), - QObject::tr("Magadan", "tz_names"), - QObject::tr("Efate", "tz_names"), - QObject::tr("Bermuda", "tz_names"), - QObject::tr("Maceio", "tz_names"), - QObject::tr("Tashkent", "tz_names"), - QObject::tr("Qyzylorda", "tz_names"), - QObject::tr("Madrid", "tz_names"), - QObject::tr("Costa Rica", "tz_names"), - QObject::tr("Antananarivo", "tz_names"), - QObject::tr("Lima", "tz_names"), - QObject::tr("Kigali", "tz_names"), - QObject::tr("Marquesas", "tz_names"), - QObject::tr("Halifax", "tz_names"), - QObject::tr("Copenhagen", "tz_names"), - QObject::tr("Comoro", "tz_names"), - QObject::tr("Anguilla", "tz_names"), - QObject::tr("Kralendijk", "tz_names"), - QObject::tr("Sydney", "tz_names"), - QObject::tr("Yakutat", "tz_names"), - QObject::tr("Aqtau", "tz_names"), - QObject::tr("Brunei", "tz_names"), - QObject::tr("Vientiane", "tz_names"), - QObject::tr("Rainy River", "tz_names"), - QObject::tr("Bogota", "tz_names"), - QObject::tr("Port of Spain", "tz_names"), - QObject::tr("Rankin Inlet", "tz_names"), - QObject::tr("Pyongyang", "tz_names"), - QObject::tr("Bamako", "tz_names"), - QObject::tr("Samarkand", "tz_names"), - QObject::tr("Srednekolymsk", "tz_names"), - QObject::tr("Nicosia", "tz_names"), - QObject::tr("Iqaluit", "tz_names"), - QObject::tr("Yakutsk", "tz_names"), - QObject::tr("Cape Verde", "tz_names"), - QObject::tr("Zagreb", "tz_names"), - QObject::tr("Indiana/Knox", "tz_names"), - QObject::tr("Djibouti", "tz_names"), - QObject::tr("Grand Turk", "tz_names"), - QObject::tr("Hong Kong", "tz_names"), - QObject::tr("Monrovia", "tz_names"), - QObject::tr("Pitcairn", "tz_names"), - QObject::tr("El Aaiun", "tz_names"), - QObject::tr("Kuala Lumpur", "tz_names"), - QObject::tr("Kuwait", "tz_names"), - QObject::tr("Christmas", "tz_names"), - QObject::tr("Stanley", "tz_names"), - QObject::tr("Gambier", "tz_names"), - QObject::tr("Phnom Penh", "tz_names"), - QObject::tr("Sofia", "tz_names"), - QObject::tr("Longyearbyen", "tz_names"), - QObject::tr("St Helena", "tz_names"), - QObject::tr("Singapore", "tz_names"), - QObject::tr("Nipigon", "tz_names"), - QObject::tr("Zaporozhye", "tz_names"), - QObject::tr("Adak", "tz_names"), - QObject::tr("El Salvador", "tz_names"), - QObject::tr("Fakaofo", "tz_names"), - QObject::tr("Samara", "tz_names"), - QObject::tr("Makassar", "tz_names"), - QObject::tr("St Johns", "tz_names"), - QObject::tr("Tehran", "tz_names"), - QObject::tr("Almaty", "tz_names"), - QObject::tr("Hovd", "tz_names"), - QObject::tr("Tortola", "tz_names"), - QObject::tr("Bangkok", "tz_names"), - QObject::tr("Nassau", "tz_names"), - QObject::tr("Tunis", "tz_names"), - QObject::tr("Omsk", "tz_names"), - QObject::tr("Tokyo", "tz_names"), - QObject::tr("Casablanca", "tz_names"), - QObject::tr("Karachi", "tz_names"), - QObject::tr("McMurdo", "tz_names"), - QObject::tr("Tallinn", "tz_names"), - QObject::tr("Marigot", "tz_names"), - QObject::tr("Macau", "tz_names"), - QObject::tr("San Marino", "tz_names"), - QObject::tr("Denver", "tz_names"), - QObject::tr("Darwin", "tz_names"), - QObject::tr("Pangnirtung", "tz_names"), - QObject::tr("Chita", "tz_names"), - QObject::tr("Zurich", "tz_names"), - QObject::tr("Ulyanovsk", "tz_names"), - QObject::tr("Bissau", "tz_names"), - QObject::tr("Lagos", "tz_names"), - QObject::tr("Kuching", "tz_names"), - QObject::tr("Monaco", "tz_names"), - QObject::tr("Davis", "tz_names"), - QObject::tr("Argentina/Jujuy", "tz_names"), - QObject::tr("Recife", "tz_names"), - QObject::tr("Colombo", "tz_names"), - QObject::tr("Banjul", "tz_names"), - QObject::tr("Mauritius", "tz_names"), - QObject::tr("Creston", "tz_names"), - QObject::tr("Malta", "tz_names"), - QObject::tr("Argentina/Buenos Aires", "tz_names"), - QObject::tr("Vienna", "tz_names"), - QObject::tr("Skopje", "tz_names"), - QObject::tr("Swift Current", "tz_names"), - QObject::tr("Urumqi", "tz_names"), - QObject::tr("Guatemala", "tz_names"), - QObject::tr("Argentina/Mendoza", "tz_names"), - QObject::tr("Phoenix", "tz_names"), - QObject::tr("Asmara", "tz_names"), - QObject::tr("Noumea", "tz_names"), - QObject::tr("Boise", "tz_names"), - QObject::tr("Novokuznetsk", "tz_names"), - QObject::tr("Brazzaville", "tz_names"), - QObject::tr("Isle of Man", "tz_names"), - QObject::tr("Tegucigalpa", "tz_names"), - QObject::tr("Troll", "tz_names"), - QObject::tr("Glace Bay", "tz_names"), - QObject::tr("Yangon", "tz_names"), - QObject::tr("Conakry", "tz_names"), - QObject::tr("Aden", "tz_names"), - QObject::tr("Mayotte", "tz_names"), - QObject::tr("Grenada", "tz_names"), - QObject::tr("Mogadishu", "tz_names"), - QObject::tr("Sitka", "tz_names"), - QObject::tr("Kwajalein", "tz_names"), - QObject::tr("Pontianak", "tz_names"), - QObject::tr("Uzhgorod", "tz_names"), - QObject::tr("Ust-Nera", "tz_names"), - QObject::tr("Nairobi", "tz_names"), - QObject::tr("Saipan", "tz_names"), - QObject::tr("Sao Paulo", "tz_names"), - QObject::tr("Gaza", "tz_names"), - QObject::tr("Jakarta", "tz_names"), - QObject::tr("Godthab", "tz_names"), - QObject::tr("Choibalsan", "tz_names"), - QObject::tr("Jersey", "tz_names"), - QObject::tr("Tripoli", "tz_names"), - QObject::tr("Blantyre", "tz_names"), - QObject::tr("Freetown", "tz_names"), - QObject::tr("Andorra", "tz_names"), - QObject::tr("Danmarkshavn", "tz_names"), - QObject::tr("Los Angeles", "tz_names"), - QObject::tr("Caracas", "tz_names"), - QObject::tr("Oslo", "tz_names"), - QObject::tr("Rothera", "tz_names"), - QObject::tr("Budapest", "tz_names"), - QObject::tr("St Lucia", "tz_names"), - QObject::tr("Indiana/Indianapolis", "tz_names"), - QObject::tr("Paris", "tz_names"), - QObject::tr("Yerevan", "tz_names"), - QObject::tr("St Barthelemy", "tz_names"), - QObject::tr("Cuiaba", "tz_names"), - QObject::tr("Asuncion", "tz_names"), - QObject::tr("Manila", "tz_names"), - QObject::tr("Edmonton", "tz_names"), - QObject::tr("Vancouver", "tz_names"), - QObject::tr("Tongatapu", "tz_names"), - QObject::tr("Bahrain", "tz_names"), - QObject::tr("Kinshasa", "tz_names"), - QObject::tr("Mariehamn", "tz_names"), - QObject::tr("Kosrae", "tz_names"), - QObject::tr("Luanda", "tz_names"), - QObject::tr("Tirane", "tz_names"), - QObject::tr("Manaus", "tz_names"), - QObject::tr("Helsinki", "tz_names"), - QObject::tr("Chihuahua", "tz_names"), - QObject::tr("Khandyga", "tz_names"), - QObject::tr("Mexico City", "tz_names"), - QObject::tr("Prague", "tz_names"), - QObject::tr("Atyrau", "tz_names"), - QObject::tr("Jayapura", "tz_names"), - QObject::tr("Novosibirsk", "tz_names"), - QObject::tr("Eucla", "tz_names"), - QObject::tr("Vilnius", "tz_names"), - QObject::tr("Dublin", "tz_names"), - QObject::tr("Luxembourg", "tz_names"), - QObject::tr("Johannesburg", "tz_names"), - QObject::tr("Yellowknife", "tz_names"), - QObject::tr("Norfolk", "tz_names"), - QObject::tr("Menominee", "tz_names"), - QObject::tr("Dushanbe", "tz_names"), - QObject::tr("Noronha", "tz_names"), - QObject::tr("Kathmandu", "tz_names"), - QObject::tr("Shanghai", "tz_names"), - QObject::tr("Goose Bay", "tz_names"), - QObject::tr("Amman", "tz_names"), - QObject::tr("Santiago", "tz_names"), - QObject::tr("Campo Grande", "tz_names"), - QObject::tr("Dili", "tz_names"), - QObject::tr("Nouakchott", "tz_names"), - QObject::tr("Bahia", "tz_names"), - QObject::tr("Guadalcanal", "tz_names"), - QObject::tr("Simferopol", "tz_names"), - QObject::tr("Douala", "tz_names"), - QObject::tr("Dar es Salaam", "tz_names"), - QObject::tr("Bratislava", "tz_names"), - QObject::tr("Minsk", "tz_names"), - QObject::tr("Indiana/Vevay", "tz_names"), - QObject::tr("Cairo", "tz_names"), - QObject::tr("Winnipeg", "tz_names"), - QObject::tr("Kiev", "tz_names"), - QObject::tr("Broken Hill", "tz_names"), - QObject::tr("Montserrat", "tz_names"), - QObject::tr("Perth", "tz_names"), - QObject::tr("Ljubljana", "tz_names"), - QObject::tr("Lisbon", "tz_names"), - QObject::tr("Majuro", "tz_names"), - QObject::tr("North Dakota/Center", "tz_names"), - QObject::tr("Lome", "tz_names"), - QObject::tr("DumontDUrville", "tz_names"), - QObject::tr("Argentina/Ushuaia", "tz_names"), - QObject::tr("Atikokan", "tz_names"), - QObject::tr("Lubumbashi", "tz_names"), - QObject::tr("Santarem", "tz_names"), - QObject::tr("Riga", "tz_names"), - QObject::tr("Kamchatka", "tz_names"), - QObject::tr("Aruba", "tz_names"), - QObject::tr("Azores", "tz_names"), - QObject::tr("Maseru", "tz_names"), - QObject::tr("Faroe", "tz_names"), - QObject::tr("Niue", "tz_names"), - QObject::tr("Gaborone", "tz_names"), - QObject::tr("Port Moresby", "tz_names"), - QObject::tr("Cocos", "tz_names"), - QObject::tr("Blanc-Sablon", "tz_names"), - QObject::tr("Argentina/San Luis", "tz_names"), - QObject::tr("Mahe", "tz_names"), - QObject::tr("Kentucky/Monticello", "tz_names"), - QObject::tr("Galapagos", "tz_names"), - QObject::tr("South Georgia", "tz_names"), - QObject::tr("Ho Chi Minh", "tz_names"), - QObject::tr("Kiritimati", "tz_names"), - QObject::tr("Mazatlan", "tz_names"), - QObject::tr("Argentina/Catamarca", "tz_names"), - QObject::tr("St Kitts", "tz_names"), - QObject::tr("Kentucky/Louisville", "tz_names"), - QObject::tr("Bougainville", "tz_names"), - QObject::tr("Lower Princes", "tz_names"), - QObject::tr("Pago Pago", "tz_names"), - QObject::tr("Curacao", "tz_names"), - QObject::tr("Tahiti", "tz_names"), - QObject::tr("Irkutsk", "tz_names"), - QObject::tr("Thunder Bay", "tz_names"), - QObject::tr("Rio Branco", "tz_names"), - QObject::tr("Argentina/San Juan", "tz_names"), - QObject::tr("Paramaribo", "tz_names"), - QObject::tr("Libreville", "tz_names"), - QObject::tr("Lusaka", "tz_names"), - QObject::tr("Hebron", "tz_names"), - QObject::tr("Algiers", "tz_names"), - QObject::tr("Ojinaga", "tz_names"), - QObject::tr("Rarotonga", "tz_names"), - QObject::tr("Maputo", "tz_names"), - QObject::tr("Honolulu", "tz_names"), - QObject::tr("Brisbane", "tz_names"), - QObject::tr("Ulaanbaatar", "tz_names"), - QObject::tr("Chuuk", "tz_names"), - QObject::tr("Aqtobe", "tz_names"), - QObject::tr("Guayaquil", "tz_names"), - QObject::tr("Canary", "tz_names"), - QObject::tr("Mbabane", "tz_names"), QObject::tr("Abidjan", "tz_names"), - QObject::tr("Muscat", "tz_names"), + QObject::tr("Accra", "tz_names"), + QObject::tr("Adak", "tz_names"), + QObject::tr("Addis Ababa", "tz_names"), + QObject::tr("Adelaide", "tz_names"), + QObject::tr("Aden", "tz_names"), + QObject::tr("Algiers", "tz_names"), + QObject::tr("Almaty", "tz_names"), + QObject::tr("Amman", "tz_names"), + QObject::tr("Amsterdam", "tz_names"), + QObject::tr("Anadyr", "tz_names"), + QObject::tr("Anchorage", "tz_names"), + QObject::tr("Andorra", "tz_names"), + QObject::tr("Anguilla", "tz_names"), + QObject::tr("Antananarivo", "tz_names"), + QObject::tr("Antigua", "tz_names"), QObject::tr("Apia", "tz_names"), - QObject::tr("North Dakota/New Salem", "tz_names"), - QObject::tr("Istanbul", "tz_names"), - QObject::tr("Belgrade", "tz_names"), - QObject::tr("Juba", "tz_names"), - QObject::tr("Midway", "tz_names"), - QObject::tr("Berlin", "tz_names"), - QObject::tr("Martinique", "tz_names"), - QObject::tr("Indiana/Vincennes", "tz_names"), + QObject::tr("Aqtau", "tz_names"), + QObject::tr("Aqtobe", "tz_names"), + QObject::tr("Araguaina", "tz_names"), + QObject::tr("Argentina/Buenos Aires", "tz_names"), + QObject::tr("Argentina/Catamarca", "tz_names"), + QObject::tr("Argentina/Cordoba", "tz_names"), + QObject::tr("Argentina/Jujuy", "tz_names"), + QObject::tr("Argentina/La Rioja", "tz_names"), + QObject::tr("Argentina/Mendoza", "tz_names"), + QObject::tr("Argentina/Rio Gallegos", "tz_names"), + QObject::tr("Argentina/Salta", "tz_names"), + QObject::tr("Argentina/San Juan", "tz_names"), + QObject::tr("Argentina/San Luis", "tz_names"), + QObject::tr("Argentina/Tucuman", "tz_names"), + QObject::tr("Argentina/Ushuaia", "tz_names"), + QObject::tr("Aruba", "tz_names"), + QObject::tr("Ashgabat", "tz_names"), + QObject::tr("Asmara", "tz_names"), + QObject::tr("Astrakhan", "tz_names"), + QObject::tr("Asuncion", "tz_names"), QObject::tr("Athens", "tz_names"), - QObject::tr("Ouagadougou", "tz_names"), - QObject::tr("Podgorica", "tz_names"), - QObject::tr("Sao Tome", "tz_names"), - QObject::tr("Vaduz", "tz_names"), - QObject::tr("Qatar", "tz_names"), - QObject::tr("Cancun", "tz_names"), - QObject::tr("Taipei", "tz_names"), - QObject::tr("Puerto Rico", "tz_names"), - QObject::tr("Metlakatla", "tz_names"), - QObject::tr("Jamaica", "tz_names"), - QObject::tr("Kaliningrad", "tz_names"), - QObject::tr("Enderbury", "tz_names"), - QObject::tr("Currie", "tz_names"), - QObject::tr("Thimphu", "tz_names"), - QObject::tr("Matamoros", "tz_names"), - QObject::tr("Montevideo", "tz_names"), - QObject::tr("Gibraltar", "tz_names"), - QObject::tr("Tijuana", "tz_names"), - QObject::tr("St Thomas", "tz_names"), - QObject::tr("London", "tz_names"), - QObject::tr("Yekaterinburg", "tz_names"), - QObject::tr("Easter", "tz_names"), + QObject::tr("Atikokan", "tz_names"), + QObject::tr("Atyrau", "tz_names"), + QObject::tr("Auckland", "tz_names"), + QObject::tr("Azores", "tz_names"), + QObject::tr("Baghdad", "tz_names"), + QObject::tr("Bahia", "tz_names"), + QObject::tr("Bahia Banderas", "tz_names"), + QObject::tr("Bahrain", "tz_names"), + QObject::tr("Baku", "tz_names"), + QObject::tr("Bamako", "tz_names"), + QObject::tr("Bangkok", "tz_names"), + QObject::tr("Bangui", "tz_names"), + QObject::tr("Banjul", "tz_names"), + QObject::tr("Barbados", "tz_names"), + QObject::tr("Barnaul", "tz_names"), + QObject::tr("Beirut", "tz_names"), + QObject::tr("Belem", "tz_names"), + QObject::tr("Belgrade", "tz_names"), + QObject::tr("Belize", "tz_names"), + QObject::tr("Berlin", "tz_names"), + QObject::tr("Bermuda", "tz_names"), + QObject::tr("Bishkek", "tz_names"), + QObject::tr("Bissau", "tz_names"), + QObject::tr("Blanc-Sablon", "tz_names"), + QObject::tr("Blantyre", "tz_names"), QObject::tr("Boa Vista", "tz_names"), - QObject::tr("Dawson Creek", "tz_names"), - QObject::tr("Hermosillo", "tz_names"), - QObject::tr("Famagusta", "tz_names"), - QObject::tr("Monterrey", "tz_names"), - QObject::tr("Dominica", "tz_names"), - QObject::tr("Guadeloupe", "tz_names"), - QObject::tr("Indiana/Tell City", "tz_names"), - QObject::tr("Dubai", "tz_names"), - QObject::tr("Malabo", "tz_names"), + QObject::tr("Bogota", "tz_names"), + QObject::tr("Boise", "tz_names"), + QObject::tr("Bougainville", "tz_names"), + QObject::tr("Bratislava", "tz_names"), + QObject::tr("Brazzaville", "tz_names"), + QObject::tr("Brisbane", "tz_names"), + QObject::tr("Broken Hill", "tz_names"), + QObject::tr("Brunei", "tz_names"), + QObject::tr("Brussels", "tz_names"), + QObject::tr("Bucharest", "tz_names"), + QObject::tr("Budapest", "tz_names"), QObject::tr("Bujumbura", "tz_names"), - QObject::tr("Fiji", "tz_names"), - QObject::tr("St Vincent", "tz_names"), - QObject::tr("Qostanay", "tz_names"), - QObject::tr("Tomsk", "tz_names"), - QObject::tr("Juneau", "tz_names"), + QObject::tr("Busingen", "tz_names"), + QObject::tr("Cairo", "tz_names"), + QObject::tr("Cambridge Bay", "tz_names"), + QObject::tr("Campo Grande", "tz_names"), + QObject::tr("Canary", "tz_names"), + QObject::tr("Cancun", "tz_names"), + QObject::tr("Cape Verde", "tz_names"), + QObject::tr("Caracas", "tz_names"), + QObject::tr("Casablanca", "tz_names"), + QObject::tr("Casey", "tz_names"), + QObject::tr("Cayenne", "tz_names"), + QObject::tr("Cayman", "tz_names"), + QObject::tr("Ceuta", "tz_names"), + QObject::tr("Chagos", "tz_names"), + QObject::tr("Chatham", "tz_names"), + QObject::tr("Chicago", "tz_names"), + QObject::tr("Chihuahua", "tz_names"), QObject::tr("Chisinau", "tz_names"), - QObject::tr("Lord Howe", "tz_names"), + QObject::tr("Chita", "tz_names"), + QObject::tr("Choibalsan", "tz_names"), + QObject::tr("Christmas", "tz_names"), + QObject::tr("Chuuk", "tz_names"), + QObject::tr("Cocos", "tz_names"), + QObject::tr("Colombo", "tz_names"), + QObject::tr("Comoro", "tz_names"), + QObject::tr("Conakry", "tz_names"), + QObject::tr("Copenhagen", "tz_names"), + QObject::tr("Costa Rica", "tz_names"), + QObject::tr("Creston", "tz_names"), + QObject::tr("Cuiaba", "tz_names"), + QObject::tr("Curacao", "tz_names"), + QObject::tr("Currie", "tz_names"), + QObject::tr("Dakar", "tz_names"), + QObject::tr("Damascus", "tz_names"), + QObject::tr("Danmarkshavn", "tz_names"), + QObject::tr("Dar es Salaam", "tz_names"), + QObject::tr("Darwin", "tz_names"), + QObject::tr("Davis", "tz_names"), + QObject::tr("Dawson", "tz_names"), + QObject::tr("Dawson Creek", "tz_names"), + QObject::tr("Denver", "tz_names"), + QObject::tr("Detroit", "tz_names"), + QObject::tr("Dhaka", "tz_names"), + QObject::tr("Dili", "tz_names"), + QObject::tr("Djibouti", "tz_names"), + QObject::tr("Dominica", "tz_names"), + QObject::tr("Douala", "tz_names"), + QObject::tr("Dubai", "tz_names"), + QObject::tr("Dublin", "tz_names"), + QObject::tr("DumontDUrville", "tz_names"), + QObject::tr("Dushanbe", "tz_names"), + QObject::tr("Easter", "tz_names"), + QObject::tr("Edmonton", "tz_names"), + QObject::tr("Efate", "tz_names"), + QObject::tr("Eirunepe", "tz_names"), + QObject::tr("El Aaiun", "tz_names"), + QObject::tr("El Salvador", "tz_names"), + QObject::tr("Enderbury", "tz_names"), + QObject::tr("Eucla", "tz_names"), + QObject::tr("Fakaofo", "tz_names"), + QObject::tr("Famagusta", "tz_names"), + QObject::tr("Faroe", "tz_names"), + QObject::tr("Fiji", "tz_names"), + QObject::tr("Fort Nelson", "tz_names"), + QObject::tr("Fortaleza", "tz_names"), + QObject::tr("Freetown", "tz_names"), + QObject::tr("Funafuti", "tz_names"), + QObject::tr("Gaborone", "tz_names"), + QObject::tr("Galapagos", "tz_names"), + QObject::tr("Gambier", "tz_names"), + QObject::tr("Gaza", "tz_names"), + QObject::tr("Gibraltar", "tz_names"), + QObject::tr("Glace Bay", "tz_names"), + QObject::tr("Godthab", "tz_names"), + QObject::tr("Goose Bay", "tz_names"), + QObject::tr("Grand Turk", "tz_names"), + QObject::tr("Grenada", "tz_names"), + QObject::tr("Guadalcanal", "tz_names"), + QObject::tr("Guadeloupe", "tz_names"), + QObject::tr("Guam", "tz_names"), + QObject::tr("Guatemala", "tz_names"), + QObject::tr("Guayaquil", "tz_names"), + QObject::tr("Guernsey", "tz_names"), + QObject::tr("Guyana", "tz_names"), + QObject::tr("Halifax", "tz_names"), + QObject::tr("Harare", "tz_names"), + QObject::tr("Havana", "tz_names"), + QObject::tr("Hebron", "tz_names"), + QObject::tr("Helsinki", "tz_names"), + QObject::tr("Hermosillo", "tz_names"), + QObject::tr("Ho Chi Minh", "tz_names"), + QObject::tr("Hobart", "tz_names"), + QObject::tr("Hong Kong", "tz_names"), + QObject::tr("Honolulu", "tz_names"), + QObject::tr("Hovd", "tz_names"), + QObject::tr("Indiana/Indianapolis", "tz_names"), + QObject::tr("Indiana/Knox", "tz_names"), + QObject::tr("Indiana/Marengo", "tz_names"), + QObject::tr("Indiana/Petersburg", "tz_names"), + QObject::tr("Indiana/Tell City", "tz_names"), + QObject::tr("Indiana/Vevay", "tz_names"), + QObject::tr("Indiana/Vincennes", "tz_names"), + QObject::tr("Indiana/Winamac", "tz_names"), + QObject::tr("Inuvik", "tz_names"), + QObject::tr("Iqaluit", "tz_names"), + QObject::tr("Irkutsk", "tz_names"), + QObject::tr("Isle of Man", "tz_names"), + QObject::tr("Istanbul", "tz_names"), + QObject::tr("Jakarta", "tz_names"), + QObject::tr("Jamaica", "tz_names"), + QObject::tr("Jayapura", "tz_names"), + QObject::tr("Jersey", "tz_names"), + QObject::tr("Jerusalem", "tz_names"), + QObject::tr("Johannesburg", "tz_names"), + QObject::tr("Juba", "tz_names"), + QObject::tr("Juneau", "tz_names"), QObject::tr("Kabul", "tz_names"), + QObject::tr("Kaliningrad", "tz_names"), + QObject::tr("Kamchatka", "tz_names"), + QObject::tr("Kampala", "tz_names"), + QObject::tr("Karachi", "tz_names"), + QObject::tr("Kathmandu", "tz_names"), + QObject::tr("Kentucky/Louisville", "tz_names"), + QObject::tr("Kentucky/Monticello", "tz_names"), + QObject::tr("Kerguelen", "tz_names"), + QObject::tr("Khandyga", "tz_names"), + QObject::tr("Khartoum", "tz_names"), + QObject::tr("Kiev", "tz_names"), + QObject::tr("Kigali", "tz_names"), + QObject::tr("Kinshasa", "tz_names"), + QObject::tr("Kiritimati", "tz_names"), + QObject::tr("Kirov", "tz_names"), + QObject::tr("Kolkata", "tz_names"), + QObject::tr("Kosrae", "tz_names"), + QObject::tr("Kralendijk", "tz_names"), + QObject::tr("Krasnoyarsk", "tz_names"), + QObject::tr("Kuala Lumpur", "tz_names"), + QObject::tr("Kuching", "tz_names"), + QObject::tr("Kuwait", "tz_names"), + QObject::tr("Kwajalein", "tz_names"), + QObject::tr("La Paz", "tz_names"), + QObject::tr("Lagos", "tz_names"), + QObject::tr("Libreville", "tz_names"), + QObject::tr("Lima", "tz_names"), + QObject::tr("Lindeman", "tz_names"), + QObject::tr("Lisbon", "tz_names"), + QObject::tr("Ljubljana", "tz_names"), + QObject::tr("Lome", "tz_names"), + QObject::tr("London", "tz_names"), + QObject::tr("Longyearbyen", "tz_names"), + QObject::tr("Lord Howe", "tz_names"), + QObject::tr("Los Angeles", "tz_names"), + QObject::tr("Lower Princes", "tz_names"), + QObject::tr("Luanda", "tz_names"), + QObject::tr("Lubumbashi", "tz_names"), + QObject::tr("Lusaka", "tz_names"), + QObject::tr("Luxembourg", "tz_names"), + QObject::tr("Macau", "tz_names"), + QObject::tr("Maceio", "tz_names"), + QObject::tr("Macquarie", "tz_names"), + QObject::tr("Madeira", "tz_names"), + QObject::tr("Madrid", "tz_names"), + QObject::tr("Magadan", "tz_names"), + QObject::tr("Mahe", "tz_names"), + QObject::tr("Majuro", "tz_names"), + QObject::tr("Makassar", "tz_names"), + QObject::tr("Malabo", "tz_names"), + QObject::tr("Maldives", "tz_names"), + QObject::tr("Malta", "tz_names"), + QObject::tr("Managua", "tz_names"), + QObject::tr("Manaus", "tz_names"), + QObject::tr("Manila", "tz_names"), + QObject::tr("Maputo", "tz_names"), + QObject::tr("Mariehamn", "tz_names"), + QObject::tr("Marigot", "tz_names"), + QObject::tr("Marquesas", "tz_names"), + QObject::tr("Martinique", "tz_names"), + QObject::tr("Maseru", "tz_names"), + QObject::tr("Matamoros", "tz_names"), + QObject::tr("Mauritius", "tz_names"), + QObject::tr("Mawson", "tz_names"), + QObject::tr("Mayotte", "tz_names"), + QObject::tr("Mazatlan", "tz_names"), + QObject::tr("Mbabane", "tz_names"), + QObject::tr("McMurdo", "tz_names"), + QObject::tr("Melbourne", "tz_names"), + QObject::tr("Menominee", "tz_names"), + QObject::tr("Merida", "tz_names"), + QObject::tr("Metlakatla", "tz_names"), + QObject::tr("Mexico City", "tz_names"), + QObject::tr("Midway", "tz_names"), + QObject::tr("Minsk", "tz_names"), + QObject::tr("Miquelon", "tz_names"), + QObject::tr("Mogadishu", "tz_names"), + QObject::tr("Monaco", "tz_names"), + QObject::tr("Moncton", "tz_names"), + QObject::tr("Monrovia", "tz_names"), + QObject::tr("Monterrey", "tz_names"), + QObject::tr("Montevideo", "tz_names"), + QObject::tr("Montserrat", "tz_names"), + QObject::tr("Moscow", "tz_names"), + QObject::tr("Muscat", "tz_names"), + QObject::tr("Nairobi", "tz_names"), + QObject::tr("Nassau", "tz_names"), + QObject::tr("Nauru", "tz_names"), + QObject::tr("Ndjamena", "tz_names"), + QObject::tr("New York", "tz_names"), + QObject::tr("Niamey", "tz_names"), + QObject::tr("Nicosia", "tz_names"), + QObject::tr("Nipigon", "tz_names"), + QObject::tr("Niue", "tz_names"), + QObject::tr("Nome", "tz_names"), + QObject::tr("Norfolk", "tz_names"), + QObject::tr("Noronha", "tz_names"), + QObject::tr("North Dakota/Beulah", "tz_names"), + QObject::tr("North Dakota/Center", "tz_names"), + QObject::tr("North Dakota/New Salem", "tz_names"), + QObject::tr("Nouakchott", "tz_names"), + QObject::tr("Noumea", "tz_names"), + QObject::tr("Novokuznetsk", "tz_names"), + QObject::tr("Novosibirsk", "tz_names"), + QObject::tr("Ojinaga", "tz_names"), + QObject::tr("Omsk", "tz_names"), + QObject::tr("Oral", "tz_names"), + QObject::tr("Oslo", "tz_names"), + QObject::tr("Ouagadougou", "tz_names"), + QObject::tr("Pago Pago", "tz_names"), + QObject::tr("Palau", "tz_names"), + QObject::tr("Palmer", "tz_names"), + QObject::tr("Panama", "tz_names"), + QObject::tr("Pangnirtung", "tz_names"), + QObject::tr("Paramaribo", "tz_names"), + QObject::tr("Paris", "tz_names"), + QObject::tr("Perth", "tz_names"), + QObject::tr("Phnom Penh", "tz_names"), + QObject::tr("Phoenix", "tz_names"), + QObject::tr("Pitcairn", "tz_names"), + QObject::tr("Podgorica", "tz_names"), + QObject::tr("Pohnpei", "tz_names"), + QObject::tr("Pontianak", "tz_names"), + QObject::tr("Port Moresby", "tz_names"), + QObject::tr("Port of Spain", "tz_names"), + QObject::tr("Port-au-Prince", "tz_names"), + QObject::tr("Porto Velho", "tz_names"), + QObject::tr("Porto-Novo", "tz_names"), + QObject::tr("Prague", "tz_names"), + QObject::tr("Puerto Rico", "tz_names"), + QObject::tr("Punta Arenas", "tz_names"), + QObject::tr("Pyongyang", "tz_names"), + QObject::tr("Qatar", "tz_names"), + QObject::tr("Qostanay", "tz_names"), + QObject::tr("Qyzylorda", "tz_names"), + QObject::tr("Rainy River", "tz_names"), + QObject::tr("Rankin Inlet", "tz_names"), + QObject::tr("Rarotonga", "tz_names"), + QObject::tr("Recife", "tz_names"), + QObject::tr("Regina", "tz_names"), + QObject::tr("Resolute", "tz_names"), + QObject::tr("Reunion", "tz_names"), + QObject::tr("Reykjavik", "tz_names"), + QObject::tr("Riga", "tz_names"), + QObject::tr("Rio Branco", "tz_names"), + QObject::tr("Riyadh", "tz_names"), + QObject::tr("Rome", "tz_names"), + QObject::tr("Rothera", "tz_names"), + QObject::tr("Saipan", "tz_names"), + QObject::tr("Sakhalin", "tz_names"), + QObject::tr("Samara", "tz_names"), + QObject::tr("Samarkand", "tz_names"), + QObject::tr("San Marino", "tz_names"), + QObject::tr("Santarem", "tz_names"), + QObject::tr("Santiago", "tz_names"), + QObject::tr("Santo Domingo", "tz_names"), + QObject::tr("Sao Paulo", "tz_names"), + QObject::tr("Sao Tome", "tz_names"), + QObject::tr("Sarajevo", "tz_names"), + QObject::tr("Saratov", "tz_names"), + QObject::tr("Scoresbysund", "tz_names"), + QObject::tr("Seoul", "tz_names"), + QObject::tr("Shanghai", "tz_names"), + QObject::tr("Simferopol", "tz_names"), + QObject::tr("Singapore", "tz_names"), + QObject::tr("Sitka", "tz_names"), + QObject::tr("Skopje", "tz_names"), + QObject::tr("Sofia", "tz_names"), + QObject::tr("South Georgia", "tz_names"), + QObject::tr("Srednekolymsk", "tz_names"), + QObject::tr("St Barthelemy", "tz_names"), + QObject::tr("St Helena", "tz_names"), + QObject::tr("St Johns", "tz_names"), + QObject::tr("St Kitts", "tz_names"), + QObject::tr("St Lucia", "tz_names"), + QObject::tr("St Thomas", "tz_names"), + QObject::tr("St Vincent", "tz_names"), + QObject::tr("Stanley", "tz_names"), + QObject::tr("Stockholm", "tz_names"), + QObject::tr("Swift Current", "tz_names"), + QObject::tr("Sydney", "tz_names"), + QObject::tr("Syowa", "tz_names"), + QObject::tr("Tahiti", "tz_names"), + QObject::tr("Taipei", "tz_names"), + QObject::tr("Tallinn", "tz_names"), + QObject::tr("Tarawa", "tz_names"), + QObject::tr("Tashkent", "tz_names"), + QObject::tr("Tbilisi", "tz_names"), + QObject::tr("Tegucigalpa", "tz_names"), + QObject::tr("Tehran", "tz_names"), + QObject::tr("Thimphu", "tz_names"), + QObject::tr("Thule", "tz_names"), + QObject::tr("Thunder Bay", "tz_names"), + QObject::tr("Tijuana", "tz_names"), + QObject::tr("Tirane", "tz_names"), + QObject::tr("Tokyo", "tz_names"), + QObject::tr("Tomsk", "tz_names"), + QObject::tr("Tongatapu", "tz_names"), QObject::tr("Toronto", "tz_names"), + QObject::tr("Tortola", "tz_names"), + QObject::tr("Tripoli", "tz_names"), + QObject::tr("Troll", "tz_names"), + QObject::tr("Tunis", "tz_names"), + QObject::tr("Ulaanbaatar", "tz_names"), + QObject::tr("Ulyanovsk", "tz_names"), + QObject::tr("Urumqi", "tz_names"), + QObject::tr("Ust-Nera", "tz_names"), + QObject::tr("Uzhgorod", "tz_names"), + QObject::tr("Vaduz", "tz_names"), + QObject::tr("Vancouver", "tz_names"), + QObject::tr("Vatican", "tz_names"), + QObject::tr("Vienna", "tz_names"), + QObject::tr("Vientiane", "tz_names"), + QObject::tr("Vilnius", "tz_names"), + QObject::tr("Vladivostok", "tz_names"), + QObject::tr("Volgograd", "tz_names"), + QObject::tr("Vostok", "tz_names"), + QObject::tr("Wake", "tz_names"), + QObject::tr("Wallis", "tz_names"), + QObject::tr("Warsaw", "tz_names"), + QObject::tr("Whitehorse", "tz_names"), + QObject::tr("Windhoek", "tz_names"), + QObject::tr("Winnipeg", "tz_names"), + QObject::tr("Yakutat", "tz_names"), + QObject::tr("Yakutsk", "tz_names"), + QObject::tr("Yangon", "tz_names"), + QObject::tr("Yekaterinburg", "tz_names"), + QObject::tr("Yellowknife", "tz_names"), + QObject::tr("Yerevan", "tz_names"), + QObject::tr("Zagreb", "tz_names"), + QObject::tr("Zaporozhye", "tz_names"), + QObject::tr("Zurich", "tz_names"), QString() }; } diff --git a/src/libcalamares/locale/zone-extractor.py b/src/libcalamares/locale/zone-extractor.py index 3622534da..6b1433adf 100644 --- a/src/libcalamares/locale/zone-extractor.py +++ b/src/libcalamares/locale/zone-extractor.py @@ -37,8 +37,8 @@ """ Python3 script to scrape some data out of zoneinfo/zone.tab. -To use this script, you must have a zone.tab in a standard location. -FreeBSD uses /usr/share/zoneinfo/zone.tab, so that's where it looks. +To use this script, you must have a zone.tab in a standard location, +/usr/share/zoneinfo/zone.tab (this is usual on FreeBSD and Linux). Prints out a few tables of zone names for use in translations. """ @@ -67,7 +67,7 @@ def write_set(file, label, set): file.write("/* This returns a reference to local, which is a terrible idea.\n * Good thing it's not meant to be compiled.\n */\n") # Note {{ is an escaped { for Python string formatting file.write("static const QStringList& {!s}_table()\n{{\n\treturn QStringList {{\n".format(label)) - for x in set: + for x in sorted(set): file.write("""\t\tQObject::tr("{!s}", "{!s}"),\n""".format(x, label)) file.write("\t\tQString()\n\t};\n}\n\n") From abd3c4171bbe66a74f4f2d33151174426adf9bf6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Nov 2019 11:08:21 +0100 Subject: [PATCH 08/57] [libcalamares] Prevent CI coding-style fixes to generated code --- src/libcalamares/locale/ZoneData_p.cpp | 3 +++ src/libcalamares/locale/zone-extractor.py | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/libcalamares/locale/ZoneData_p.cpp b/src/libcalamares/locale/ZoneData_p.cpp index f0b92f33f..b73d17ad3 100644 --- a/src/libcalamares/locale/ZoneData_p.cpp +++ b/src/libcalamares/locale/ZoneData_p.cpp @@ -18,6 +18,9 @@ */ /** THIS FILE EXISTS ONLY FOR TRANSLATIONS PURPOSES **/ + +// *INDENT-OFF* +// clang-format off /* This returns a reference to local, which is a terrible idea. * Good thing it's not meant to be compiled. */ diff --git a/src/libcalamares/locale/zone-extractor.py b/src/libcalamares/locale/zone-extractor.py index 6b1433adf..92165d824 100644 --- a/src/libcalamares/locale/zone-extractor.py +++ b/src/libcalamares/locale/zone-extractor.py @@ -91,6 +91,9 @@ cpp_header_comment = """/* GENERATED FILE DO NOT EDIT */ /** THIS FILE EXISTS ONLY FOR TRANSLATIONS PURPOSES **/ + +// *INDENT-OFF* +// clang-format off """ if __name__ == "__main__": From 3af2754022d41dc091c0f26a22e23bddbb19b8f8 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Nov 2019 11:18:35 +0100 Subject: [PATCH 09/57] [libcalamares] Implement translatable-pair-of-char* - This is base functionality for a translatable model of TimeZone names that is scraped from zone.tab --- src/libcalamares/locale/TimeZone.cpp | 83 ++++++++++++++++++++++++++++ src/libcalamares/locale/TimeZone.h | 31 ++++++++--- 2 files changed, 105 insertions(+), 9 deletions(-) create mode 100644 src/libcalamares/locale/TimeZone.cpp diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp new file mode 100644 index 000000000..900548c72 --- /dev/null +++ b/src/libcalamares/locale/TimeZone.cpp @@ -0,0 +1,83 @@ +/* === This file is part of Calamares - === + * + * Copyright 2019, Adriaan de Groot + * + * 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 "TimeZone.h" + +#include + +namespace CalamaresUtils +{ +namespace Locale +{ + + +CStringPair::CStringPair( CStringPair&& t ) +{ + // My pointers are initialized to nullptr + std::swap( m_human, t.m_human ); + std::swap( m_key, t.m_key ); +} + +CStringPair::CStringPair( const CStringPair& t ) + : m_human( t.m_human ? strdup( t.m_human ) : nullptr ) + , m_key( t.m_key ? strdup( t.m_key ) : nullptr ) +{ +} + +/** @brief Massage an identifier into a human-readable form + * + * Makes a copy of @p s, caller must free() it. + */ +static char* +munge( const char* s ) +{ + char* t = strdup( s ); + if ( !t ) + { + return nullptr; + } + + // replace("_"," ") in the Python script + char* p = t; + while ( *p ) + { + if ( ( *p ) == '_' ) + { + *p = ' '; + } + ++p; + } + + return t; +} + +CStringPair::CStringPair( const char* s1 ) + : m_human( s1 ? munge( s1 ) : nullptr ) + , m_key( s1 ? strdup( s1 ) : nullptr ) +{ +} + + +CStringPair::~CStringPair() +{ + free( m_human ); + free( m_key ); +} + +} // namespace Locale +} // namespace CalamaresUtils diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index b9102dff9..f3590c898 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -19,6 +19,7 @@ #ifndef LOCALE_TIMEZONE_H #define LOCALE_TIMEZONE_H +#include #include namespace CalamaresUtils @@ -39,14 +40,20 @@ namespace Locale class CStringPair { public: - explicit CStringPair(const char *s1); - CStringPair(CStringPair&& t); - CStringPair(const CStringPair&) = delete; - ~CStringPair(); + /// @brief An empty pair + CStringPair() {}; + /// @brief Given an identifier, create the pair + explicit CStringPair( const char* s1 ); + CStringPair( CStringPair&& t ); + CStringPair( const CStringPair& ); + virtual ~CStringPair(); -private: - const char* m_human = nullptr; - const char* m_key = nullptr; + /// @brief Give the localized human-readable form + virtual QString tr() const = 0; + +protected: + char* m_human = nullptr; + char* m_key = nullptr; }; /// @brief A pair of strings for timezone regions (e.g. "America") @@ -54,6 +61,9 @@ class TZRegion : public CStringPair { public: using CStringPair::CStringPair; + + // NOTE: context name must match what's used in zone-extractor.py + QString tr() const override { return QObject::tr( m_human, "tz_regions" ); } }; /// @brief A pair of strings for specific timezone names (e.g. "New_York") @@ -61,9 +71,12 @@ class TZZone : public CStringPair { public: using CStringPair::CStringPair; + + // NOTE: context name must match what's used in zone-extractor.py + QString tr() const override { return QObject::tr( m_human, "tz_names" ); } }; -} -} +} // namespace Locale +} // namespace CalamaresUtils #endif // LOCALE_TIMEZONE_H From 71f3614eb771e4c24c8799739915acace5a6d05b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Nov 2019 11:19:30 +0100 Subject: [PATCH 10/57] [libcalamares] Add TimeZone support to build - Add to CMakeLists.txt - Test basic scenarios --- src/libcalamares/CMakeLists.txt | 1 + src/libcalamares/locale/Tests.cpp | 32 +++++++++++++++++++++++++++++++ src/libcalamares/locale/Tests.h | 4 ++++ 3 files changed, 37 insertions(+) diff --git a/src/libcalamares/CMakeLists.txt b/src/libcalamares/CMakeLists.txt index f942dbde1..ffc2e20b6 100644 --- a/src/libcalamares/CMakeLists.txt +++ b/src/libcalamares/CMakeLists.txt @@ -34,6 +34,7 @@ set( libSources locale/Label.cpp locale/LabelModel.cpp locale/Lookup.cpp + locale/TimeZone.cpp locale/TranslatableConfiguration.cpp # Network service diff --git a/src/libcalamares/locale/Tests.cpp b/src/libcalamares/locale/Tests.cpp index a9e5e7399..6acb62eab 100644 --- a/src/libcalamares/locale/Tests.cpp +++ b/src/libcalamares/locale/Tests.cpp @@ -19,6 +19,7 @@ #include "Tests.h" #include "locale/LabelModel.h" +#include "locale/TimeZone.h" #include "locale/TranslatableConfiguration.h" #include "CalamaresVersion.h" @@ -199,3 +200,34 @@ LocaleTests::testTranslatableConfig2() QVERIFY( ts3.isEmpty() ); QCOMPARE( ts3.count(), 1 ); // The empty string } + +void +LocaleTests::testSimpleZones() +{ + using namespace CalamaresUtils::Locale; + + { + TZRegion r; + QVERIFY( r.tr().isEmpty() ); + } + { + TZZone n; + QVERIFY( n.tr().isEmpty() ); + } + { + TZRegion r0( "xAmsterdam" ); + QCOMPARE( r0.tr(), QStringLiteral( "xAmsterdam" ) ); + TZRegion r1( r0 ); + QCOMPARE( r0.tr(), QStringLiteral( "xAmsterdam" ) ); + QCOMPARE( r1.tr(), QStringLiteral( "xAmsterdam" ) ); + TZRegion r2( std::move( r0 ) ); + QCOMPARE( r2.tr(), QStringLiteral( "xAmsterdam" ) ); + QCOMPARE( r0.tr(), QString() ); + } +} + +void +LocaleTests::testComplexZones() +{ + // Stub for now +} diff --git a/src/libcalamares/locale/Tests.h b/src/libcalamares/locale/Tests.h index c6949f3e4..96ee48b0b 100644 --- a/src/libcalamares/locale/Tests.h +++ b/src/libcalamares/locale/Tests.h @@ -36,6 +36,10 @@ private Q_SLOTS: void testTranslatableLanguages(); void testTranslatableConfig1(); void testTranslatableConfig2(); + + // TimeZone testing + void testSimpleZones(); + void testComplexZones(); }; #endif From fc7f49b61061b635cdbfc47e7cd0e3038513d1b4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Nov 2019 12:28:41 +0100 Subject: [PATCH 11/57] [libcalamares] Expand tests for TimeZone translations --- src/libcalamares/locale/Tests.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/libcalamares/locale/Tests.cpp b/src/libcalamares/locale/Tests.cpp index 6acb62eab..106a77b4c 100644 --- a/src/libcalamares/locale/Tests.cpp +++ b/src/libcalamares/locale/Tests.cpp @@ -224,10 +224,31 @@ LocaleTests::testSimpleZones() QCOMPARE( r2.tr(), QStringLiteral( "xAmsterdam" ) ); QCOMPARE( r0.tr(), QString() ); } + { + TZZone r0( nullptr ); + QVERIFY( r0.tr().isEmpty() ); + TZZone r1( r0 ); + QVERIFY( r1.tr().isEmpty() ); + TZZone r2( std::move( r0 ) ); + QVERIFY( r2.tr().isEmpty() ); + } } void LocaleTests::testComplexZones() { - // Stub for now + using namespace CalamaresUtils::Locale; + + { + TZZone r0( "America/New_York" ); + TZZone r1( "America/New York" ); + + QCOMPARE( r0.tr(), r1.tr() ); + QCOMPARE( r0.tr(), QStringLiteral( "America/New York" ) ); + } + { + TZZone r( "zxc,;*_vm" ); + QVERIFY( !r.tr().isEmpty() ); + QCOMPARE( r.tr(), QStringLiteral( "zxc,;* vm" ) ); // Only _ is special + } } From 94fe4d2fdae529c7234e1ba8c74ebce4bd3224f0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 26 Nov 2019 12:30:59 +0100 Subject: [PATCH 12/57] [libcalamares] Avoid weak vtables in string-pair implementation --- src/libcalamares/locale/TimeZone.cpp | 15 +++++++++++++++ src/libcalamares/locale/TimeZone.h | 8 ++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index 900548c72..420344ed7 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -79,5 +79,20 @@ CStringPair::~CStringPair() free( m_key ); } + +QString +TZRegion::tr() const +{ + // NOTE: context name must match what's used in zone-extractor.py + return QObject::tr( m_human, "tz_regions" ); +} + +QString +TZZone::tr() const +{ + // NOTE: context name must match what's used in zone-extractor.py + return QObject::tr( m_human, "tz_names" ); +} + } // namespace Locale } // namespace CalamaresUtils diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index f3590c898..8bba1c45d 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -61,9 +61,7 @@ class TZRegion : public CStringPair { public: using CStringPair::CStringPair; - - // NOTE: context name must match what's used in zone-extractor.py - QString tr() const override { return QObject::tr( m_human, "tz_regions" ); } + QString tr() const override; }; /// @brief A pair of strings for specific timezone names (e.g. "New_York") @@ -71,9 +69,7 @@ class TZZone : public CStringPair { public: using CStringPair::CStringPair; - - // NOTE: context name must match what's used in zone-extractor.py - QString tr() const override { return QObject::tr( m_human, "tz_names" ); } + QString tr() const override; }; } // namespace Locale From 6e1504fafc947aa7ca53e75bafd60577352e05ef Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Dec 2019 14:52:54 +0100 Subject: [PATCH 13/57] [license] Use just one button - replace the text plus toolbutton (which has an ambiguous arrow in it) by a single button with text saying what it will do. --- src/modules/license/LicenseWidget.cpp | 62 ++++++--------------------- src/modules/license/LicenseWidget.h | 6 +-- 2 files changed, 16 insertions(+), 52 deletions(-) diff --git a/src/modules/license/LicenseWidget.cpp b/src/modules/license/LicenseWidget.cpp index a4c1dfaaa..0d4190d57 100644 --- a/src/modules/license/LicenseWidget.cpp +++ b/src/modules/license/LicenseWidget.cpp @@ -27,13 +27,9 @@ #include #include #include -#include +#include #include -static constexpr const auto ArrowOpenExternalLink = Qt::RightArrow; -static constexpr const auto ArrowLocalLicenseIsCollapsed = Qt::UpArrow; -static constexpr const auto ArrowLocalLicenseIsExpanded = Qt::DownArrow; - static QString loadLocalFile( const QUrl& u ) { @@ -56,9 +52,9 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent ) : QWidget( parent ) , m_entry( std::move( entry ) ) , m_label( new QLabel( this ) ) - , m_viewLicenseLabel( new QLabel( this ) ) - , m_expandLicenseButton( nullptr ) + , m_viewLicenseButton( new QPushButton( this ) ) , m_fullText( nullptr ) + , m_isExpanded( m_entry.expandByDefault() ) { QPalette pal( palette() ); pal.setColor( QPalette::Background, palette().window().color().lighter( 108 ) ); @@ -76,46 +72,28 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent ) m_label->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); wiLayout->addWidget( m_label ); - m_viewLicenseLabel->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ); - m_viewLicenseLabel->setAlignment( Qt::AlignVCenter | Qt::AlignRight ); - wiLayout->addWidget( m_viewLicenseLabel ); + m_viewLicenseButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); + wiLayout->addWidget( m_viewLicenseButton ); - m_expandLicenseButton = new QToolButton( this ); - wiLayout->addWidget( m_expandLicenseButton ); if ( m_entry.isLocal() ) { QVBoxLayout* vLayout = new QVBoxLayout; - - m_expandLicenseButton->setArrowType( ArrowLocalLicenseIsCollapsed ); - connect( m_expandLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::expandClicked ); - vLayout->addLayout( wiLayout ); m_fullText = new QLabel( this ); m_fullText->setText( loadLocalFile( m_entry.m_url ) ); - m_fullText->hide(); m_fullText->setStyleSheet( "border-top: 1px solid black; margin-top: 1em; padding-top: 1em;" ); m_fullText->setObjectName( "licenseItemFullText" ); + m_fullText->setHidden( !m_isExpanded ); + vLayout->addWidget( m_fullText ); setLayout( vLayout ); - - if ( m_entry.expandByDefault() ) - { - // Since we started in a collapsed state, toggle it to expand. - // This can only be done once the full text has been added. - expandClicked(); - } + connect( m_viewLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::expandClicked ); } else { - m_expandLicenseButton->setArrowType( ArrowOpenExternalLink ); - connect( m_expandLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::viewClicked ); - - // Normally setOpenExternalLinks( true ) would do, but we need the - // open code anyway for the toolbutton, let's share it. - connect( m_viewLicenseLabel, &QLabel::linkActivated, this, &LicenseWidget::viewClicked ); - setLayout( wiLayout ); // Only the horizontal layout needed + connect( m_viewLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::viewClicked ); } retranslateUi(); @@ -174,19 +152,11 @@ LicenseWidget::retranslateUi() void LicenseWidget::expandClicked() { - if ( m_expandLicenseButton->arrowType() == ArrowLocalLicenseIsExpanded ) - { - m_expandLicenseButton->setArrowType( ArrowLocalLicenseIsCollapsed ); - } - else - { - m_expandLicenseButton->setArrowType( ArrowLocalLicenseIsExpanded ); - } - + m_isExpanded = !m_isExpanded; // Show/hide based on the new arrow direction. if ( m_fullText ) { - m_fullText->setHidden( m_expandLicenseButton->arrowType() == ArrowLocalLicenseIsCollapsed ); + m_fullText->setHidden( !m_isExpanded ); } updateExpandToolTip(); @@ -198,17 +168,11 @@ LicenseWidget::updateExpandToolTip() { if ( m_entry.isLocal() ) { - const bool isNowCollapsed = m_expandLicenseButton->arrowType() == ArrowLocalLicenseIsCollapsed; - - m_expandLicenseButton->setToolTip( isNowCollapsed ? tr( "Shows the complete license text" ) - : tr( "Hide license text" ) ); - m_viewLicenseLabel->setText( isNowCollapsed ? tr( "Show license agreement" ) : tr( "Hide license agreement" ) ); + m_viewLicenseButton->setText( m_isExpanded ? tr( "Hide license text" ) : tr( "Show the license text" ) ); } else { - m_expandLicenseButton->setToolTip( tr( "Opens the license agreement in a browser window." ) ); - m_viewLicenseLabel->setText( - tr( "View license agreement" ).arg( m_entry.m_url.toString() ) ); + m_viewLicenseButton->setText( tr( "Open license agreement in browser." ) ); } } diff --git a/src/modules/license/LicenseWidget.h b/src/modules/license/LicenseWidget.h index e11d7a746..600516d6d 100644 --- a/src/modules/license/LicenseWidget.h +++ b/src/modules/license/LicenseWidget.h @@ -27,7 +27,7 @@ #include #include -class QToolButton; +class QPushButton; class LicenseWidget : public QWidget { @@ -44,8 +44,8 @@ private: LicenseEntry m_entry; QLabel* m_label; - QLabel* m_viewLicenseLabel; - QToolButton* m_expandLicenseButton; + QPushButton* m_viewLicenseButton; QLabel* m_fullText; + bool m_isExpanded; }; #endif From 7330afd96ad90d4cc0999aca7a220ed5aa9bb614 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Dec 2019 16:49:43 +0100 Subject: [PATCH 14/57] [license] Massage display of buttons - try to keep them the same height - show the URL that will be opened --- src/modules/license/LicenseWidget.cpp | 48 +++++++++++++++++---------- src/modules/license/LicenseWidget.h | 3 +- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/src/modules/license/LicenseWidget.cpp b/src/modules/license/LicenseWidget.cpp index 0d4190d57..0d6ef76d6 100644 --- a/src/modules/license/LicenseWidget.cpp +++ b/src/modules/license/LicenseWidget.cpp @@ -53,7 +53,7 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent ) , m_entry( std::move( entry ) ) , m_label( new QLabel( this ) ) , m_viewLicenseButton( new QPushButton( this ) ) - , m_fullText( nullptr ) + , m_licenceTextLabel( new QLabel( this ) ) , m_isExpanded( m_entry.expandByDefault() ) { QPalette pal( palette() ); @@ -69,33 +69,40 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent ) QHBoxLayout* wiLayout = new QHBoxLayout; m_label->setWordWrap( true ); - m_label->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); + m_label->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); wiLayout->addWidget( m_label ); - m_viewLicenseButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum ); + wiLayout->addSpacing( 1 ); + m_viewLicenseButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); wiLayout->addWidget( m_viewLicenseButton ); + QVBoxLayout* vLayout = new QVBoxLayout; + vLayout->addLayout( wiLayout ); + m_licenceTextLabel->setStyleSheet( "border-top: 1px solid black; margin-top: 0px; padding-top: 1em;" ); + m_licenceTextLabel->setObjectName( "licenseItemFullText" ); + if ( m_entry.isLocal() ) { - QVBoxLayout* vLayout = new QVBoxLayout; - vLayout->addLayout( wiLayout ); - m_fullText = new QLabel( this ); - m_fullText->setText( loadLocalFile( m_entry.m_url ) ); - m_fullText->setStyleSheet( "border-top: 1px solid black; margin-top: 1em; padding-top: 1em;" ); - m_fullText->setObjectName( "licenseItemFullText" ); - - m_fullText->setHidden( !m_isExpanded ); - - vLayout->addWidget( m_fullText ); - setLayout( vLayout ); + m_fullTextContents = loadLocalFile( m_entry.m_url ); + if ( m_isExpanded ) + { + m_licenceTextLabel->setText( m_fullTextContents ); + } + else + { + m_licenceTextLabel->setText( tr( "URL: %1" ).arg( m_entry.m_url.toDisplayString() ) ); + } connect( m_viewLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::expandClicked ); } else { - setLayout( wiLayout ); // Only the horizontal layout needed + m_licenceTextLabel->setText( tr( "URL: %1" ).arg( m_entry.m_url.toDisplayString() ) ); connect( m_viewLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::viewClicked ); } + vLayout->addWidget( m_licenceTextLabel ); + setLayout( vLayout ); + retranslateUi(); } @@ -154,9 +161,16 @@ LicenseWidget::expandClicked() { m_isExpanded = !m_isExpanded; // Show/hide based on the new arrow direction. - if ( m_fullText ) + if ( !m_fullTextContents.isEmpty() ) { - m_fullText->setHidden( !m_isExpanded ); + if ( m_isExpanded ) + { + m_licenceTextLabel->setText( m_fullTextContents ); + } + else + { + m_licenceTextLabel->setText( tr( "URL: %1" ).arg( m_entry.m_url.toDisplayString() ) ); + } } updateExpandToolTip(); diff --git a/src/modules/license/LicenseWidget.h b/src/modules/license/LicenseWidget.h index 600516d6d..ffbb9d3c3 100644 --- a/src/modules/license/LicenseWidget.h +++ b/src/modules/license/LicenseWidget.h @@ -45,7 +45,8 @@ private: LicenseEntry m_entry; QLabel* m_label; QPushButton* m_viewLicenseButton; - QLabel* m_fullText; + QLabel* m_licenceTextLabel; + QString m_fullTextContents; bool m_isExpanded; }; #endif From 8a912e6ca1ead0b47c70ed3d9a34356151a05aaa Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Dec 2019 17:08:35 +0100 Subject: [PATCH 15/57] [license] Fix the height of each item - needs a qwidget to put the top-items (license name, button) in - fixes issue where the gap between the button and the hrule would change depending on what is expanded --- src/modules/license/LicenseWidget.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/modules/license/LicenseWidget.cpp b/src/modules/license/LicenseWidget.cpp index 0d6ef76d6..4fb338d46 100644 --- a/src/modules/license/LicenseWidget.cpp +++ b/src/modules/license/LicenseWidget.cpp @@ -66,18 +66,21 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent ) setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ); setContentsMargins( 4, 4, 4, 4 ); + QVBoxLayout* vLayout = new QVBoxLayout; + QWidget* topPart = new QWidget( this ); + vLayout->addWidget( topPart ); + QHBoxLayout* wiLayout = new QHBoxLayout; + topPart->setLayout( wiLayout ); m_label->setWordWrap( true ); m_label->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); wiLayout->addWidget( m_label ); - wiLayout->addSpacing( 1 ); - m_viewLicenseButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); + wiLayout->addSpacing( 10 ); + m_viewLicenseButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Fixed ); wiLayout->addWidget( m_viewLicenseButton ); - QVBoxLayout* vLayout = new QVBoxLayout; - vLayout->addLayout( wiLayout ); m_licenceTextLabel->setStyleSheet( "border-top: 1px solid black; margin-top: 0px; padding-top: 1em;" ); m_licenceTextLabel->setObjectName( "licenseItemFullText" ); From c22022056369cee5c91804684c55d069420ca154 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Dec 2019 17:14:35 +0100 Subject: [PATCH 16/57] [license] Give stylesheets meaningful names --- src/modules/license/LicensePage.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/modules/license/LicensePage.cpp b/src/modules/license/LicensePage.cpp index fc90d843c..8f6f700ca 100644 --- a/src/modules/license/LicensePage.cpp +++ b/src/modules/license/LicensePage.cpp @@ -44,6 +44,12 @@ #include +static const char mustAccept[] = "#acceptFrame { border: 1px solid red;" + "background-color: #fff6f6;" + "border-radius: 4px;" + "padding: 2px; }"; +static const char okAccept[] = "#acceptFrame { padding: 3px }"; + const NamedEnumTable< LicenseEntry::Type >& LicenseEntry::typeNames() { @@ -107,10 +113,7 @@ LicensePage::LicensePage( QWidget* parent ) ui->additionalText->setWordWrap( true ); ui->acceptFrame->setFrameStyle( QFrame::NoFrame | QFrame::Plain ); - ui->acceptFrame->setStyleSheet( "#acceptFrame { border: 1px solid red;" - "background-color: #fff6f6;" - "border-radius: 4px;" - "padding: 2px; }" ); + ui->acceptFrame->setStyleSheet( mustAccept ); ui->acceptFrame->layout()->setMargin( CalamaresUtils::defaultFontHeight() / 2 ); updateGlobalStorage( false ); // Have not agreed yet @@ -195,14 +198,11 @@ LicensePage::checkAcceptance( bool checked ) m_isNextEnabled = checked || m_allLicensesOptional; if ( !m_isNextEnabled ) { - ui->acceptFrame->setStyleSheet( "#acceptFrame { border: 1px solid red;" - "background-color: #fff8f8;" - "border-radius: 4px;" - "padding: 2px; }" ); + ui->acceptFrame->setStyleSheet( mustAccept ); } else { - ui->acceptFrame->setStyleSheet( "#acceptFrame { padding: 3px }" ); + ui->acceptFrame->setStyleSheet( okAccept ); } emit nextStatusChanged( m_isNextEnabled ); } From 59ea0417fc693adb45c4a4d72dc46a467f834f64 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Dec 2019 17:25:07 +0100 Subject: [PATCH 17/57] [license] Move a less-useful message to tooltip - the message about setup continuing can be a tooltip --- src/modules/license/LicensePage.cpp | 10 +++++----- src/modules/license/LicensePage.ui | 20 ++------------------ 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/src/modules/license/LicensePage.cpp b/src/modules/license/LicensePage.cpp index 8f6f700ca..526820920 100644 --- a/src/modules/license/LicensePage.cpp +++ b/src/modules/license/LicensePage.cpp @@ -110,8 +110,6 @@ LicensePage::LicensePage( QWidget* parent ) ui->mainText->setWordWrap( true ); ui->mainText->setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ); - ui->additionalText->setWordWrap( true ); - ui->acceptFrame->setFrameStyle( QFrame::NoFrame | QFrame::Plain ); ui->acceptFrame->setStyleSheet( mustAccept ); ui->acceptFrame->layout()->setMargin( CalamaresUtils::defaultFontHeight() / 2 ); @@ -157,7 +155,8 @@ LicensePage::retranslate() ui->mainText->setText( tr( "This setup procedure will install proprietary " "software that is subject to licensing terms." ) + br + review ); - ui->additionalText->setText( tr( "If you do not agree with the terms, the setup procedure cannot continue." ) ); + QString mustAcceptText( tr( "If you do not agree with the terms, the setup procedure cannot continue." ) ); + ui->acceptCheckBox->setToolTip( mustAcceptText ); } else { @@ -166,8 +165,9 @@ LicensePage::retranslate() "in order to provide additional features and enhance the user " "experience." ) + br + review ); - ui->additionalText->setText( tr( "If you do not agree with the terms, proprietary software will not " - "be installed, and open source alternatives will be used instead." ) ); + QString okAcceptText( tr( "If you do not agree with the terms, proprietary software will not " + "be installed, and open source alternatives will be used instead." ) ); + ui->acceptCheckBox->setToolTip( okAcceptText ); } ui->retranslateUi( this ); diff --git a/src/modules/license/LicensePage.ui b/src/modules/license/LicensePage.ui index a81fae2b8..b5936d5de 100644 --- a/src/modules/license/LicensePage.ui +++ b/src/modules/license/LicensePage.ui @@ -15,7 +15,7 @@ - + @@ -87,7 +87,7 @@ 0 0 765 - 81 + 89 @@ -107,22 +107,6 @@ - - - - - 0 - 0 - - - - - - - <additionalText> - - - From ac1c0d97d2027507517c6e49704253d3b419ca7e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Dec 2019 17:34:46 +0100 Subject: [PATCH 18/57] [license] Prevent single item from expanding - the last item would expand vertically to fill the scroll area; add a spacer that pushes against it --- src/modules/license/LicensePage.cpp | 1 + src/modules/license/LicenseWidget.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/src/modules/license/LicensePage.cpp b/src/modules/license/LicensePage.cpp index 526820920..237e8d0dc 100644 --- a/src/modules/license/LicensePage.cpp +++ b/src/modules/license/LicensePage.cpp @@ -137,6 +137,7 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList ) m_entries.append( w ); m_allLicensesOptional &= !entry.isRequired(); } + ui->licenseEntriesLayout->addSpacerItem( new QSpacerItem( 10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); ui->acceptCheckBox->setChecked( false ); checkAcceptance( false ); diff --git a/src/modules/license/LicenseWidget.cpp b/src/modules/license/LicenseWidget.cpp index 4fb338d46..b78972c00 100644 --- a/src/modules/license/LicenseWidget.cpp +++ b/src/modules/license/LicenseWidget.cpp @@ -68,6 +68,7 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent ) QVBoxLayout* vLayout = new QVBoxLayout; QWidget* topPart = new QWidget( this ); + topPart->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); vLayout->addWidget( topPart ); QHBoxLayout* wiLayout = new QHBoxLayout; @@ -102,6 +103,7 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent ) m_licenceTextLabel->setText( tr( "URL: %1" ).arg( m_entry.m_url.toDisplayString() ) ); connect( m_viewLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::viewClicked ); } + m_licenceTextLabel->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); vLayout->addWidget( m_licenceTextLabel ); setLayout( vLayout ); From 7d88b6d0cdf1e6cda60f308162917b0cdcd7e54d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Dec 2019 20:47:32 +0100 Subject: [PATCH 19/57] [license] Show filenames as filenames - Use File: to display filenames, rather than URL: plus a file:-scheme - Document the change in CHANGES --- CHANGES | 4 ++- src/modules/license/LicenseWidget.cpp | 36 +++++++++++++++------------ src/modules/license/LicenseWidget.h | 1 + 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/CHANGES b/CHANGES index 1f721faca..b82024769 100644 --- a/CHANGES +++ b/CHANGES @@ -12,7 +12,9 @@ This release contains contributions from (alphabetically by first name): - No changes to core functionality. ## Modules ## - - No changes to modules. + - The *license* module has seen a significant change to its looks. + Actions are now labeled more clearly, and the URL (or filename) + for each license is displayed. # 3.2.17.1 (2019-12-02) # diff --git a/src/modules/license/LicenseWidget.cpp b/src/modules/license/LicenseWidget.cpp index b78972c00..09d2230e5 100644 --- a/src/modules/license/LicenseWidget.cpp +++ b/src/modules/license/LicenseWidget.cpp @@ -88,14 +88,7 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent ) if ( m_entry.isLocal() ) { m_fullTextContents = loadLocalFile( m_entry.m_url ); - if ( m_isExpanded ) - { - m_licenceTextLabel->setText( m_fullTextContents ); - } - else - { - m_licenceTextLabel->setText( tr( "URL: %1" ).arg( m_entry.m_url.toDisplayString() ) ); - } + showLocalLicenseText(); connect( m_viewLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::expandClicked ); } else @@ -161,6 +154,24 @@ LicenseWidget::retranslateUi() updateExpandToolTip(); } +void +LicenseWidget::showLocalLicenseText() +{ + if ( m_isExpanded ) + { + m_licenceTextLabel->setText( m_fullTextContents ); + } + else + { + QString fileName = m_entry.m_url.toDisplayString(); + if ( fileName.startsWith( "file:" ) ) + { + fileName = fileName.remove( 0, 5 ); + } + m_licenceTextLabel->setText( tr( "File: %1" ).arg( fileName ) ); + } +} + void LicenseWidget::expandClicked() { @@ -168,14 +179,7 @@ LicenseWidget::expandClicked() // Show/hide based on the new arrow direction. if ( !m_fullTextContents.isEmpty() ) { - if ( m_isExpanded ) - { - m_licenceTextLabel->setText( m_fullTextContents ); - } - else - { - m_licenceTextLabel->setText( tr( "URL: %1" ).arg( m_entry.m_url.toDisplayString() ) ); - } + showLocalLicenseText(); } updateExpandToolTip(); diff --git a/src/modules/license/LicenseWidget.h b/src/modules/license/LicenseWidget.h index ffbb9d3c3..a386ae353 100644 --- a/src/modules/license/LicenseWidget.h +++ b/src/modules/license/LicenseWidget.h @@ -38,6 +38,7 @@ public: void retranslateUi(); private: + void showLocalLicenseText(); // Display (or hide) the local license text void expandClicked(); // "slot" to toggle show/hide of local license text void viewClicked(); // "slot" to open link void updateExpandToolTip(); From b2c2255f6a7c73e796397ecfa9e5886e8c6e9afb Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Dec 2019 21:46:10 +0100 Subject: [PATCH 20/57] [libcalamares] Add a model of timezone regions --- src/libcalamares/locale/TimeZone.cpp | 86 ++++++++++++++++++++++++++++ src/libcalamares/locale/TimeZone.h | 23 ++++++++ 2 files changed, 109 insertions(+) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index 420344ed7..75d1e8e38 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -18,8 +18,14 @@ #include "TimeZone.h" +#include +#include +#include + #include +static const char TZ_DATA_FILE[] = "/usr/share/zoneinfo/zone.tab"; + namespace CalamaresUtils { namespace Locale @@ -27,6 +33,8 @@ namespace Locale CStringPair::CStringPair( CStringPair&& t ) + : m_human( nullptr ) + , m_key( nullptr ) { // My pointers are initialized to nullptr std::swap( m_human, t.m_human ); @@ -94,5 +102,83 @@ TZZone::tr() const return QObject::tr( m_human, "tz_names" ); } +TZRegionModel::TZRegionModel() +{ + + QFile file( TZ_DATA_FILE ); + if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) + { + return; + } + + QStringList regions; + + QTextStream in( &file ); + while ( !in.atEnd() ) + { + QString line = in.readLine().trimmed().split( '#', QString::KeepEmptyParts ).first().trimmed(); + if ( line.isEmpty() ) + { + continue; + } + + QStringList list = line.split( QRegExp( "[\t ]" ), QString::SkipEmptyParts ); + if ( list.size() < 3 ) + { + continue; + } + + QStringList timezoneParts = list.at( 2 ).split( '/', QString::SkipEmptyParts ); + if ( timezoneParts.size() < 2 ) + { + continue; + } + + QString region = timezoneParts.first().trimmed(); + ; + if ( region.isEmpty() ) + { + continue; + } + + if ( !regions.contains( region ) ) + { + regions.append( region ); + } + } + + m_regions.reserve( regions.length() ); + for ( int i = 0; i < regions.length(); ++i ) + { + m_regions.append( TZRegion( regions[ i ].toUtf8().data() ) ); + } +} + +TZRegionModel::~TZRegionModel() {} + +int +TZRegionModel::rowCount( const QModelIndex& parent ) const +{ + return m_regions.count(); +} + +QVariant +TZRegionModel::data( const QModelIndex& index, int role ) const +{ + if ( role != LabelRole ) + { + return QVariant(); + } + + if ( !index.isValid() ) + { + return QVariant(); + } + + const TZRegion& region = m_regions.at( index.row() ); + return region.tr(); +} + + } // namespace Locale } // namespace CalamaresUtils diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 8bba1c45d..c08aa6499 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -19,6 +19,9 @@ #ifndef LOCALE_TIMEZONE_H #define LOCALE_TIMEZONE_H +#include "DllMacro.h" + +#include #include #include @@ -72,6 +75,26 @@ public: QString tr() const override; }; +class DLLEXPORT TZRegionModel : public QAbstractListModel +{ +public: + enum + { + LabelRole = Qt::DisplayRole + }; + + /// @brief Create from the zone.tab file + TZRegionModel(); + virtual ~TZRegionModel() override; + + int rowCount( const QModelIndex& parent ) const override; + + QVariant data( const QModelIndex& index, int role ) const override; + +private: + QVector< TZRegion > m_regions; +}; + } // namespace Locale } // namespace CalamaresUtils From b29b89579e3ed49c90cb820fd20b8e386b4438f7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Dec 2019 15:55:04 -0500 Subject: [PATCH 21/57] [libcalamares] Present TZ regions in consistent order --- src/libcalamares/locale/TimeZone.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index 75d1e8e38..9a8c605a1 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -146,6 +146,7 @@ TZRegionModel::TZRegionModel() regions.append( region ); } } + regions.sort(); m_regions.reserve( regions.length() ); for ( int i = 0; i < regions.length(); ++i ) From 1d17cf5c778ba497b906102efdb423dbf9c27279 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Dec 2019 17:20:46 -0400 Subject: [PATCH 22/57] [libcalamares] Accessors for key and complete region data --- src/libcalamares/locale/TimeZone.cpp | 9 +++++++++ src/libcalamares/locale/TimeZone.h | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index 9a8c605a1..eb82bb3fa 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -180,6 +180,15 @@ TZRegionModel::data( const QModelIndex& index, int role ) const return region.tr(); } +const TZRegion& +TZRegionModel::region( int index ) const +{ + if ( ( index < 0 ) || ( index >= m_regions.count() ) ) + { + index = 0; + } + return m_regions[ index ]; +} } // namespace Locale } // namespace CalamaresUtils diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index c08aa6499..98d87b1b4 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -54,6 +54,8 @@ public: /// @brief Give the localized human-readable form virtual QString tr() const = 0; + const char* key() const { return m_key; } + protected: char* m_human = nullptr; char* m_key = nullptr; @@ -91,6 +93,8 @@ public: QVariant data( const QModelIndex& index, int role ) const override; + const TZRegion& region( int index ) const; + private: QVector< TZRegion > m_regions; }; From 97235e9b3d657f5e932b317209dff7984ea87c8f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 10:11:08 +0100 Subject: [PATCH 23/57] [libcalamares] Switch CStringPair key to QString - the key is used in various places as a key for Qt data structures, so it's more convenient to have QString than a bare char* --- src/libcalamares/locale/TimeZone.cpp | 7 +++---- src/libcalamares/locale/TimeZone.h | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index eb82bb3fa..e04423f8a 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -34,7 +34,7 @@ namespace Locale CStringPair::CStringPair( CStringPair&& t ) : m_human( nullptr ) - , m_key( nullptr ) + , m_key() { // My pointers are initialized to nullptr std::swap( m_human, t.m_human ); @@ -43,7 +43,7 @@ CStringPair::CStringPair( CStringPair&& t ) CStringPair::CStringPair( const CStringPair& t ) : m_human( t.m_human ? strdup( t.m_human ) : nullptr ) - , m_key( t.m_key ? strdup( t.m_key ) : nullptr ) + , m_key( t.m_key ) { } @@ -76,7 +76,7 @@ munge( const char* s ) CStringPair::CStringPair( const char* s1 ) : m_human( s1 ? munge( s1 ) : nullptr ) - , m_key( s1 ? strdup( s1 ) : nullptr ) + , m_key( s1 ? QString( s1 ) : QString() ) { } @@ -84,7 +84,6 @@ CStringPair::CStringPair( const char* s1 ) CStringPair::~CStringPair() { free( m_human ); - free( m_key ); } diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 98d87b1b4..844e94a47 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -54,11 +54,11 @@ public: /// @brief Give the localized human-readable form virtual QString tr() const = 0; - const char* key() const { return m_key; } + QString key() const { return m_key; } protected: char* m_human = nullptr; - char* m_key = nullptr; + QString m_key; }; /// @brief A pair of strings for timezone regions (e.g. "America") From 2625bb18df7b0a6a6edeb07220dcec71551a2a1a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 11:27:02 +0200 Subject: [PATCH 24/57] [libcalamares] TZRegionModel gets a data role --- src/libcalamares/locale/TimeZone.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index e04423f8a..97795ab84 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -165,7 +165,7 @@ TZRegionModel::rowCount( const QModelIndex& parent ) const QVariant TZRegionModel::data( const QModelIndex& index, int role ) const { - if ( role != LabelRole ) + if ( ( role != LabelRole ) && ( role != Qt::UserRole ) ) { return QVariant(); } @@ -176,7 +176,7 @@ TZRegionModel::data( const QModelIndex& index, int role ) const } const TZRegion& region = m_regions.at( index.row() ); - return region.tr(); + return role == LabelRole ? region.tr() : region.key(); } const TZRegion& From afb5430c42b127542c6d499c8454dc9041fb04e4 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 11:30:48 +0200 Subject: [PATCH 25/57] [locale] Use TZRegionModel - instead of populating combo box with texts, use the model read in from zone.tab - this **partly** deprecates the LocaleGlobal stuff --- src/modules/locale/LocalePage.cpp | 20 +++++++------------- src/modules/locale/LocalePage.h | 5 +++++ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index fc715e3f3..402351acf 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -28,6 +28,7 @@ #include "Settings.h" #include "locale/Label.h" +#include "locale/TimeZone.h" #include "utils/CalamaresUtilsGui.h" #include "utils/Logger.h" #include "utils/Retranslator.h" @@ -143,8 +144,8 @@ containsLocation( const QList< LocaleGlobal::Location >& locations, const QStrin void LocalePage::init( const QString& initialRegion, const QString& initialZone, const QString& localeGenPath ) { - m_regionCombo->blockSignals( true ); - m_zoneCombo->blockSignals( true ); + m_regionModel.reset( new CalamaresUtils::Locale::TZRegionModel ); + m_regionCombo->setModel( m_regionModel.get() ); // Setup locations QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations(); @@ -152,14 +153,6 @@ LocalePage::init( const QString& initialRegion, const QString& initialZone, cons QStringList keys = regions.keys(); keys.sort(); - foreach ( const QString& key, keys ) - { - m_regionCombo->addItem( LocaleGlobal::Location::pretty( key ), key ); - } - - m_regionCombo->blockSignals( false ); - m_zoneCombo->blockSignals( false ); - m_regionCombo->currentIndexChanged( m_regionCombo->currentIndex() ); if ( keys.contains( initialRegion ) && containsLocation( regions.value( initialRegion ), initialZone ) ) @@ -402,13 +395,14 @@ LocalePage::updateGlobalStorage() updateLocaleLabels(); } - void LocalePage::regionChanged( int currentIndex ) { Q_UNUSED( currentIndex ) + QString selectedRegion = m_regionCombo->currentData().toString(); + QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations(); - if ( !regions.contains( m_regionCombo->currentData().toString() ) ) + if ( !regions.contains( selectedRegion ) ) { return; } @@ -417,7 +411,7 @@ LocalePage::regionChanged( int currentIndex ) m_zoneCombo->clear(); - const QList< LocaleGlobal::Location > zones = regions.value( m_regionCombo->currentData().toString() ); + const QList< LocaleGlobal::Location > zones = regions.value( selectedRegion ); for ( const LocaleGlobal::Location& zone : zones ) { m_zoneCombo->addItem( LocaleGlobal::Location::pretty( zone.zone ), zone.zone ); diff --git a/src/modules/locale/LocalePage.h b/src/modules/locale/LocalePage.h index 73097252b..f4d352ccf 100644 --- a/src/modules/locale/LocalePage.h +++ b/src/modules/locale/LocalePage.h @@ -24,9 +24,12 @@ #include "timezonewidget/localeglobal.h" #include "Job.h" +#include "locale/TimeZone.h" #include +#include + class QComboBox; class QLabel; class QPushButton; @@ -71,6 +74,8 @@ private: void changeLocale(); void changeFormats(); + std::unique_ptr< CalamaresUtils::Locale::TZRegionModel > m_regionModel; + TimeZoneWidget* m_tzWidget; QComboBox* m_regionCombo; QComboBox* m_zoneCombo; From 01bba7b4668954ffdbb328da961e72bd21887c20 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Dec 2019 23:36:05 -1100 Subject: [PATCH 26/57] [libcalamares] Make explicit when a model comes from a file --- src/libcalamares/locale/TimeZone.cpp | 24 ++++++++++++++++++------ src/libcalamares/locale/TimeZone.h | 9 ++++++++- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index 97795ab84..86ecd4097 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -101,13 +101,23 @@ TZZone::tr() const return QObject::tr( m_human, "tz_names" ); } -TZRegionModel::TZRegionModel() -{ +TZRegionModel::TZRegionModel() {} - QFile file( TZ_DATA_FILE ); +std::shared_ptr< TZRegionModel > +TZRegionModel::fromZoneTab() +{ + return TZRegionModel::fromFile( TZ_DATA_FILE ); +} + +std::shared_ptr< TZRegionModel > +TZRegionModel::fromFile( const char* fileName ) +{ + auto model = std::make_shared< TZRegionModel >(); + + QFile file( fileName ); if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) { - return; + return model; } QStringList regions; @@ -147,11 +157,13 @@ TZRegionModel::TZRegionModel() } regions.sort(); - m_regions.reserve( regions.length() ); + model->m_regions.reserve( regions.length() ); for ( int i = 0; i < regions.length(); ++i ) { - m_regions.append( TZRegion( regions[ i ].toUtf8().data() ) ); + model->m_regions.append( TZRegion( regions[ i ].toUtf8().data() ) ); } + + return model; } TZRegionModel::~TZRegionModel() {} diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 844e94a47..ef3ba2477 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -25,6 +25,8 @@ #include #include +#include + namespace CalamaresUtils { namespace Locale @@ -85,10 +87,15 @@ public: LabelRole = Qt::DisplayRole }; - /// @brief Create from the zone.tab file + /// @brief Create empty model (useless) TZRegionModel(); virtual ~TZRegionModel() override; + /// @brief Create model from a zone.tab-like file + static std::shared_ptr< TZRegionModel > fromFile( const char* fileName ); + /// @brief Calls fromFile with the standard zone.tab name + static std::shared_ptr< TZRegionModel > fromZoneTab(); + int rowCount( const QModelIndex& parent ) const override; QVariant data( const QModelIndex& index, int role ) const override; From 9f06903115ab46660154a3ce286320903fecc3fc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 9 Dec 2019 23:36:32 -1100 Subject: [PATCH 27/57] [local] Chase API change in TZRegionModel --- src/modules/locale/LocalePage.cpp | 2 +- src/modules/locale/LocalePage.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index 402351acf..5dfad3516 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -144,7 +144,7 @@ containsLocation( const QList< LocaleGlobal::Location >& locations, const QStrin void LocalePage::init( const QString& initialRegion, const QString& initialZone, const QString& localeGenPath ) { - m_regionModel.reset( new CalamaresUtils::Locale::TZRegionModel ); + m_regionModel = CalamaresUtils::Locale::TZRegionModel::fromZoneTab(); m_regionCombo->setModel( m_regionModel.get() ); // Setup locations diff --git a/src/modules/locale/LocalePage.h b/src/modules/locale/LocalePage.h index f4d352ccf..e918076d9 100644 --- a/src/modules/locale/LocalePage.h +++ b/src/modules/locale/LocalePage.h @@ -74,7 +74,7 @@ private: void changeLocale(); void changeFormats(); - std::unique_ptr< CalamaresUtils::Locale::TZRegionModel > m_regionModel; + std::shared_ptr< CalamaresUtils::Locale::TZRegionModel > m_regionModel; TimeZoneWidget* m_tzWidget; QComboBox* m_regionCombo; From 9a5e614172ccdbe213ab3a13bb9f5d9375289bbd Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 17:24:33 +0630 Subject: [PATCH 28/57] [libcalamares] Build the TZRegion list in one pass - read the file and create the regions on-the-fly, then sort the resulting list (instead of building a string list and then building the regions afterwards) --- src/libcalamares/locale/TimeZone.cpp | 23 ++++++++++++----------- src/libcalamares/locale/TimeZone.h | 6 ++++-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index 86ecd4097..c03afd833 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -120,6 +120,7 @@ TZRegionModel::fromFile( const char* fileName ) return model; } + model->m_regions.reserve( 12 ); // There's 10 in the file right now QStringList regions; QTextStream in( &file ); @@ -153,20 +154,20 @@ TZRegionModel::fromFile( const char* fileName ) if ( !regions.contains( region ) ) { regions.append( region ); + model->m_regions.append( new TZRegion( region.toUtf8().data() ) ); } } - regions.sort(); - - model->m_regions.reserve( regions.length() ); - for ( int i = 0; i < regions.length(); ++i ) - { - model->m_regions.append( TZRegion( regions[ i ].toUtf8().data() ) ); - } + std::sort( model->m_regions.begin(), model->m_regions.end(), []( const TZRegion* l, const TZRegion* r ) { + return *l < *r; + } ); return model; } -TZRegionModel::~TZRegionModel() {} +TZRegionModel::~TZRegionModel() +{ + qDeleteAll( m_regions ); +} int TZRegionModel::rowCount( const QModelIndex& parent ) const @@ -187,11 +188,11 @@ TZRegionModel::data( const QModelIndex& index, int role ) const return QVariant(); } - const TZRegion& region = m_regions.at( index.row() ); - return role == LabelRole ? region.tr() : region.key(); + const TZRegion* region = m_regions.at( index.row() ); + return role == LabelRole ? region->tr() : region->key(); } -const TZRegion& +const TZRegion* TZRegionModel::region( int index ) const { if ( ( index < 0 ) || ( index >= m_regions.count() ) ) diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index ef3ba2477..db54292c9 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -69,6 +69,8 @@ class TZRegion : public CStringPair public: using CStringPair::CStringPair; QString tr() const override; + + bool operator<( const TZRegion& other ) const { return m_key < other.m_key; } }; /// @brief A pair of strings for specific timezone names (e.g. "New_York") @@ -100,10 +102,10 @@ public: QVariant data( const QModelIndex& index, int role ) const override; - const TZRegion& region( int index ) const; + const TZRegion* region( int index ) const; private: - QVector< TZRegion > m_regions; + QList< TZRegion* > m_regions; }; } // namespace Locale From da277fa7baec275ce95247f400d680971f9f2942 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 17:42:32 +0630 Subject: [PATCH 29/57] [libcalamares] Drop superfluous enum --- src/libcalamares/locale/TimeZone.cpp | 4 ++-- src/libcalamares/locale/TimeZone.h | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index c03afd833..8144a407b 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -178,7 +178,7 @@ TZRegionModel::rowCount( const QModelIndex& parent ) const QVariant TZRegionModel::data( const QModelIndex& index, int role ) const { - if ( ( role != LabelRole ) && ( role != Qt::UserRole ) ) + if ( ( role != Qt::DisplayRole ) && ( role != Qt::UserRole ) ) { return QVariant(); } @@ -189,7 +189,7 @@ TZRegionModel::data( const QModelIndex& index, int role ) const } const TZRegion* region = m_regions.at( index.row() ); - return role == LabelRole ? region->tr() : region->key(); + return role == Qt::DisplayRole ? region->tr() : region->key(); } const TZRegion* diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index db54292c9..4311997a4 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -84,11 +84,6 @@ public: class DLLEXPORT TZRegionModel : public QAbstractListModel { public: - enum - { - LabelRole = Qt::DisplayRole - }; - /// @brief Create empty model (useless) TZRegionModel(); virtual ~TZRegionModel() override; From f4509f3380ed67ce2ea0157676dafa7e533bb17d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 10:45:56 -0100 Subject: [PATCH 30/57] [libcalamares] Move loading to TZRegion - don't make the model load files, provide convenience functions for loading in the value classes - create model from lists of value pointers --- src/libcalamares/locale/TimeZone.cpp | 42 +++++++++++++++------------- src/libcalamares/locale/TimeZone.h | 32 ++++++++++++++++----- src/modules/locale/LocalePage.cpp | 8 ++++-- src/modules/locale/LocalePage.h | 3 +- 4 files changed, 55 insertions(+), 30 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index 8144a407b..784d77b9c 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -94,25 +94,21 @@ TZRegion::tr() const return QObject::tr( m_human, "tz_regions" ); } -QString -TZZone::tr() const +TZRegion::~TZRegion() { - // NOTE: context name must match what's used in zone-extractor.py - return QObject::tr( m_human, "tz_names" ); + qDeleteAll( m_zones ); } -TZRegionModel::TZRegionModel() {} - -std::shared_ptr< TZRegionModel > -TZRegionModel::fromZoneTab() +TZRegionList +TZRegion::fromZoneTab() { - return TZRegionModel::fromFile( TZ_DATA_FILE ); + return TZRegion::fromFile( TZ_DATA_FILE ); } -std::shared_ptr< TZRegionModel > -TZRegionModel::fromFile( const char* fileName ) +TZRegionList +TZRegion::fromFile( const char* fileName ) { - auto model = std::make_shared< TZRegionModel >(); + TZRegionList model; QFile file( fileName ); if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) @@ -120,7 +116,6 @@ TZRegionModel::fromFile( const char* fileName ) return model; } - model->m_regions.reserve( 12 ); // There's 10 in the file right now QStringList regions; QTextStream in( &file ); @@ -154,21 +149,28 @@ TZRegionModel::fromFile( const char* fileName ) if ( !regions.contains( region ) ) { regions.append( region ); - model->m_regions.append( new TZRegion( region.toUtf8().data() ) ); + model.append( new TZRegion( region.toUtf8().data() ) ); } } - std::sort( model->m_regions.begin(), model->m_regions.end(), []( const TZRegion* l, const TZRegion* r ) { - return *l < *r; - } ); + std::sort( model.begin(), model.end(), []( const TZRegion* l, const TZRegion* r ) { return *l < *r; } ); return model; } -TZRegionModel::~TZRegionModel() +QString +TZZone::tr() const { - qDeleteAll( m_regions ); + // NOTE: context name must match what's used in zone-extractor.py + return QObject::tr( m_human, "tz_names" ); } +TZRegionModel::TZRegionModel( TZRegionList l ) + : m_regions( l ) +{ +} + +TZRegionModel::~TZRegionModel() {} + int TZRegionModel::rowCount( const QModelIndex& parent ) const { @@ -197,7 +199,7 @@ TZRegionModel::region( int index ) const { if ( ( index < 0 ) || ( index >= m_regions.count() ) ) { - index = 0; + return nullptr; } return m_regions[ index ]; } diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 4311997a4..ff92141fa 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -63,14 +63,35 @@ protected: QString m_key; }; +class TZZone; +class TZRegion; +using TZZoneList = QList< TZZone* >; +using TZRegionList = QList< TZRegion* >; + /// @brief A pair of strings for timezone regions (e.g. "America") class TZRegion : public CStringPair { public: using CStringPair::CStringPair; + virtual ~TZRegion(); QString tr() const override; bool operator<( const TZRegion& other ) const { return m_key < other.m_key; } + + /** @brief Create model from a zone.tab-like file + * + * Returns a list of all the regions; each region has a list + * of zones within that region. + * + * The list owns the regions, and the regions own their own list of zones. + * When getting rid of the list, remember to qDeleteAll() on it. + */ + static TZRegionList fromFile( const char* fileName ); + /// @brief Calls fromFile with the standard zone.tab name + static TZRegionList fromZoneTab(); + +private: + TZZoneList m_zones; }; /// @brief A pair of strings for specific timezone names (e.g. "New_York") @@ -84,15 +105,12 @@ public: class DLLEXPORT TZRegionModel : public QAbstractListModel { public: - /// @brief Create empty model (useless) + /// @brief Create empty model TZRegionModel(); + /// @brief Create model from list (non-owning) + TZRegionModel( TZRegionList ); virtual ~TZRegionModel() override; - /// @brief Create model from a zone.tab-like file - static std::shared_ptr< TZRegionModel > fromFile( const char* fileName ); - /// @brief Calls fromFile with the standard zone.tab name - static std::shared_ptr< TZRegionModel > fromZoneTab(); - int rowCount( const QModelIndex& parent ) const override; QVariant data( const QModelIndex& index, int role ) const override; @@ -100,7 +118,7 @@ public: const TZRegion* region( int index ) const; private: - QList< TZRegion* > m_regions; + TZRegionList m_regions; }; } // namespace Locale diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index 5dfad3516..e5d14027f 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -110,7 +110,10 @@ LocalePage::LocalePage( QWidget* parent ) } -LocalePage::~LocalePage() {} +LocalePage::~LocalePage() +{ + qDeleteAll( m_regionList ); +} void @@ -144,7 +147,8 @@ containsLocation( const QList< LocaleGlobal::Location >& locations, const QStrin void LocalePage::init( const QString& initialRegion, const QString& initialZone, const QString& localeGenPath ) { - m_regionModel = CalamaresUtils::Locale::TZRegionModel::fromZoneTab(); + m_regionList = CalamaresUtils::Locale::TZRegion::fromZoneTab(); + m_regionModel = std::make_unique< CalamaresUtils::Locale::TZRegionModel >( m_regionList ); m_regionCombo->setModel( m_regionModel.get() ); // Setup locations diff --git a/src/modules/locale/LocalePage.h b/src/modules/locale/LocalePage.h index e918076d9..07f9fe0f2 100644 --- a/src/modules/locale/LocalePage.h +++ b/src/modules/locale/LocalePage.h @@ -74,7 +74,8 @@ private: void changeLocale(); void changeFormats(); - std::shared_ptr< CalamaresUtils::Locale::TZRegionModel > m_regionModel; + CalamaresUtils::Locale::TZRegionList m_regionList; + std::unique_ptr< CalamaresUtils::Locale::TZRegionModel > m_regionModel; TimeZoneWidget* m_tzWidget; QComboBox* m_regionCombo; From 1a8439069e2706e25b9ef4bd09049d375b42d418 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 15:36:53 +0200 Subject: [PATCH 31/57] [libcalamares] Extend TZ with location and country --- src/libcalamares/locale/TimeZone.cpp | 60 ++++++++++++++++++++++++++++ src/libcalamares/locale/TimeZone.h | 17 ++++++++ 2 files changed, 77 insertions(+) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index 784d77b9c..4bf23150a 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -18,6 +18,8 @@ #include "TimeZone.h" +#include "utils/Logger.h" + #include #include #include @@ -26,6 +28,35 @@ static const char TZ_DATA_FILE[] = "/usr/share/zoneinfo/zone.tab"; +static double +getRightGeoLocation( QString str ) +{ + double sign = 1, num = 0.00; + + // Determine sign + if ( str.startsWith( '-' ) ) + { + sign = -1; + str.remove( 0, 1 ); + } + else if ( str.startsWith( '+' ) ) + { + str.remove( 0, 1 ); + } + + if ( str.length() == 4 || str.length() == 6 ) + { + num = str.mid( 0, 2 ).toDouble() + str.mid( 2, 2 ).toDouble() / 60.0; + } + else if ( str.length() == 5 || str.length() == 7 ) + { + num = str.mid( 0, 3 ).toDouble() + str.mid( 3, 2 ).toDouble() / 60.0; + } + + return sign * num; +} + + namespace CalamaresUtils { namespace Locale @@ -151,12 +182,34 @@ TZRegion::fromFile( const char* fileName ) regions.append( region ); model.append( new TZRegion( region.toUtf8().data() ) ); } + + QString countryCode = list.at( 0 ).trimmed(); + if ( countryCode.size() != 2 ) + { + continue; + } + + timezoneParts.removeFirst(); + TZZone z( timezoneParts.join( '/' ).toUtf8().constData(), countryCode, list.at( 1 ) ); + cDebug() << "Region" << region << z; } std::sort( model.begin(), model.end(), []( const TZRegion* l, const TZRegion* r ) { return *l < *r; } ); return model; } +TZZone::TZZone( const char* zoneName, const QString& country, QString position ) + : CStringPair( zoneName ) + , m_country( country ) +{ + int cooSplitPos = position.indexOf( QRegExp( "[-+]" ), 1 ); + if ( cooSplitPos > 0 ) + { + m_latitude = getRightGeoLocation( position.mid( 0, cooSplitPos ) ); + m_longitude = getRightGeoLocation( position.mid( cooSplitPos + 1 ) ); + } +} + QString TZZone::tr() const { @@ -164,6 +217,13 @@ TZZone::tr() const return QObject::tr( m_human, "tz_names" ); } +void +TZZone::print( QDebug& log ) const +{ + log << key() << '(' << m_country << ' ' << m_latitude << ',' << m_longitude << ')'; +} + + TZRegionModel::TZRegionModel( TZRegionList l ) : m_regions( l ) { diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index ff92141fa..6e4ba062d 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -21,6 +21,8 @@ #include "DllMacro.h" +#include "utils/Logger.h" + #include #include #include @@ -100,8 +102,23 @@ class TZZone : public CStringPair public: using CStringPair::CStringPair; QString tr() const override; + + TZZone( const char* zoneName, const QString& country, QString position ); + + void print( QDebug& ) const; + +protected: + QString m_country; + double m_latitude = 0.0, m_longitude = 0.0; }; +inline QDebug& +operator<<( QDebug& log, const TZZone& z ) +{ + z.print( log ); + return log; +} + class DLLEXPORT TZRegionModel : public QAbstractListModel { public: From fc8364ea549e2da518afcda2ee68074d75eb840f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 14:06:22 +0000 Subject: [PATCH 32/57] [libcalamares] Store zones with each region - move operator< to base class - add each zone to the list held by the region - sort zones at the end --- src/libcalamares/locale/TimeZone.cpp | 23 ++++++++++++++++------- src/libcalamares/locale/TimeZone.h | 4 ++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index 4bf23150a..dd8ffbf41 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -147,8 +147,7 @@ TZRegion::fromFile( const char* fileName ) return model; } - QStringList regions; - + TZRegion* thisRegion = nullptr; QTextStream in( &file ); while ( !in.atEnd() ) { @@ -177,10 +176,16 @@ TZRegion::fromFile( const char* fileName ) continue; } - if ( !regions.contains( region ) ) + auto it + = std::find_if( model.begin(), model.end(), [®ion]( const TZRegion* r ) { return r->m_key == region; } ); + if ( it != model.end() ) { - regions.append( region ); - model.append( new TZRegion( region.toUtf8().data() ) ); + thisRegion = *it; + } + else + { + thisRegion = new TZRegion( region.toUtf8().data() ); + model.append( thisRegion ); } QString countryCode = list.at( 0 ).trimmed(); @@ -190,11 +195,15 @@ TZRegion::fromFile( const char* fileName ) } timezoneParts.removeFirst(); - TZZone z( timezoneParts.join( '/' ).toUtf8().constData(), countryCode, list.at( 1 ) ); - cDebug() << "Region" << region << z; + thisRegion->m_zones.append( new TZZone( timezoneParts.join( '/' ).toUtf8().constData(), countryCode, list.at( 1 ) ) ); } std::sort( model.begin(), model.end(), []( const TZRegion* l, const TZRegion* r ) { return *l < *r; } ); + for ( auto& r : model ) + { + std::sort( r->m_zones.begin(), r->m_zones.end(), []( const TZZone* l, const TZZone* r ) { return *l < *r; } ); + } + return model; } diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 6e4ba062d..896661b99 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -60,6 +60,8 @@ public: QString key() const { return m_key; } + bool operator<( const CStringPair& other ) const { return m_key < other.m_key; } + protected: char* m_human = nullptr; QString m_key; @@ -78,8 +80,6 @@ public: virtual ~TZRegion(); QString tr() const override; - bool operator<( const TZRegion& other ) const { return m_key < other.m_key; } - /** @brief Create model from a zone.tab-like file * * Returns a list of all the regions; each region has a list From 6092172f8dbdf59628d1794cefd9abc27e9a677a Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 15:32:15 +0100 Subject: [PATCH 33/57] [libcalamares] Regions and zones change to QList - By using QList< CStringPair* > consistently, we can save a bunch of model code at the cost of an occasional dynamic_cast; it's fairly rare for there to be a need for the derived pointer. --- src/libcalamares/locale/TimeZone.cpp | 50 ++++++++++++++++------------ src/libcalamares/locale/TimeZone.h | 30 ++++++++--------- src/modules/locale/LocalePage.cpp | 2 +- src/modules/locale/LocalePage.h | 5 +-- 4 files changed, 46 insertions(+), 41 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index dd8ffbf41..e2e13c828 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -130,16 +130,16 @@ TZRegion::~TZRegion() qDeleteAll( m_zones ); } -TZRegionList +CStringPairList TZRegion::fromZoneTab() { return TZRegion::fromFile( TZ_DATA_FILE ); } -TZRegionList +CStringPairList TZRegion::fromFile( const char* fileName ) { - TZRegionList model; + CStringPairList model; QFile file( fileName ); if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) ) @@ -176,11 +176,11 @@ TZRegion::fromFile( const char* fileName ) continue; } - auto it - = std::find_if( model.begin(), model.end(), [®ion]( const TZRegion* r ) { return r->m_key == region; } ); + auto keyMatch = [®ion]( const CStringPair* r ) { return r->key() == region; }; + auto it = std::find_if( model.begin(), model.end(), keyMatch ); if ( it != model.end() ) { - thisRegion = *it; + thisRegion = dynamic_cast< TZRegion* >( *it ); } else { @@ -195,13 +195,19 @@ TZRegion::fromFile( const char* fileName ) } timezoneParts.removeFirst(); - thisRegion->m_zones.append( new TZZone( timezoneParts.join( '/' ).toUtf8().constData(), countryCode, list.at( 1 ) ) ); + thisRegion->m_zones.append( + new TZZone( timezoneParts.join( '/' ).toUtf8().constData(), countryCode, list.at( 1 ) ) ); } - std::sort( model.begin(), model.end(), []( const TZRegion* l, const TZRegion* r ) { return *l < *r; } ); - for ( auto& r : model ) + auto sorter = []( const CStringPair* l, const CStringPair* r ) { return *l < *r; }; + std::sort( model.begin(), model.end(), sorter ); + for ( auto& it : model ) { - std::sort( r->m_zones.begin(), r->m_zones.end(), []( const TZZone* l, const TZZone* r ) { return *l < *r; } ); + TZRegion* r = dynamic_cast< TZRegion* >( it ); + if ( r ) + { + std::sort( r->m_zones.begin(), r->m_zones.end(), sorter ); + } } return model; @@ -233,21 +239,21 @@ TZZone::print( QDebug& log ) const } -TZRegionModel::TZRegionModel( TZRegionList l ) - : m_regions( l ) +CStringListModel::CStringListModel( CStringPairList l ) + : m_list( l ) { } -TZRegionModel::~TZRegionModel() {} +CStringListModel::~CStringListModel() {} int -TZRegionModel::rowCount( const QModelIndex& parent ) const +CStringListModel::rowCount( const QModelIndex& parent ) const { - return m_regions.count(); + return m_list.count(); } QVariant -TZRegionModel::data( const QModelIndex& index, int role ) const +CStringListModel::data( const QModelIndex& index, int role ) const { if ( ( role != Qt::DisplayRole ) && ( role != Qt::UserRole ) ) { @@ -259,18 +265,18 @@ TZRegionModel::data( const QModelIndex& index, int role ) const return QVariant(); } - const TZRegion* region = m_regions.at( index.row() ); - return role == Qt::DisplayRole ? region->tr() : region->key(); + const auto* item = m_list.at( index.row() ); + return item ? ( role == Qt::DisplayRole ? item->tr() : item->key() ) : QVariant(); } -const TZRegion* -TZRegionModel::region( int index ) const +const CStringPair* +CStringListModel::item( int index ) const { - if ( ( index < 0 ) || ( index >= m_regions.count() ) ) + if ( ( index < 0 ) || ( index >= m_list.count() ) ) { return nullptr; } - return m_regions[ index ]; + return m_list[ index ]; } } // namespace Locale diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 896661b99..0f09d48ca 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -57,7 +57,6 @@ public: /// @brief Give the localized human-readable form virtual QString tr() const = 0; - QString key() const { return m_key; } bool operator<( const CStringPair& other ) const { return m_key < other.m_key; } @@ -67,10 +66,7 @@ protected: QString m_key; }; -class TZZone; -class TZRegion; -using TZZoneList = QList< TZZone* >; -using TZRegionList = QList< TZRegion* >; +using CStringPairList = QList< CStringPair* >; /// @brief A pair of strings for timezone regions (e.g. "America") class TZRegion : public CStringPair @@ -80,20 +76,22 @@ public: virtual ~TZRegion(); QString tr() const override; - /** @brief Create model from a zone.tab-like file + /** @brief Create list from a zone.tab-like file * * Returns a list of all the regions; each region has a list - * of zones within that region. + * of zones within that region. Dyamically, the items in the + * returned list are TZRegions; their zones dynamically are + * TZZones even though all those lists have type CStringPairList. * * The list owns the regions, and the regions own their own list of zones. * When getting rid of the list, remember to qDeleteAll() on it. */ - static TZRegionList fromFile( const char* fileName ); + static CStringPairList fromFile( const char* fileName ); /// @brief Calls fromFile with the standard zone.tab name - static TZRegionList fromZoneTab(); + static CStringPairList fromZoneTab(); private: - TZZoneList m_zones; + CStringPairList m_zones; }; /// @brief A pair of strings for specific timezone names (e.g. "New_York") @@ -119,23 +117,23 @@ operator<<( QDebug& log, const TZZone& z ) return log; } -class DLLEXPORT TZRegionModel : public QAbstractListModel +class CStringListModel : public QAbstractListModel { public: /// @brief Create empty model - TZRegionModel(); + CStringListModel(); /// @brief Create model from list (non-owning) - TZRegionModel( TZRegionList ); - virtual ~TZRegionModel() override; + CStringListModel( CStringPairList ); + virtual ~CStringListModel() override; int rowCount( const QModelIndex& parent ) const override; QVariant data( const QModelIndex& index, int role ) const override; - const TZRegion* region( int index ) const; + const CStringPair* item( int index ) const; private: - TZRegionList m_regions; + CStringPairList m_list; }; } // namespace Locale diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index e5d14027f..bce12e817 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -148,7 +148,7 @@ void LocalePage::init( const QString& initialRegion, const QString& initialZone, const QString& localeGenPath ) { m_regionList = CalamaresUtils::Locale::TZRegion::fromZoneTab(); - m_regionModel = std::make_unique< CalamaresUtils::Locale::TZRegionModel >( m_regionList ); + m_regionModel = std::make_unique< CalamaresUtils::Locale::CStringListModel >( m_regionList ); m_regionCombo->setModel( m_regionModel.get() ); // Setup locations diff --git a/src/modules/locale/LocalePage.h b/src/modules/locale/LocalePage.h index 07f9fe0f2..7c2eba253 100644 --- a/src/modules/locale/LocalePage.h +++ b/src/modules/locale/LocalePage.h @@ -74,8 +74,9 @@ private: void changeLocale(); void changeFormats(); - CalamaresUtils::Locale::TZRegionList m_regionList; - std::unique_ptr< CalamaresUtils::Locale::TZRegionModel > m_regionModel; + // Dynamically, QList< TZRegion* > + CalamaresUtils::Locale::CStringPairList m_regionList; + std::unique_ptr< CalamaresUtils::Locale::CStringListModel > m_regionModel; TimeZoneWidget* m_tzWidget; QComboBox* m_regionCombo; From c75e87007317b142267338df657b1fa078a6deb1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 15:54:43 +0100 Subject: [PATCH 34/57] [libcalamares] CStringList::find() convenience function - search for a key and return a type-cast pointer to the result - while here, simplify some other code - the find() function could be done with std::find_if but doesn't get any shorter or more elegant --- src/libcalamares/locale/TimeZone.h | 19 ++++++++++++++++++- src/modules/locale/LocalePage.cpp | 10 +++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 0f09d48ca..86ddd516e 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -66,7 +66,22 @@ protected: QString m_key; }; -using CStringPairList = QList< CStringPair* >; +class CStringPairList : public QList< CStringPair* > +{ +public: + template < typename T > + T* find( const QString& key ) const + { + for ( auto* p : *this ) + { + if ( p->key() == key ) + { + return dynamic_cast< T* >( p ); + } + } + return nullptr; + } +}; /// @brief A pair of strings for timezone regions (e.g. "America") class TZRegion : public CStringPair @@ -90,6 +105,8 @@ public: /// @brief Calls fromFile with the standard zone.tab name static CStringPairList fromZoneTab(); + const CStringPairList& zones() const { return m_zones; } + private: CStringPairList m_zones; }; diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index bce12e817..4bda31d00 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -147,10 +147,13 @@ containsLocation( const QList< LocaleGlobal::Location >& locations, const QStrin void LocalePage::init( const QString& initialRegion, const QString& initialZone, const QString& localeGenPath ) { - m_regionList = CalamaresUtils::Locale::TZRegion::fromZoneTab(); - m_regionModel = std::make_unique< CalamaresUtils::Locale::CStringListModel >( m_regionList ); + using namespace CalamaresUtils::Locale; + + m_regionList = TZRegion::fromZoneTab(); + m_regionModel = std::make_unique< CStringListModel >( m_regionList ); m_regionCombo->setModel( m_regionModel.get() ); + // Setup locations QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations(); @@ -159,7 +162,8 @@ LocalePage::init( const QString& initialRegion, const QString& initialZone, cons m_regionCombo->currentIndexChanged( m_regionCombo->currentIndex() ); - if ( keys.contains( initialRegion ) && containsLocation( regions.value( initialRegion ), initialZone ) ) + auto* region = m_regionList.find< TZRegion >( initialRegion ); + if ( region && region->zones().find< TZZone >( initialZone ) ) { m_tzWidget->setCurrentLocation( initialRegion, initialZone ); } From 226530cf6fc2b26b2d41c811d70f82643d44652b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Dec 2019 01:04:09 +1000 Subject: [PATCH 35/57] [locale] Use model functions from locale service - drop the home-grown combo-box filling, use model --- src/modules/locale/LocalePage.cpp | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index 4bda31d00..3bfb9bba1 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -152,14 +152,6 @@ LocalePage::init( const QString& initialRegion, const QString& initialZone, cons m_regionList = TZRegion::fromZoneTab(); m_regionModel = std::make_unique< CStringListModel >( m_regionList ); m_regionCombo->setModel( m_regionModel.get() ); - - - // Setup locations - QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations(); - - QStringList keys = regions.keys(); - keys.sort(); - m_regionCombo->currentIndexChanged( m_regionCombo->currentIndex() ); auto* region = m_regionList.find< TZRegion >( initialRegion ); @@ -406,29 +398,20 @@ LocalePage::updateGlobalStorage() void LocalePage::regionChanged( int currentIndex ) { + using namespace CalamaresUtils::Locale; + Q_UNUSED( currentIndex ) QString selectedRegion = m_regionCombo->currentData().toString(); - QHash< QString, QList< LocaleGlobal::Location > > regions = LocaleGlobal::getLocations(); - if ( !regions.contains( selectedRegion ) ) + TZRegion* region = m_regionList.find< TZRegion >( selectedRegion ); + if ( !region ) { return; } m_zoneCombo->blockSignals( true ); - - m_zoneCombo->clear(); - - const QList< LocaleGlobal::Location > zones = regions.value( selectedRegion ); - for ( const LocaleGlobal::Location& zone : zones ) - { - m_zoneCombo->addItem( LocaleGlobal::Location::pretty( zone.zone ), zone.zone ); - } - - m_zoneCombo->model()->sort( 0 ); - + m_zoneCombo->setModel( new CStringListModel( region->zones() ) ); m_zoneCombo->blockSignals( false ); - m_zoneCombo->currentIndexChanged( m_zoneCombo->currentIndex() ); } From a39c77dfaf0acda6746d3f29ab4a2197d9c5b4d7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Dec 2019 01:11:51 +1000 Subject: [PATCH 36/57] [libcalamares] Store region name in each zone as well --- src/libcalamares/locale/TimeZone.cpp | 5 +++-- src/libcalamares/locale/TimeZone.h | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index e2e13c828..ea77fc39e 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -196,7 +196,7 @@ TZRegion::fromFile( const char* fileName ) timezoneParts.removeFirst(); thisRegion->m_zones.append( - new TZZone( timezoneParts.join( '/' ).toUtf8().constData(), countryCode, list.at( 1 ) ) ); + new TZZone( region, timezoneParts.join( '/' ).toUtf8().constData(), countryCode, list.at( 1 ) ) ); } auto sorter = []( const CStringPair* l, const CStringPair* r ) { return *l < *r; }; @@ -213,8 +213,9 @@ TZRegion::fromFile( const char* fileName ) return model; } -TZZone::TZZone( const char* zoneName, const QString& country, QString position ) +TZZone::TZZone( const QString& region, const char* zoneName, const QString& country, QString position ) : CStringPair( zoneName ) + , m_region( region ) , m_country( country ) { int cooSplitPos = position.indexOf( QRegExp( "[-+]" ), 1 ); diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 86ddd516e..19d0011b2 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -118,11 +118,12 @@ public: using CStringPair::CStringPair; QString tr() const override; - TZZone( const char* zoneName, const QString& country, QString position ); + TZZone( const QString& region, const char* zoneName, const QString& country, QString position ); void print( QDebug& ) const; protected: + QString m_region; QString m_country; double m_latitude = 0.0, m_longitude = 0.0; }; From 4089a01cb1f30350d31d5c87aa5efc7faf262632 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Dec 2019 01:31:56 +1000 Subject: [PATCH 37/57] [locale] Create TZ model earlier --- src/modules/locale/LocalePage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index 3bfb9bba1..ecdfb1935 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -42,6 +42,8 @@ LocalePage::LocalePage( QWidget* parent ) : QWidget( parent ) , m_blockTzWidgetSet( false ) + , m_regionList( CalamaresUtils::Locale::TZRegion::fromZoneTab() ) + , m_regionModel( std::make_unique< CalamaresUtils::Locale::CStringListModel >( m_regionList ) ) { QBoxLayout* mainLayout = new QVBoxLayout; @@ -149,8 +151,6 @@ LocalePage::init( const QString& initialRegion, const QString& initialZone, cons { using namespace CalamaresUtils::Locale; - m_regionList = TZRegion::fromZoneTab(); - m_regionModel = std::make_unique< CStringListModel >( m_regionList ); m_regionCombo->setModel( m_regionModel.get() ); m_regionCombo->currentIndexChanged( m_regionCombo->currentIndex() ); From 3f57b929ee2a2a6a0f7c04e4c3a33625b20bde73 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Dec 2019 01:43:53 +1000 Subject: [PATCH 38/57] [libcalamares] Make the zoneTab region list static - there's only one zone.tab, it won't change during a run, load it only once (this allows for a single global list). --- src/libcalamares/locale/TimeZone.cpp | 5 +++-- src/libcalamares/locale/TimeZone.h | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index ea77fc39e..ad09d82d5 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -130,10 +130,11 @@ TZRegion::~TZRegion() qDeleteAll( m_zones ); } -CStringPairList +const CStringPairList& TZRegion::fromZoneTab() { - return TZRegion::fromFile( TZ_DATA_FILE ); + static CStringPairList zoneTab = TZRegion::fromFile( TZ_DATA_FILE ); + return zoneTab; } CStringPairList diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 19d0011b2..dd1f9714d 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -103,7 +103,7 @@ public: */ static CStringPairList fromFile( const char* fileName ); /// @brief Calls fromFile with the standard zone.tab name - static CStringPairList fromZoneTab(); + static const CStringPairList& fromZoneTab(); const CStringPairList& zones() const { return m_zones; } From 1880eb514811c4e13c8fb9ae4b5a31a23d72ad64 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 16:10:16 +0000 Subject: [PATCH 39/57] [libcalamares] Add accessors for TZZone --- src/libcalamares/locale/TimeZone.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index dd1f9714d..73e73cf85 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -120,6 +120,11 @@ public: TZZone( const QString& region, const char* zoneName, const QString& country, QString position ); + QString region() const { return m_region; } + QString country() const { return m_country; } + double latitude() const { return m_latitude; } + double longitude() const { return m_longitude; } + void print( QDebug& ) const; protected: From 08dc9011d620dca99a13919d30464c6f9e08b8fd Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 17:11:10 +0100 Subject: [PATCH 40/57] [libcalamares] Off-by-one folded the world in half - Dropped the sign from longitudes, wrapping the west onto the east --- src/libcalamares/locale/TimeZone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index ad09d82d5..a9550ebb6 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -223,7 +223,7 @@ TZZone::TZZone( const QString& region, const char* zoneName, const QString& coun if ( cooSplitPos > 0 ) { m_latitude = getRightGeoLocation( position.mid( 0, cooSplitPos ) ); - m_longitude = getRightGeoLocation( position.mid( cooSplitPos + 1 ) ); + m_longitude = getRightGeoLocation( position.mid( cooSplitPos ) ); } } From 1e0492422449c4b6f843a71037f82832ea37e2bf Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 17:29:35 +0100 Subject: [PATCH 41/57] [locale] Drop the TZ-widget's timezone database - use the global TZ service instead - contains hacks to keep some of the API unchanged, which will be removed shortly --- .../locale/timezonewidget/localeglobal.cpp | 88 +++---------------- .../locale/timezonewidget/localeglobal.h | 14 ++- .../locale/timezonewidget/timezonewidget.cpp | 77 ++++++++-------- .../locale/timezonewidget/timezonewidget.h | 7 +- 4 files changed, 68 insertions(+), 118 deletions(-) diff --git a/src/modules/locale/timezonewidget/localeglobal.cpp b/src/modules/locale/timezonewidget/localeglobal.cpp index 683b2bebc..a9c7d3077 100644 --- a/src/modules/locale/timezonewidget/localeglobal.cpp +++ b/src/modules/locale/timezonewidget/localeglobal.cpp @@ -22,6 +22,8 @@ #include "localeglobal.h" +#include "locale/TimeZone.h" + #include //### @@ -29,7 +31,6 @@ //### QHash > > LocaleGlobal::locales; -QHash > LocaleGlobal::locations; //### @@ -53,12 +54,21 @@ LocaleGlobal::Location::comment() const return qtz.comment(); } +LocaleGlobal::Location & LocaleGlobal::Location::operator=(const CalamaresUtils::Locale::TZZone& location) +{ + region = location.region(); + zone = location.key(); + country = location.country(); + latitude = location.latitude(); + longitude = location.longitude(); + return *this; +} + void LocaleGlobal::init() { // TODO: Error handling initLocales(); - initLocations(); } @@ -70,12 +80,6 @@ LocaleGlobal::getLocales() { -QHash< QString, QList< LocaleGlobal::Location > > -LocaleGlobal::getLocations() { - return locations; -} - - //### //### Private methods //### @@ -126,71 +130,3 @@ LocaleGlobal::initLocales() { locales[lang][territory].append(locale); } } - - - -void -LocaleGlobal::initLocations() { - static const char TZ_DATA_FILE[] = "/usr/share/zoneinfo/zone.tab"; - - locations.clear(); - - QFile file(TZ_DATA_FILE); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) - return; - - QTextStream in(&file); - while (!in.atEnd()) { - QString line = in.readLine().trimmed().split('#', QString::KeepEmptyParts).first().trimmed(); - if (line.isEmpty()) - continue; - - QStringList list = line.split(QRegExp("[\t ]"), QString::SkipEmptyParts); - if (list.size() < 3) - continue; - - Location location; - QStringList timezoneParts = list.at(2).split('/', QString::SkipEmptyParts); - int cooSplitPos = QString(list.at(1)).remove(0, 1).indexOf(QRegExp("[-+]")) + 1; - - if (timezoneParts.size() < 2) - continue; - - QString countryCode = list.at(0).trimmed(); - if (countryCode.size() != 2) - continue; - - location.region = timezoneParts.takeFirst(); - location.zone = timezoneParts.join( '/' ); - location.latitude = getRightGeoLocation(list.at(1).mid(0, cooSplitPos)); - location.longitude = getRightGeoLocation(list.at(1).mid(cooSplitPos)); - location.country = countryCode; - - locations[location.region].append(location); - } -} - - - -double -LocaleGlobal::getRightGeoLocation(QString str) { - double sign = 1, num = 0.00; - - // Determind sign - if (str.startsWith('-')) { - sign = -1; - str.remove(0, 1); - } - else if (str.startsWith('+')) { - str.remove(0, 1); - } - - - if (str.length() == 4 || str.length() == 6) - num = str.mid(0, 2).toDouble() + str.mid(2, 2).toDouble() / 60; - else if (str.length() == 5 || str.length() == 7) - num = str.mid(0, 3).toDouble() + str.mid(3, 2).toDouble() / 60; - - return sign * num; -} - diff --git a/src/modules/locale/timezonewidget/localeglobal.h b/src/modules/locale/timezonewidget/localeglobal.h index 1a8f796d4..2b0bf0de7 100644 --- a/src/modules/locale/timezonewidget/localeglobal.h +++ b/src/modules/locale/timezonewidget/localeglobal.h @@ -36,6 +36,14 @@ #include #include "localeconst.h" +namespace CalamaresUtils +{ + namespace Locale + { + class TZZone; + } +} + class LocaleGlobal { public: @@ -50,19 +58,17 @@ public: double latitude, longitude; static QString pretty( const QString& s ); QString comment() const; + + Location& operator=(const CalamaresUtils::Locale::TZZone&); }; static void init(); static QHash > > getLocales(); - static QHash > getLocations(); private: static QHash > > locales; - static QHash > locations; static void initLocales(); - static void initLocations(); - static double getRightGeoLocation( QString str ); }; inline QDebug& operator <<( QDebug& s, const LocaleGlobal::Location& l ) diff --git a/src/modules/locale/timezonewidget/timezonewidget.cpp b/src/modules/locale/timezonewidget/timezonewidget.cpp index 33a8f25ac..bcf95cc25 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.cpp +++ b/src/modules/locale/timezonewidget/timezonewidget.cpp @@ -1,7 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2014-2015, Teo Mrnjavac - * Copyright 2017-2018, Adriaan de Groot + * Copyright 2017-2019, Adriaan de Groot * * Originally from the Manjaro Installation Framework * by Roland Singer @@ -24,6 +24,7 @@ #include #include "utils/Logger.h" +#include "locale/TimeZone.h" #include "timezonewidget.h" @@ -67,28 +68,27 @@ TimeZoneWidget::TimeZoneWidget( QWidget* parent ) : } -void TimeZoneWidget::setCurrentLocation( QString region, QString zone ) +void TimeZoneWidget::setCurrentLocation( QString regionName, QString zoneName ) { - QHash > hash = LocaleGlobal::getLocations(); - - if ( !hash.contains( region ) ) - return; - - QList locations = hash.value( region ); - for ( int i = 0; i < locations.size(); ++i ) + using namespace CalamaresUtils::Locale; + const auto& regions = TZRegion::fromZoneTab(); + auto *region = regions.find( regionName ); + if ( !region ) { - if ( locations.at( i ).zone == zone ) - { - setCurrentLocation( locations.at( i ) ); - break; - } + return; + } + + auto *zone = region->zones().find< TZZone >(zoneName); + if ( zone ) + { + setCurrentLocation( zone ); } } -void TimeZoneWidget::setCurrentLocation( LocaleGlobal::Location location ) +void TimeZoneWidget::setCurrentLocation( const CalamaresUtils::Locale::TZZone *location ) { - currentLocation = location; + currentLocation = *location; // Set zone QPoint pos = getLocationPosition( currentLocation.longitude, currentLocation.latitude ); @@ -259,32 +259,37 @@ void TimeZoneWidget::mousePressEvent( QMouseEvent* event ) // Set nearest location int nX = 999999, mX = event->pos().x(); int nY = 999999, mY = event->pos().y(); - QHash > hash = LocaleGlobal::getLocations(); - QHash >::iterator iter = hash.begin(); - while ( iter != hash.end() ) + using namespace CalamaresUtils::Locale; + const TZZone* closest = nullptr; + for ( const auto* region_p : TZRegion::fromZoneTab() ) { - QList locations = iter.value(); - - for ( int i = 0; i < locations.size(); ++i ) + const auto* region = dynamic_cast(region_p); + if ( region ) { - LocaleGlobal::Location loc = locations[i]; - QPoint locPos = getLocationPosition( loc.longitude, loc.latitude ); - - if ( ( abs( mX - locPos.x() ) + abs( mY - locPos.y() ) < abs( mX - nX ) + abs( mY - nY ) ) ) + for ( const auto* zone_p : region->zones() ) { - currentLocation = loc; - nX = locPos.x(); - nY = locPos.y(); + const auto* zone = dynamic_cast(zone_p); + if ( zone ) + { + QPoint locPos = getLocationPosition( zone->longitude(), zone->latitude() ); + + if ( ( abs( mX - locPos.x() ) + abs( mY - locPos.y() ) < abs( mX - nX ) + abs( mY - nY ) ) ) + { + closest = zone; + nX = locPos.x(); + nY = locPos.y(); + } + } } } - - ++iter; } - // Set zone image and repaint widget - setCurrentLocation( currentLocation ); - - // Emit signal - emit locationChanged( currentLocation ); + if ( closest ) + { + // Set zone image and repaint widget + setCurrentLocation( closest ); + // Emit signal + emit locationChanged( currentLocation ); + } } diff --git a/src/modules/locale/timezonewidget/timezonewidget.h b/src/modules/locale/timezonewidget/timezonewidget.h index dd49b3311..5b09709ba 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.h +++ b/src/modules/locale/timezonewidget/timezonewidget.h @@ -24,6 +24,10 @@ #ifndef TIMEZONEWIDGET_H #define TIMEZONEWIDGET_H +#include "localeglobal.h" + +#include "locale/TimeZone.h" + #include #include #include @@ -34,7 +38,6 @@ #include #include #include -#include "localeglobal.h" #define RGB_TRANSPARENT 0 @@ -54,7 +57,7 @@ public: return currentLocation; } void setCurrentLocation( QString region, QString zone ); - void setCurrentLocation( LocaleGlobal::Location location ); + void setCurrentLocation( const CalamaresUtils::Locale::TZZone *location ); signals: void locationChanged( LocaleGlobal::Location location ); From 7354d35fafe5cb99047e496489b42f4e96ed231f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 17:42:58 +0100 Subject: [PATCH 42/57] [locale] Apply coding style to timezonewidget/ --- .../locale/timezonewidget/localeconst.h | 2 +- .../locale/timezonewidget/localeglobal.cpp | 74 ++++++++----- .../locale/timezonewidget/localeglobal.h | 35 +++--- .../locale/timezonewidget/timezonewidget.cpp | 104 ++++++++++++------ .../locale/timezonewidget/timezonewidget.h | 31 +++--- 5 files changed, 153 insertions(+), 93 deletions(-) diff --git a/src/modules/locale/timezonewidget/localeconst.h b/src/modules/locale/timezonewidget/localeconst.h index 2de1b0dac..8648f0c93 100644 --- a/src/modules/locale/timezonewidget/localeconst.h +++ b/src/modules/locale/timezonewidget/localeconst.h @@ -28,4 +28,4 @@ #define USER_IMAGES_PATH "/usr/share/pixmaps/faces" -#endif // LOCALECONST_H +#endif // LOCALECONST_H diff --git a/src/modules/locale/timezonewidget/localeglobal.cpp b/src/modules/locale/timezonewidget/localeglobal.cpp index a9c7d3077..ef7d64d4d 100644 --- a/src/modules/locale/timezonewidget/localeglobal.cpp +++ b/src/modules/locale/timezonewidget/localeglobal.cpp @@ -30,7 +30,7 @@ //### Private variables //### -QHash > > LocaleGlobal::locales; +QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > LocaleGlobal::locales; //### @@ -48,13 +48,12 @@ LocaleGlobal::Location::pretty( const QString& s ) QString LocaleGlobal::Location::comment() const { - QTimeZone qtz = QTimeZone( QString( "%1/%2" ) - .arg( region ) - .arg( zone ).toLatin1() ); + QTimeZone qtz = QTimeZone( QString( "%1/%2" ).arg( region ).arg( zone ).toLatin1() ); return qtz.comment(); } -LocaleGlobal::Location & LocaleGlobal::Location::operator=(const CalamaresUtils::Locale::TZZone& location) +LocaleGlobal::Location& +LocaleGlobal::Location::operator=( const CalamaresUtils::Locale::TZZone& location ) { region = location.region(); zone = location.key(); @@ -66,67 +65,86 @@ LocaleGlobal::Location & LocaleGlobal::Location::operator=(const CalamaresUtils: void -LocaleGlobal::init() { +LocaleGlobal::init() +{ // TODO: Error handling initLocales(); } - QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > -LocaleGlobal::getLocales() { +LocaleGlobal::getLocales() +{ return locales; } - //### //### Private methods //### void -LocaleGlobal::initLocales() { +LocaleGlobal::initLocales() +{ locales.clear(); - QStringList files = QDir(LOCALESDIR).entryList(QDir::Files, QDir::Name); + 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)) + 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); + QTextStream in( &file ); QString commentChar = "%"; Locale locale; QString lang, territory; locale.locale = filename; - while (!in.atEnd()) { + while ( !in.atEnd() ) + { QString line = in.readLine().trimmed(); - QStringList split = line.split(commentChar, QString::KeepEmptyParts).first().split(QRegExp(" (?=[^\"]*(\"[^\"]*\"[^\"]*)*$)"), QString::SkipEmptyParts); + QStringList split = line.split( commentChar, QString::KeepEmptyParts ) + .first() + .split( QRegExp( " (?=[^\"]*(\"[^\"]*\"[^\"]*)*$)" ), QString::SkipEmptyParts ); - if (split.size() < 2) + if ( split.size() < 2 ) + { continue; + } - QString sub1 = QString(split.at(0)).remove("\""); - QString sub2 = QString(split.at(1)).remove("\""); + QString sub1 = QString( split.at( 0 ) ).remove( "\"" ); + QString sub2 = QString( split.at( 1 ) ).remove( "\"" ); - if (sub1 == "comment_char") + if ( sub1 == "comment_char" ) + { commentChar = sub2; - else if (sub1 == "title") + } + else if ( sub1 == "title" ) + { locale.description = sub2; - else if (sub1 == "territory") - territory= sub2; - else if (sub1 == "language") + } + else if ( sub1 == "territory" ) + { + territory = sub2; + } + else if ( sub1 == "language" ) + { lang = sub2; + } } - if (lang.isEmpty() || territory.isEmpty()) + if ( lang.isEmpty() || territory.isEmpty() ) + { continue; + } - locales[lang][territory].append(locale); + locales[ lang ][ territory ].append( locale ); } } diff --git a/src/modules/locale/timezonewidget/localeglobal.h b/src/modules/locale/timezonewidget/localeglobal.h index 2b0bf0de7..4f40db083 100644 --- a/src/modules/locale/timezonewidget/localeglobal.h +++ b/src/modules/locale/timezonewidget/localeglobal.h @@ -24,25 +24,25 @@ #ifndef LOCALEGLOBAL_H #define LOCALEGLOBAL_H -#include -#include -#include +#include "localeconst.h" +#include #include -#include -#include +#include #include +#include #include #include -#include -#include "localeconst.h" +#include +#include +#include namespace CalamaresUtils { - namespace Locale - { - class TZZone; - } +namespace Locale +{ +class TZZone; } +} // namespace CalamaresUtils class LocaleGlobal { @@ -59,21 +59,22 @@ public: static QString pretty( const QString& s ); QString comment() const; - Location& operator=(const CalamaresUtils::Locale::TZZone&); + Location& operator=( const CalamaresUtils::Locale::TZZone& ); }; static void init(); - static QHash > > getLocales(); + static QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > getLocales(); private: - static QHash > > locales; + static QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > locales; static void initLocales(); }; -inline QDebug& operator <<( QDebug& s, const LocaleGlobal::Location& l ) +inline QDebug& +operator<<( QDebug& s, const LocaleGlobal::Location& l ) { - return s << l.region << '/' << l.zone << '(' << l.country << ") @N" << l.latitude << 'E' << l.longitude; + return s << l.region << '/' << l.zone << '(' << l.country << ") @N" << l.latitude << 'E' << l.longitude; } -#endif // LOCALEGLOBAL_H +#endif // LOCALEGLOBAL_H diff --git a/src/modules/locale/timezonewidget/timezonewidget.cpp b/src/modules/locale/timezonewidget/timezonewidget.cpp index bcf95cc25..f60e32c96 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.cpp +++ b/src/modules/locale/timezonewidget/timezonewidget.cpp @@ -23,8 +23,8 @@ #include -#include "utils/Logger.h" #include "locale/TimeZone.h" +#include "utils/Logger.h" #include "timezonewidget.h" @@ -38,8 +38,8 @@ constexpr static double MATH_PI = 3.14159265; constexpr static QLatin1String ZONE_NAME( "zone" ); #endif -TimeZoneWidget::TimeZoneWidget( QWidget* parent ) : - QWidget( parent ) +TimeZoneWidget::TimeZoneWidget( QWidget* parent ) + : QWidget( parent ) { setMouseTracking( false ); setCursor( Qt::PointingHandCursor ); @@ -60,7 +60,8 @@ TimeZoneWidget::TimeZoneWidget( QWidget* parent ) : QStringList zones = QString( ZONES ).split( " ", QString::SkipEmptyParts ); for ( int i = 0; i < zones.size(); ++i ) { - timeZoneImages.append( QImage( ":/images/timezone_" + zones.at( i ) + ".png" ).scaled( X_SIZE, Y_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) ); + timeZoneImages.append( QImage( ":/images/timezone_" + zones.at( i ) + ".png" ) + .scaled( X_SIZE, Y_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) ); #ifdef DEBUG_TIMEZONES timeZoneImages.last().setText( ZONE_NAME, zones.at( i ) ); #endif @@ -68,17 +69,18 @@ TimeZoneWidget::TimeZoneWidget( QWidget* parent ) : } -void TimeZoneWidget::setCurrentLocation( QString regionName, QString zoneName ) +void +TimeZoneWidget::setCurrentLocation( QString regionName, QString zoneName ) { using namespace CalamaresUtils::Locale; const auto& regions = TZRegion::fromZoneTab(); - auto *region = regions.find( regionName ); + auto* region = regions.find< TZRegion >( regionName ); if ( !region ) { return; } - auto *zone = region->zones().find< TZZone >(zoneName); + auto* zone = region->zones().find< TZZone >( zoneName ); if ( zone ) { setCurrentLocation( zone ); @@ -86,7 +88,8 @@ void TimeZoneWidget::setCurrentLocation( QString regionName, QString zoneName ) } -void TimeZoneWidget::setCurrentLocation( const CalamaresUtils::Locale::TZZone *location ) +void +TimeZoneWidget::setCurrentLocation( const CalamaresUtils::Locale::TZZone* location ) { currentLocation = *location; @@ -104,7 +107,7 @@ void TimeZoneWidget::setCurrentLocation( const CalamaresUtils::Locale::TZZone *l for ( int i = 0; i < timeZoneImages.size(); ++i ) { - QImage zone = timeZoneImages[i]; + QImage zone = timeZoneImages[ i ]; // If not transparent set as current if ( zone.pixel( pos ) != RGB_TRANSPARENT ) @@ -119,7 +122,9 @@ void TimeZoneWidget::setCurrentLocation( const CalamaresUtils::Locale::TZZone *l cDebug() << Logger::SubEntry << "First zone found" << i << zone.text( ZONE_NAME ); } else + { cDebug() << Logger::SubEntry << "Also in zone" << i << zone.text( ZONE_NAME ); + } #else currentZoneImage = zone; break; @@ -132,13 +137,13 @@ void TimeZoneWidget::setCurrentLocation( const CalamaresUtils::Locale::TZZone *l } - //### //### Private //### -QPoint TimeZoneWidget::getLocationPosition( double longitude, double latitude ) +QPoint +TimeZoneWidget::getLocationPosition( double longitude, double latitude ) { const int width = this->width(); const int height = this->height(); @@ -152,39 +157,64 @@ QPoint TimeZoneWidget::getLocationPosition( double longitude, double latitude ) // of the different cities / regions looks ok -- at least Thule ends up in the right // country, and Inuvik isn't in the ocean. if ( latitude > 70.0 ) + { y -= sin( MATH_PI * ( latitude - 70.0 ) / 56.0 ) * MAP_Y_OFFSET * height * 0.8; + } if ( latitude > 74.0 ) + { y += 4; + } if ( latitude > 69.0 ) + { y -= 2; + } if ( latitude > 59.0 ) + { y -= 4 * int( ( latitude - 54.0 ) / 5.0 ); + } if ( latitude > 54.0 ) + { y -= 2; + } if ( latitude > 49.0 ) - y -= int ( (latitude - 44.0) / 5.0 ); + { + y -= int( ( latitude - 44.0 ) / 5.0 ); + } // Far south, some stretching occurs as well, but it is less pronounced. // Move down by 1 pixel per 5 degrees past 10 south if ( latitude < 0 ) - y += int( (-latitude) / 5.0 ); + { + y += int( ( -latitude ) / 5.0 ); + } // Antarctica isn't shown on the map, but you could try clicking there if ( latitude < -60 ) + { y = height - 1; + } if ( x < 0 ) - x = width+x; + { + x = width + x; + } if ( x >= width ) + { x -= width; + } if ( y < 0 ) - y = height+y; + { + y = height + y; + } if ( y >= height ) + { y -= height; + } - return QPoint( int(x), int(y) ); + return QPoint( int( x ), int( y ) ); } -void TimeZoneWidget::paintEvent( QPaintEvent* ) +void +TimeZoneWidget::paintEvent( QPaintEvent* ) { const int width = this->width(); const int height = this->height(); @@ -203,17 +233,19 @@ void TimeZoneWidget::paintEvent( QPaintEvent* ) #ifdef DEBUG_TIMEZONES QPoint point = getLocationPosition( currentLocation.longitude, currentLocation.latitude ); // Draw latitude lines - for ( int y_lat = -50; y_lat < 80 ; y_lat+=5 ) + for ( int y_lat = -50; y_lat < 80; y_lat += 5 ) { QPen p( y_lat ? Qt::black : Qt::red ); p.setWidth( 0 ); painter.setPen( p ); QPoint latLine0( getLocationPosition( 0, y_lat ) ); - int llx = latLine0.x() + ((y_lat & 1) ? -10 : 0); + int llx = latLine0.x() + ( ( y_lat & 1 ) ? -10 : 0 ); int lly = latLine0.y(); - for ( int c = 0 ; c < width ; ++c ) + for ( int c = 0; c < width; ++c ) + { painter.drawPoint( c, lly ); + } } // Just a dot in the selected location, no label painter.setPen( Qt::red ); @@ -222,24 +254,32 @@ void TimeZoneWidget::paintEvent( QPaintEvent* ) // Draw pin at current location QPoint point = getLocationPosition( currentLocation.longitude, currentLocation.latitude ); - painter.drawImage( point.x() - pin.width()/2, point.y() - pin.height()/2, pin ); + painter.drawImage( point.x() - pin.width() / 2, point.y() - pin.height() / 2, pin ); // Draw text and box const int textWidth = fontMetrics.horizontalAdvance( LocaleGlobal::Location::pretty( currentLocation.zone ) ); const int textHeight = fontMetrics.height(); - QRect rect = QRect( point.x() - textWidth/2 - 5, point.y() - textHeight - 8, textWidth + 10, textHeight - 2 ); + QRect rect = QRect( point.x() - textWidth / 2 - 5, point.y() - textHeight - 8, textWidth + 10, textHeight - 2 ); if ( rect.x() <= 5 ) + { rect.moveLeft( 5 ); - if ( rect.right() >= width-5 ) + } + if ( rect.right() >= width - 5 ) + { rect.moveRight( width - 5 ); + } if ( rect.y() <= 5 ) + { rect.moveTop( 5 ); - if ( rect.y() >= height-5 ) - rect.moveBottom( height-5 ); + } + if ( rect.y() >= height - 5 ) + { + rect.moveBottom( height - 5 ); + } - painter.setPen( QPen() ); // no pen + painter.setPen( QPen() ); // no pen painter.setBrush( QColor( 40, 40, 40 ) ); painter.drawRoundedRect( rect, 3, 3 ); painter.setPen( Qt::white ); @@ -250,11 +290,13 @@ void TimeZoneWidget::paintEvent( QPaintEvent* ) } - -void TimeZoneWidget::mousePressEvent( QMouseEvent* event ) +void +TimeZoneWidget::mousePressEvent( QMouseEvent* event ) { if ( event->button() != Qt::LeftButton ) + { return; + } // Set nearest location int nX = 999999, mX = event->pos().x(); @@ -264,17 +306,17 @@ void TimeZoneWidget::mousePressEvent( QMouseEvent* event ) const TZZone* closest = nullptr; for ( const auto* region_p : TZRegion::fromZoneTab() ) { - const auto* region = dynamic_cast(region_p); + const auto* region = dynamic_cast< const TZRegion* >( region_p ); if ( region ) { for ( const auto* zone_p : region->zones() ) { - const auto* zone = dynamic_cast(zone_p); + const auto* zone = dynamic_cast< const TZZone* >( zone_p ); if ( zone ) { QPoint locPos = getLocationPosition( zone->longitude(), zone->latitude() ); - if ( ( abs( mX - locPos.x() ) + abs( mY - locPos.y() ) < abs( mX - nX ) + abs( mY - nY ) ) ) + if ( ( abs( mX - locPos.x() ) + abs( mY - locPos.y() ) < abs( mX - nX ) + abs( mY - nY ) ) ) { closest = zone; nX = locPos.x(); diff --git a/src/modules/locale/timezonewidget/timezonewidget.h b/src/modules/locale/timezonewidget/timezonewidget.h index 5b09709ba..3f5baf16b 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.h +++ b/src/modules/locale/timezonewidget/timezonewidget.h @@ -28,20 +28,22 @@ #include "locale/TimeZone.h" -#include -#include -#include #include -#include -#include -#include -#include -#include #include +#include +#include +#include +#include +#include +#include +#include +#include #define RGB_TRANSPARENT 0 -#define ZONES "0.0 1.0 2.0 3.0 3.5 4.0 4.5 5.0 5.5 5.75 6.0 6.5 7.0 8.0 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.75 13.0 -1.0 -2.0 -3.0 -3.5 -4.0 -4.5 -5.0 -5.5 -6.0 -7.0 -8.0 -9.0 -9.5 -10.0 -11.0" +#define ZONES \ + "0.0 1.0 2.0 3.0 3.5 4.0 4.5 5.0 5.5 5.75 6.0 6.5 7.0 8.0 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.75 13.0 -1.0 -2.0 " \ + "-3.0 -3.5 -4.0 -4.5 -5.0 -5.5 -6.0 -7.0 -8.0 -9.0 -9.5 -10.0 -11.0" #define X_SIZE 780 #define Y_SIZE 340 @@ -52,12 +54,9 @@ class TimeZoneWidget : public QWidget public: explicit TimeZoneWidget( QWidget* parent = nullptr ); - LocaleGlobal::Location getCurrentLocation() - { - return currentLocation; - } + LocaleGlobal::Location getCurrentLocation() { return currentLocation; } void setCurrentLocation( QString region, QString zone ); - void setCurrentLocation( const CalamaresUtils::Locale::TZZone *location ); + void setCurrentLocation( const CalamaresUtils::Locale::TZZone* location ); signals: void locationChanged( LocaleGlobal::Location location ); @@ -65,7 +64,7 @@ signals: private: QFont font; QImage background, pin, currentZoneImage; - QList timeZoneImages; + QList< QImage > timeZoneImages; LocaleGlobal::Location currentLocation; QPoint getLocationPosition( const LocaleGlobal::Location& l ) @@ -78,4 +77,4 @@ private: void mousePressEvent( QMouseEvent* event ); }; -#endif // TIMEZONEWIDGET_H +#endif // TIMEZONEWIDGET_H From 9d9d9c361d8c5a0f22519dfe25a250fe88709514 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 17:45:38 +0100 Subject: [PATCH 43/57] [locale] Clean up constants - move LOCALESDIR to the one place it's used - remove file with only unused #defines --- .../locale/timezonewidget/localeconst.h | 31 ------------------- .../locale/timezonewidget/localeglobal.cpp | 2 ++ .../locale/timezonewidget/localeglobal.h | 1 - 3 files changed, 2 insertions(+), 32 deletions(-) delete mode 100644 src/modules/locale/timezonewidget/localeconst.h diff --git a/src/modules/locale/timezonewidget/localeconst.h b/src/modules/locale/timezonewidget/localeconst.h deleted file mode 100644 index 8648f0c93..000000000 --- a/src/modules/locale/timezonewidget/localeconst.h +++ /dev/null @@ -1,31 +0,0 @@ -/* === This file is part of Calamares - === - * - * Copyright 2014, 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 . - */ - -#ifndef LOCALECONST_H -#define LOCALECONST_H - - -#define LOCALESDIR "/usr/share/i18n/locales" -#define USER_IMAGES_PATH "/usr/share/pixmaps/faces" - - -#endif // LOCALECONST_H diff --git a/src/modules/locale/timezonewidget/localeglobal.cpp b/src/modules/locale/timezonewidget/localeglobal.cpp index ef7d64d4d..593de5cab 100644 --- a/src/modules/locale/timezonewidget/localeglobal.cpp +++ b/src/modules/locale/timezonewidget/localeglobal.cpp @@ -87,6 +87,8 @@ LocaleGlobal::getLocales() void LocaleGlobal::initLocales() { + static const char LOCALESDIR[] = "/usr/share/i18n/locales"; + locales.clear(); QStringList files = QDir( LOCALESDIR ).entryList( QDir::Files, QDir::Name ); diff --git a/src/modules/locale/timezonewidget/localeglobal.h b/src/modules/locale/timezonewidget/localeglobal.h index 4f40db083..b5e175c7c 100644 --- a/src/modules/locale/timezonewidget/localeglobal.h +++ b/src/modules/locale/timezonewidget/localeglobal.h @@ -24,7 +24,6 @@ #ifndef LOCALEGLOBAL_H #define LOCALEGLOBAL_H -#include "localeconst.h" #include #include #include From 2dfbed40c5f3e9b4b398b2e141d5e57accbd0929 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 09:57:40 -0700 Subject: [PATCH 44/57] [locale] Move defines - Used in only one place, move to .cpp - Drop useless scaling all the images *are* that size already - Add debugging check that the images match expected size --- .../locale/timezonewidget/timezonewidget.cpp | 18 +++++++++++++++--- .../locale/timezonewidget/timezonewidget.h | 3 --- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/modules/locale/timezonewidget/timezonewidget.cpp b/src/modules/locale/timezonewidget/timezonewidget.cpp index f60e32c96..307e1d9b8 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.cpp +++ b/src/modules/locale/timezonewidget/timezonewidget.cpp @@ -28,6 +28,8 @@ #include "timezonewidget.h" +// Pixel value indicating that a spot is outside of a zone +#define RGB_TRANSPARENT 0 static constexpr double MAP_Y_OFFSET = 0.125; static constexpr double MAP_X_OFFSET = -0.0370; @@ -49,9 +51,16 @@ TimeZoneWidget::TimeZoneWidget( QWidget* parent ) font.setBold( false ); // Images - background = QImage( ":/images/bg.png" ).scaled( X_SIZE, Y_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ); + background = QImage( ":/images/bg.png" ); pin = QImage( ":/images/pin.png" ); +#ifdef DEBUG_TIMEZONES + if ( background.size() != QSize( 780, 340 ) ) + { + cWarning() << "Timezone background size mitsmatch" << background.size(); + } +#endif + // Set size setMinimumSize( background.size() ); setMaximumSize( background.size() ); @@ -60,9 +69,12 @@ TimeZoneWidget::TimeZoneWidget( QWidget* parent ) QStringList zones = QString( ZONES ).split( " ", QString::SkipEmptyParts ); for ( int i = 0; i < zones.size(); ++i ) { - timeZoneImages.append( QImage( ":/images/timezone_" + zones.at( i ) + ".png" ) - .scaled( X_SIZE, Y_SIZE, Qt::IgnoreAspectRatio, Qt::SmoothTransformation ) ); + timeZoneImages.append( QImage( ":/images/timezone_" + zones.at( i ) + ".png" ) ); #ifdef DEBUG_TIMEZONES + if ( timeZoneImages.last().size() != background.size() ) + { + cWarning() << "Timezone image size mismatch" << zones.at( i ) << timeZoneImages.last().size(); + } timeZoneImages.last().setText( ZONE_NAME, zones.at( i ) ); #endif } diff --git a/src/modules/locale/timezonewidget/timezonewidget.h b/src/modules/locale/timezonewidget/timezonewidget.h index 3f5baf16b..87b817349 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.h +++ b/src/modules/locale/timezonewidget/timezonewidget.h @@ -40,12 +40,9 @@ #include -#define RGB_TRANSPARENT 0 #define ZONES \ "0.0 1.0 2.0 3.0 3.5 4.0 4.5 5.0 5.5 5.75 6.0 6.5 7.0 8.0 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.75 13.0 -1.0 -2.0 " \ "-3.0 -3.5 -4.0 -4.5 -5.0 -5.5 -6.0 -7.0 -8.0 -9.0 -9.5 -10.0 -11.0" -#define X_SIZE 780 -#define Y_SIZE 340 class TimeZoneWidget : public QWidget From fb9d53909e2feca3f27274a85aa7e365fa5bcd8d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 16:09:48 -0100 Subject: [PATCH 45/57] [locale] Drop ZONES #define - this was a "cheap" way to write a list, but going through QStringList::split() is just a long-way-around for static initialization --- src/modules/locale/timezonewidget/timezonewidget.cpp | 8 +++++--- src/modules/locale/timezonewidget/timezonewidget.h | 6 ------ 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/modules/locale/timezonewidget/timezonewidget.cpp b/src/modules/locale/timezonewidget/timezonewidget.cpp index 307e1d9b8..a392cc863 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.cpp +++ b/src/modules/locale/timezonewidget/timezonewidget.cpp @@ -66,10 +66,12 @@ TimeZoneWidget::TimeZoneWidget( QWidget* parent ) setMaximumSize( background.size() ); // Zone images - QStringList zones = QString( ZONES ).split( " ", QString::SkipEmptyParts ); - for ( int i = 0; i < zones.size(); ++i ) + for ( const auto* zoneName : + { "0.0", "1.0", "2.0", "3.0", "3.5", "4.0", "4.5", "5.0", "5.5", "5.75", "6.0", "6.5", "7.0", + "8.0", "9.0", "9.5", "10.0", "10.5", "11.0", "11.5", "12.0", "12.75", "13.0", "-1.0", "-2.0", "-3.0", + "-3.5", "-4.0", "-4.5", "-5.0", "-5.5", "-6.0", "-7.0", "-8.0", "-9.0", "-9.5", "-10.0", "-11.0" } ) { - timeZoneImages.append( QImage( ":/images/timezone_" + zones.at( i ) + ".png" ) ); + timeZoneImages.append( QImage( QStringLiteral( ":/images/timezone_" ) + zoneName + ".png" ) ); #ifdef DEBUG_TIMEZONES if ( timeZoneImages.last().size() != background.size() ) { diff --git a/src/modules/locale/timezonewidget/timezonewidget.h b/src/modules/locale/timezonewidget/timezonewidget.h index 87b817349..7a3572f10 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.h +++ b/src/modules/locale/timezonewidget/timezonewidget.h @@ -39,12 +39,6 @@ #include #include - -#define ZONES \ - "0.0 1.0 2.0 3.0 3.5 4.0 4.5 5.0 5.5 5.75 6.0 6.5 7.0 8.0 9.0 9.5 10.0 10.5 11.0 11.5 12.0 12.75 13.0 -1.0 -2.0 " \ - "-3.0 -3.5 -4.0 -4.5 -5.0 -5.5 -6.0 -7.0 -8.0 -9.0 -9.5 -10.0 -11.0" - - class TimeZoneWidget : public QWidget { Q_OBJECT From e164f8d63a72ca97e9e782d2c0427e3fb6fb864b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 16:19:06 -0100 Subject: [PATCH 46/57] [locale] Fix build with DEBUG_TIMEZONE - all the API changes were not reflected in the debugging code --- src/modules/locale/timezonewidget/timezonewidget.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/modules/locale/timezonewidget/timezonewidget.cpp b/src/modules/locale/timezonewidget/timezonewidget.cpp index a392cc863..41b5b1980 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.cpp +++ b/src/modules/locale/timezonewidget/timezonewidget.cpp @@ -75,9 +75,9 @@ TimeZoneWidget::TimeZoneWidget( QWidget* parent ) #ifdef DEBUG_TIMEZONES if ( timeZoneImages.last().size() != background.size() ) { - cWarning() << "Timezone image size mismatch" << zones.at( i ) << timeZoneImages.last().size(); + cWarning() << "Timezone image size mismatch" << zoneName << timeZoneImages.last().size(); } - timeZoneImages.last().setText( ZONE_NAME, zones.at( i ) ); + timeZoneImages.last().setText( ZONE_NAME, zoneName ); #endif } } @@ -111,8 +111,7 @@ TimeZoneWidget::setCurrentLocation( const CalamaresUtils::Locale::TZZone* locati QPoint pos = getLocationPosition( currentLocation.longitude, currentLocation.latitude ); #ifdef DEBUG_TIMEZONES - cDebug() << "Setting location" << location.region << location.zone << location.country; - cDebug() << Logger::SubEntry << "longitude" << location.longitude << "latitude" << location.latitude; + cDebug() << "Setting location" << location->region() << *location; cDebug() << Logger::SubEntry << "pixel x" << pos.x() << "pixel y" << pos.y(); bool found = false; From 93ae44e214699b8c2b54fa64c2e48436b479dd35 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 22:33:54 +0000 Subject: [PATCH 47/57] [libcalamares] Split translatable timezone data - Hide the one file from lupdate by giving it a weird suffix - Call lupdate a second time for the timezone translations - While here, adjust so that the options precede the directories they are supposed to affect I don't want to give the translation teams 444 new strings all at once (about 90% of which don't need translation). --- .tx/config | 6 ++++++ ci/txpush.sh | 4 +++- .../locale/{ZoneData_p.cpp => ZoneData_p.cxxtr} | 0 3 files changed, 9 insertions(+), 1 deletion(-) rename src/libcalamares/locale/{ZoneData_p.cpp => ZoneData_p.cxxtr} (100%) diff --git a/.tx/config b/.tx/config index 3cf9489f6..cdae01013 100644 --- a/.tx/config +++ b/.tx/config @@ -7,6 +7,12 @@ source_file = lang/calamares_en.ts source_lang = en type = QT +[calamares.tz] +file_filter = lang/tz_.ts +source_file = lang/tz_en.ts +source_lang = en +type = QT + [calamares.dummypythonqt] file_filter = src/modules/dummypythonqt/lang//LC_MESSAGES/dummypythonqt.po source_file = src/modules/dummypythonqt/lang/dummypythonqt.pot diff --git a/ci/txpush.sh b/ci/txpush.sh index 04e49921d..954e0b4b1 100755 --- a/ci/txpush.sh +++ b/ci/txpush.sh @@ -56,9 +56,11 @@ lupdate -version > /dev/null 2>&1 || { echo "! No working lupdate" ; lupdate -ve # Don't pull branding translations in, # those are done separately. _srcdirs="src/calamares src/libcalamares src/libcalamaresui src/modules src/qml" -lupdate $_srcdirs -ts -no-obsolete lang/calamares_en.ts +lupdate -no-obsolete $_srcdirs -ts lang/calamares_en.ts +lupdate -no-obsolete -extensions cxxtr src/libcalamares/locale -ts lang/tz_en.ts tx push --source --no-interactive -r calamares.calamares-master +tx push --source --no-interactive -r calamares.tz tx push --source --no-interactive -r calamares.fdo ### PYTHON MODULES diff --git a/src/libcalamares/locale/ZoneData_p.cpp b/src/libcalamares/locale/ZoneData_p.cxxtr similarity index 100% rename from src/libcalamares/locale/ZoneData_p.cpp rename to src/libcalamares/locale/ZoneData_p.cxxtr From 3e3334349baaa76cd9002c9dec4e0a85ec23cbe7 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 22:43:52 +0000 Subject: [PATCH 48/57] i18n: untranslated timezone names --- lang/tz_en.ts | 2617 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2617 insertions(+) create mode 100644 lang/tz_en.ts diff --git a/lang/tz_en.ts b/lang/tz_en.ts new file mode 100644 index 000000000..7e46eab3d --- /dev/null +++ b/lang/tz_en.ts @@ -0,0 +1,2617 @@ + + + + + QObject + + + Africa + tz_regions + + + + + America + tz_regions + + + + + Antarctica + tz_regions + + + + + Arctic + tz_regions + + + + + Asia + tz_regions + + + + + Atlantic + tz_regions + + + + + Australia + tz_regions + + + + + Europe + tz_regions + + + + + Indian + tz_regions + + + + + Pacific + tz_regions + + + + + Abidjan + tz_names + + + + + Accra + tz_names + + + + + Adak + tz_names + + + + + Addis Ababa + tz_names + + + + + Adelaide + tz_names + + + + + Aden + tz_names + + + + + Algiers + tz_names + + + + + Almaty + tz_names + + + + + Amman + tz_names + + + + + Amsterdam + tz_names + + + + + Anadyr + tz_names + + + + + Anchorage + tz_names + + + + + Andorra + tz_names + + + + + Anguilla + tz_names + + + + + Antananarivo + tz_names + + + + + Antigua + tz_names + + + + + Apia + tz_names + + + + + Aqtau + tz_names + + + + + Aqtobe + tz_names + + + + + Araguaina + tz_names + + + + + Argentina/Buenos Aires + tz_names + + + + + Argentina/Catamarca + tz_names + + + + + Argentina/Cordoba + tz_names + + + + + Argentina/Jujuy + tz_names + + + + + Argentina/La Rioja + tz_names + + + + + Argentina/Mendoza + tz_names + + + + + Argentina/Rio Gallegos + tz_names + + + + + Argentina/Salta + tz_names + + + + + Argentina/San Juan + tz_names + + + + + Argentina/San Luis + tz_names + + + + + Argentina/Tucuman + tz_names + + + + + Argentina/Ushuaia + tz_names + + + + + Aruba + tz_names + + + + + Ashgabat + tz_names + + + + + Asmara + tz_names + + + + + Astrakhan + tz_names + + + + + Asuncion + tz_names + + + + + Athens + tz_names + + + + + Atikokan + tz_names + + + + + Atyrau + tz_names + + + + + Auckland + tz_names + + + + + Azores + tz_names + + + + + Baghdad + tz_names + + + + + Bahia + tz_names + + + + + Bahia Banderas + tz_names + + + + + Bahrain + tz_names + + + + + Baku + tz_names + + + + + Bamako + tz_names + + + + + Bangkok + tz_names + + + + + Bangui + tz_names + + + + + Banjul + tz_names + + + + + Barbados + tz_names + + + + + Barnaul + tz_names + + + + + Beirut + tz_names + + + + + Belem + tz_names + + + + + Belgrade + tz_names + + + + + Belize + tz_names + + + + + Berlin + tz_names + + + + + Bermuda + tz_names + + + + + Bishkek + tz_names + + + + + Bissau + tz_names + + + + + Blanc-Sablon + tz_names + + + + + Blantyre + tz_names + + + + + Boa Vista + tz_names + + + + + Bogota + tz_names + + + + + Boise + tz_names + + + + + Bougainville + tz_names + + + + + Bratislava + tz_names + + + + + Brazzaville + tz_names + + + + + Brisbane + tz_names + + + + + Broken Hill + tz_names + + + + + Brunei + tz_names + + + + + Brussels + tz_names + + + + + Bucharest + tz_names + + + + + Budapest + tz_names + + + + + Bujumbura + tz_names + + + + + Busingen + tz_names + + + + + Cairo + tz_names + + + + + Cambridge Bay + tz_names + + + + + Campo Grande + tz_names + + + + + Canary + tz_names + + + + + Cancun + tz_names + + + + + Cape Verde + tz_names + + + + + Caracas + tz_names + + + + + Casablanca + tz_names + + + + + Casey + tz_names + + + + + Cayenne + tz_names + + + + + Cayman + tz_names + + + + + Ceuta + tz_names + + + + + Chagos + tz_names + + + + + Chatham + tz_names + + + + + Chicago + tz_names + + + + + Chihuahua + tz_names + + + + + Chisinau + tz_names + + + + + Chita + tz_names + + + + + Choibalsan + tz_names + + + + + Christmas + tz_names + + + + + Chuuk + tz_names + + + + + Cocos + tz_names + + + + + Colombo + tz_names + + + + + Comoro + tz_names + + + + + Conakry + tz_names + + + + + Copenhagen + tz_names + + + + + Costa Rica + tz_names + + + + + Creston + tz_names + + + + + Cuiaba + tz_names + + + + + Curacao + tz_names + + + + + Currie + tz_names + + + + + Dakar + tz_names + + + + + Damascus + tz_names + + + + + Danmarkshavn + tz_names + + + + + Dar es Salaam + tz_names + + + + + Darwin + tz_names + + + + + Davis + tz_names + + + + + Dawson + tz_names + + + + + Dawson Creek + tz_names + + + + + Denver + tz_names + + + + + Detroit + tz_names + + + + + Dhaka + tz_names + + + + + Dili + tz_names + + + + + Djibouti + tz_names + + + + + Dominica + tz_names + + + + + Douala + tz_names + + + + + Dubai + tz_names + + + + + Dublin + tz_names + + + + + DumontDUrville + tz_names + + + + + Dushanbe + tz_names + + + + + Easter + tz_names + + + + + Edmonton + tz_names + + + + + Efate + tz_names + + + + + Eirunepe + tz_names + + + + + El Aaiun + tz_names + + + + + El Salvador + tz_names + + + + + Enderbury + tz_names + + + + + Eucla + tz_names + + + + + Fakaofo + tz_names + + + + + Famagusta + tz_names + + + + + Faroe + tz_names + + + + + Fiji + tz_names + + + + + Fort Nelson + tz_names + + + + + Fortaleza + tz_names + + + + + Freetown + tz_names + + + + + Funafuti + tz_names + + + + + Gaborone + tz_names + + + + + Galapagos + tz_names + + + + + Gambier + tz_names + + + + + Gaza + tz_names + + + + + Gibraltar + tz_names + + + + + Glace Bay + tz_names + + + + + Godthab + tz_names + + + + + Goose Bay + tz_names + + + + + Grand Turk + tz_names + + + + + Grenada + tz_names + + + + + Guadalcanal + tz_names + + + + + Guadeloupe + tz_names + + + + + Guam + tz_names + + + + + Guatemala + tz_names + + + + + Guayaquil + tz_names + + + + + Guernsey + tz_names + + + + + Guyana + tz_names + + + + + Halifax + tz_names + + + + + Harare + tz_names + + + + + Havana + tz_names + + + + + Hebron + tz_names + + + + + Helsinki + tz_names + + + + + Hermosillo + tz_names + + + + + Ho Chi Minh + tz_names + + + + + Hobart + tz_names + + + + + Hong Kong + tz_names + + + + + Honolulu + tz_names + + + + + Hovd + tz_names + + + + + Indiana/Indianapolis + tz_names + + + + + Indiana/Knox + tz_names + + + + + Indiana/Marengo + tz_names + + + + + Indiana/Petersburg + tz_names + + + + + Indiana/Tell City + tz_names + + + + + Indiana/Vevay + tz_names + + + + + Indiana/Vincennes + tz_names + + + + + Indiana/Winamac + tz_names + + + + + Inuvik + tz_names + + + + + Iqaluit + tz_names + + + + + Irkutsk + tz_names + + + + + Isle of Man + tz_names + + + + + Istanbul + tz_names + + + + + Jakarta + tz_names + + + + + Jamaica + tz_names + + + + + Jayapura + tz_names + + + + + Jersey + tz_names + + + + + Jerusalem + tz_names + + + + + Johannesburg + tz_names + + + + + Juba + tz_names + + + + + Juneau + tz_names + + + + + Kabul + tz_names + + + + + Kaliningrad + tz_names + + + + + Kamchatka + tz_names + + + + + Kampala + tz_names + + + + + Karachi + tz_names + + + + + Kathmandu + tz_names + + + + + Kentucky/Louisville + tz_names + + + + + Kentucky/Monticello + tz_names + + + + + Kerguelen + tz_names + + + + + Khandyga + tz_names + + + + + Khartoum + tz_names + + + + + Kiev + tz_names + + + + + Kigali + tz_names + + + + + Kinshasa + tz_names + + + + + Kiritimati + tz_names + + + + + Kirov + tz_names + + + + + Kolkata + tz_names + + + + + Kosrae + tz_names + + + + + Kralendijk + tz_names + + + + + Krasnoyarsk + tz_names + + + + + Kuala Lumpur + tz_names + + + + + Kuching + tz_names + + + + + Kuwait + tz_names + + + + + Kwajalein + tz_names + + + + + La Paz + tz_names + + + + + Lagos + tz_names + + + + + Libreville + tz_names + + + + + Lima + tz_names + + + + + Lindeman + tz_names + + + + + Lisbon + tz_names + + + + + Ljubljana + tz_names + + + + + Lome + tz_names + + + + + London + tz_names + + + + + Longyearbyen + tz_names + + + + + Lord Howe + tz_names + + + + + Los Angeles + tz_names + + + + + Lower Princes + tz_names + + + + + Luanda + tz_names + + + + + Lubumbashi + tz_names + + + + + Lusaka + tz_names + + + + + Luxembourg + tz_names + + + + + Macau + tz_names + + + + + Maceio + tz_names + + + + + Macquarie + tz_names + + + + + Madeira + tz_names + + + + + Madrid + tz_names + + + + + Magadan + tz_names + + + + + Mahe + tz_names + + + + + Majuro + tz_names + + + + + Makassar + tz_names + + + + + Malabo + tz_names + + + + + Maldives + tz_names + + + + + Malta + tz_names + + + + + Managua + tz_names + + + + + Manaus + tz_names + + + + + Manila + tz_names + + + + + Maputo + tz_names + + + + + Mariehamn + tz_names + + + + + Marigot + tz_names + + + + + Marquesas + tz_names + + + + + Martinique + tz_names + + + + + Maseru + tz_names + + + + + Matamoros + tz_names + + + + + Mauritius + tz_names + + + + + Mawson + tz_names + + + + + Mayotte + tz_names + + + + + Mazatlan + tz_names + + + + + Mbabane + tz_names + + + + + McMurdo + tz_names + + + + + Melbourne + tz_names + + + + + Menominee + tz_names + + + + + Merida + tz_names + + + + + Metlakatla + tz_names + + + + + Mexico City + tz_names + + + + + Midway + tz_names + + + + + Minsk + tz_names + + + + + Miquelon + tz_names + + + + + Mogadishu + tz_names + + + + + Monaco + tz_names + + + + + Moncton + tz_names + + + + + Monrovia + tz_names + + + + + Monterrey + tz_names + + + + + Montevideo + tz_names + + + + + Montserrat + tz_names + + + + + Moscow + tz_names + + + + + Muscat + tz_names + + + + + Nairobi + tz_names + + + + + Nassau + tz_names + + + + + Nauru + tz_names + + + + + Ndjamena + tz_names + + + + + New York + tz_names + + + + + Niamey + tz_names + + + + + Nicosia + tz_names + + + + + Nipigon + tz_names + + + + + Niue + tz_names + + + + + Nome + tz_names + + + + + Norfolk + tz_names + + + + + Noronha + tz_names + + + + + North Dakota/Beulah + tz_names + + + + + North Dakota/Center + tz_names + + + + + North Dakota/New Salem + tz_names + + + + + Nouakchott + tz_names + + + + + Noumea + tz_names + + + + + Novokuznetsk + tz_names + + + + + Novosibirsk + tz_names + + + + + Ojinaga + tz_names + + + + + Omsk + tz_names + + + + + Oral + tz_names + + + + + Oslo + tz_names + + + + + Ouagadougou + tz_names + + + + + Pago Pago + tz_names + + + + + Palau + tz_names + + + + + Palmer + tz_names + + + + + Panama + tz_names + + + + + Pangnirtung + tz_names + + + + + Paramaribo + tz_names + + + + + Paris + tz_names + + + + + Perth + tz_names + + + + + Phnom Penh + tz_names + + + + + Phoenix + tz_names + + + + + Pitcairn + tz_names + + + + + Podgorica + tz_names + + + + + Pohnpei + tz_names + + + + + Pontianak + tz_names + + + + + Port Moresby + tz_names + + + + + Port of Spain + tz_names + + + + + Port-au-Prince + tz_names + + + + + Porto Velho + tz_names + + + + + Porto-Novo + tz_names + + + + + Prague + tz_names + + + + + Puerto Rico + tz_names + + + + + Punta Arenas + tz_names + + + + + Pyongyang + tz_names + + + + + Qatar + tz_names + + + + + Qostanay + tz_names + + + + + Qyzylorda + tz_names + + + + + Rainy River + tz_names + + + + + Rankin Inlet + tz_names + + + + + Rarotonga + tz_names + + + + + Recife + tz_names + + + + + Regina + tz_names + + + + + Resolute + tz_names + + + + + Reunion + tz_names + + + + + Reykjavik + tz_names + + + + + Riga + tz_names + + + + + Rio Branco + tz_names + + + + + Riyadh + tz_names + + + + + Rome + tz_names + + + + + Rothera + tz_names + + + + + Saipan + tz_names + + + + + Sakhalin + tz_names + + + + + Samara + tz_names + + + + + Samarkand + tz_names + + + + + San Marino + tz_names + + + + + Santarem + tz_names + + + + + Santiago + tz_names + + + + + Santo Domingo + tz_names + + + + + Sao Paulo + tz_names + + + + + Sao Tome + tz_names + + + + + Sarajevo + tz_names + + + + + Saratov + tz_names + + + + + Scoresbysund + tz_names + + + + + Seoul + tz_names + + + + + Shanghai + tz_names + + + + + Simferopol + tz_names + + + + + Singapore + tz_names + + + + + Sitka + tz_names + + + + + Skopje + tz_names + + + + + Sofia + tz_names + + + + + South Georgia + tz_names + + + + + Srednekolymsk + tz_names + + + + + St Barthelemy + tz_names + + + + + St Helena + tz_names + + + + + St Johns + tz_names + + + + + St Kitts + tz_names + + + + + St Lucia + tz_names + + + + + St Thomas + tz_names + + + + + St Vincent + tz_names + + + + + Stanley + tz_names + + + + + Stockholm + tz_names + + + + + Swift Current + tz_names + + + + + Sydney + tz_names + + + + + Syowa + tz_names + + + + + Tahiti + tz_names + + + + + Taipei + tz_names + + + + + Tallinn + tz_names + + + + + Tarawa + tz_names + + + + + Tashkent + tz_names + + + + + Tbilisi + tz_names + + + + + Tegucigalpa + tz_names + + + + + Tehran + tz_names + + + + + Thimphu + tz_names + + + + + Thule + tz_names + + + + + Thunder Bay + tz_names + + + + + Tijuana + tz_names + + + + + Tirane + tz_names + + + + + Tokyo + tz_names + + + + + Tomsk + tz_names + + + + + Tongatapu + tz_names + + + + + Toronto + tz_names + + + + + Tortola + tz_names + + + + + Tripoli + tz_names + + + + + Troll + tz_names + + + + + Tunis + tz_names + + + + + Ulaanbaatar + tz_names + + + + + Ulyanovsk + tz_names + + + + + Urumqi + tz_names + + + + + Ust-Nera + tz_names + + + + + Uzhgorod + tz_names + + + + + Vaduz + tz_names + + + + + Vancouver + tz_names + + + + + Vatican + tz_names + + + + + Vienna + tz_names + + + + + Vientiane + tz_names + + + + + Vilnius + tz_names + + + + + Vladivostok + tz_names + + + + + Volgograd + tz_names + + + + + Vostok + tz_names + + + + + Wake + tz_names + + + + + Wallis + tz_names + + + + + Warsaw + tz_names + + + + + Whitehorse + tz_names + + + + + Windhoek + tz_names + + + + + Winnipeg + tz_names + + + + + Yakutat + tz_names + + + + + Yakutsk + tz_names + + + + + Yangon + tz_names + + + + + Yekaterinburg + tz_names + + + + + Yellowknife + tz_names + + + + + Yerevan + tz_names + + + + + Zagreb + tz_names + + + + + Zaporozhye + tz_names + + + + + Zurich + tz_names + + + + From 93826c3c2aab96ec615ae8595d921a5b200b488b Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 10 Dec 2019 23:23:43 +0000 Subject: [PATCH 49/57] i18n: Dutch TZ translations (provisional) --- lang/tz_nl.ts | 2617 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 2617 insertions(+) create mode 100644 lang/tz_nl.ts diff --git a/lang/tz_nl.ts b/lang/tz_nl.ts new file mode 100644 index 000000000..e1eb8d1e5 --- /dev/null +++ b/lang/tz_nl.ts @@ -0,0 +1,2617 @@ + + + + + QObject + + + Africa + tz_regions + Afrika + + + + America + tz_regions + Amerika + + + + Antarctica + tz_regions + + + + + Arctic + tz_regions + + + + + Asia + tz_regions + Azië + + + + Atlantic + tz_regions + Atlantisch + + + + Australia + tz_regions + Australië + + + + Europe + tz_regions + Europa + + + + Indian + tz_regions + + + + + Pacific + tz_regions + Stille Oceaan + + + + Abidjan + tz_names + + + + + Accra + tz_names + + + + + Adak + tz_names + + + + + Addis Ababa + tz_names + + + + + Adelaide + tz_names + + + + + Aden + tz_names + + + + + Algiers + tz_names + + + + + Almaty + tz_names + + + + + Amman + tz_names + + + + + Amsterdam + tz_names + + + + + Anadyr + tz_names + + + + + Anchorage + tz_names + + + + + Andorra + tz_names + + + + + Anguilla + tz_names + + + + + Antananarivo + tz_names + + + + + Antigua + tz_names + + + + + Apia + tz_names + + + + + Aqtau + tz_names + + + + + Aqtobe + tz_names + + + + + Araguaina + tz_names + + + + + Argentina/Buenos Aires + tz_names + + + + + Argentina/Catamarca + tz_names + + + + + Argentina/Cordoba + tz_names + + + + + Argentina/Jujuy + tz_names + + + + + Argentina/La Rioja + tz_names + + + + + Argentina/Mendoza + tz_names + + + + + Argentina/Rio Gallegos + tz_names + + + + + Argentina/Salta + tz_names + + + + + Argentina/San Juan + tz_names + + + + + Argentina/San Luis + tz_names + + + + + Argentina/Tucuman + tz_names + + + + + Argentina/Ushuaia + tz_names + + + + + Aruba + tz_names + + + + + Ashgabat + tz_names + + + + + Asmara + tz_names + + + + + Astrakhan + tz_names + + + + + Asuncion + tz_names + + + + + Athens + tz_names + + + + + Atikokan + tz_names + + + + + Atyrau + tz_names + + + + + Auckland + tz_names + + + + + Azores + tz_names + + + + + Baghdad + tz_names + + + + + Bahia + tz_names + + + + + Bahia Banderas + tz_names + + + + + Bahrain + tz_names + + + + + Baku + tz_names + + + + + Bamako + tz_names + + + + + Bangkok + tz_names + + + + + Bangui + tz_names + + + + + Banjul + tz_names + + + + + Barbados + tz_names + + + + + Barnaul + tz_names + + + + + Beirut + tz_names + + + + + Belem + tz_names + + + + + Belgrade + tz_names + + + + + Belize + tz_names + + + + + Berlin + tz_names + Berlijn + + + + Bermuda + tz_names + + + + + Bishkek + tz_names + + + + + Bissau + tz_names + + + + + Blanc-Sablon + tz_names + + + + + Blantyre + tz_names + + + + + Boa Vista + tz_names + + + + + Bogota + tz_names + + + + + Boise + tz_names + + + + + Bougainville + tz_names + + + + + Bratislava + tz_names + + + + + Brazzaville + tz_names + + + + + Brisbane + tz_names + + + + + Broken Hill + tz_names + + + + + Brunei + tz_names + + + + + Brussels + tz_names + + + + + Bucharest + tz_names + + + + + Budapest + tz_names + + + + + Bujumbura + tz_names + + + + + Busingen + tz_names + + + + + Cairo + tz_names + + + + + Cambridge Bay + tz_names + + + + + Campo Grande + tz_names + + + + + Canary + tz_names + + + + + Cancun + tz_names + + + + + Cape Verde + tz_names + + + + + Caracas + tz_names + + + + + Casablanca + tz_names + + + + + Casey + tz_names + + + + + Cayenne + tz_names + + + + + Cayman + tz_names + + + + + Ceuta + tz_names + + + + + Chagos + tz_names + + + + + Chatham + tz_names + + + + + Chicago + tz_names + + + + + Chihuahua + tz_names + + + + + Chisinau + tz_names + + + + + Chita + tz_names + + + + + Choibalsan + tz_names + + + + + Christmas + tz_names + + + + + Chuuk + tz_names + + + + + Cocos + tz_names + + + + + Colombo + tz_names + + + + + Comoro + tz_names + + + + + Conakry + tz_names + + + + + Copenhagen + tz_names + + + + + Costa Rica + tz_names + + + + + Creston + tz_names + + + + + Cuiaba + tz_names + + + + + Curacao + tz_names + + + + + Currie + tz_names + + + + + Dakar + tz_names + + + + + Damascus + tz_names + + + + + Danmarkshavn + tz_names + + + + + Dar es Salaam + tz_names + + + + + Darwin + tz_names + + + + + Davis + tz_names + + + + + Dawson + tz_names + + + + + Dawson Creek + tz_names + + + + + Denver + tz_names + + + + + Detroit + tz_names + + + + + Dhaka + tz_names + + + + + Dili + tz_names + + + + + Djibouti + tz_names + + + + + Dominica + tz_names + + + + + Douala + tz_names + + + + + Dubai + tz_names + + + + + Dublin + tz_names + + + + + DumontDUrville + tz_names + + + + + Dushanbe + tz_names + + + + + Easter + tz_names + + + + + Edmonton + tz_names + + + + + Efate + tz_names + + + + + Eirunepe + tz_names + + + + + El Aaiun + tz_names + + + + + El Salvador + tz_names + + + + + Enderbury + tz_names + + + + + Eucla + tz_names + + + + + Fakaofo + tz_names + + + + + Famagusta + tz_names + + + + + Faroe + tz_names + + + + + Fiji + tz_names + + + + + Fort Nelson + tz_names + + + + + Fortaleza + tz_names + + + + + Freetown + tz_names + + + + + Funafuti + tz_names + + + + + Gaborone + tz_names + + + + + Galapagos + tz_names + + + + + Gambier + tz_names + + + + + Gaza + tz_names + + + + + Gibraltar + tz_names + + + + + Glace Bay + tz_names + + + + + Godthab + tz_names + + + + + Goose Bay + tz_names + + + + + Grand Turk + tz_names + + + + + Grenada + tz_names + + + + + Guadalcanal + tz_names + + + + + Guadeloupe + tz_names + + + + + Guam + tz_names + + + + + Guatemala + tz_names + + + + + Guayaquil + tz_names + + + + + Guernsey + tz_names + + + + + Guyana + tz_names + + + + + Halifax + tz_names + + + + + Harare + tz_names + + + + + Havana + tz_names + + + + + Hebron + tz_names + + + + + Helsinki + tz_names + + + + + Hermosillo + tz_names + + + + + Ho Chi Minh + tz_names + + + + + Hobart + tz_names + + + + + Hong Kong + tz_names + + + + + Honolulu + tz_names + + + + + Hovd + tz_names + + + + + Indiana/Indianapolis + tz_names + + + + + Indiana/Knox + tz_names + + + + + Indiana/Marengo + tz_names + + + + + Indiana/Petersburg + tz_names + + + + + Indiana/Tell City + tz_names + + + + + Indiana/Vevay + tz_names + + + + + Indiana/Vincennes + tz_names + + + + + Indiana/Winamac + tz_names + + + + + Inuvik + tz_names + + + + + Iqaluit + tz_names + + + + + Irkutsk + tz_names + + + + + Isle of Man + tz_names + + + + + Istanbul + tz_names + + + + + Jakarta + tz_names + + + + + Jamaica + tz_names + + + + + Jayapura + tz_names + + + + + Jersey + tz_names + + + + + Jerusalem + tz_names + + + + + Johannesburg + tz_names + + + + + Juba + tz_names + + + + + Juneau + tz_names + + + + + Kabul + tz_names + + + + + Kaliningrad + tz_names + + + + + Kamchatka + tz_names + + + + + Kampala + tz_names + + + + + Karachi + tz_names + + + + + Kathmandu + tz_names + + + + + Kentucky/Louisville + tz_names + + + + + Kentucky/Monticello + tz_names + + + + + Kerguelen + tz_names + + + + + Khandyga + tz_names + + + + + Khartoum + tz_names + + + + + Kiev + tz_names + + + + + Kigali + tz_names + + + + + Kinshasa + tz_names + + + + + Kiritimati + tz_names + + + + + Kirov + tz_names + + + + + Kolkata + tz_names + + + + + Kosrae + tz_names + + + + + Kralendijk + tz_names + + + + + Krasnoyarsk + tz_names + + + + + Kuala Lumpur + tz_names + + + + + Kuching + tz_names + + + + + Kuwait + tz_names + + + + + Kwajalein + tz_names + + + + + La Paz + tz_names + + + + + Lagos + tz_names + + + + + Libreville + tz_names + + + + + Lima + tz_names + + + + + Lindeman + tz_names + + + + + Lisbon + tz_names + + + + + Ljubljana + tz_names + + + + + Lome + tz_names + + + + + London + tz_names + + + + + Longyearbyen + tz_names + + + + + Lord Howe + tz_names + + + + + Los Angeles + tz_names + + + + + Lower Princes + tz_names + + + + + Luanda + tz_names + + + + + Lubumbashi + tz_names + + + + + Lusaka + tz_names + + + + + Luxembourg + tz_names + + + + + Macau + tz_names + + + + + Maceio + tz_names + + + + + Macquarie + tz_names + + + + + Madeira + tz_names + + + + + Madrid + tz_names + + + + + Magadan + tz_names + + + + + Mahe + tz_names + + + + + Majuro + tz_names + + + + + Makassar + tz_names + + + + + Malabo + tz_names + + + + + Maldives + tz_names + + + + + Malta + tz_names + + + + + Managua + tz_names + + + + + Manaus + tz_names + + + + + Manila + tz_names + + + + + Maputo + tz_names + + + + + Mariehamn + tz_names + + + + + Marigot + tz_names + + + + + Marquesas + tz_names + + + + + Martinique + tz_names + + + + + Maseru + tz_names + + + + + Matamoros + tz_names + + + + + Mauritius + tz_names + + + + + Mawson + tz_names + + + + + Mayotte + tz_names + + + + + Mazatlan + tz_names + + + + + Mbabane + tz_names + + + + + McMurdo + tz_names + + + + + Melbourne + tz_names + + + + + Menominee + tz_names + + + + + Merida + tz_names + + + + + Metlakatla + tz_names + + + + + Mexico City + tz_names + + + + + Midway + tz_names + + + + + Minsk + tz_names + + + + + Miquelon + tz_names + + + + + Mogadishu + tz_names + + + + + Monaco + tz_names + + + + + Moncton + tz_names + + + + + Monrovia + tz_names + + + + + Monterrey + tz_names + + + + + Montevideo + tz_names + + + + + Montserrat + tz_names + + + + + Moscow + tz_names + + + + + Muscat + tz_names + + + + + Nairobi + tz_names + + + + + Nassau + tz_names + + + + + Nauru + tz_names + + + + + Ndjamena + tz_names + + + + + New York + tz_names + + + + + Niamey + tz_names + + + + + Nicosia + tz_names + + + + + Nipigon + tz_names + + + + + Niue + tz_names + + + + + Nome + tz_names + + + + + Norfolk + tz_names + + + + + Noronha + tz_names + + + + + North Dakota/Beulah + tz_names + + + + + North Dakota/Center + tz_names + + + + + North Dakota/New Salem + tz_names + + + + + Nouakchott + tz_names + + + + + Noumea + tz_names + + + + + Novokuznetsk + tz_names + + + + + Novosibirsk + tz_names + + + + + Ojinaga + tz_names + + + + + Omsk + tz_names + + + + + Oral + tz_names + + + + + Oslo + tz_names + + + + + Ouagadougou + tz_names + + + + + Pago Pago + tz_names + + + + + Palau + tz_names + + + + + Palmer + tz_names + + + + + Panama + tz_names + + + + + Pangnirtung + tz_names + + + + + Paramaribo + tz_names + + + + + Paris + tz_names + Parijs + + + + Perth + tz_names + + + + + Phnom Penh + tz_names + + + + + Phoenix + tz_names + + + + + Pitcairn + tz_names + + + + + Podgorica + tz_names + + + + + Pohnpei + tz_names + + + + + Pontianak + tz_names + + + + + Port Moresby + tz_names + + + + + Port of Spain + tz_names + + + + + Port-au-Prince + tz_names + + + + + Porto Velho + tz_names + + + + + Porto-Novo + tz_names + + + + + Prague + tz_names + + + + + Puerto Rico + tz_names + + + + + Punta Arenas + tz_names + + + + + Pyongyang + tz_names + + + + + Qatar + tz_names + + + + + Qostanay + tz_names + + + + + Qyzylorda + tz_names + + + + + Rainy River + tz_names + + + + + Rankin Inlet + tz_names + + + + + Rarotonga + tz_names + + + + + Recife + tz_names + + + + + Regina + tz_names + + + + + Resolute + tz_names + + + + + Reunion + tz_names + + + + + Reykjavik + tz_names + + + + + Riga + tz_names + + + + + Rio Branco + tz_names + + + + + Riyadh + tz_names + + + + + Rome + tz_names + + + + + Rothera + tz_names + + + + + Saipan + tz_names + + + + + Sakhalin + tz_names + + + + + Samara + tz_names + + + + + Samarkand + tz_names + + + + + San Marino + tz_names + + + + + Santarem + tz_names + + + + + Santiago + tz_names + + + + + Santo Domingo + tz_names + + + + + Sao Paulo + tz_names + + + + + Sao Tome + tz_names + + + + + Sarajevo + tz_names + + + + + Saratov + tz_names + + + + + Scoresbysund + tz_names + + + + + Seoul + tz_names + + + + + Shanghai + tz_names + + + + + Simferopol + tz_names + + + + + Singapore + tz_names + + + + + Sitka + tz_names + + + + + Skopje + tz_names + + + + + Sofia + tz_names + + + + + South Georgia + tz_names + + + + + Srednekolymsk + tz_names + + + + + St Barthelemy + tz_names + + + + + St Helena + tz_names + + + + + St Johns + tz_names + + + + + St Kitts + tz_names + + + + + St Lucia + tz_names + + + + + St Thomas + tz_names + + + + + St Vincent + tz_names + + + + + Stanley + tz_names + + + + + Stockholm + tz_names + + + + + Swift Current + tz_names + + + + + Sydney + tz_names + + + + + Syowa + tz_names + + + + + Tahiti + tz_names + + + + + Taipei + tz_names + + + + + Tallinn + tz_names + + + + + Tarawa + tz_names + + + + + Tashkent + tz_names + + + + + Tbilisi + tz_names + + + + + Tegucigalpa + tz_names + + + + + Tehran + tz_names + + + + + Thimphu + tz_names + + + + + Thule + tz_names + + + + + Thunder Bay + tz_names + + + + + Tijuana + tz_names + + + + + Tirane + tz_names + + + + + Tokyo + tz_names + + + + + Tomsk + tz_names + + + + + Tongatapu + tz_names + + + + + Toronto + tz_names + + + + + Tortola + tz_names + + + + + Tripoli + tz_names + + + + + Troll + tz_names + + + + + Tunis + tz_names + + + + + Ulaanbaatar + tz_names + + + + + Ulyanovsk + tz_names + + + + + Urumqi + tz_names + + + + + Ust-Nera + tz_names + + + + + Uzhgorod + tz_names + + + + + Vaduz + tz_names + + + + + Vancouver + tz_names + + + + + Vatican + tz_names + + + + + Vienna + tz_names + + + + + Vientiane + tz_names + + + + + Vilnius + tz_names + + + + + Vladivostok + tz_names + + + + + Volgograd + tz_names + + + + + Vostok + tz_names + + + + + Wake + tz_names + + + + + Wallis + tz_names + + + + + Warsaw + tz_names + + + + + Whitehorse + tz_names + + + + + Windhoek + tz_names + + + + + Winnipeg + tz_names + + + + + Yakutat + tz_names + + + + + Yakutsk + tz_names + + + + + Yangon + tz_names + + + + + Yekaterinburg + tz_names + + + + + Yellowknife + tz_names + + + + + Yerevan + tz_names + + + + + Zagreb + tz_names + + + + + Zaporozhye + tz_names + + + + + Zurich + tz_names + + + + From 8fc94900d3a7e19d4f88c80c251cb81859dd6f1c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Dec 2019 06:39:57 -0500 Subject: [PATCH 50/57] CMake: add the tz_ translation files to the i18n build --- CMakeModules/CalamaresAddTranslations.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeModules/CalamaresAddTranslations.cmake b/CMakeModules/CalamaresAddTranslations.cmake index 4892cc0f9..d74e4bdfb 100644 --- a/CMakeModules/CalamaresAddTranslations.cmake +++ b/CMakeModules/CalamaresAddTranslations.cmake @@ -67,8 +67,12 @@ macro(add_calamares_translations language) # calamares and qt language files set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}\n" ) foreach( lang ${CALAMARES_LANGUAGES} ) - set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}calamares_${lang}.qm\n" ) - list( APPEND TS_FILES "${CMAKE_SOURCE_DIR}/lang/calamares_${lang}.ts" ) + foreach( tlsource "calamares_${lang}" "tz_${lang}" ) + if( EXISTS "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" ) + set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}${tlsource}.qm\n" ) + list( APPEND TS_FILES "${CMAKE_SOURCE_DIR}/lang/${tlsource}.ts" ) + endif() + endforeach() endforeach() set( calamares_i18n_qrc_content "${calamares_i18n_qrc_content}\n" ) From 0ed2a3e35f56db9cc173a725187f63a3ba770997 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Dec 2019 06:40:22 -0500 Subject: [PATCH 51/57] [libcalamares] Refactor translation-setting - Split the actual loading of translations into classes to encapsulate the loading logic, - Build a collection of classes to do the different kinds of translation loading, - Build a generic function to load something and update a static pointer to the translation. This makes installTranslator() much easier to read, and encapsulates the type-specific loading somewhere else. While here, add a timezone- translations loader so that the split-out TZ translations also work. --- src/libcalamares/utils/Retranslator.cpp | 212 ++++++++++++++++-------- 1 file changed, 139 insertions(+), 73 deletions(-) diff --git a/src/libcalamares/utils/Retranslator.cpp b/src/libcalamares/utils/Retranslator.cpp index d761263ac..047f642e4 100644 --- a/src/libcalamares/utils/Retranslator.cpp +++ b/src/libcalamares/utils/Retranslator.cpp @@ -25,90 +25,156 @@ #include #include +/** @brief Helper class for loading translations + * + * This is used by the loadSingletonTranslator() function to hand off + * work to translation-type specific code. + */ +struct TranslationLoader +{ + static QString mungeLocaleName( const QLocale& locale ) + { + QString localeName = locale.name(); + localeName.replace( "-", "_" ); + + if ( localeName == "C" ) + { + localeName = "en"; + } + + // Special case of sr@latin + // + // See top-level CMakeLists.txt about special cases for translation loading. + if ( locale.language() == QLocale::Language::Serbian && locale.script() == QLocale::Script::LatinScript ) + { + localeName = QStringLiteral( "sr@latin" ); + } + return localeName; + } + + TranslationLoader( const QLocale& locale ) + : m_locale( locale ) + , m_localeName( mungeLocaleName( locale ) ) + { + } + + virtual ~TranslationLoader() {}; + /// @brief Loads @p translator with the specific translations of this type + virtual bool tryLoad( QTranslator* translator ) = 0; + + const QLocale& m_locale; + QString m_localeName; +}; + +struct BrandingLoader : public TranslationLoader +{ + BrandingLoader( const QLocale& locale, const QString& prefix ) + : TranslationLoader( locale ) + , m_prefix( prefix ) + { + } + + bool tryLoad( QTranslator* translator ) override + { + if ( m_prefix.isEmpty() ) + { + return false; + } + QString brandingTranslationsDirPath( m_prefix ); + brandingTranslationsDirPath.truncate( m_prefix.lastIndexOf( QDir::separator() ) ); + QDir brandingTranslationsDir( brandingTranslationsDirPath ); + if ( brandingTranslationsDir.exists() ) + { + QString filenameBase( m_prefix ); + filenameBase.remove( 0, m_prefix.lastIndexOf( QDir::separator() ) + 1 ); + if ( translator->load( m_locale, filenameBase, "_", brandingTranslationsDir.absolutePath() ) ) + { + cDebug() << Logger::SubEntry << "Branding using locale:" << m_localeName; + return true; + } + else + { + cDebug() << Logger::SubEntry << "Branding using default, system locale not found:" << m_localeName; + // TODO: this loads something completely different + return translator->load( m_prefix + "en" ); + } + } + return false; + } + + QString m_prefix; +}; + +struct CalamaresLoader : public TranslationLoader +{ + using TranslationLoader::TranslationLoader; + + bool tryLoad( QTranslator* translator ) override + { + if ( translator->load( QString( ":/lang/calamares_" ) + m_localeName ) ) + { + cDebug() << Logger::SubEntry << "Calamares using locale:" << m_localeName; + return true; + } + else + { + cDebug() << Logger::SubEntry << "Calamares using default, system locale not found:" << m_localeName; + return translator->load( QString( ":/lang/calamares_en" ) ); + } + } +}; + +struct TZLoader : public TranslationLoader +{ + using TranslationLoader::TranslationLoader; + bool tryLoad( QTranslator* translator ) override + { + if ( translator->load( QString( ":/lang/tz_" ) + m_localeName ) ) + { + cDebug() << Logger::SubEntry << "Calamares Timezones using locale:" << m_localeName; + return true; + } + else + { + cDebug() << Logger::SubEntry + << "Calamares Timezones using default, system locale not found:" << m_localeName; + return translator->load( QString( ":/lang/tz_en" ) ); + } + } +}; + +static void +loadSingletonTranslator( TranslationLoader&& loader, QTranslator*& translator_p ) +{ + QTranslator* translator = new QTranslator(); + loader.tryLoad( translator ); + + if ( translator_p ) + { + QCoreApplication::removeTranslator( translator_p ); + delete translator_p; + } + + QCoreApplication::installTranslator( translator ); + translator_p = translator; +} namespace CalamaresUtils { static QTranslator* s_brandingTranslator = nullptr; static QTranslator* s_translator = nullptr; +static QTranslator* s_tztranslator = nullptr; static QString s_translatorLocaleName; void installTranslator( const QLocale& locale, const QString& brandingTranslationsPrefix, QObject* parent ) { - QString localeName = locale.name(); - localeName.replace( "-", "_" ); + loadSingletonTranslator( BrandingLoader( locale, brandingTranslationsPrefix ), s_brandingTranslator ); + loadSingletonTranslator( TZLoader( locale ), s_tztranslator ); - if ( localeName == "C" ) - { - localeName = "en"; - } - - // Special case of sr@latin - // - // See top-level CMakeLists.txt about special cases for translation loading. - if ( locale.language() == QLocale::Language::Serbian && locale.script() == QLocale::Script::LatinScript ) - { - localeName = QStringLiteral( "sr@latin" ); - } - - cDebug() << "Looking for translations for" << localeName; - - QTranslator* translator = nullptr; - - // Branding translations - if ( !brandingTranslationsPrefix.isEmpty() ) - { - QString brandingTranslationsDirPath( brandingTranslationsPrefix ); - brandingTranslationsDirPath.truncate( brandingTranslationsPrefix.lastIndexOf( QDir::separator() ) ); - QDir brandingTranslationsDir( brandingTranslationsDirPath ); - if ( brandingTranslationsDir.exists() ) - { - QString filenameBase( brandingTranslationsPrefix ); - filenameBase.remove( 0, brandingTranslationsPrefix.lastIndexOf( QDir::separator() ) + 1 ); - translator = new QTranslator( parent ); - if ( translator->load( locale, filenameBase, "_", brandingTranslationsDir.absolutePath() ) ) - { - cDebug() << Logger::SubEntry << "Branding using locale:" << localeName; - } - else - { - cDebug() << Logger::SubEntry << "Branding using default, system locale not found:" << localeName; - translator->load( brandingTranslationsPrefix + "en" ); - } - - if ( s_brandingTranslator ) - { - QCoreApplication::removeTranslator( s_brandingTranslator ); - delete s_brandingTranslator; - } - - QCoreApplication::installTranslator( translator ); - s_brandingTranslator = translator; - } - } - - // Calamares translations - translator = new QTranslator( parent ); - if ( translator->load( QString( ":/lang/calamares_" ) + localeName ) ) - { - cDebug() << Logger::SubEntry << "Calamares using locale:" << localeName; - } - else - { - cDebug() << Logger::SubEntry << "Calamares using default, system locale not found:" << localeName; - translator->load( QString( ":/lang/calamares_en" ) ); - } - - if ( s_translator ) - { - QCoreApplication::removeTranslator( s_translator ); - delete s_translator; - } - - QCoreApplication::installTranslator( translator ); - s_translator = translator; - - s_translatorLocaleName = localeName; + CalamaresLoader l( locale ); // because we want the extracted localeName + loadSingletonTranslator( std::move( l ), s_translator ); + s_translatorLocaleName = l.m_localeName; } From daa76080f1b413697d49eddb23b7925891afad33 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Dec 2019 07:00:42 -0500 Subject: [PATCH 52/57] [libcalamares] Add meaningful aliases for key() --- src/libcalamares/locale/TimeZone.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 73e73cf85..248c6b582 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -91,6 +91,8 @@ public: virtual ~TZRegion(); QString tr() const override; + QString region() const { return key(); } + /** @brief Create list from a zone.tab-like file * * Returns a list of all the regions; each region has a list @@ -121,6 +123,7 @@ public: TZZone( const QString& region, const char* zoneName, const QString& country, QString position ); QString region() const { return m_region; } + QString zone() const { return key(); } QString country() const { return m_country; } double latitude() const { return m_latitude; } double longitude() const { return m_longitude; } From 4945408911c40e723ed7cd8aa910ef46e4383e62 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Dec 2019 07:01:15 -0500 Subject: [PATCH 53/57] [libcalamares] Remove debugging cruft --- src/libcalamares/locale/TimeZone.cpp | 6 ------ src/libcalamares/locale/TimeZone.h | 9 --------- 2 files changed, 15 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index a9550ebb6..05aeaf885 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -234,12 +234,6 @@ TZZone::tr() const return QObject::tr( m_human, "tz_names" ); } -void -TZZone::print( QDebug& log ) const -{ - log << key() << '(' << m_country << ' ' << m_latitude << ',' << m_longitude << ')'; -} - CStringListModel::CStringListModel( CStringPairList l ) : m_list( l ) diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 248c6b582..567b42241 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -128,21 +128,12 @@ public: double latitude() const { return m_latitude; } double longitude() const { return m_longitude; } - void print( QDebug& ) const; - protected: QString m_region; QString m_country; double m_latitude = 0.0, m_longitude = 0.0; }; -inline QDebug& -operator<<( QDebug& log, const TZZone& z ) -{ - z.print( log ); - return log; -} - class CStringListModel : public QAbstractListModel { public: From 242b79e2e1292a6f926229c29063473fb94a11fc Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Dec 2019 08:36:23 -0500 Subject: [PATCH 54/57] [locale] Remove old Location information - all the TZ location information now lives in the Calamares locale service and the TZ list - replace the Location class that was local to the timezone widget by the TZZone class - chase a bunch of small API changes that this needs --- src/modules/locale/LocalePage.cpp | 38 ++++++------------- src/modules/locale/LocalePage.h | 2 +- .../locale/timezonewidget/localeglobal.cpp | 26 ------------- .../locale/timezonewidget/localeglobal.h | 16 -------- .../locale/timezonewidget/timezonewidget.cpp | 13 ++++--- .../locale/timezonewidget/timezonewidget.h | 16 ++++---- 6 files changed, 28 insertions(+), 83 deletions(-) diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index ecdfb1935..4e43fc177 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -133,19 +133,6 @@ LocalePage::updateLocaleLabels() m_formatsLabel->setText( labels.second ); } -static inline bool -containsLocation( const QList< LocaleGlobal::Location >& locations, const QString& zone ) -{ - for ( const LocaleGlobal::Location& location : locations ) - { - if ( location.zone == zone ) - { - return true; - } - } - return false; -} - void LocalePage::init( const QString& initialRegion, const QString& initialZone, const QString& localeGenPath ) { @@ -163,7 +150,6 @@ LocalePage::init( const QString& initialRegion, const QString& initialZone, cons { m_tzWidget->setCurrentLocation( "America", "New_York" ); } - emit m_tzWidget->locationChanged( m_tzWidget->getCurrentLocation() ); // Some distros come with a meaningfully commented and easy to parse locale.gen, // and others ship a separate file /usr/share/i18n/SUPPORTED with a clean list of @@ -298,9 +284,9 @@ Calamares::JobList LocalePage::createJobs() { QList< Calamares::job_ptr > list; - LocaleGlobal::Location location = m_tzWidget->getCurrentLocation(); + const CalamaresUtils::Locale::TZZone* location = m_tzWidget->currentLocation(); - Calamares::Job* j = new SetTimezoneJob( location.region, location.zone ); + Calamares::Job* j = new SetTimezoneJob( location->region(), location->zone() ); list.append( Calamares::job_ptr( j ) ); return list; @@ -333,7 +319,7 @@ LocaleConfiguration LocalePage::guessLocaleConfiguration() const { return LocaleConfiguration::fromLanguageAndLocation( - QLocale().name(), m_localeGenLines, m_tzWidget->getCurrentLocation().country ); + QLocale().name(), m_localeGenLines, m_tzWidget->currentLocation()->country() ); } @@ -351,12 +337,12 @@ LocalePage::updateGlobalStorage() { auto* gs = Calamares::JobQueue::instance()->globalStorage(); - LocaleGlobal::Location location = m_tzWidget->getCurrentLocation(); - bool locationChanged - = ( location.region != gs->value( "locationRegion" ) ) || ( location.zone != gs->value( "locationZone" ) ); + const auto* location = m_tzWidget->currentLocation(); + bool locationChanged = ( location->region() != gs->value( "locationRegion" ) ) + || ( location->zone() != gs->value( "locationZone" ) ); - gs->insert( "locationRegion", location.region ); - gs->insert( "locationZone", location.zone ); + gs->insert( "locationRegion", location->region() ); + gs->insert( "locationZone", location->zone() ); updateGlobalLocale(); @@ -366,7 +352,7 @@ LocalePage::updateGlobalStorage() if ( locationChanged && Calamares::Settings::instance()->doChroot() ) { QProcess::execute( "timedatectl", // depends on systemd - { "set-timezone", location.region + '/' + location.zone } ); + { "set-timezone", location->region() + '/' + location->zone() } ); } #endif @@ -427,12 +413,12 @@ LocalePage::zoneChanged( int currentIndex ) } void -LocalePage::locationChanged( LocaleGlobal::Location location ) +LocalePage::locationChanged( const CalamaresUtils::Locale::TZZone* location ) { m_blockTzWidgetSet = true; // Set region index - int index = m_regionCombo->findData( location.region ); + int index = m_regionCombo->findData( location->region() ); if ( index < 0 ) { return; @@ -441,7 +427,7 @@ LocalePage::locationChanged( LocaleGlobal::Location location ) m_regionCombo->setCurrentIndex( index ); // Set zone index - index = m_zoneCombo->findData( location.zone ); + index = m_zoneCombo->findData( location->zone() ); if ( index < 0 ) { return; diff --git a/src/modules/locale/LocalePage.h b/src/modules/locale/LocalePage.h index 7c2eba253..d6aaa6de8 100644 --- a/src/modules/locale/LocalePage.h +++ b/src/modules/locale/LocalePage.h @@ -70,7 +70,7 @@ private: void regionChanged( int currentIndex ); void zoneChanged( int currentIndex ); - void locationChanged( LocaleGlobal::Location location ); + void locationChanged( const CalamaresUtils::Locale::TZZone* location ); void changeLocale(); void changeFormats(); diff --git a/src/modules/locale/timezonewidget/localeglobal.cpp b/src/modules/locale/timezonewidget/localeglobal.cpp index 593de5cab..d0e889148 100644 --- a/src/modules/locale/timezonewidget/localeglobal.cpp +++ b/src/modules/locale/timezonewidget/localeglobal.cpp @@ -38,32 +38,6 @@ QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > LocaleGlobal:: //### -QString -LocaleGlobal::Location::pretty( const QString& s ) -{ - return QString( s ).replace( '_', ' ' ).simplified(); -} - - -QString -LocaleGlobal::Location::comment() const -{ - QTimeZone qtz = QTimeZone( QString( "%1/%2" ).arg( region ).arg( zone ).toLatin1() ); - return qtz.comment(); -} - -LocaleGlobal::Location& -LocaleGlobal::Location::operator=( const CalamaresUtils::Locale::TZZone& location ) -{ - region = location.region(); - zone = location.key(); - country = location.country(); - latitude = location.latitude(); - longitude = location.longitude(); - return *this; -} - - void LocaleGlobal::init() { diff --git a/src/modules/locale/timezonewidget/localeglobal.h b/src/modules/locale/timezonewidget/localeglobal.h index b5e175c7c..1dc9548d0 100644 --- a/src/modules/locale/timezonewidget/localeglobal.h +++ b/src/modules/locale/timezonewidget/localeglobal.h @@ -51,16 +51,6 @@ public: QString description, locale; }; - struct Location - { - QString region, zone, country; - double latitude, longitude; - static QString pretty( const QString& s ); - QString comment() const; - - Location& operator=( const CalamaresUtils::Locale::TZZone& ); - }; - static void init(); static QHash< QString, QHash< QString, QList< LocaleGlobal::Locale > > > getLocales(); @@ -70,10 +60,4 @@ private: static void initLocales(); }; -inline QDebug& -operator<<( QDebug& s, const LocaleGlobal::Location& l ) -{ - return s << l.region << '/' << l.zone << '(' << l.country << ") @N" << l.latitude << 'E' << l.longitude; -} - #endif // LOCALEGLOBAL_H diff --git a/src/modules/locale/timezonewidget/timezonewidget.cpp b/src/modules/locale/timezonewidget/timezonewidget.cpp index 41b5b1980..926226f8c 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.cpp +++ b/src/modules/locale/timezonewidget/timezonewidget.cpp @@ -105,10 +105,10 @@ TimeZoneWidget::setCurrentLocation( QString regionName, QString zoneName ) void TimeZoneWidget::setCurrentLocation( const CalamaresUtils::Locale::TZZone* location ) { - currentLocation = *location; + m_currentLocation = location; // Set zone - QPoint pos = getLocationPosition( currentLocation.longitude, currentLocation.latitude ); + QPoint pos = getLocationPosition( location ); #ifdef DEBUG_TIMEZONES cDebug() << "Setting location" << location->region() << *location; @@ -147,6 +147,7 @@ TimeZoneWidget::setCurrentLocation( const CalamaresUtils::Locale::TZZone* locati // Repaint widget repaint(); + emit locationChanged( m_currentLocation ); } @@ -265,12 +266,12 @@ TimeZoneWidget::paintEvent( QPaintEvent* ) painter.drawPoint( point ); #else // Draw pin at current location - QPoint point = getLocationPosition( currentLocation.longitude, currentLocation.latitude ); + QPoint point = getLocationPosition( m_currentLocation ); painter.drawImage( point.x() - pin.width() / 2, point.y() - pin.height() / 2, pin ); // Draw text and box - const int textWidth = fontMetrics.horizontalAdvance( LocaleGlobal::Location::pretty( currentLocation.zone ) ); + const int textWidth = fontMetrics.horizontalAdvance( m_currentLocation ? m_currentLocation->tr() : QString() ); const int textHeight = fontMetrics.height(); QRect rect = QRect( point.x() - textWidth / 2 - 5, point.y() - textHeight - 8, textWidth + 10, textHeight - 2 ); @@ -296,7 +297,7 @@ TimeZoneWidget::paintEvent( QPaintEvent* ) painter.setBrush( QColor( 40, 40, 40 ) ); painter.drawRoundedRect( rect, 3, 3 ); painter.setPen( Qt::white ); - painter.drawText( rect.x() + 5, rect.bottom() - 4, LocaleGlobal::Location::pretty( currentLocation.zone ) ); + painter.drawText( rect.x() + 5, rect.bottom() - 4, m_currentLocation ? m_currentLocation->tr() : QString() ); #endif painter.end(); @@ -345,6 +346,6 @@ TimeZoneWidget::mousePressEvent( QMouseEvent* event ) // Set zone image and repaint widget setCurrentLocation( closest ); // Emit signal - emit locationChanged( currentLocation ); + emit locationChanged( m_currentLocation ); } } diff --git a/src/modules/locale/timezonewidget/timezonewidget.h b/src/modules/locale/timezonewidget/timezonewidget.h index 7a3572f10..d91c5cf27 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.h +++ b/src/modules/locale/timezonewidget/timezonewidget.h @@ -43,25 +43,25 @@ class TimeZoneWidget : public QWidget { Q_OBJECT public: + using TZZone = CalamaresUtils::Locale::TZZone; + explicit TimeZoneWidget( QWidget* parent = nullptr ); - LocaleGlobal::Location getCurrentLocation() { return currentLocation; } void setCurrentLocation( QString region, QString zone ); - void setCurrentLocation( const CalamaresUtils::Locale::TZZone* location ); + void setCurrentLocation( const TZZone* location ); + const TZZone* currentLocation() { return m_currentLocation; } + signals: - void locationChanged( LocaleGlobal::Location location ); + void locationChanged( const TZZone* location ); private: QFont font; QImage background, pin, currentZoneImage; QList< QImage > timeZoneImages; - LocaleGlobal::Location currentLocation; + const TZZone* m_currentLocation = nullptr; // Not owned by me - QPoint getLocationPosition( const LocaleGlobal::Location& l ) - { - return getLocationPosition( l.longitude, l.latitude ); - } + QPoint getLocationPosition( const TZZone* l ) { return getLocationPosition( l->longitude(), l->latitude() ); } QPoint getLocationPosition( double longitude, double latitude ); void paintEvent( QPaintEvent* event ); From 7bea19a62cca65296cc1a211d96bc397d5d41bc6 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Dec 2019 08:43:36 -0500 Subject: [PATCH 55/57] [locale] Fix build with debugging enabled (API changes) --- src/modules/locale/timezonewidget/timezonewidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/locale/timezonewidget/timezonewidget.cpp b/src/modules/locale/timezonewidget/timezonewidget.cpp index 926226f8c..a96aaafa3 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.cpp +++ b/src/modules/locale/timezonewidget/timezonewidget.cpp @@ -111,7 +111,7 @@ TimeZoneWidget::setCurrentLocation( const CalamaresUtils::Locale::TZZone* locati QPoint pos = getLocationPosition( location ); #ifdef DEBUG_TIMEZONES - cDebug() << "Setting location" << location->region() << *location; + cDebug() << "Setting location" << location->region() << location->zone() << '(' << location->country() << '@' << location->latitude() << 'N' << location->longitude() << 'E' << ')'; cDebug() << Logger::SubEntry << "pixel x" << pos.x() << "pixel y" << pos.y(); bool found = false; @@ -245,7 +245,7 @@ TimeZoneWidget::paintEvent( QPaintEvent* ) painter.drawImage( 0, 0, currentZoneImage ); #ifdef DEBUG_TIMEZONES - QPoint point = getLocationPosition( currentLocation.longitude, currentLocation.latitude ); + QPoint point = getLocationPosition( m_currentLocation ); // Draw latitude lines for ( int y_lat = -50; y_lat < 80; y_lat += 5 ) { From f5d7ef1bb75060d51f8c57b7b0a8e0ac7a15c3e1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Dec 2019 14:50:46 +0100 Subject: [PATCH 56/57] Changes: document TZ translations --- CHANGES | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 1f721faca..4d822815d 100644 --- a/CHANGES +++ b/CHANGES @@ -9,10 +9,14 @@ This release contains contributions from (alphabetically by first name): - No other contributors this time around. ## Core ## - - No changes to core functionality. + - Timezone support code has migrated into the core of Calamares. This + means that modules now have easier access to timezone information. + Translations for timezones have also been enabled, so it is **possible** + at least to translate the displayed zones in the *welcome* module. ## Modules ## - - No changes to modules. + - The *welcome* module now supports translations for timezone and + location names (e.g. "Berlin" is "Berlijn" in Dutch). # 3.2.17.1 (2019-12-02) # From 0e7982ec371246cc6e189ada32b2787f204479e5 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 11 Dec 2019 18:33:24 +0100 Subject: [PATCH 57/57] [libcalamares] Don't force Hindi on India. FIXES #1284 --- src/libcalamares/locale/CountryData_p.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libcalamares/locale/CountryData_p.cpp b/src/libcalamares/locale/CountryData_p.cpp index f4736fa2e..4382950ec 100644 --- a/src/libcalamares/locale/CountryData_p.cpp +++ b/src/libcalamares/locale/CountryData_p.cpp @@ -15,6 +15,13 @@ * Conditions herein. */ +/* MODIFICATIONS + * + * Edited anyway: + * 20191211 India changed to AnyLanguage, since Hindi doesn't make sense. #1284 + * + */ + // BEGIN Generated from CLDR data // *INDENT-OFF* // clang-format off @@ -115,7 +122,7 @@ static const CountryData country_data_table[] = { { QLocale::Language::Spanish, QLocale::Country::CanaryIslands, 'I', 'C' }, { QLocale::Language::Indonesian, QLocale::Country::Indonesia, 'I', 'D' }, { QLocale::Language::Hebrew, QLocale::Country::Israel, 'I', 'L' }, -{ QLocale::Language::Hindi, QLocale::Country::India, 'I', 'N' }, +{ QLocale::Language::AnyLanguage, QLocale::Country::India, 'I', 'N' }, { QLocale::Language::Arabic, QLocale::Country::Iraq, 'I', 'Q' }, { QLocale::Language::Persian, QLocale::Country::Iran, 'I', 'R' }, { QLocale::Language::Icelandic, QLocale::Country::Iceland, 'I', 'S' },