cui/source/dialogs/dlgname.cxx | 1 + cui/uiconfig/ui/numberdialog.ui | 1 + vcl/qt5/QtInstanceFormattedSpinButton.cxx | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-)
New commits: commit 0fd4cfdc0826a4dfde62e0adf1a43dd64969af6a Author: Michael Weghorn <[email protected]> AuthorDate: Thu Feb 20 14:00:12 2025 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Thu Feb 20 18:25:02 2025 +0100 tdf#130857 qt weld: Avoid losing decimals in SvxDecimalNumberDialog For QDoubleSpinBox (and thus the custom QtDoubleSpinBox subclass used in QtFormattedSpinBox), the number of decimals set via QDoubleSpinBox::setDecimals [1] does not only affect how many decimals are displayed, but also applies to the actual value used (which makes sure they are consistent). As a consequence, setting the amount of decimals to 0 results in rounding to an integer when setting the value. So far, this happened for SvxDecimalNumberDialog because the "digits" property for the "GtkSpinButton" in the .ui file uses the default value of 0. Change this to 2 instead (which matches the amount of decimals shown with both, the GTK and the VCL variants) when opening the dialog. For SvxNumberDialog that uses the same .ui file, explicitly set the number of decimals to 0, to keep the behavior unchanged for that one. This addresses those issues mentioned in previous commit Change-Id: I25707ab6c5877eea2270bc21a27d08483d0f52e6 Author: Michael Weghorn <[email protected]> Date: Thu Feb 20 11:12:51 2025 +0100 tdf#130857 qt weld: Support Svx(Decimal)NumberDialog > Handling for decimal numbers using QtInstanceFormattedSpinButton > still needs some tweaks that will be done in upcoming commits. > (For example, it currently rounds the value when double-clicking > on a proparty that has a floating point value set, and only allows > typing integer values, not actual floating point values.) [1] https://doc.qt.io/qt-6/qdoublespinbox.html#decimals-prop Change-Id: I9a242c704a1199cbbf7b16e96151d950223905b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181948 Reviewed-by: Michael Weghorn <[email protected]> Tested-by: Jenkins diff --git a/cui/source/dialogs/dlgname.cxx b/cui/source/dialogs/dlgname.cxx index d49c5fa28579..130de538b859 100644 --- a/cui/source/dialogs/dlgname.cxx +++ b/cui/source/dialogs/dlgname.cxx @@ -72,6 +72,7 @@ SvxNumberDialog::SvxNumberDialog(weld::Window* pParent, const OUString& rDesc, s , m_xFtDescription(m_xBuilder->weld_label(u"description_label"_ustr)) { m_xFtDescription->set_label(rDesc); + m_xEdtNumber->set_digits(0); m_xEdtNumber->set_min(nMin); m_xEdtNumber->set_max(nMax); m_xEdtNumber->set_value(nValue); diff --git a/cui/uiconfig/ui/numberdialog.ui b/cui/uiconfig/ui/numberdialog.ui index a73c160efeec..86215d0795eb 100644 --- a/cui/uiconfig/ui/numberdialog.ui +++ b/cui/uiconfig/ui/numberdialog.ui @@ -104,6 +104,7 @@ <property name="can-focus">True</property> <property name="truncate-multiline">True</property> <property name="adjustment">adjustment1</property> + <property name="digits">2</property> </object> <packing> <property name="expand">False</property> commit ca05be9dde72a72d8b76136887381d8e25f2a215 Author: Michael Weghorn <[email protected]> AuthorDate: Wed Feb 19 22:50:50 2025 +0100 Commit: Michael Weghorn <[email protected]> CommitDate: Thu Feb 20 18:24:55 2025 +0100 tdf#130857 qt weld: Implement FormattedSpinButton text -> value conversion Use the method introduced in previous commit Change-Id: I475fc97c78feb05703a9a134b004d1c12ccd855a Author: Michael Weghorn <[email protected]> Date: Wed Feb 19 22:45:53 2025 +0100 tdf#130857 Formatter: Extract helper method to convert text to value to set the function used by QtDoubleSpinBox::valueFromText to convert text to a value for the QtFormattedSpinButton use case. See also similar commit commit 6871b55b6915396caa3e5aca7e233f6a5efc7864 Author: Michael Weghorn <[email protected]> Date: Sat Feb 15 17:47:01 2025 +0100 tdf#130857 qt weld: Implement SpinButton text <-> value conversion for the QtInstanceSpinButton case. Change-Id: Ic6e31163ab47e716f8d305f45168c0af25266534 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/181944 Tested-by: Jenkins Reviewed-by: Michael Weghorn <[email protected]> diff --git a/vcl/qt5/QtInstanceFormattedSpinButton.cxx b/vcl/qt5/QtInstanceFormattedSpinButton.cxx index 9cc88cab83d3..b56a973c3383 100644 --- a/vcl/qt5/QtInstanceFormattedSpinButton.cxx +++ b/vcl/qt5/QtInstanceFormattedSpinButton.cxx @@ -33,9 +33,11 @@ QtInstanceFormattedSpinButton::QtInstanceFormattedSpinButton(QtDoubleSpinBox* pS connect(m_pSpinBox, &QDoubleSpinBox::textChanged, this, &QtInstanceFormattedSpinButton::handleTextChanged); - // set function to convert value to text + // set functions to convert between value and formatted text m_pSpinBox->setFormatValueFunction( [this](double fValue) { return GetFormatter().FormatValue(fValue); }); + m_pSpinBox->setParseTextFunction( + [this](const QString& rText) { return GetFormatter().ParseText(toOUString(rText)); }); } QWidget* QtInstanceFormattedSpinButton::getQWidget() const { return m_pSpinBox; }
