-
Notifications
You must be signed in to change notification settings - Fork 199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Show link on hover #634
Show link on hover #634
Conversation
- Catch QWebEnginePage's Signal linkHovered(url:str) - Show hide url with statusbar Preliminary implementation using QMainWindow.statusBar()
Implementation as urlPopup(QLabel) added to ReTextWindow Known Issue: For links at the very bottom of the screen (footer) the popup covers the link and thus prevents hovering long enough to read. TODO: maybe find better place for 'self.urlPopup = ...' in window.py
Revert changes to window.py and dialogs.py
It does not look nice with dark themes: I recommend that you take colors from QPalette where possible, rather than hard-coding them. If QPalette doesn't have the needed colors, please define both light and dark versions, you can add them after this line: Line 54 in adeba38
|
Avoid detour via method only routing a str. Possible longer docstring for UrlPopup: """ Show link target on mouse hover QWebEnginePage emits signal 'linkHovered' which provides url: str -- target of link hovered (or empty on mouse-release) """
So the only thing remaining is my comment about dark themes. |
untestet in dark-mode
Please excuse being that quiet on this for so long.
Thanks to motivation by @donjan I tried some more and pushed 8935a93 for further use… -> Help appreciated Some alternative code (palette usage found on the internet last year, no alpha):
Resources: https://stackoverflow.com/a/2756376 suggests ("not to use the palette and go for Qt Style Sheet") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much. Can I ask you for a couple more things?
ReText/editor.py
Outdated
@@ -52,6 +52,8 @@ | |||
'restDirectives': {'light': '#800080', 'dark': '#d070d0'}, | |||
'restRoles': {'light': '#800000', 'dark': '#d07070'}, | |||
'whitespaceOnEnd': {'light': '#80e1e1a5', 'dark': '#8096966e'}, | |||
'UrlPopup': {'light': '#fafafafa', 'dark': '#fa323232'}, | |||
'UrlPopupBorder': {'light': '#64323232', 'dark': '#64fafafa'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please start a new section (add # Preview
header). Also, please start the keys with a lower-case letter for consistency (url
, not Url
).
Also, please put a trailing comma at the end.
ReText/webenginepreview.py
Outdated
self.window = window | ||
|
||
def hex_rgba(color): | ||
''' color:QColor ''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be made a static method or a top-level function?
This way we will have only one instance of this function for all labels.
Also, you can import QColor and use native type annotation (color: QColor
).
- colors: Add #Preview section' Rename UrlPopup -> urlPopupArea (consistent with other 'Areas') - import QColor (native type annotation) - make function hex_rgba(color: QColor) toplevel Tested: id(hex_rgba) always identical object with or without `@staticmethod` - raise UrlPopup text by 1px (especially letter '_' was very close to window border)
function returns str: 'rgba(...)'
see commit msg, note that dark-mode still not tested by me unsure about position of hex_rgba() in file -- kept it close to it's class (to-string-conversion of QColor could be part of getColor(colorName, rgba=False) but I don't like this because function gets blown up for other use) |
Please:
super().__init__(parent)
.setText('')
additional tosetVisible(False)
Thank you for creating and maintaining ReText!