[LyX/master] Localize display of glue lengths in dialogs

Juergen Spitzmueller spitz at lyx.org
Tue Aug 9 06:58:17 UTC 2022


commit 079bc8ca40aa71f720a74ac9f47288cc4d0ca1f5
Author: Juergen Spitzmueller <spitz at lyx.org>
Date:   Tue Aug 9 09:44:12 2022 +0200

    Localize display of glue lengths in dialogs
---
 src/frontends/qt/qt_helpers.cpp |   10 +++++++++-
 src/frontends/qt/qt_helpers.h   |    5 ++++-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/frontends/qt/qt_helpers.cpp b/src/frontends/qt/qt_helpers.cpp
index f9112e5..db39b4c 100644
--- a/src/frontends/qt/qt_helpers.cpp
+++ b/src/frontends/qt/qt_helpers.cpp
@@ -161,7 +161,7 @@ void lengthToWidgets(QLineEdit * input, LengthCombo * combo,
 	} else if (!isValidLength(len) && !isStrDbl(len)) {
 		// use input field only for gluelengths
 		combo->setCurrentItem(defaultUnit);
-		input->setText(toqstr(len));
+		input->setText(locLengthString(toqstr(len)));
 	} else {
 		lengthToWidgets(input, combo, Length(len), defaultUnit);
 	}
@@ -214,6 +214,14 @@ QString formatLocFPNumber(double d)
 }
 
 
+QString locLengthString(QString const & str)
+{
+	QLocale loc;
+	QString res = str;
+	return res.replace(QString("."), loc.decimalPoint());
+}
+
+
 QString unlocLengthString(QString const & str)
 {
 	QLocale loc;
diff --git a/src/frontends/qt/qt_helpers.h b/src/frontends/qt/qt_helpers.h
index 34035ae..07812c3 100644
--- a/src/frontends/qt/qt_helpers.h
+++ b/src/frontends/qt/qt_helpers.h
@@ -72,7 +72,10 @@ void doubleToWidget(QLineEdit * input, std::string const & value,
  */
 QString formatLocFPNumber(double d);
 
-// Method to replace localized decimal separator by dot
+/// Method to replace dot with localized decimal separator
+QString locLengthString(QString const & str);
+
+/// Method to replace localized decimal separator by dot
 QString unlocLengthString(QString const & str);
 
 /// Method to sort QStrings locale-aware (e.g. in combo widgets)


More information about the lyx-cvs mailing list