Bug 493412 - Keyboard Shortcuts option to assign an empty shortcut assigns the spacebar to that action
Summary: Keyboard Shortcuts option to assign an empty shortcut assigns the spacebar to...
Status: RESOLVED FIXED
Alias: None
Product: frameworks-kxmlgui
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: 6.6.0
Platform: Fedora RPMs Linux
: NOR normal
Target Milestone: ---
Assignee: kdelibs bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-09-20 19:44 UTC by John Kizer
Modified: 2024-09-26 06:17 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Kizer 2024-09-20 19:44:23 UTC
SUMMARY
In the Keyboard Shortcuts dialog, accepting the option to assign an empty shortcut when reusing an existing key combination instead assigns the spacebar to the action that was previously associated to that shortcut

STEPS TO REPRODUCE
1. Assign a shortcut to Focus Search
2. Try to assign the same shortcut to Show Search
3. Click the Reassign button when offered

OBSERVED RESULT
Spacebar is assigned as the shortcut to Focus Search

EXPECTED RESULT
Nothing should be a shortcut for Focus Search

SOFTWARE/OS VERSIONS
KDE Plasma Version: 6.1.5
KDE Frameworks Version: 6.6.0
Qt Version: 6.7.2
Comment 1 Justin Zobel 2024-09-22 06:05:18 UTC
I'm unable to replicate this on git master, the Focus Search goes blank as it should.

Can you please test on 24.08.1 either from Fedora (if there's an upgrade available) or via Flatpak please?
Comment 2 John Kizer 2024-09-22 18:03:12 UTC
(In reply to Justin Zobel from comment #1)
> I'm unable to replicate this on git master, the Focus Search goes blank as
> it should.
> 
> Can you please test on 24.08.1 either from Fedora (if there's an upgrade
> available) or via Flatpak please?

Sorry, I realize I missed a step to reproduce! Step 4 in Steps to Reproduce should have been "Close and reopen Kate". I see the same issue with Kate 24.08.1 from Flathub as well. From what I can see, the steps taken seem to write these lines to .config/katerc:

[Shortcuts]
kate_mdi_focus_toolview_kate_plugin_katesearch=;\s
kate_mdi_toolview_kate_plugin_katesearch=Ctrl+F

Which doesn't show up until Kate is restarted, but causes it to read Space as the default keybinding for the shortcut that was intended to be blank.

Sorry about that - are you seeing that as well?
Comment 3 Justin Zobel 2024-09-24 03:57:03 UTC
Confirmed on kate from git master with the extra step.

cat .config/katerc | grep focus
kate_mdi_focus_toolview_kate_plugin_katesearch=;\s
Comment 4 John Kizer 2024-09-25 00:25:29 UTC
I'm having a heck of a time figuring out how to get to the next step, but from what I can tell so far, there's a problem in how the shortcut property of the QKeySequence for an Alternate shortcut is converted to a string, at least when writing to the katerc file. That ends up causing a space to always be inserted after the semicolon.

This was causing the issue I was observing in my case, but it also affects trying to set an Alternate shortcut in the first place - it looks like if someone tries to set both a Primary and Alternate shortcut for the same thing in that same dialog, it'll work during that session, but katerc will have a space incorrectly inserted after the semicolon (like "Ctrl+F; Alt+Shift+R") - so when Kate is restarted and it loads from katerc, it won't load the alternate correctly.

I gave it a shot to try following the debugging instructions on the Community website, and try to look at what the data looks like "inside" QKeySequence, but I don't know if I'm doing the right thing at all there - but I can at least confirm that in kactioncollection.cpp, the shortcut value for a "stolen"/empty one in that process is "; ":

> Thread 1 "kate" hit Breakpoint 4, KActionCollection::writeSettings (this=<optimized out>, config=0x7ffe1f0c2f20, writeAll=false,
>    oneAction=<optimized out>) at /usr/src/debug/kf6-kxmlgui-6.6.0-1.fc40.x86_64/src/kactioncollection.cpp:692
> 692                     qCDebug(DEBUG_KXMLGUI) << "\twriting " << actionName << " = " << s;
> (gdb) list
> 687                     // not set to its default value. Write it
> 688                     QString s = QKeySequence::listToString(action->shortcuts());
> 689                     if (s.isEmpty()) {
> 690                         s = QStringLiteral("none");
> 691                     }
> 692                     qCDebug(DEBUG_KXMLGUI) << "\twriting " << actionName << " = " << s;
> 693                     config->writeEntry(actionName, s, flags);
> 694
> 695                 } else if (bConfigHasAction) {
> 696                     // Otherwise, this key is the same as default but exists in
> (gdb) print actionName
> $25 = "kate_mdi_focus_toolview_kate_plugin_katesearch"
> (gdb) print s
> $26 = "; "

I'm just not sure where to go to investigate further - I'm trying out Qt Creator but I think I'm in over my head because I can't figure out how to look "inside" the QKeySequence referenced on line 688?
Comment 5 Christoph Cullmann 2024-09-25 16:24:39 UTC
That looks like an issue in kxmlgui. I hope we will have time to debug this more, thanks already for the nice investigation!
Comment 6 Bug Janitor Service 2024-09-26 05:21:37 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1593
Comment 7 Waqar Ahmed 2024-09-26 06:17:45 UTC
Git commit a23a9939e4aa21db7404b68bc5dad66d83fbbdd4 by Waqar Ahmed, on behalf of John Kizer.
Committed on 26/09/2024 at 06:12.
Pushed by waqar into branch 'master'.

Fix expected separator for kate_mdi shortcuts

Shortcuts for MDI ToolViews are read in via separate code from other shortcuts, and that separate code expected a separator of a semicolon only, not the semicolon+space combination used everywhere else.

M  +1    -1    apps/lib/katemdi.cpp

https://invent.kde.org/utilities/kate/-/commit/a23a9939e4aa21db7404b68bc5dad66d83fbbdd4