feat(lite): merge TUN mode with IPv6 routing
This commit is contained in:
+65
-1
@@ -2,7 +2,23 @@
|
||||
|
||||
from PyQt5.QtCore import Qt, QRectF, pyqtSignal
|
||||
from PyQt5.QtGui import QColor, QPainter
|
||||
from PyQt5.QtWidgets import QCheckBox, QLabel
|
||||
from PyQt5.QtWidgets import QCheckBox, QLabel, QFrame, QHBoxLayout
|
||||
|
||||
try:
|
||||
from PyQt5.QtWidgets import QGraphicsDropShadowEffect
|
||||
except ImportError: # 轻量测试桩不提供图形效果类,真实 PyQt5 仍使用阴影。
|
||||
class QGraphicsDropShadowEffect: # type: ignore[no-redef]
|
||||
def __init__(self, *_args, **_kwargs):
|
||||
pass
|
||||
|
||||
def setBlurRadius(self, *_args):
|
||||
pass
|
||||
|
||||
def setOffset(self, *_args):
|
||||
pass
|
||||
|
||||
def setColor(self, *_args):
|
||||
pass
|
||||
|
||||
from .theme import C_BORDER, C_GREEN, C_RED, C_TITLE
|
||||
|
||||
@@ -102,3 +118,51 @@ class StatusDot(QLabel):
|
||||
border: 1px solid rgba(136, 153, 170, 50);
|
||||
}}
|
||||
""")
|
||||
|
||||
|
||||
class ProxyModeCard(QFrame):
|
||||
"""整个卡片可点击;描边表示选择,圆点表示所选模式的运行状态。"""
|
||||
|
||||
clicked = pyqtSignal()
|
||||
|
||||
def __init__(self, title: str, parent=None):
|
||||
super().__init__(parent)
|
||||
self.setCursor(Qt.PointingHandCursor)
|
||||
self._glow = QGraphicsDropShadowEffect(self)
|
||||
self._glow.setBlurRadius(12)
|
||||
self._glow.setOffset(0, 1)
|
||||
self.setGraphicsEffect(self._glow)
|
||||
row = QHBoxLayout(self)
|
||||
row.setContentsMargins(11, 10, 11, 10)
|
||||
row.setSpacing(5)
|
||||
self.title = QLabel(title)
|
||||
self.title.setStyleSheet("font-weight: bold; background: transparent;")
|
||||
self.dot = StatusDot()
|
||||
for child in (self.title, self.dot):
|
||||
child.setAttribute(Qt.WA_TransparentForMouseEvents)
|
||||
row.addWidget(self.title)
|
||||
row.addStretch()
|
||||
row.addWidget(self.dot)
|
||||
self.set_state(False, False)
|
||||
|
||||
def set_state(self, selected: bool, running: bool) -> None:
|
||||
border = C_TITLE if selected else "#e2e8ef"
|
||||
background = "#f5f7f9" if selected else "#fafcfe"
|
||||
self.setStyleSheet(
|
||||
f"QFrame {{ background-color: {background}; border: {'2px' if selected else '1px'} "
|
||||
f"solid {border}; border-radius: 8px; }}"
|
||||
"QFrame:hover { border-color: #cbd6e2; background-color: #ffffff; }"
|
||||
"QLabel { border: none; }"
|
||||
)
|
||||
self._glow.setColor(QColor(136, 153, 170, 105 if selected else 52))
|
||||
if not selected:
|
||||
self.dot.set_disabled()
|
||||
elif running:
|
||||
self.dot.set_on()
|
||||
else:
|
||||
self.dot.set_off()
|
||||
|
||||
def mouseReleaseEvent(self, event):
|
||||
if event.button() == Qt.LeftButton and self.rect().contains(event.pos()):
|
||||
self.clicked.emit()
|
||||
super().mouseReleaseEvent(event)
|
||||
|
||||
Reference in New Issue
Block a user