ui v1.1
This commit is contained in:
BIN
ui/app.ico
Normal file
BIN
ui/app.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.7 KiB |
37
ui/editor.py
37
ui/editor.py
@@ -1,10 +1,19 @@
|
|||||||
# v3.0.0 editor.py
|
# v4.1.0 editor-link-click-fix-v1
|
||||||
import re
|
import re
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
|
||||||
from PyQt6.QtCore import Qt, QUrl
|
from PyQt6.QtCore import (
|
||||||
from PyQt6.QtGui import QDesktopServices
|
Qt,
|
||||||
from PyQt6.QtWidgets import QTextEdit
|
QUrl,
|
||||||
|
)
|
||||||
|
|
||||||
|
from PyQt6.QtGui import (
|
||||||
|
QDesktopServices,
|
||||||
|
)
|
||||||
|
|
||||||
|
from PyQt6.QtWidgets import (
|
||||||
|
QTextEdit,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
URL_PATTERN = re.compile(
|
URL_PATTERN = re.compile(
|
||||||
@@ -15,9 +24,14 @@ URL_PATTERN = re.compile(
|
|||||||
|
|
||||||
class LinkTextEdit(QTextEdit):
|
class LinkTextEdit(QTextEdit):
|
||||||
|
|
||||||
def mouseReleaseEvent(self, event) -> None:
|
def mouseReleaseEvent(
|
||||||
|
self,
|
||||||
|
event,
|
||||||
|
) -> None:
|
||||||
if (
|
if (
|
||||||
event.modifiers()
|
event.button()
|
||||||
|
== Qt.MouseButton.LeftButton
|
||||||
|
and event.modifiers()
|
||||||
& Qt.KeyboardModifier.ControlModifier
|
& Qt.KeyboardModifier.ControlModifier
|
||||||
):
|
):
|
||||||
cursor = self.cursorForPosition(
|
cursor = self.cursorForPosition(
|
||||||
@@ -47,14 +61,19 @@ class LinkTextEdit(QTextEdit):
|
|||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
webbrowser.open(target)
|
webbrowser.open(
|
||||||
|
target
|
||||||
|
)
|
||||||
|
|
||||||
except Exception:
|
except Exception:
|
||||||
QDesktopServices.openUrl(
|
QDesktopServices.openUrl(
|
||||||
QUrl(target)
|
QUrl(target)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
event.accept()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
super().mouseReleaseEvent(event)
|
super().mouseReleaseEvent(
|
||||||
|
event
|
||||||
|
)
|
||||||
@@ -28,7 +28,7 @@ def build_stylesheet(
|
|||||||
QWidget#container {{
|
QWidget#container {{
|
||||||
background: {background};
|
background: {background};
|
||||||
border: 1px solid {border};
|
border: 1px solid {border};
|
||||||
border-radius: 16px;
|
border-radius: 7px;
|
||||||
}}
|
}}
|
||||||
|
|
||||||
QWidget#container:hover {{
|
QWidget#container:hover {{
|
||||||
|
|||||||
Reference in New Issue
Block a user