refactor: 拆分页面 UI 模块 (#3)

This commit is contained in:
chengma
2026-08-06 12:06:16 +08:00
parent 1f95de373a
commit 5916de4b92
3 changed files with 243 additions and 0 deletions
+79
View File
@@ -20,3 +20,82 @@
注意:设备连接**不是**独立的顶级页面,统一放在本页,
见 `docs/client/01-requirements.md` §3。
"""
from PyQt5.QtWidgets import QHBoxLayout, QSizePolicy, QVBoxLayout, QWidget
from qfluentwidgets import (
CaptionLabel,
CardWidget,
FluentIcon as FIF,
LineEdit,
PushButton,
SubtitleLabel,
TitleLabel,
)
class DevicePage(QWidget):
"""Android 设备连接页。"""
def __init__(self, parent=None):
super().__init__(parent)
self.setObjectName("devicePage")
self.addressInput = LineEdit(self)
self.addressInput.setText("192.168.0.173:5555")
self.addressInput.setPlaceholderText("IP:端口")
self.addressInput.setClearButtonEnabled(True)
self.addressInput.setAccessibleName("Android 设备地址")
self.connectButton = PushButton(FIF.LINK, "连接设备", self)
self.connectButton.setAccessibleName("连接 Android 设备")
self.deviceStatusLabel = CaptionLabel("当前状态:未连接", self)
card = CardWidget(self)
card.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
cardLayout = QVBoxLayout(card)
cardLayout.setContentsMargins(24, 20, 24, 22)
cardLayout.setSpacing(12)
cardLayout.addWidget(SubtitleLabel("无线调试设备", card))
cardLayout.addWidget(CaptionLabel("设备地址", card))
connectionLayout = QHBoxLayout()
connectionLayout.setSpacing(12)
connectionLayout.addWidget(self.addressInput, 1)
connectionLayout.addWidget(self.connectButton)
cardLayout.addLayout(connectionLayout)
cardLayout.addWidget(self.deviceStatusLabel)
layout = QVBoxLayout(self)
layout.setContentsMargins(36, 30, 36, 36)
layout.setSpacing(16)
layout.addWidget(TitleLabel("设备管理", self))
# description = BodyLabel("管理 uiautomator2 使用的 Android 设备连接。", self)
# description.setWordWrap(True)
# layout.addWidget(description)
layout.addWidget(card)
layout.addStretch(1)
class SettingsPage(QWidget):
"""后续设置项的扩展入口。"""
def __init__(self, parent=None):
super().__init__(parent)
self.setObjectName("settingsPage")
card = CardWidget(self)
card.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed)
cardLayout = QVBoxLayout(card)
cardLayout.setContentsMargins(24, 20, 24, 22)
cardLayout.setSpacing(8)
cardLayout.addWidget(SubtitleLabel("应用设置", card))
# hint = BodyLabel("主题、日志和任务策略可以在这里继续扩展。", card)
# hint.setWordWrap(True)
# cardLayout.addWidget(hint)
layout = QVBoxLayout(self)
layout.setContentsMargins(36, 30, 36, 36)
layout.setSpacing(16)
layout.addWidget(TitleLabel("设置", self))
layout.addWidget(card)
layout.addStretch(1)