Skip to content

Commit

Permalink
Intermediate advances on dark-mode
Browse files Browse the repository at this point in the history
untestet in dark-mode
  • Loading branch information
red-kite committed Apr 1, 2024
1 parent 93b02ee commit 8935a93
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
2 changes: 2 additions & 0 deletions ReText/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
}

colorValues = {}
Expand Down
22 changes: 17 additions & 5 deletions ReText/webenginepreview.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from ReText import globalSettings
from ReText.editor import getColor
from ReText.syncscroll import SyncScroll
from PyQt6.QtCore import QEvent, Qt
from PyQt6.QtGui import QDesktopServices, QFontInfo, QGuiApplication, QTextDocument
Expand All @@ -39,21 +40,32 @@ def interceptRequest(self, info):


class UrlPopup(QLabel):

def __init__(self, window):
super().__init__(window)
self.window = window

def hex_rgba(color):
''' color:QColor '''
return "rgba({r}, {g}, {b}, {a})".format(
r = color.red(),
g = color.green(),
b = color.blue(),
a = color.alpha())
self.setStyleSheet('''
border: 1px solid #64323232;
border: 1px solid {:s};
border-radius: 3px;
background: #FAFAFAFA;
''')
background: {:s};
'''.format(hex_rgba(getColor('UrlPopupBorder')),
hex_rgba(getColor('UrlPopup'))))
self.fontHeight = self.fontMetrics().height()
self.setVisible(False)

def pop(self, url: str):
""" Show link target on mouse hover """
""" Show link target on mouse hover
QWebEnginePage emits signal 'linkHovered' which provides
url: str -- target of link hovered (or empty on mouse-release)
"""
if url:
self.setText(url)
windowBottom = self.window.rect().bottom()
Expand Down

0 comments on commit 8935a93

Please sign in to comment.