https://bugs.kde.org/show_bug.cgi?id=525945

            Bug ID: 525945
           Summary: Decimal separator key shows "." instead of the
                    locale's separator after pressing Ctrl
    Classification: Applications
           Product: kcalc
      Version First 26.08.1
       Reported In:
          Platform: Arch Linux
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: general
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
  Target Milestone: ---

SUMMARY
In a locale whose decimal separator is not a point (for example
LC_NUMERIC=fr_FR.UTF-8 or de_DE.UTF-8), the decimal separator key correctly
shows "," at startup. After pressing and releasing Ctrl once, it shows "." and
keeps showing "." until KCalc is restarted. The key itself still works (it
still enters the locale's separator), only its label is wrong.

STEPS TO REPRODUCE
1. Start KCalc with a comma locale, e.g. `LC_NUMERIC=fr_FR.UTF-8 kcalc`
2. Check the decimal separator key: it shows ","
3. Press Ctrl and release it (while it is held, the keys show their shortcuts,
which is expected)

OBSERVED RESULT
After Ctrl is released, the key shows "." and never goes back to ",".

EXPECTED RESULT
The key goes back to "," when Ctrl is released.

CAUSE
- kcalc.ui gives pbPeriod the text ".".
- KCalcButton::setText() records its text as the normal-mode label only while
that label is still empty ("normal mode may not have been explicitly set"). So
the "." from kcalc.ui becomes the normal-mode label.
- In the KCalculator constructor,
`pbPeriod->setText(QString(QLocale().decimalPoint()))` then changes the visible
text to ",", but the normal-mode label stays ".".
- When Ctrl is released, KCalcButton::slotSetAccelDisplayMode(false) restores
`m_mode[m_modeFlags].label`, which is ".".

POSSIBLE FIX
Set the normal-mode label instead of only the text, in kcalc.cpp:

```
-    pbPeriod->setText(QString(QLocale().decimalPoint()));
+    pbPeriod->addMode(ModeNormal, QString(QLocale().decimalPoint()),
i18n("Decimal point"));
```

I did not change KCalcButton::setText() to always overwrite the label, because
slotSetMode() also goes through setText(), so switching to Shift mode would
then overwrite the normal label of every button.

I found this while working on a personal fork of KCalc, where this one-line
change fixes it. Happy to open a merge request if that helps.

Note: I used an AI assistant (Claude) to trace the cause through the code. I
checked the behaviour and the fix myself.

SOFTWARE/OS VERSIONS
Linux: CachyOS (Arch-based)
KCalc: 26.08.1 (the code involved is unchanged on master as of 2026-09-14,
ae7d1f1c)
Qt: 6.11.2

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to