kdbg icon indicating copy to clipboard operation
kdbg copied to clipboard

When run in KDE, some accelerators (`&<letter>`) are not being interpreted?

Open hartwork opened this issue 1 year ago • 8 comments

Some of the accelerator keys seem to not be set up properly in kdbg. A screenshot probably say it best:

kdbg_Screenshot_20231026_033000

Any ideas why this is happening?

hartwork avatar Oct 26 '23 01:10 hartwork

Works for me as expected: the accelerators are invisible and become visible as underlined letters only when I press Alt. This happens both in English and localized versions.

j6t avatar Oct 26 '23 20:10 j6t

@j6t for me, this is what I see all the time (without pressing Alt). Also, some of the accelerators do work, e.g. Brea_k_p… on the very lower left.

hartwork avatar Oct 26 '23 21:10 hartwork

I have no idea what is going on. Can you try to move away .config/kdbgrc so that you start with pristine settings? Do you have an old kdbgui.rc somewhere in your $HOME/.??*? Try moving it out of the way.

j6t avatar Oct 28 '23 17:10 j6t

@j6t deleted ~/.config/kdbgrc now, same. It seems as if all of these accelerators appear in two places that are interconnected and either some code tries to help us by showing that one of the two will not be working or finds an unused accelerator itself and then uses the string with & in the right and the wrong place. Only guessing here. Functionality wise it seems fine, just the display seems broken and it looks like a bug through user eyes.

hartwork avatar Oct 28 '23 17:10 hartwork

Hi again @j6t,

I did a little digging on this matter. I found:

  • That you only see accelerators when pressing Alt is because you're on Windows while I see them all the time because I'm on Linux, as I learned at https://doc.qt.io/qt-5/qshortcut.html#details .

  • The accelerators are auto-added by kwidgetsaddons (KAcceleratorManager::manage) and kxmlgui (KCheckAccelerators::checkAccelerators) of KDE and it affects the window title of QDockWidet.

  • Auto-adding of accelerators can be disabled globally by adding this to ~/.config/kdeglobals (but keeping them enabled seems desirable):

    [Development]
    AutoCheckAccelerators=false
    

    Learned at https://stackoverflow.com/a/32711483/11626624 and confirmed locally on Linux.

  • It can also be disabled for single widgets via KAcceleratorManager::setNoAccel(widget);.

  • QDockWidet uses the same title for its tabs and its title bar, but they process the & added by KDE differently.

  • QDockWidet's default-drawn title bar cannot be accessed as a widget, titleBarWidget() only returns non-nullptr if someone has set a custom one previously via setTitleBarWidget(). So that's a dead end (and drawing our own would take away native styling).

  • The internal magic title bar happens in method QDockWidget::paintEvent where line initStyleOption(&titleOpt); sets the title but we cannot override either of the two methods because they are non-virtual in Qt 5. I guess that would have been the best place for a workaround patch. initStyleOption seems to have become virtual in Qt 6, so it may take Qt 6 for a fix. At least some hope.

  • PS: I also found an interesting comment in the code of method KAcceleratorManagerPrivate::manageDockWidget explaining that its author considers the combination of QDockWidget and shortcuts "broken for now".

What do you think?

Best, Sebastian

hartwork avatar Oct 29 '23 00:10 hartwork

  • That you only see accelerators when pressing Alt is because you're on Windows while I see them all the time because I'm on Linux, as I learned at https://doc.qt.io/qt-5/qshortcut.html#details .

I am not on Windows, for that matter. I use openSUSE and KDE (not Gnome). The statement on that site is clearly not up-to-date. I even observe the behavior in the menu bar of VS Code, which I would not expect to be based on Qt, or Gnome. shrug

I could live with the hotkeys disabled in all QDockWidgets, but everywhere else (dialogs, menus...) they must remain, of course.

j6t avatar Oct 29 '23 17:10 j6t

  • That you only see accelerators when pressing Alt is because you're on Windows while I see them all the time because I'm on Linux, as I learned at https://doc.qt.io/qt-5/qshortcut.html#details .

I am not on Windows, for that matter. I use openSUSE and KDE (not Gnome). The statement on that site is clearly not up-to-date. I even observe the behavior in the menu bar of VS Code, which I would not expect to be based on Qt, or Gnome. shrug

@j6t interesting, thanks for the clarification!

PS: I'm on XFCE on Gentoo.

I could live with the hotkeys disabled in all QDockWidgets, but everywhere else (dialogs, menus...) they must remain, of course.

It would be easy to patch createDockWidget to exclude these widgets but losing the accelerators is probably worse than getting rid of the & display artefacts at the moment. I think I'd vote to postpone this until after adding support for Qt 6.

PS: Is anything left blocking #31 and #32 to merge? I'd be happy to improve anything that still needs improvement.

hartwork avatar Oct 29 '23 18:10 hartwork

PS: Is anything left blocking #31 and #32 to merge? I'd be happy to improve anything that still needs improvement.

Nothing obvious, yet. I just take my time.

j6t avatar Oct 29 '23 21:10 j6t