Review Request 116028: Add a hover effect for the selection toggle.

Emmanuel Pescosta emmanuelpescosta099 at gmail.com
Fri Feb 28 11:44:50 GMT 2014



> On Feb. 26, 2014, 5:28 p.m., Frank Reininghaus wrote:
> > Thanks for analyzing this problem.
> > 
> > I actually thought that QGraphicsView/QGraphicsScene send hover events not only to one item (the KItemListView, which lets KItemListController handle its events), but also to other items (which may be children of another item), like the selection toggle (indirect child of the KItemListView) in our case. Is that wrong? I found nothing in the QGraphics* docs that says that children will not get hover events anymore if their parent receives and handles hover events.
> 
> Emmanuel Pescosta wrote:
>     > Is that wrong?
>     Yes it forwards the events to the children, but when you override the event function, you have to call the base::*Event to make it working.
>     
>     Some time ago I worked with others on a project, where you can build networks (nodes, connections, ...), we did that with QGraphics*.
>     We had multiple editing modes (normal, connection, node adding, ...) and we made use of the event forwarding.
>     
>     E.g. (no real world code):
>     void EditorGraphicsViewWidget::mousePressEvent(QMouseEvent* event)
>     {
>             switch (m_editMode) {
>             case NodeAdding:
>                 /* code for node adding */
>                 break;
>     
>             case ConnectionAdding:
>                  /* code */
>                  break;
>            
>             case Normal:
>             default:
>                  QGraphicsView::mousePressEvent(event); // only these events are forwarded to the connections/nodes/other graphics items
>             }
>     }
>     
>     I thinks it's the same with hover events. Always view -> widget -> child widget -> child child widget -> ...
>     
>     void KItemListView::event(QEvent* event) does the event handling in Dolphin views, all events which can be processed in the controller aren't forwarded to the children.
>     
>     The next thing is, every graphics item needs a bounding rect to make it working as far as I know (Dolphin doesn't implement this) - Dolphin has the controller for that, maybe to handle the to more complex item list widget bounding rects (icon bounding rect + text bounding rect + spacing between them).

Btw. I played around with qml some time ago (https://lh6.googleusercontent.com/-zi0JDMHv9-M/Uu7XIvUU6jI/AAAAAAAAAuQ/n1k156s1MC8/w884-h707-no/qmlfile.png)
I have added a file selector, which shows up we you hover an item (same as Dolphin).

The show/hide selector handling is done in the file item onEntered/onExited functions (similar to Dolphins approach). - Works great so far ;)

BUT when I enable hoverEnabled in the selector and hover the selector, then a strange problem appears. -> It starts flickering really fast

[1] The problem is, that the selector grabs all hover events, when you are within its bounding box, so the file item is not hovered anymore and onExited will be called, which
deletes the selector -> The file item is now hovered again, because you are within its bouding box (selector bounding box is not here anymore), so onEntered will be called, 
which creates the selector again. When you are still within the selectors new bounding rect the problem starts again. [jump to 1]

Maybe we run into the same problem, when we let QGraphics* handle the hover stuff. (Not tested in the widget world)


- Emmanuel


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://git.reviewboard.kde.org/r/116028/#review50959
-----------------------------------------------------------


On Feb. 24, 2014, 6:27 p.m., Emmanuel Pescosta wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://git.reviewboard.kde.org/r/116028/
> -----------------------------------------------------------
> 
> (Updated Feb. 24, 2014, 6:27 p.m.)
> 
> 
> Review request for Dolphin.
> 
> 
> Bugs: 299328
>     http://bugs.kde.org/show_bug.cgi?id=299328
> 
> 
> Repository: kde-baseapps
> 
> 
> Description
> -------
> 
> Add a hover effect for the selection toggle.
> 
> The KItemListController handles all hover events, so we can't use the hoverMoveEvent in the KItemListWidget directly.
> Instead, if the current widget is valid, we set the widget hover position in KItemListController::hoverMoveEvent, so that the widget can react on it.
> 
> KItemListSelectionToggle has setHovered instead of hoverEnterEvent/hoverLeaveEvent now, we set the hover state in
> KItemListWidget::setHoverPosition.
> 
> The icon state toggles now between ActiveState and DisabledState (I hope these are the right states for this usecase)
> 
> 
> Diffs
> -----
> 
>   dolphin/src/kitemviews/kitemlistcontroller.cpp 7344b99 
>   dolphin/src/kitemviews/kitemlistwidget.h 954629d 
>   dolphin/src/kitemviews/kitemlistwidget.cpp 85cd70c 
>   dolphin/src/kitemviews/private/kitemlistselectiontoggle.h ba29293 
>   dolphin/src/kitemviews/private/kitemlistselectiontoggle.cpp 6bbf3c2 
> 
> Diff: https://git.reviewboard.kde.org/r/116028/diff/
> 
> 
> Testing
> -------
> 
> Works.
> 
> 
> Thanks,
> 
> Emmanuel Pescosta
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.kde.org/mailman/private/kfm-devel/attachments/20140228/bc9ae5a7/attachment.htm>


More information about the kfm-devel mailing list