Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KDE adds "&" in group name and article tabs names (history and favorites) #1484

Open
cuongha0701 opened this issue Apr 28, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@cuongha0701
Copy link

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 shenlebantongying added the bug Something isn't working label May 15, 2024
@shenlebantongying
Copy link
Collaborator

shenlebantongying commented May 15, 2024

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 goldendict/goldendict@ed2876d

Previous similar bugs:

goldendict/goldendict#847
goldendict/goldendict#1031

@xiaoyifang
Copy link
Owner

image

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

@shenlebantongying
Copy link
Collaborator

shenlebantongying commented Jul 10, 2024

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

This is exactly what GD is doing 😅.

goldendict/goldendict@ed2876d#diff-ca4a0baa33b84a02d00fc0857a37dda1d26e53c3f0f99f8f92fc7d9bb706858bR284-R286

I think the root fix is either

  • Fix KDE
  • Stop storing program states/variables in UI widgets, refactor the related code properly into something like MVC

@xiaoyifang
Copy link
Owner

xiaoyifang commented Jul 10, 2024

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.

@shenlebantongying
Copy link
Collaborator

To fix this issue, the usages of tabText need to be revised. The related lines of code are probably suboptimal because "storing states in UI widgets" appears to be a bad practice.

https://github.com/search?q=repo%3Axiaoyifang%2Fgoldendict-ng%20tabText

@xiaoyifang
Copy link
Owner

xiaoyifang commented Nov 4, 2024

A second brutal solution :
Do not allow & in tab. (strip all & away). The complex part is users can modify the group name which has to be sync back to the model.

@shenlebantongying
Copy link
Collaborator

shenlebantongying commented Nov 4, 2024

The & means “and” and it is printed on every keyboard. I think someone will certainly use it for Group names.

@shenlebantongying shenlebantongying changed the title [Bug] GoldenDict keep adding "&" in group name KDE adds "&" in group name and article tabs names (history and favorites) Nov 4, 2024
@shenlebantongying
Copy link
Collaborator

Little more info to reproduce this issue:

The letters of the word have to be not in other texts in UI.

(I just use a word with letter z).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants