From 7510e883b8ad57cc10326db8026ac9b82c1f167f Mon Sep 17 00:00:00 2001 From: bill-auger Date: Mon, 11 Nov 2019 01:47:10 -0500 Subject: [PATCH 01/21] pre-select default item in packagechooser --- .../packagechooser/PackageChooserPage.cpp | 10 ++++++++ .../packagechooser/PackageChooserPage.h | 3 +++ .../packagechooser/PackageChooserViewStep.cpp | 25 +++++++++++++++++++ .../packagechooser/PackageChooserViewStep.h | 2 ++ .../packagechooser/packagechooser.conf | 4 +++ 5 files changed, 44 insertions(+) diff --git a/src/modules/packagechooser/PackageChooserPage.cpp b/src/modules/packagechooser/PackageChooserPage.cpp index b4d9f99af..1997c6dcf 100644 --- a/src/modules/packagechooser/PackageChooserPage.cpp +++ b/src/modules/packagechooser/PackageChooserPage.cpp @@ -140,6 +140,16 @@ PackageChooserPage::setModel( QAbstractItemModel* model ) &PackageChooserPage::updateLabels ); } +void +PackageChooserPage::setSelection( const QModelIndex& index ) +{ + if ( index.isValid() ) + { + ui->products->selectionModel()->select( index, QItemSelectionModel::Select ); + currentChanged( index ); + } +} + bool PackageChooserPage::hasSelection() const { diff --git a/src/modules/packagechooser/PackageChooserPage.h b/src/modules/packagechooser/PackageChooserPage.h index 79b9fa69c..b4ef2169b 100644 --- a/src/modules/packagechooser/PackageChooserPage.h +++ b/src/modules/packagechooser/PackageChooserPage.h @@ -35,10 +35,13 @@ class PackageChooserPage : public QWidget public: explicit PackageChooserPage( PackageChooserMode mode, QWidget* parent = nullptr ); + /// @brief Sets the data model for the listview void setModel( QAbstractItemModel* model ); /// @brief Sets the introductory (no-package-selected) texts void setIntroduction( const PackageItem& item ); + /// @brief Selects a listview item + void setSelection( const QModelIndex& index ); /// @brief Is anything selected? bool hasSelection() const; /** @brief Get the list of selected ids diff --git a/src/modules/packagechooser/PackageChooserViewStep.cpp b/src/modules/packagechooser/PackageChooserViewStep.cpp index 6fb29a4f7..36f6ae015 100644 --- a/src/modules/packagechooser/PackageChooserViewStep.cpp +++ b/src/modules/packagechooser/PackageChooserViewStep.cpp @@ -144,6 +144,12 @@ PackageChooserViewStep::isAtEnd() const return true; } +void +PackageChooserViewStep::onActivate() +{ + if ( !m_widget->hasSelection() ) + m_widget->setSelection( m_defaultIdx ); +} void PackageChooserViewStep::onLeave() @@ -198,6 +204,9 @@ PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap } } + QString default_item_id = CalamaresUtils::getString( configurationMap, "default" ); + m_defaultIdx = QModelIndex(); + bool first_time = !m_model; if ( configurationMap.contains( "items" ) ) { @@ -208,6 +217,22 @@ PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap { hookupModel(); } + + // find default item + if ( first_time && m_model && !default_item_id.isEmpty() ) + { + for (int item_n = 0; item_n < m_model->packageCount(); ++item_n) + { + QModelIndex item_idx = m_model->index( item_n, 0 ); + QVariant item_id = m_model->data( item_idx, PackageListModel::IdRole ); + + if ( item_id.toString() == default_item_id ) + { + m_defaultIdx = item_idx; + break; + } + } + } } void diff --git a/src/modules/packagechooser/PackageChooserViewStep.h b/src/modules/packagechooser/PackageChooserViewStep.h index 499571c12..29e65ef82 100644 --- a/src/modules/packagechooser/PackageChooserViewStep.h +++ b/src/modules/packagechooser/PackageChooserViewStep.h @@ -50,6 +50,7 @@ public: bool isAtBeginning() const override; bool isAtEnd() const override; + void onActivate() override; void onLeave() override; Calamares::JobList jobs() const override; @@ -67,6 +68,7 @@ private: PackageChooserMode m_mode; QString m_id; CalamaresUtils::Locale::TranslatedString* m_stepName; // As it appears in the sidebar + QModelIndex m_defaultIdx; }; CALAMARES_PLUGIN_FACTORY_DECLARATION( PackageChooserViewStepFactory ) diff --git a/src/modules/packagechooser/packagechooser.conf b/src/modules/packagechooser/packagechooser.conf index b82a52d3f..d48fa83ce 100644 --- a/src/modules/packagechooser/packagechooser.conf +++ b/src/modules/packagechooser/packagechooser.conf @@ -33,6 +33,10 @@ labels: step: "Packages" step[nl]: "Pakketten" +# (Optional) 'id' of pre-selected list-view item. +# Pre-selects one of the items below. +# default: kde + # Items to display in the chooser. In general, this should be a # pretty short list to avoid overwhelming the UI. This is a list # of objects, and the items are displayed in list order. From a3da47cd9cff94945ef58ddc8300b86acc438919 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20M=C3=BCller?= Date: Mon, 16 Dec 2019 09:34:21 +0100 Subject: [PATCH 02/21] [initcpiocfg] update plymouth check --- src/modules/initcpiocfg/main.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index 166cccf44..462528cb4 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -4,7 +4,7 @@ # === This file is part of Calamares - === # # Copyright 2014, Rohan Garg -# Copyright 2015, Philip Müller +# Copyright 2015 - 2019, Philip Müller # Copyright 2017, Alf Gaida # Copyright 2019, Adriaan de Groot # @@ -22,6 +22,7 @@ # along with Calamares. If not, see . import libcalamares +from libcalamares.utils import debug, target_env_call import os from collections import OrderedDict @@ -100,6 +101,11 @@ def write_mkinitcpio_lines(hooks, modules, files, root_mount_point): with open(path, "w") as mkinitcpio_file: mkinitcpio_file.write("\n".join(mklins) + "\n") +def detect_plymouth(): + isPlymouth = target_env_call(["sh", "-c", "which plymouth"]) + debug("which plymouth exit code: {!s}".format(isPlymouth)) + + return isPlymouth def modify_mkinitcpio_conf(partitions, root_mount_point): """ @@ -121,8 +127,7 @@ def modify_mkinitcpio_conf(partitions, root_mount_point): unencrypted_separate_boot = False # It is important that the plymouth hook comes before any encrypt hook - plymouth_bin = os.path.join(root_mount_point, "usr/bin/plymouth") - if os.path.exists(plymouth_bin): + if detect_plymouth() == 0: hooks.append("plymouth") for partition in partitions: From 85d3f9e9b9297415ce1230f9c634271e24de0be2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20M=C3=BCller?= Date: Mon, 16 Dec 2019 09:40:54 +0100 Subject: [PATCH 03/21] [initcpiocfg] add usr hook if partition is separate --- src/modules/initcpiocfg/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index 166cccf44..8925a1181 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -144,6 +144,9 @@ def modify_mkinitcpio_conf(partitions, root_mount_point): and "luksMapperName" not in partition): unencrypted_separate_boot = True + if partition["mountPoint"] == "/usr": + hooks.append("usr") + if encrypt_hook: hooks.append("encrypt") if not unencrypted_separate_boot and \ From fe64903d2f532441fe5f14e22dcf1a5a282fd51f Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 6 Jan 2020 14:34:47 +0100 Subject: [PATCH 04/21] [initcpiocfg] Polish PR #1290 - List discrete years in copyright - Add docstrings - Massage detect_plymouth() to return bool (easier in if() context) --- src/modules/initcpiocfg/main.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/modules/initcpiocfg/main.py b/src/modules/initcpiocfg/main.py index 462528cb4..63ac9f15e 100644 --- a/src/modules/initcpiocfg/main.py +++ b/src/modules/initcpiocfg/main.py @@ -4,7 +4,7 @@ # === This file is part of Calamares - === # # Copyright 2014, Rohan Garg -# Copyright 2015 - 2019, Philip Müller +# Copyright 2015,2019, Philip Müller # Copyright 2017, Alf Gaida # Copyright 2019, Adriaan de Groot # @@ -102,10 +102,16 @@ def write_mkinitcpio_lines(hooks, modules, files, root_mount_point): mkinitcpio_file.write("\n".join(mklins) + "\n") def detect_plymouth(): + """ + Checks existence (runnability) of plymouth in the target system. + + @return True if plymouth exists in the target, False otherwise + """ + # Used to only check existence of path /usr/bin/plymouth in target isPlymouth = target_env_call(["sh", "-c", "which plymouth"]) debug("which plymouth exit code: {!s}".format(isPlymouth)) - return isPlymouth + return isPlymouth == 0 def modify_mkinitcpio_conf(partitions, root_mount_point): """ @@ -127,7 +133,7 @@ def modify_mkinitcpio_conf(partitions, root_mount_point): unencrypted_separate_boot = False # It is important that the plymouth hook comes before any encrypt hook - if detect_plymouth() == 0: + if detect_plymouth(): hooks.append("plymouth") for partition in partitions: From 25f0ba672c0a76f444931765b1b0a3e16cf908bb Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 6 Jan 2020 17:22:09 +0100 Subject: [PATCH 05/21] i18n: fix spelling of Kyiv - Add Ukranian translations of zone names. Since I don't write Ukranian, add only a translation (er .. in this case, the proper original spelling) of Kyiv. - Fix spelling in English following UN resolution. - Dutch remains unchanged, since as far as I can tell the Dutch Government still sticks to the Soviet-era spelling. FIXES #1298 --- lang/tz_en.ts | 2 +- lang/tz_uk.ts | 2617 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 2618 insertions(+), 1 deletion(-) create mode 100644 lang/tz_uk.ts diff --git a/lang/tz_en.ts b/lang/tz_en.ts index 7e46eab3d..ba9b5a350 100644 --- a/lang/tz_en.ts +++ b/lang/tz_en.ts @@ -1285,7 +1285,7 @@ Kiev tz_names - + Kyiv diff --git a/lang/tz_uk.ts b/lang/tz_uk.ts new file mode 100644 index 000000000..6059079ca --- /dev/null +++ b/lang/tz_uk.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 bb4771a12a9dc014e0ee213bee464515ad86f7f1 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 6 Jan 2020 17:41:32 +0100 Subject: [PATCH 06/21] Changes: it's the locale module with translated zone names --- CHANGES | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 712bdfeb1..bc3d7d396 100644 --- a/CHANGES +++ b/CHANGES @@ -12,13 +12,13 @@ This release contains contributions from (alphabetically by first name): - 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. + at least to translate the displayed zones in the *locale* module. ## 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. - - The *welcome* module now supports translations for timezone and + - The *locale* module now supports translations for timezone and location names (e.g. "Berlin" is "Berlijn" in Dutch). From d21ed0cc7ff93209e45696ceb6cf4f4a204313c0 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Mon, 6 Jan 2020 17:55:13 +0100 Subject: [PATCH 07/21] [packagechooser] Coding style --- src/modules/packagechooser/PackageChooserPage.cpp | 1 - src/modules/packagechooser/PackageChooserViewStep.cpp | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/packagechooser/PackageChooserPage.cpp b/src/modules/packagechooser/PackageChooserPage.cpp index 1997c6dcf..16f50abab 100644 --- a/src/modules/packagechooser/PackageChooserPage.cpp +++ b/src/modules/packagechooser/PackageChooserPage.cpp @@ -53,7 +53,6 @@ PackageChooserPage::PackageChooserPage( PackageChooserMode mode, QWidget* parent } ui->products->setMinimumWidth( 10 * CalamaresUtils::defaultFontHeight() ); - } /** @brief size the given @p pixmap to @p size diff --git a/src/modules/packagechooser/PackageChooserViewStep.cpp b/src/modules/packagechooser/PackageChooserViewStep.cpp index 36f6ae015..c933147ee 100644 --- a/src/modules/packagechooser/PackageChooserViewStep.cpp +++ b/src/modules/packagechooser/PackageChooserViewStep.cpp @@ -148,7 +148,9 @@ void PackageChooserViewStep::onActivate() { if ( !m_widget->hasSelection() ) + { m_widget->setSelection( m_defaultIdx ); + } } void @@ -221,7 +223,7 @@ PackageChooserViewStep::setConfigurationMap( const QVariantMap& configurationMap // find default item if ( first_time && m_model && !default_item_id.isEmpty() ) { - for (int item_n = 0; item_n < m_model->packageCount(); ++item_n) + for ( int item_n = 0; item_n < m_model->packageCount(); ++item_n ) { QModelIndex item_idx = m_model->index( item_n, 0 ); QVariant item_id = m_model->data( item_idx, PackageListModel::IdRole ); From 1625bb1daed5522b5c569f74e0b6f8fa4b603afa Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 00:09:04 +0100 Subject: [PATCH 08/21] [locale] Support Qt 5.9 FIXES #1296 --- src/modules/locale/timezonewidget/timezonewidget.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/locale/timezonewidget/timezonewidget.cpp b/src/modules/locale/timezonewidget/timezonewidget.cpp index a96aaafa3..400af0841 100644 --- a/src/modules/locale/timezonewidget/timezonewidget.cpp +++ b/src/modules/locale/timezonewidget/timezonewidget.cpp @@ -271,7 +271,14 @@ TimeZoneWidget::paintEvent( QPaintEvent* ) painter.drawImage( point.x() - pin.width() / 2, point.y() - pin.height() / 2, pin ); // Draw text and box - const int textWidth = fontMetrics.horizontalAdvance( m_currentLocation ? m_currentLocation->tr() : QString() ); + // .. the lambda manages deprecations: the old one works in Qt 5.9 and Qt 5.10, + // while the new one avoids deprecation messages in Qt 5.13 and later. +#if QT_VERSION >= QT_VERSION_CHECK( 5, 11, 0 ) + auto textwidth = [&]( const QString& s ) { return fontMetrics.horizontalAdvance( s ); }; +#else + auto textwidth = [&]( const QString& s ) { return fontMetrics.width( s ); }; +#endif + const int textWidth = textwidth( 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 ); From 17d09342e9c7d2bc2352780e4fc7b5eff35f0b22 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 00:27:11 +0100 Subject: [PATCH 09/21] [libcalamaresui] Add a setting for window placement --- src/branding/default/branding.desc | 6 ++++++ src/libcalamaresui/Branding.cpp | 9 +++++++++ src/libcalamaresui/Branding.h | 11 ++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/branding/default/branding.desc b/src/branding/default/branding.desc index 5d9b29c69..f70715aea 100644 --- a/src/branding/default/branding.desc +++ b/src/branding/default/branding.desc @@ -35,6 +35,12 @@ windowExpanding: normal # in CalamaresUtilsGui, 800x520. windowSize: 800px,520px +# Placement of Calamares window. Either "center" or "free". +# Whether "center" actually works does depend on the window +# manager in use (and only makes sense if you're not using +# *windowExpanding* set to "fullscreen"). +windowPlacement: center + # These are strings shown to the user in the user interface. # There is no provision for translating them -- since they # are names, the string is included as-is. diff --git a/src/libcalamaresui/Branding.cpp b/src/libcalamaresui/Branding.cpp index edbced5fa..a5b6e5dce 100644 --- a/src/libcalamaresui/Branding.cpp +++ b/src/libcalamaresui/Branding.cpp @@ -410,6 +410,9 @@ Branding::initSimpleSettings( const YAML::Node& doc ) { QStringLiteral( "fullscreen" ), WindowExpansion::Fullscreen }, { QStringLiteral( "noexpand" ), WindowExpansion::Fixed } }; + static const NamedEnumTable< WindowPlacement > placementNames { + { QStringLiteral( "free" ), WindowPlacement::Free }, { QStringLiteral( "center" ), WindowPlacement::Center } + }; bool ok = false; m_welcomeStyleCalamares = doc[ "welcomeStyleCalamares" ].as< bool >( false ); @@ -420,6 +423,12 @@ Branding::initSimpleSettings( const YAML::Node& doc ) cWarning() << "Branding module-setting *windowExpanding* interpreted as" << expansionNames.find( m_windowExpansion, ok ); } + m_windowPlacement = placementNames.find( getString( doc, "windowPlacement" ), ok ); + if ( !ok ) + { + cWarning() << "Branding module-setting *windowPlacement* interpreted as" + << placementNames.find( m_windowPlacement, ok ); + } QString windowSize = getString( doc, "windowSize" ); if ( !windowSize.isEmpty() ) diff --git a/src/libcalamaresui/Branding.h b/src/libcalamaresui/Branding.h index 3723fd07f..30e8be846 100644 --- a/src/libcalamaresui/Branding.h +++ b/src/libcalamaresui/Branding.h @@ -108,6 +108,13 @@ public: { } }; + /** @brief Placement of main window. + */ + enum class WindowPlacement + { + Center, + Free + }; static Branding* instance(); @@ -162,6 +169,7 @@ public: { return QPair< WindowDimension, WindowDimension >( m_windowWidth, m_windowHeight ); } + bool windowPlacementCentered() const { return m_windowPlacement == WindowPlacement::Center; } /** * Creates a map called "branding" in the global storage, and inserts an @@ -193,9 +201,10 @@ private: bool m_welcomeStyleCalamares; bool m_welcomeExpandingLogo; - WindowExpansion m_windowExpansion; + WindowExpansion m_windowExpansion; WindowDimension m_windowHeight, m_windowWidth; + WindowPlacement m_windowPlacement; }; template < typename U > From 60c659c82b90e91222ed572fcebc9935f2c31d45 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 00:28:52 +0100 Subject: [PATCH 10/21] Changes: document new branding element --- CHANGES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES b/CHANGES index bc3d7d396..b702583d0 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,9 @@ This release contains contributions from (alphabetically by first name): 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 *locale* module. + - Branding can now specify whether to (try to) display the Calamares window + in the middle of the desktop or not. The *windowPlacement* key in + `branding.desc` specifies *center* or *free* placement. ## Modules ## - The *license* module has seen a significant change to its looks. From 43caf7b46a51531ec6d5e55b03eb7606219fadad Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 00:34:15 +0100 Subject: [PATCH 11/21] [calamares] Restore functionality for 'center window' --- src/calamares/CalamaresApplication.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index 527f92c85..c5fdb6273 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -357,6 +357,10 @@ CalamaresApplication::initView() QTimer::singleShot( 0, m_moduleManager, &Calamares::ModuleManager::loadModules ); + if ( Calamares::Branding::instance() && Calamares::Branding::instance()->windowPlacementCentered() ) + { + m_mainwindow->move( this->desktop()->availableGeometry().center() - m_mainwindow->rect().center() ); + } cDebug() << "STARTUP: CalamaresWindow created; loadModules started"; } From 121013fd96beadae60727b573c47343f69ffa622 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 01:06:26 +0100 Subject: [PATCH 12/21] [calamares] Avoid deprecated desktop() - Put Calamares on the first screen where it fits - This is wordy and weird --- src/calamares/CalamaresApplication.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index c5fdb6273..8e30dfa83 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -39,6 +39,7 @@ #include #include #include +#include #include @@ -359,7 +360,17 @@ CalamaresApplication::initView() if ( Calamares::Branding::instance() && Calamares::Branding::instance()->windowPlacementCentered() ) { - m_mainwindow->move( this->desktop()->availableGeometry().center() - m_mainwindow->rect().center() ); + QList< QScreen* > screens = qApp->screens(); + QPoint windowCenter = m_mainwindow->rect().center(); + for ( const auto* screen : screens ) + { + QPoint screenCenter = screen->availableGeometry().center(); + if ( ( screenCenter.x() >= windowCenter.x() ) && ( screenCenter.y() >= windowCenter.y() ) ) + { + m_mainwindow->move( screenCenter - windowCenter ); + break; + } + } } cDebug() << "STARTUP: CalamaresWindow created; loadModules started"; } From 61b6d058d7d5f9696ce2d68b36a30a66be544f8e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 01:16:36 +0100 Subject: [PATCH 13/21] Changes: credits for packagechooser bits --- CHANGES | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index b702583d0..42a0b8c51 100644 --- a/CHANGES +++ b/CHANGES @@ -6,7 +6,7 @@ website will have to do for older versions. # 3.2.18 (unreleased) # This release contains contributions from (alphabetically by first name): - - No other contributors this time around. + - Bill Auger ## Core ## - Timezone support code has migrated into the core of Calamares. This @@ -23,6 +23,8 @@ This release contains contributions from (alphabetically by first name): for each license is displayed. - The *locale* module now supports translations for timezone and location names (e.g. "Berlin" is "Berlijn" in Dutch). + - *Packagechooser* is a little more careful with displaying + default and empty package names. (thanks to Bill Auger) # 3.2.17.1 (2019-12-02) # From fcb0109b7b600c2bab429f0af8064ef34c0e8005 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 09:56:13 +0100 Subject: [PATCH 14/21] [calamares] Refactor center-placement - Just move it to its own function where it can have more documentation - Tested on multi-screen setups SEE #1293 --- src/calamares/CalamaresApplication.cpp | 47 ++++++++++++++++++++------ 1 file changed, 36 insertions(+), 11 deletions(-) diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index 8e30dfa83..a4ae30acb 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -343,6 +343,41 @@ CalamaresApplication::initModuleManager() m_moduleManager->init(); } +/** @brief centers the widget @p w on (a) screen + * + * This tries to duplicate the (deprecated) qApp->desktop()->availableGeometry() + * placement by iterating over screens and putting Calamares in the first + * one where it fits; this is *generally* the primary screen. + * + * With debugging, it would look something like this (2 screens attached, + * primary at +1080+240 because I have a very strange X setup). Before + * being mapped, the Calamares window is at +0+0 but does have a size. + * The first screen's geometry includes the offset from the origin in + * screen coordinates. + * + * Proposed window size: 1024 520 + * Window QRect(0,0 1024x520) + * Screen QRect(1080,240 2560x1440) + * Moving QPoint(1848,700) + * Screen QRect(0,0 1080x1920) + * + */ +static void +centerWindowOnScreen( QWidget* w ) +{ + QList< QScreen* > screens = qApp->screens(); + QPoint windowCenter = w->rect().center(); + + for ( const auto* screen : screens ) + { + QPoint screenCenter = screen->availableGeometry().center(); + if ( !itFits && ( screenCenter.x() >= windowCenter.x() ) && ( screenCenter.y() >= windowCenter.y() ) ) + { + w->move( screenCenter - windowCenter ); + break; + } + } +} void CalamaresApplication::initView() @@ -360,17 +395,7 @@ CalamaresApplication::initView() if ( Calamares::Branding::instance() && Calamares::Branding::instance()->windowPlacementCentered() ) { - QList< QScreen* > screens = qApp->screens(); - QPoint windowCenter = m_mainwindow->rect().center(); - for ( const auto* screen : screens ) - { - QPoint screenCenter = screen->availableGeometry().center(); - if ( ( screenCenter.x() >= windowCenter.x() ) && ( screenCenter.y() >= windowCenter.y() ) ) - { - m_mainwindow->move( screenCenter - windowCenter ); - break; - } - } + centerWindowOnScreen( m_mainwindow ); } cDebug() << "STARTUP: CalamaresWindow created; loadModules started"; } From b4c0ebe8ab936d0ad3d9e15b8cdb94e32841e042 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 10:04:10 +0100 Subject: [PATCH 15/21] [calamares] Use screen and window sizes, not position --- src/calamares/CalamaresApplication.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/calamares/CalamaresApplication.cpp b/src/calamares/CalamaresApplication.cpp index a4ae30acb..1584b11fa 100644 --- a/src/calamares/CalamaresApplication.cpp +++ b/src/calamares/CalamaresApplication.cpp @@ -367,13 +367,14 @@ centerWindowOnScreen( QWidget* w ) { QList< QScreen* > screens = qApp->screens(); QPoint windowCenter = w->rect().center(); + QSize windowSize = w->rect().size(); for ( const auto* screen : screens ) { - QPoint screenCenter = screen->availableGeometry().center(); - if ( !itFits && ( screenCenter.x() >= windowCenter.x() ) && ( screenCenter.y() >= windowCenter.y() ) ) + QSize screenSize = screen->availableGeometry().size(); + if ( ( screenSize.width() >= windowSize.width() ) && ( screenSize.height() >= windowSize.height() ) ) { - w->move( screenCenter - windowCenter ); + w->move( screen->availableGeometry().center() - windowCenter ); break; } } From 1b62b2f66ce1a7aa1ca990174f456d3429f83dac Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 10:19:22 +0100 Subject: [PATCH 16/21] [libcalamares] Reduce warnings (extra ;, empty statement ..) --- src/libcalamares/locale/TimeZone.cpp | 3 +-- src/libcalamares/locale/TimeZone.h | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libcalamares/locale/TimeZone.cpp b/src/libcalamares/locale/TimeZone.cpp index 05aeaf885..58695ee0e 100644 --- a/src/libcalamares/locale/TimeZone.cpp +++ b/src/libcalamares/locale/TimeZone.cpp @@ -171,7 +171,6 @@ TZRegion::fromFile( const char* fileName ) } QString region = timezoneParts.first().trimmed(); - ; if ( region.isEmpty() ) { continue; @@ -243,7 +242,7 @@ CStringListModel::CStringListModel( CStringPairList l ) CStringListModel::~CStringListModel() {} int -CStringListModel::rowCount( const QModelIndex& parent ) const +CStringListModel::rowCount( const QModelIndex& ) const { return m_list.count(); } diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 567b42241..5048b7276 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -48,7 +48,7 @@ class CStringPair { public: /// @brief An empty pair - CStringPair() {}; + CStringPair() {} /// @brief Given an identifier, create the pair explicit CStringPair( const char* s1 ); CStringPair( CStringPair&& t ); @@ -88,7 +88,7 @@ class TZRegion : public CStringPair { public: using CStringPair::CStringPair; - virtual ~TZRegion(); + virtual ~TZRegion() override; QString tr() const override; QString region() const { return key(); } From 5fbd0169cad6444e58a361e9277299b7122cc87c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 10:33:21 +0100 Subject: [PATCH 17/21] [libcalamares] Reduce clang warnings (only-inline-virtual, unused parameters) --- src/libcalamares/utils/Retranslator.cpp | 112 +++++++++++++----------- 1 file changed, 62 insertions(+), 50 deletions(-) diff --git a/src/libcalamares/utils/Retranslator.cpp b/src/libcalamares/utils/Retranslator.cpp index 047f642e4..4c7c3b3f5 100644 --- a/src/libcalamares/utils/Retranslator.cpp +++ b/src/libcalamares/utils/Retranslator.cpp @@ -58,7 +58,7 @@ struct TranslationLoader { } - virtual ~TranslationLoader() {}; + virtual ~TranslationLoader(); /// @brief Loads @p translator with the specific translations of this type virtual bool tryLoad( QTranslator* translator ) = 0; @@ -66,6 +66,7 @@ struct TranslationLoader QString m_localeName; }; +/// @brief Loads translations for branding struct BrandingLoader : public TranslationLoader { BrandingLoader( const QLocale& locale, const QString& prefix ) @@ -74,74 +75,85 @@ struct BrandingLoader : public TranslationLoader { } - 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; - } + bool tryLoad( QTranslator* translator ) override; QString m_prefix; }; +/// @brief Loads regular Calamares translations (program text) 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" ) ); - } - } + bool tryLoad( QTranslator* translator ) override; }; +/// @brief Loads timezone name translations struct TZLoader : public TranslationLoader { using TranslationLoader::TranslationLoader; - bool tryLoad( QTranslator* translator ) override + bool tryLoad( QTranslator* translator ) override; +}; + +TranslationLoader::~TranslationLoader() {} + +bool +BrandingLoader::tryLoad( QTranslator* translator ) +{ + if ( m_prefix.isEmpty() ) { - if ( translator->load( QString( ":/lang/tz_" ) + m_localeName ) ) + 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 << "Calamares Timezones using locale:" << m_localeName; + cDebug() << Logger::SubEntry << "Branding 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" ) ); + 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; +} + +bool +CalamaresLoader::tryLoad( QTranslator* translator ) +{ + 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" ) ); + } +} + +bool +TZLoader::tryLoad( QTranslator* translator ) +{ + 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 ) @@ -167,7 +179,7 @@ static QTranslator* s_tztranslator = nullptr; static QString s_translatorLocaleName; void -installTranslator( const QLocale& locale, const QString& brandingTranslationsPrefix, QObject* parent ) +installTranslator( const QLocale& locale, const QString& brandingTranslationsPrefix, QObject* ) { loadSingletonTranslator( BrandingLoader( locale, brandingTranslationsPrefix ), s_brandingTranslator ); loadSingletonTranslator( TZLoader( locale ), s_tztranslator ); From 2dff2d9d70a9143a459b7f0a171ac7dcd1a59a0d Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 10:41:14 +0100 Subject: [PATCH 18/21] [libcalamares] TZRegion is hard to copy - delete the copy and move constructors - adjust tests (which were just interested in simple tr() behavior) to use TZZone instead --- src/libcalamares/locale/Tests.cpp | 6 +++--- src/libcalamares/locale/TimeZone.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/libcalamares/locale/Tests.cpp b/src/libcalamares/locale/Tests.cpp index 106a77b4c..b63eb9e18 100644 --- a/src/libcalamares/locale/Tests.cpp +++ b/src/libcalamares/locale/Tests.cpp @@ -215,12 +215,12 @@ LocaleTests::testSimpleZones() QVERIFY( n.tr().isEmpty() ); } { - TZRegion r0( "xAmsterdam" ); + TZZone r0( "xAmsterdam" ); QCOMPARE( r0.tr(), QStringLiteral( "xAmsterdam" ) ); - TZRegion r1( r0 ); + TZZone r1( r0 ); QCOMPARE( r0.tr(), QStringLiteral( "xAmsterdam" ) ); QCOMPARE( r1.tr(), QStringLiteral( "xAmsterdam" ) ); - TZRegion r2( std::move( r0 ) ); + TZZone r2( std::move( r0 ) ); QCOMPARE( r2.tr(), QStringLiteral( "xAmsterdam" ) ); QCOMPARE( r0.tr(), QString() ); } diff --git a/src/libcalamares/locale/TimeZone.h b/src/libcalamares/locale/TimeZone.h index 5048b7276..3345e61f8 100644 --- a/src/libcalamares/locale/TimeZone.h +++ b/src/libcalamares/locale/TimeZone.h @@ -89,6 +89,7 @@ class TZRegion : public CStringPair public: using CStringPair::CStringPair; virtual ~TZRegion() override; + TZRegion( const TZRegion& ) = delete; QString tr() const override; QString region() const { return key(); } From 1a8926181efbd15fbe81efe7e15d4fba86a1216c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 10:46:26 +0100 Subject: [PATCH 19/21] [locale] Warnings-- (initialization-order) --- src/modules/locale/LocalePage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index 4e43fc177..c1df7c81c 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -41,9 +41,9 @@ 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 ) ) + , m_blockTzWidgetSet( false ) { QBoxLayout* mainLayout = new QVBoxLayout; From 1bc8a28eac026f1e3140681f6339f9b00deb4154 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 11:20:45 +0100 Subject: [PATCH 20/21] CMake: Calamares doesn't want -p in automoc FIXES #1286 --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b823ccbe..e547ddb84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -220,6 +220,8 @@ if( CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) set( CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined" ) + # The path prefix is only relevant for CMake 3.16 and later, fixes #1286 + set( CMAKE_AUTOMOC_PATH_PREFIX OFF ) set( CALAMARES_AUTOMOC_OPTIONS "-butils/moc-warnings.h" ) set( CALAMARES_AUTOUIC_OPTIONS --include utils/moc-warnings.h ) else() From c482990bc5b5233e2f4abda75fda8700308f5bea Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 7 Jan 2020 11:38:18 +0100 Subject: [PATCH 21/21] CMake: fix find-boost --- CMakeLists.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e547ddb84..6edc4e4cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -324,6 +324,10 @@ set_package_properties( ) if ( PYTHONLIBS_FOUND ) + # Since Boost provides CMake config files (starting with Boost 1.70. + # or so) the mess that is the Calamares find code picks the wrong + # bits. Suppress those CMake config files, as suggested by @jmrcpn + set(Boost_NO_BOOST_CMAKE ON) include( BoostPython3 ) find_boost_python3( ${BOOSTPYTHON_VERSION} ${PYTHONLIBS_VERSION_STRING} CALAMARES_BOOST_PYTHON3_FOUND ) set_package_properties(