retext-project / retext

ReText: Simple but powerful editor for Markdown and reStructuredText
GNU General Public License v2.0
1.86k stars 198 forks source link

Mouse cursor on link hover #623

Closed donjan closed 5 months ago

donjan commented 1 year ago

Using ReText 8.0.1 on Ubuntu 22.04.

Enabled the WebEngine renderer option (had to pip install PyQt6-WebEngine). With live preview on.

Observed behaviour

When hovering over a link, the mouse cursor stays arrow shaped. Screenshot from 2023-06-05 00-22-29

Expected behaviour

The mouse cursor should change into a hand with pointed index finger, as it does in ReText 7.x and in web browsers. Screenshot from 2023-06-05 00-24-58

donjan commented 5 months ago

This could be done in webenginepreview.py by adding QCursor to the from PyQt6.QtGui import line and defining the two cursors:

hand_cursor = QCursor(Qt.CursorShape.PointingHandCursor)
arrow_cursor = QCursor(Qt.CursorShape.ArrowCursor)

Then in webenginepreview.py::ReTextWebEnginePreview, once we have the webPage object, hook into it with

webPage.linkHovered.connect(lambda value: self.setCursor(hand_cursor if value else arrow_cursor))

Works for me: Screenshot from 2024-04-10 00-05-48

MR upcoming, I'll try to use camel case.