tibirna / qgit

Official git repository for QGit.
Other
174 stars 68 forks source link

Extract ref name from QAction's iconText() instead of text() #7

Closed gaaf closed 6 years ago

gaaf commented 6 years ago

When selecting a branch on the context menu, the action text is supposed to have the ref name in it. In some cases, Qt mangles the text and inserts an ampersand (shortcut marker) on the triggered action (shortcuts are not shown in the UI). I don't know why Qt does this, this seems undocumented behavior. Due to the mangling, the ref obviously can't be found. By using iconText() instead of text(), Qt returns the text with ampersands removed.

As Qt is mangling texts, maybe a better fix would be to set the ref name into the userdata somewhere, but this quick fix works for me. It'll probably break on refnames with ampersands, but they should be rare.

gaaf commented 6 years ago

The cause is somewhat explained here: https://stackoverflow.com/questions/32999344/prevent-qt-from-generating-shortcuts https://stackoverflow.com/questions/32688153/how-to-disable-automatic-mnemonics-in-a-qt-application-on-kde

Oh well, it ssems to be a KDE feature/bug (sigh) https://bugs.kde.org/show_bug.cgi?id=337491

I suppose this PR should be regarded as a workaround for that bug.

tibirna commented 6 years ago

Well, I'd rather this doesn't rely on QAction's standard data items at all. These can be arbitrarily modified. We should have a custom BranchNameAction that inherits QAction and just adds a "branch" attribute and accessors.

I'll pull the workaround for now, but this is still a todo.

Thanks!