From d545904f5c6117f2b4743ce88bbab5942afacb3c Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 6 Jun 2017 10:45:35 -0400 Subject: [PATCH] Locale: don't overwrite explicit choice If the user selects a language from the dialog (by clicking 'change'), then preserve that explicit choice even when clicking on another location which would reset the language based on the installer- language. --- src/modules/locale/LocaleConfiguration.cpp | 3 +++ src/modules/locale/LocaleConfiguration.h | 5 +++++ src/modules/locale/LocalePage.cpp | 25 +++++++++++++++++++++- 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/modules/locale/LocaleConfiguration.cpp b/src/modules/locale/LocaleConfiguration.cpp index bf9d940de..3631befec 100644 --- a/src/modules/locale/LocaleConfiguration.cpp +++ b/src/modules/locale/LocaleConfiguration.cpp @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2016, Teo Mrnjavac + * Copyright 2017, 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 @@ -20,6 +21,8 @@ #include LocaleConfiguration::LocaleConfiguration() + : explicit_lang( false ) + , explicit_lc( false ) { } diff --git a/src/modules/locale/LocaleConfiguration.h b/src/modules/locale/LocaleConfiguration.h index 54e498c40..a93ddffac 100644 --- a/src/modules/locale/LocaleConfiguration.h +++ b/src/modules/locale/LocaleConfiguration.h @@ -1,6 +1,7 @@ /* === This file is part of Calamares - === * * Copyright 2016, Teo Mrnjavac + * Copyright 2017, 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 @@ -40,6 +41,10 @@ public: lc_telephone, lc_measurement, lc_identification; QString myLanguageLocaleBcp47; QMap< QString, QString > toMap(); + + // If the user has explicitly selected language (from the dialog) + // or numbers format, set these to avoid implicit changes to them. + bool explicit_lang, explicit_lc; }; #endif // LOCALECONFIGURATION_H diff --git a/src/modules/locale/LocalePage.cpp b/src/modules/locale/LocalePage.cpp index 81c324021..03f58157e 100644 --- a/src/modules/locale/LocalePage.cpp +++ b/src/modules/locale/LocalePage.cpp @@ -172,6 +172,7 @@ LocalePage::LocalePage( QWidget* parent ) !dlg->selectedLCLocale().isEmpty() ) { m_selectedLocaleConfiguration.lang = dlg->selectedLCLocale(); + m_selectedLocaleConfiguration.explicit_lang = true; this->updateLocaleLabels(); } @@ -201,6 +202,7 @@ LocalePage::LocalePage( QWidget* parent ) m_selectedLocaleConfiguration.lc_telephone = dlg->selectedLCLocale(); m_selectedLocaleConfiguration.lc_measurement = dlg->selectedLCLocale(); m_selectedLocaleConfiguration.lc_identification = dlg->selectedLCLocale(); + m_selectedLocaleConfiguration.explicit_lc = true; this->updateLocaleLabels(); } @@ -478,6 +480,27 @@ LocalePage::updateGlobalStorage() location.region + '/' + location.zone } ); } - m_selectedLocaleConfiguration = guessLocaleConfiguration(); + // Preserve those settings that have been made explicit. + auto newLocale = guessLocaleConfiguration(); + if ( !m_selectedLocaleConfiguration.isEmpty() && + m_selectedLocaleConfiguration.explicit_lang ) + newLocale.lang = m_selectedLocaleConfiguration.lang; + if ( !m_selectedLocaleConfiguration.isEmpty() && + m_selectedLocaleConfiguration.explicit_lc ) + { + newLocale.lc_numeric = m_selectedLocaleConfiguration.lc_numeric; + newLocale.lc_time = m_selectedLocaleConfiguration.lc_time; + newLocale.lc_monetary = m_selectedLocaleConfiguration.lc_monetary; + newLocale.lc_paper = m_selectedLocaleConfiguration.lc_paper; + newLocale.lc_name = m_selectedLocaleConfiguration.lc_name; + newLocale.lc_address = m_selectedLocaleConfiguration.lc_address; + newLocale.lc_telephone = m_selectedLocaleConfiguration.lc_telephone; + newLocale.lc_measurement = m_selectedLocaleConfiguration.lc_measurement; + newLocale.lc_identification = m_selectedLocaleConfiguration.lc_identification; + } + newLocale.explicit_lang = m_selectedLocaleConfiguration.explicit_lang; + newLocale.explicit_lc = m_selectedLocaleConfiguration.explicit_lc; + + m_selectedLocaleConfiguration = newLocale; updateLocaleLabels(); }