feat: 优化设置布局并支持管理端地址切换 (#130)

This commit is contained in:
chengma
2026-08-11 09:24:04 +08:00
parent 4ede126f58
commit cd2889d76c
9 changed files with 347 additions and 47 deletions
+55 -26
View File
@@ -13,7 +13,7 @@ from typing import Iterable, Optional
from PyQt5.QtCore import QAbstractTableModel, QEvent, QModelIndex, Qt, pyqtSignal
from PyQt5.QtWidgets import (
QAbstractItemView,
QFormLayout,
QGridLayout,
QHeaderView,
QHBoxLayout,
QLineEdit,
@@ -243,6 +243,11 @@ class SettingsPage(QWidget):
self.deviceNameInput.setMaxLength(50)
self.deviceNameInput.setAccessibleName("当前客户端设备名")
self.adminBaseUrlInput = LineEdit(self)
self.adminBaseUrlInput.setPlaceholderText("http://127.0.0.1:8080")
self.adminBaseUrlInput.setClearButtonEnabled(True)
self.adminBaseUrlInput.setAccessibleName("Admin 管理端地址")
self.currentDeviceSaveButton = PushButton(FIF.SAVE, "保存", self)
self.currentDeviceSaveButton.setAccessibleName("保存当前设备信息")
self.currentDeviceStatusLabel = CaptionLabel(
@@ -373,16 +378,26 @@ class SettingsPage(QWidget):
titleLayout.addWidget(self.currentDeviceStatusLabel, 1)
layout.addLayout(titleLayout)
form = QFormLayout()
form.setHorizontalSpacing(16)
form.setVerticalSpacing(12)
deviceIdLabel = CaptionLabel("设备号", card)
deviceIdLabel.setBuddy(self.deviceIdInput)
deviceNameLabel = CaptionLabel("设备名", card)
deviceNameLabel.setBuddy(self.deviceNameInput)
form.addRow(deviceIdLabel, self.deviceIdInput)
form.addRow(deviceNameLabel, self.deviceNameInput)
layout.addLayout(form)
self.currentDeviceFormLayout = QGridLayout()
self.currentDeviceFormLayout.setHorizontalSpacing(12)
self.currentDeviceFormLayout.setVerticalSpacing(12)
self.currentDeviceFormLayout.setColumnStretch(1, 1)
self.currentDeviceFormLayout.setColumnStretch(3, 1)
self.deviceIdLabel = CaptionLabel("设备号", card)
self.deviceIdLabel.setBuddy(self.deviceIdInput)
self.deviceNameLabel = CaptionLabel("设备名", card)
self.deviceNameLabel.setBuddy(self.deviceNameInput)
self.adminBaseUrlLabel = CaptionLabel("管理端地址", card)
self.adminBaseUrlLabel.setBuddy(self.adminBaseUrlInput)
self.currentDeviceFormLayout.addWidget(self.deviceIdLabel, 0, 0)
self.currentDeviceFormLayout.addWidget(self.deviceIdInput, 0, 1)
self.currentDeviceFormLayout.addWidget(self.deviceNameLabel, 0, 2)
self.currentDeviceFormLayout.addWidget(self.deviceNameInput, 0, 3)
self.currentDeviceFormLayout.addWidget(self.adminBaseUrlLabel, 1, 0)
self.currentDeviceFormLayout.addWidget(
self.adminBaseUrlInput, 1, 1, 1, 3
)
layout.addLayout(self.currentDeviceFormLayout)
commandLayout = QHBoxLayout()
commandLayout.addStretch(1)
@@ -434,21 +449,30 @@ class SettingsPage(QWidget):
titleLayout.addWidget(self.updateStatusLabel, 1)
layout.addLayout(titleLayout)
form = QFormLayout()
form.setHorizontalSpacing(16)
form.setVerticalSpacing(12)
versionLabel = CaptionLabel("当前版本", card)
manifestLabel = CaptionLabel("清单地址", card)
usernameLabel = CaptionLabel("账号", card)
passwordLabel = CaptionLabel("密码", card)
manifestLabel.setBuddy(self.updateManifestUrlInput)
usernameLabel.setBuddy(self.updateUsernameInput)
passwordLabel.setBuddy(self.updatePasswordInput)
form.addRow(versionLabel, self.currentVersionLabel)
form.addRow(manifestLabel, self.updateManifestUrlInput)
form.addRow(usernameLabel, self.updateUsernameInput)
form.addRow(passwordLabel, self.updatePasswordInput)
layout.addLayout(form)
self.updateFormLayout = QGridLayout()
self.updateFormLayout.setHorizontalSpacing(12)
self.updateFormLayout.setVerticalSpacing(12)
# 输入区按约 45:55 分配,标签列只占自身需要的宽度。
self.updateFormLayout.setColumnStretch(1, 45)
self.updateFormLayout.setColumnStretch(3, 55)
self.versionLabel = CaptionLabel("当前版本", card)
self.manifestLabel = CaptionLabel("清单地址", card)
self.usernameLabel = CaptionLabel("账号", card)
self.passwordLabel = CaptionLabel("密码", card)
self.manifestLabel.setBuddy(self.updateManifestUrlInput)
self.usernameLabel.setBuddy(self.updateUsernameInput)
self.passwordLabel.setBuddy(self.updatePasswordInput)
self.updateFormLayout.addWidget(self.versionLabel, 0, 0)
self.updateFormLayout.addWidget(self.currentVersionLabel, 0, 1, 1, 3)
self.updateFormLayout.addWidget(self.manifestLabel, 1, 0)
self.updateFormLayout.addWidget(
self.updateManifestUrlInput, 1, 1, 1, 3
)
self.updateFormLayout.addWidget(self.usernameLabel, 2, 0)
self.updateFormLayout.addWidget(self.updateUsernameInput, 2, 1)
self.updateFormLayout.addWidget(self.passwordLabel, 2, 2)
self.updateFormLayout.addWidget(self.updatePasswordInput, 2, 3)
layout.addLayout(self.updateFormLayout)
commandLayout = QHBoxLayout()
commandLayout.addStretch(1)
@@ -468,6 +492,11 @@ class SettingsPage(QWidget):
self.currentDeviceStatusLabel.setText(message)
def set_admin_base_url(self, base_url: str) -> None:
"""显示当前保存的 Admin 管理端地址。"""
self.adminBaseUrlInput.setText(base_url)
def set_android_devices(self, devices: Iterable[AndroidDeviceRow]) -> None:
"""显示后续 ADB 服务返回的设备列表。"""