新增功能:
- 底部提示行改为:左对齐"请勿二次分发此软件!"+ 右对齐"设置"入口(hover 下划线+手型,与节点标签一致) - 新增设置弹窗(风格与登录框一致),目前仅含"退出登录":清除加密凭据与本地节点配置,下次启动/开启代理时要求重新登录
This commit is contained in:
+78
-8
@@ -1139,21 +1139,24 @@ _NL_BASE = f"color: {C_TITLE}; font-size: 12px;"
|
|||||||
_NL_HOVER = _NL_BASE + " text-decoration: underline;"
|
_NL_HOVER = _NL_BASE + " text-decoration: underline;"
|
||||||
|
|
||||||
class NodeLabel(QLabel):
|
class NodeLabel(QLabel):
|
||||||
"""节点标签:hover 显示下划线+手型光标,点击发出 clicked 信号。"""
|
"""可点击标签:hover 显示下划线+手型光标,点击发出 clicked 信号。"""
|
||||||
clicked = pyqtSignal()
|
clicked = pyqtSignal()
|
||||||
|
|
||||||
def __init__(self, text=""):
|
def __init__(self, text="", tooltip="点击切换节点", base=None, hover=None):
|
||||||
super().__init__(text)
|
super().__init__(text)
|
||||||
self.setStyleSheet(_NL_BASE)
|
self._base = base or _NL_BASE
|
||||||
self.setToolTip("点击切换节点")
|
self._hover = hover or self._base + " text-decoration: underline;"
|
||||||
|
self.setStyleSheet(self._base)
|
||||||
|
if tooltip:
|
||||||
|
self.setToolTip(tooltip)
|
||||||
|
|
||||||
def enterEvent(self, e):
|
def enterEvent(self, e):
|
||||||
self.setStyleSheet(_NL_HOVER)
|
self.setStyleSheet(self._hover)
|
||||||
self.setCursor(Qt.PointingHandCursor)
|
self.setCursor(Qt.PointingHandCursor)
|
||||||
super().enterEvent(e)
|
super().enterEvent(e)
|
||||||
|
|
||||||
def leaveEvent(self, e):
|
def leaveEvent(self, e):
|
||||||
self.setStyleSheet(_NL_BASE)
|
self.setStyleSheet(self._base)
|
||||||
self.unsetCursor()
|
self.unsetCursor()
|
||||||
super().leaveEvent(e)
|
super().leaveEvent(e)
|
||||||
|
|
||||||
@@ -1309,6 +1312,57 @@ class LoginDialog(QDialog):
|
|||||||
self.lb_err.setText(info)
|
self.lb_err.setText(info)
|
||||||
self.lb_err.show()
|
self.lb_err.show()
|
||||||
|
|
||||||
|
# ── 设置弹窗 ─────────────────────────────────────────
|
||||||
|
|
||||||
|
class SettingsDialog(QDialog):
|
||||||
|
"""设置弹窗(当前仅含退出登录:清除凭据与本地节点配置)。"""
|
||||||
|
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
self.setWindowTitle("设置")
|
||||||
|
self.setWindowIcon(load_icon())
|
||||||
|
self.setFixedSize(280, 150)
|
||||||
|
self.setStyleSheet(f"""
|
||||||
|
QDialog {{ background-color: {C_BG}; }}
|
||||||
|
QLabel {{ color: {C_TEXT}; font-family: "Microsoft YaHei", "Segoe UI", sans-serif; font-size: 12px; }}
|
||||||
|
""")
|
||||||
|
|
||||||
|
layout = QVBoxLayout(self)
|
||||||
|
layout.setSpacing(12)
|
||||||
|
layout.setContentsMargins(20, 16, 20, 16)
|
||||||
|
|
||||||
|
title = QLabel("设置")
|
||||||
|
title.setStyleSheet(f"color: {C_TITLE}; font-size: 15px; font-weight: bold;")
|
||||||
|
title.setAlignment(Qt.AlignCenter)
|
||||||
|
layout.addWidget(title)
|
||||||
|
|
||||||
|
btn_logout = QPushButton("退出登录")
|
||||||
|
btn_logout.setStyleSheet(f"""
|
||||||
|
QPushButton {{
|
||||||
|
background-color: {C_CARD}; color: {C_RED};
|
||||||
|
border: 1px solid {C_RED}; border-radius: 6px;
|
||||||
|
padding: 7px 16px; font-size: 13px;
|
||||||
|
}}
|
||||||
|
QPushButton:hover {{ background-color: #ffecec; }}
|
||||||
|
""")
|
||||||
|
btn_logout.setToolTip("清除登录凭据与本地节点配置,下次启动需重新登录")
|
||||||
|
btn_logout.clicked.connect(self._logout)
|
||||||
|
layout.addWidget(btn_logout)
|
||||||
|
|
||||||
|
layout.addStretch()
|
||||||
|
|
||||||
|
def _logout(self):
|
||||||
|
"""退出登录:删除加密凭据与本地节点配置,清空内存缓存。"""
|
||||||
|
global _NODES
|
||||||
|
for name in ("auth.json", "nodes.json"):
|
||||||
|
try:
|
||||||
|
(_USER_DIR / name).unlink(missing_ok=True)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
_NODES = None
|
||||||
|
log("已退出登录:凭据与节点配置已清除,下次启动或开启代理时需重新登录")
|
||||||
|
self.accept()
|
||||||
|
|
||||||
# ── 状态指示灯(小圆点) ───────────────────────────────
|
# ── 状态指示灯(小圆点) ───────────────────────────────
|
||||||
|
|
||||||
class StatusDot(QLabel):
|
class StatusDot(QLabel):
|
||||||
@@ -1529,10 +1583,20 @@ class MainWindow(QWidget):
|
|||||||
hints_layout.setContentsMargins(0, 0, 0, 0)
|
hints_layout.setContentsMargins(0, 0, 0, 0)
|
||||||
hints_layout.setSpacing(1)
|
hints_layout.setSpacing(1)
|
||||||
|
|
||||||
|
# 第一行:左对齐警示 + 右对齐"设置"入口
|
||||||
|
top_row = QHBoxLayout()
|
||||||
|
top_row.setContentsMargins(0, 0, 0, 0)
|
||||||
warn_label = QLabel("请勿二次分发此软件!")
|
warn_label = QLabel("请勿二次分发此软件!")
|
||||||
warn_label.setStyleSheet(f"color: {C_RED}; font-size: 11px;")
|
warn_label.setStyleSheet(f"color: {C_RED}; font-size: 11px;")
|
||||||
warn_label.setAlignment(Qt.AlignCenter)
|
top_row.addWidget(warn_label)
|
||||||
hints_layout.addWidget(warn_label)
|
top_row.addStretch()
|
||||||
|
self.link_settings = NodeLabel(
|
||||||
|
"设置", tooltip="设置",
|
||||||
|
base=f"color: {C_SUBTEXT}; font-size: 11px;",
|
||||||
|
hover=f"color: {C_TEXT}; font-size: 11px; text-decoration: underline;")
|
||||||
|
self.link_settings.clicked.connect(self._show_settings_dialog)
|
||||||
|
top_row.addWidget(self.link_settings)
|
||||||
|
hints_layout.addLayout(top_row)
|
||||||
|
|
||||||
privacy_label = QLabel("使用此软件将会收集并上报您的 IP 地址及部分设备信息")
|
privacy_label = QLabel("使用此软件将会收集并上报您的 IP 地址及部分设备信息")
|
||||||
privacy_label.setStyleSheet("color: #c8ccd4; font-size: 9px;")
|
privacy_label.setStyleSheet("color: #c8ccd4; font-size: 9px;")
|
||||||
@@ -1668,6 +1732,12 @@ class MainWindow(QWidget):
|
|||||||
self._op_done.emit("stop", False)
|
self._op_done.emit("stop", False)
|
||||||
|
|
||||||
|
|
||||||
|
# ── 设置 ──
|
||||||
|
def _show_settings_dialog(self):
|
||||||
|
"""打开设置弹窗;退出登录后刷新节点标题。"""
|
||||||
|
SettingsDialog(self).exec_()
|
||||||
|
self._refresh_subtitle()
|
||||||
|
|
||||||
# ── 节点登录 ──
|
# ── 节点登录 ──
|
||||||
def _maybe_show_login(self):
|
def _maybe_show_login(self):
|
||||||
"""启动时节点未配置:隐藏主窗口只显示登录框;登录成功恢复,取消则退出。"""
|
"""启动时节点未配置:隐藏主窗口只显示登录框;登录成功恢复,取消则退出。"""
|
||||||
|
|||||||
Reference in New Issue
Block a user