xiaoyifang / goldendict-ng

The Next Generation GoldenDict
https://xiaoyifang.github.io/goldendict-ng/
Other
1.49k stars 80 forks source link

[Bug] GoldenDict keep adding "&" in group name #1484

Open cuongha0701 opened 2 months ago

cuongha0701 commented 2 months ago

Describe the bug GoldenDict keep adding "&" character in group name

To Reproduce Steps to reproduce the behavior:

  1. Go to Edit
  2. Click on Dictionaries
  3. Click on Groups
  4. Click on OK | Apply button
  5. See error

Screenshots Screenshot_20240428_115805

OS and software versions KDE Plasma 6.0.4 Goldendict-ng 24.02.16.e78aff27 at 2024-04-24T04:58:00Z Qt 6.7.0 GCC 13.2.1 20230801 arch linux 6.8.7-arch1-2 x86_64-little_endian-lp64 Flags: MAKE_ZIM_SUPPORT USE_ICONV MAKE_CHINESE_CONVERSION_SUPPORT

shenlebantongying commented 2 months ago

Yes, I reproduced on KDE6 + Qt6.7. This is a KDE only bug.

The & has a special meaning https://doc.qt.io/qt-6/qshortcut.html#details for mnemonic shortcuts.

By holding Alt, the first group tab is highlighted, while the others are not, Alt+Z will jump to the first tab.

The first tab will trigger this bug.

image

KDE automatically modifies the text string to include a & for mnemonic shortcuts, and we do & escaping, which makes the modification persist.

Escaping on GD's side https://github.com/goldendict/goldendict/commit/ed2876d7b2ab634af5613de136dcfd2340c80a7c

Previous similar bugs:

https://github.com/goldendict/goldendict/issues/847 https://github.com/goldendict/goldendict/issues/1031

xiaoyifang commented 2 months ago

https://stackoverflow.com/questions/32688153/how-to-disable-automatic-mnemonics-in-a-qt-application-on-kde

xiaoyifang commented 2 weeks ago

image

A possible solution: 1, when add new group , escape the & character. 2, when display ,do not escape the & character.

shenlebantongying commented 2 weeks ago

1, when add new group , escape the & character.

This is exactly what GD is doing 😅.

https://github.com/goldendict/goldendict/commit/ed2876d7b2ab634af5613de136dcfd2340c80a7c#diff-ca4a0baa33b84a02d00fc0857a37dda1d26e53c3f0f99f8f92fc7d9bb706858bR284-R286

I think the root fix is either

xiaoyifang commented 2 weeks ago

Gd-ng has done the following two things: 1, when add new group , escape the & character. 2, when display ,escape the & character. (DO NOT NEEDED)

image

only 1 is needed.