Bug 406387

Summary: Clicked signal wrongly used as a trigger for activated signal (QTreeWidget, PyQt5)
Product: [Plasma] plasma-integration Reporter: william.belr
Component: generalAssignee: Plasma Bugs List <plasma-bugs-null>
Status: CLOSED NOT A BUG    
Severity: normal CC: kde, plasma-bugs-null
Priority: NOR    
Version First Reported In: 5.15.3   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description william.belr 2019-04-10 05:16:42 UTC
SUMMARY
In QTreeWidget (and perhaps others), the activated signal is usually triggered by a double click, or by pressing enter. Under Plasma KDE, 'clicked' is also used as a trigger. This does not comply with the expected Qt behavior and cause trouble for cross platform applications. 


STEPS TO REPRODUCE
0. Install PyQt5
1. Run this script in a terminal: https://pastebin.com/raw/jfNiiFj6
2. Left click on the 'example item' tree widget item
3. Note the stdout


OBSERVED RESULT (Manjaro-KDE)
pressed
clicked
activated


EXPECTED RESULT (non KDE, Openbox)
pressed
clicked


SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Manjaro
KDE Plasma Version: 5.15.3
KDE Frameworks Version: 5.56.0
Qt Version: 5.12.2 (built against 5.12.1)
Comment 1 David Edmundson 2019-04-10 09:28:15 UTC
>. This does not comply with the expected Qt behavior


From the docs

void QAbstractItemView::activated(const QModelIndex &index)

This signal is emitted when the item specified by index is activated by the user. How to activate items depends on the platform; e.g., by single- or double-clicking the item, or by pressing the Return or Enter key when the item is current.
Comment 2 william.belr 2019-04-10 13:35:10 UTC
The problem is that there are already distinct signals for either click, doubleclick, but none for when Return is pressed on the item. Therefore, it is easy to add a connection to either click or doubleclick if needed, but the only way to add a trigger for Return in this case would be with a keyPressEvent, which is quite a big workaround for a problem that affect a single DE. This is why it is important not to attribute to many signal to activated().
Comment 3 David Edmundson 2019-04-10 20:04:47 UTC
The relevant hint is  QStyle::SH_ItemView_ActivateItemOnSingleClick

Even if we did change our default to suit this one application you're still broken for any other qstyle that sets that hint.  

This is an application bug, not a DE one.

If you think Qt behaviour should be different, please take that up with Qt.