first commit
This commit is contained in:
583
widgets/settingswidget.cpp
Normal file
583
widgets/settingswidget.cpp
Normal file
@@ -0,0 +1,583 @@
|
||||
#include "settingswidget.h"
|
||||
#include "overlaydialogswidget.h"
|
||||
#include <QDateTime>
|
||||
#include <QTabBar>
|
||||
|
||||
const QString SettingsWidget::LABEL_STYLE =
|
||||
"font-size: 14px; color: #37474F;";
|
||||
|
||||
const QString SettingsWidget::VALUE_STYLE =
|
||||
"font-size: 14px; color: #1976D2; font-weight: bold;";
|
||||
|
||||
const QString SettingsWidget::BUTTON_STYLE =
|
||||
"QPushButton { background: #ECEFF1; color: #37474F; border: none; border-radius: 6px; "
|
||||
"padding: 10px 20px; font-size: 14px; font-weight: 500; }"
|
||||
"QPushButton:hover { background: #CFD8DC; }"
|
||||
"QPushButton:pressed { background: #B0BEC5; }";
|
||||
|
||||
const QString SettingsWidget::BUTTON_PRIMARY_STYLE =
|
||||
"QPushButton { background: #1976D2; color: white; border: none; border-radius: 6px; "
|
||||
"padding: 10px 20px; font-size: 14px; font-weight: 500; }"
|
||||
"QPushButton:hover { background: #1565C0; }"
|
||||
"QPushButton:pressed { background: #0D47A1; }";
|
||||
|
||||
const QString SettingsWidget::BUTTON_DANGER_STYLE =
|
||||
"QPushButton { background: #D32F2F; color: white; border: none; border-radius: 6px; "
|
||||
"padding: 10px 20px; font-size: 14px; font-weight: 500; }"
|
||||
"QPushButton:hover { background: #C62828; }"
|
||||
"QPushButton:pressed { background: #B71C1C; }";
|
||||
|
||||
SettingsWidget::SettingsWidget(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
setupUI();
|
||||
}
|
||||
|
||||
void SettingsWidget::setupUI()
|
||||
{
|
||||
auto *mainLayout = new QVBoxLayout(this);
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
mainLayout->setSpacing(0);
|
||||
|
||||
// 标题栏
|
||||
auto *headerWidget = new QWidget(this);
|
||||
headerWidget->setFixedHeight(60);
|
||||
headerWidget->setStyleSheet("background: qlineargradient(x1:0, y1:0, x2:1, y2:0, "
|
||||
"stop:0 #1976D2, stop:1 #1565C0);");
|
||||
|
||||
auto *headerLayout = new QHBoxLayout(headerWidget);
|
||||
headerLayout->setContentsMargins(16, 0, 16, 0);
|
||||
|
||||
m_backBtn = new QPushButton("← 返回", this);
|
||||
m_backBtn->setStyleSheet(
|
||||
"QPushButton { background: rgba(255,255,255,0.2); color: white; border: none; "
|
||||
"border-radius: 6px; padding: 8px 16px; font-size: 14px; }"
|
||||
"QPushButton:hover { background: rgba(255,255,255,0.3); }");
|
||||
m_backBtn->setCursor(Qt::PointingHandCursor);
|
||||
connect(m_backBtn, &QPushButton::clicked, this, &SettingsWidget::backRequested);
|
||||
headerLayout->addWidget(m_backBtn);
|
||||
|
||||
m_titleLabel = new QLabel("系统设置", this);
|
||||
m_titleLabel->setStyleSheet("color: white; font-size: 18px; font-weight: bold;");
|
||||
m_titleLabel->setAlignment(Qt::AlignCenter);
|
||||
headerLayout->addWidget(m_titleLabel, 1);
|
||||
|
||||
// 占位,保持标题居中
|
||||
auto *spacer = new QWidget(this);
|
||||
spacer->setFixedWidth(80);
|
||||
headerLayout->addWidget(spacer);
|
||||
|
||||
mainLayout->addWidget(headerWidget);
|
||||
|
||||
// 选项卡
|
||||
m_tabWidget = new QTabWidget(this);
|
||||
m_tabWidget->setStyleSheet(
|
||||
"QTabWidget::pane { border: none; background: #F5F5F5; }"
|
||||
"QTabBar::tab { background: #ECEFF1; color: #546E7A; padding: 12px 20px; "
|
||||
"font-size: 14px; border: none; margin-right: 2px; min-width: 70px; }"
|
||||
"QTabBar::tab:selected { background: white; color: #1976D2; font-weight: bold; "
|
||||
"border-bottom: 3px solid #1976D2; }"
|
||||
"QTabBar::tab:hover { background: #CFD8DC; }");
|
||||
m_tabWidget->tabBar()->setExpanding(false);
|
||||
|
||||
m_tabWidget->addTab(createDeviceInfoTab(), "设备信息");
|
||||
m_tabWidget->addTab(createSystemConfigTab(), "系统配置");
|
||||
m_tabWidget->addTab(createCalibrationTab(), "校准设置");
|
||||
m_tabWidget->addTab(createNetworkTab(), "网络设置");
|
||||
m_tabWidget->addTab(createAboutTab(), "关于");
|
||||
|
||||
mainLayout->addWidget(m_tabWidget, 1);
|
||||
}
|
||||
|
||||
QGroupBox *SettingsWidget::createStyledGroupBox(const QString &title)
|
||||
{
|
||||
auto *groupBox = new QGroupBox(title, this);
|
||||
groupBox->setStyleSheet(
|
||||
"QGroupBox { font-size: 15px; font-weight: bold; color: #37474F; "
|
||||
"border: 1px solid #E0E0E0; border-radius: 8px; margin-top: 12px; padding-top: 8px; "
|
||||
"background: white; }"
|
||||
"QGroupBox::title { subcontrol-origin: margin; left: 16px; padding: 0 8px; }");
|
||||
return groupBox;
|
||||
}
|
||||
|
||||
QWidget *SettingsWidget::createDeviceInfoTab()
|
||||
{
|
||||
auto *scrollArea = new QScrollArea(this);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea->setStyleSheet("QScrollArea { border: none; background: #F5F5F5; }");
|
||||
|
||||
auto *content = new QWidget();
|
||||
auto *layout = new QVBoxLayout(content);
|
||||
layout->setContentsMargins(24, 24, 24, 24);
|
||||
layout->setSpacing(16);
|
||||
|
||||
// 设备信息组
|
||||
auto *deviceGroup = createStyledGroupBox("设备信息");
|
||||
auto *deviceLayout = new QGridLayout(deviceGroup);
|
||||
deviceLayout->setContentsMargins(16, 24, 16, 16);
|
||||
deviceLayout->setSpacing(12);
|
||||
|
||||
deviceLayout->addWidget(new QLabel("设备型号:", this), 0, 0);
|
||||
m_deviceModelLabel = new QLabel("iCALI-Pro 2000", this);
|
||||
m_deviceModelLabel->setStyleSheet(VALUE_STYLE);
|
||||
deviceLayout->addWidget(m_deviceModelLabel, 0, 1);
|
||||
|
||||
deviceLayout->addWidget(new QLabel("序列号:", this), 1, 0);
|
||||
m_serialNumberLabel = new QLabel("ICALI-2024-001234", this);
|
||||
m_serialNumberLabel->setStyleSheet(VALUE_STYLE);
|
||||
deviceLayout->addWidget(m_serialNumberLabel, 1, 1);
|
||||
|
||||
deviceLayout->addWidget(new QLabel("固件版本:", this), 2, 0);
|
||||
m_firmwareVersionLabel = new QLabel("v2.1.0 (Build 20241231)", this);
|
||||
m_firmwareVersionLabel->setStyleSheet(VALUE_STYLE);
|
||||
deviceLayout->addWidget(m_firmwareVersionLabel, 2, 1);
|
||||
|
||||
deviceLayout->addWidget(new QLabel("硬件版本:", this), 3, 0);
|
||||
m_hardwareVersionLabel = new QLabel("Rev.C", this);
|
||||
m_hardwareVersionLabel->setStyleSheet(VALUE_STYLE);
|
||||
deviceLayout->addWidget(m_hardwareVersionLabel, 3, 1);
|
||||
|
||||
deviceLayout->setColumnStretch(1, 1);
|
||||
layout->addWidget(deviceGroup);
|
||||
|
||||
// 存储信息组
|
||||
auto *storageGroup = createStyledGroupBox("存储信息");
|
||||
auto *storageLayout = new QGridLayout(storageGroup);
|
||||
storageLayout->setContentsMargins(16, 24, 16, 16);
|
||||
storageLayout->setSpacing(12);
|
||||
|
||||
storageLayout->addWidget(new QLabel("内部存储:", this), 0, 0);
|
||||
auto *internalStorage = new QLabel("已用 2.3GB / 8GB", this);
|
||||
internalStorage->setStyleSheet(VALUE_STYLE);
|
||||
storageLayout->addWidget(internalStorage, 0, 1);
|
||||
|
||||
storageLayout->addWidget(new QLabel("SD卡:", this), 1, 0);
|
||||
auto *sdCard = new QLabel("已用 1.2GB / 32GB", this);
|
||||
sdCard->setStyleSheet(VALUE_STYLE);
|
||||
storageLayout->addWidget(sdCard, 1, 1);
|
||||
|
||||
storageLayout->setColumnStretch(1, 1);
|
||||
layout->addWidget(storageGroup);
|
||||
|
||||
// 运行状态组
|
||||
auto *statusGroup = createStyledGroupBox("运行状态");
|
||||
auto *statusLayout = new QGridLayout(statusGroup);
|
||||
statusLayout->setContentsMargins(16, 24, 16, 16);
|
||||
statusLayout->setSpacing(12);
|
||||
|
||||
statusLayout->addWidget(new QLabel("运行时间:", this), 0, 0);
|
||||
auto *uptime = new QLabel("3天 12小时 45分", this);
|
||||
uptime->setStyleSheet(VALUE_STYLE);
|
||||
statusLayout->addWidget(uptime, 0, 1);
|
||||
|
||||
statusLayout->addWidget(new QLabel("CPU温度:", this), 1, 0);
|
||||
auto *cpuTemp = new QLabel("42°C", this);
|
||||
cpuTemp->setStyleSheet(VALUE_STYLE);
|
||||
statusLayout->addWidget(cpuTemp, 1, 1);
|
||||
|
||||
statusLayout->addWidget(new QLabel("电池状态:", this), 2, 0);
|
||||
auto *battery = new QLabel("充电中 85%", this);
|
||||
battery->setStyleSheet("font-size: 14px; color: #43A047; font-weight: bold;");
|
||||
statusLayout->addWidget(battery, 2, 1);
|
||||
|
||||
statusLayout->setColumnStretch(1, 1);
|
||||
layout->addWidget(statusGroup);
|
||||
|
||||
layout->addStretch();
|
||||
scrollArea->setWidget(content);
|
||||
return scrollArea;
|
||||
}
|
||||
|
||||
QWidget *SettingsWidget::createSystemConfigTab()
|
||||
{
|
||||
auto *scrollArea = new QScrollArea(this);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea->setStyleSheet("QScrollArea { border: none; background: #F5F5F5; }");
|
||||
|
||||
auto *content = new QWidget();
|
||||
auto *layout = new QVBoxLayout(content);
|
||||
layout->setContentsMargins(24, 24, 24, 24);
|
||||
layout->setSpacing(16);
|
||||
|
||||
// 显示设置组
|
||||
auto *displayGroup = createStyledGroupBox("显示设置");
|
||||
auto *displayLayout = new QGridLayout(displayGroup);
|
||||
displayLayout->setContentsMargins(16, 24, 16, 16);
|
||||
displayLayout->setSpacing(12);
|
||||
|
||||
displayLayout->addWidget(new QLabel("语言:", this), 0, 0);
|
||||
m_languageCombo = new QComboBox(this);
|
||||
m_languageCombo->addItems({"简体中文", "English"});
|
||||
m_languageCombo->setStyleSheet(
|
||||
"QComboBox { padding: 8px 12px; border: 1px solid #E0E0E0; border-radius: 6px; "
|
||||
"background: white; font-size: 14px; min-height: 36px; }"
|
||||
"QComboBox::drop-down { subcontrol-origin: padding; subcontrol-position: top right; "
|
||||
"width: 36px; border: none; border-left: 1px solid #E0E0E0; background: #f5f5f5; "
|
||||
"border-top-right-radius: 6px; border-bottom-right-radius: 6px; }"
|
||||
"QComboBox::down-arrow { border-left: 6px solid transparent; border-right: 6px solid transparent; "
|
||||
"border-top: 8px solid #666; }"
|
||||
"QComboBox QAbstractItemView { background: white; border: 1px solid #ddd; border-radius: 6px; "
|
||||
"selection-background-color: #e3f2fd; outline: none; }"
|
||||
"QComboBox QAbstractItemView::item { min-height: 40px; padding: 10px 12px; }");
|
||||
m_languageCombo->setCursor(Qt::PointingHandCursor);
|
||||
displayLayout->addWidget(m_languageCombo, 0, 1);
|
||||
|
||||
displayLayout->addWidget(new QLabel("主题:", this), 1, 0);
|
||||
m_themeCombo = new QComboBox(this);
|
||||
m_themeCombo->addItems({"浅色", "深色", "跟随系统"});
|
||||
m_themeCombo->setStyleSheet(
|
||||
"QComboBox { padding: 8px 12px; border: 1px solid #E0E0E0; border-radius: 6px; "
|
||||
"background: white; font-size: 14px; min-height: 36px; }"
|
||||
"QComboBox::drop-down { subcontrol-origin: padding; subcontrol-position: top right; "
|
||||
"width: 36px; border: none; border-left: 1px solid #E0E0E0; background: #f5f5f5; "
|
||||
"border-top-right-radius: 6px; border-bottom-right-radius: 6px; }"
|
||||
"QComboBox::down-arrow { border-left: 6px solid transparent; border-right: 6px solid transparent; "
|
||||
"border-top: 8px solid #666; }"
|
||||
"QComboBox QAbstractItemView { background: white; border: 1px solid #ddd; border-radius: 6px; "
|
||||
"selection-background-color: #e3f2fd; outline: none; }"
|
||||
"QComboBox QAbstractItemView::item { min-height: 40px; padding: 10px 12px; }");
|
||||
m_themeCombo->setCursor(Qt::PointingHandCursor);
|
||||
displayLayout->addWidget(m_themeCombo, 1, 1);
|
||||
|
||||
displayLayout->addWidget(new QLabel("屏幕亮度:", this), 2, 0);
|
||||
m_brightnessSpinBox = new QSpinBox(this);
|
||||
m_brightnessSpinBox->setRange(10, 100);
|
||||
m_brightnessSpinBox->setValue(80);
|
||||
m_brightnessSpinBox->setSuffix("%");
|
||||
m_brightnessSpinBox->setStyleSheet(
|
||||
"QSpinBox { padding: 8px; border: 1px solid #E0E0E0; border-radius: 4px; "
|
||||
"background: white; font-size: 14px; }");
|
||||
displayLayout->addWidget(m_brightnessSpinBox, 2, 1);
|
||||
|
||||
displayLayout->setColumnStretch(1, 1);
|
||||
layout->addWidget(displayGroup);
|
||||
|
||||
// 声音设置组
|
||||
auto *soundGroup = createStyledGroupBox("声音设置");
|
||||
auto *soundLayout = new QGridLayout(soundGroup);
|
||||
soundLayout->setContentsMargins(16, 24, 16, 16);
|
||||
soundLayout->setSpacing(12);
|
||||
|
||||
soundLayout->addWidget(new QLabel("音量:", this), 0, 0);
|
||||
m_volumeSpinBox = new QSpinBox(this);
|
||||
m_volumeSpinBox->setRange(0, 100);
|
||||
m_volumeSpinBox->setValue(50);
|
||||
m_volumeSpinBox->setSuffix("%");
|
||||
m_volumeSpinBox->setStyleSheet(
|
||||
"QSpinBox { padding: 8px; border: 1px solid #E0E0E0; border-radius: 4px; "
|
||||
"background: white; font-size: 14px; }");
|
||||
soundLayout->addWidget(m_volumeSpinBox, 0, 1);
|
||||
|
||||
soundLayout->setColumnStretch(1, 1);
|
||||
layout->addWidget(soundGroup);
|
||||
|
||||
// 省电设置组
|
||||
auto *powerGroup = createStyledGroupBox("省电设置");
|
||||
auto *powerLayout = new QGridLayout(powerGroup);
|
||||
powerLayout->setContentsMargins(16, 24, 16, 16);
|
||||
powerLayout->setSpacing(12);
|
||||
|
||||
m_autoSleepCheck = new QCheckBox("自动休眠", this);
|
||||
m_autoSleepCheck->setChecked(true);
|
||||
m_autoSleepCheck->setStyleSheet("QCheckBox { font-size: 14px; }");
|
||||
powerLayout->addWidget(m_autoSleepCheck, 0, 0, 1, 2);
|
||||
|
||||
powerLayout->addWidget(new QLabel("休眠时间:", this), 1, 0);
|
||||
m_sleepTimeSpinBox = new QSpinBox(this);
|
||||
m_sleepTimeSpinBox->setRange(1, 60);
|
||||
m_sleepTimeSpinBox->setValue(10);
|
||||
m_sleepTimeSpinBox->setSuffix(" 分钟");
|
||||
m_sleepTimeSpinBox->setStyleSheet(
|
||||
"QSpinBox { padding: 8px; border: 1px solid #E0E0E0; border-radius: 4px; "
|
||||
"background: white; font-size: 14px; }");
|
||||
powerLayout->addWidget(m_sleepTimeSpinBox, 1, 1);
|
||||
|
||||
powerLayout->setColumnStretch(1, 1);
|
||||
layout->addWidget(powerGroup);
|
||||
|
||||
// 按钮区域
|
||||
auto *buttonLayout = new QHBoxLayout();
|
||||
buttonLayout->addStretch();
|
||||
|
||||
auto *resetBtn = new QPushButton("恢复默认", this);
|
||||
resetBtn->setStyleSheet(BUTTON_STYLE);
|
||||
resetBtn->setCursor(Qt::PointingHandCursor);
|
||||
connect(resetBtn, &QPushButton::clicked, this, &SettingsWidget::onResetClicked);
|
||||
buttonLayout->addWidget(resetBtn);
|
||||
|
||||
auto *saveBtn = new QPushButton("保存设置", this);
|
||||
saveBtn->setStyleSheet(BUTTON_PRIMARY_STYLE);
|
||||
saveBtn->setCursor(Qt::PointingHandCursor);
|
||||
connect(saveBtn, &QPushButton::clicked, this, &SettingsWidget::onSaveClicked);
|
||||
buttonLayout->addWidget(saveBtn);
|
||||
|
||||
layout->addLayout(buttonLayout);
|
||||
layout->addStretch();
|
||||
|
||||
scrollArea->setWidget(content);
|
||||
return scrollArea;
|
||||
}
|
||||
|
||||
QWidget *SettingsWidget::createCalibrationTab()
|
||||
{
|
||||
auto *scrollArea = new QScrollArea(this);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea->setStyleSheet("QScrollArea { border: none; background: #F5F5F5; }");
|
||||
|
||||
auto *content = new QWidget();
|
||||
auto *layout = new QVBoxLayout(content);
|
||||
layout->setContentsMargins(24, 24, 24, 24);
|
||||
layout->setSpacing(16);
|
||||
|
||||
// 校准状态组
|
||||
auto *statusGroup = createStyledGroupBox("校准状态");
|
||||
auto *statusLayout = new QGridLayout(statusGroup);
|
||||
statusLayout->setContentsMargins(16, 24, 16, 16);
|
||||
statusLayout->setSpacing(12);
|
||||
|
||||
statusLayout->addWidget(new QLabel("上次校准:", this), 0, 0);
|
||||
m_lastCalibrationLabel = new QLabel("2024-12-15 09:30:00", this);
|
||||
m_lastCalibrationLabel->setStyleSheet(VALUE_STYLE);
|
||||
statusLayout->addWidget(m_lastCalibrationLabel, 0, 1);
|
||||
|
||||
statusLayout->addWidget(new QLabel("校准状态:", this), 1, 0);
|
||||
m_calibrationStatusLabel = new QLabel("✓ 已校准", this);
|
||||
m_calibrationStatusLabel->setStyleSheet("font-size: 14px; color: #43A047; font-weight: bold;");
|
||||
statusLayout->addWidget(m_calibrationStatusLabel, 1, 1);
|
||||
|
||||
statusLayout->addWidget(new QLabel("下次校准:", this), 2, 0);
|
||||
auto *nextCal = new QLabel("2025-12-15 (剩余350天)", this);
|
||||
nextCal->setStyleSheet(VALUE_STYLE);
|
||||
statusLayout->addWidget(nextCal, 2, 1);
|
||||
|
||||
statusLayout->setColumnStretch(1, 1);
|
||||
layout->addWidget(statusGroup);
|
||||
|
||||
// 校准操作组
|
||||
auto *actionGroup = createStyledGroupBox("校准操作");
|
||||
auto *actionLayout = new QVBoxLayout(actionGroup);
|
||||
actionLayout->setContentsMargins(16, 24, 16, 16);
|
||||
actionLayout->setSpacing(12);
|
||||
|
||||
auto *note = new QLabel("请确保设备处于稳定状态,并连接标准校准源后再进行校准操作。", this);
|
||||
note->setWordWrap(true);
|
||||
note->setStyleSheet("font-size: 13px; color: #757575; padding: 8px; "
|
||||
"background: #FFF8E1; border-radius: 4px;");
|
||||
actionLayout->addWidget(note);
|
||||
|
||||
auto *calibrateBtn = new QPushButton("开始校准", this);
|
||||
calibrateBtn->setStyleSheet(BUTTON_PRIMARY_STYLE);
|
||||
calibrateBtn->setFixedHeight(44);
|
||||
calibrateBtn->setCursor(Qt::PointingHandCursor);
|
||||
connect(calibrateBtn, &QPushButton::clicked, this, &SettingsWidget::onCalibrateClicked);
|
||||
actionLayout->addWidget(calibrateBtn);
|
||||
|
||||
layout->addWidget(actionGroup);
|
||||
|
||||
layout->addStretch();
|
||||
scrollArea->setWidget(content);
|
||||
return scrollArea;
|
||||
}
|
||||
|
||||
QWidget *SettingsWidget::createNetworkTab()
|
||||
{
|
||||
auto *scrollArea = new QScrollArea(this);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea->setStyleSheet("QScrollArea { border: none; background: #F5F5F5; }");
|
||||
|
||||
auto *content = new QWidget();
|
||||
auto *layout = new QVBoxLayout(content);
|
||||
layout->setContentsMargins(24, 24, 24, 24);
|
||||
layout->setSpacing(16);
|
||||
|
||||
// 服务器设置组
|
||||
auto *serverGroup = createStyledGroupBox("服务器设置");
|
||||
auto *serverLayout = new QGridLayout(serverGroup);
|
||||
serverLayout->setContentsMargins(16, 24, 16, 16);
|
||||
serverLayout->setSpacing(12);
|
||||
|
||||
serverLayout->addWidget(new QLabel("服务器地址:", this), 0, 0);
|
||||
m_serverAddressEdit = new QLineEdit(this);
|
||||
m_serverAddressEdit->setPlaceholderText("例如: 192.168.1.100");
|
||||
m_serverAddressEdit->setStyleSheet(
|
||||
"QLineEdit { padding: 8px; border: 1px solid #E0E0E0; border-radius: 4px; "
|
||||
"background: white; font-size: 14px; }");
|
||||
serverLayout->addWidget(m_serverAddressEdit, 0, 1);
|
||||
|
||||
serverLayout->addWidget(new QLabel("端口号:", this), 1, 0);
|
||||
m_serverPortSpinBox = new QSpinBox(this);
|
||||
m_serverPortSpinBox->setRange(1, 65535);
|
||||
m_serverPortSpinBox->setValue(8080);
|
||||
m_serverPortSpinBox->setStyleSheet(
|
||||
"QSpinBox { padding: 8px; border: 1px solid #E0E0E0; border-radius: 4px; "
|
||||
"background: white; font-size: 14px; }");
|
||||
serverLayout->addWidget(m_serverPortSpinBox, 1, 1);
|
||||
|
||||
m_autoConnectCheck = new QCheckBox("启动时自动连接", this);
|
||||
m_autoConnectCheck->setStyleSheet("QCheckBox { font-size: 14px; }");
|
||||
serverLayout->addWidget(m_autoConnectCheck, 2, 0, 1, 2);
|
||||
|
||||
serverLayout->setColumnStretch(1, 1);
|
||||
layout->addWidget(serverGroup);
|
||||
|
||||
// 连接状态组
|
||||
auto *connGroup = createStyledGroupBox("连接状态");
|
||||
auto *connLayout = new QGridLayout(connGroup);
|
||||
connLayout->setContentsMargins(16, 24, 16, 16);
|
||||
connLayout->setSpacing(12);
|
||||
|
||||
connLayout->addWidget(new QLabel("网络状态:", this), 0, 0);
|
||||
auto *netStatus = new QLabel("● 已连接 (WiFi)", this);
|
||||
netStatus->setStyleSheet("font-size: 14px; color: #43A047; font-weight: bold;");
|
||||
connLayout->addWidget(netStatus, 0, 1);
|
||||
|
||||
connLayout->addWidget(new QLabel("IP地址:", this), 1, 0);
|
||||
auto *ipAddr = new QLabel("192.168.1.88", this);
|
||||
ipAddr->setStyleSheet(VALUE_STYLE);
|
||||
connLayout->addWidget(ipAddr, 1, 1);
|
||||
|
||||
connLayout->addWidget(new QLabel("服务器状态:", this), 2, 0);
|
||||
auto *serverStatus = new QLabel("○ 未连接", this);
|
||||
serverStatus->setStyleSheet("font-size: 14px; color: #757575;");
|
||||
connLayout->addWidget(serverStatus, 2, 1);
|
||||
|
||||
connLayout->setColumnStretch(1, 1);
|
||||
layout->addWidget(connGroup);
|
||||
|
||||
layout->addStretch();
|
||||
scrollArea->setWidget(content);
|
||||
return scrollArea;
|
||||
}
|
||||
|
||||
QWidget *SettingsWidget::createAboutTab()
|
||||
{
|
||||
auto *scrollArea = new QScrollArea(this);
|
||||
scrollArea->setWidgetResizable(true);
|
||||
scrollArea->setStyleSheet("QScrollArea { border: none; background: #F5F5F5; }");
|
||||
|
||||
auto *content = new QWidget();
|
||||
auto *layout = new QVBoxLayout(content);
|
||||
layout->setContentsMargins(24, 24, 24, 24);
|
||||
layout->setSpacing(16);
|
||||
|
||||
// 关于组
|
||||
auto *aboutGroup = createStyledGroupBox("关于");
|
||||
auto *aboutLayout = new QVBoxLayout(aboutGroup);
|
||||
aboutLayout->setContentsMargins(16, 24, 16, 16);
|
||||
aboutLayout->setSpacing(12);
|
||||
|
||||
auto *appName = new QLabel("智能校验仪 iCALI", this);
|
||||
appName->setStyleSheet("font-size: 20px; font-weight: bold; color: #1976D2;");
|
||||
appName->setAlignment(Qt::AlignCenter);
|
||||
aboutLayout->addWidget(appName);
|
||||
|
||||
auto *version = new QLabel("版本 2.1.0", this);
|
||||
version->setStyleSheet("font-size: 14px; color: #757575;");
|
||||
version->setAlignment(Qt::AlignCenter);
|
||||
aboutLayout->addWidget(version);
|
||||
|
||||
auto *copyright = new QLabel("© 2024 某公司. 保留所有权利.", this);
|
||||
copyright->setStyleSheet("font-size: 12px; color: #9E9E9E;");
|
||||
copyright->setAlignment(Qt::AlignCenter);
|
||||
aboutLayout->addWidget(copyright);
|
||||
|
||||
layout->addWidget(aboutGroup);
|
||||
|
||||
// 维护操作组
|
||||
auto *maintainGroup = createStyledGroupBox("维护操作");
|
||||
auto *maintainLayout = new QVBoxLayout(maintainGroup);
|
||||
maintainLayout->setContentsMargins(16, 24, 16, 16);
|
||||
maintainLayout->setSpacing(12);
|
||||
|
||||
auto *exportLogBtn = new QPushButton("导出日志", this);
|
||||
exportLogBtn->setStyleSheet(BUTTON_STYLE);
|
||||
exportLogBtn->setFixedHeight(44);
|
||||
exportLogBtn->setCursor(Qt::PointingHandCursor);
|
||||
connect(exportLogBtn, &QPushButton::clicked, this, &SettingsWidget::onExportLogClicked);
|
||||
maintainLayout->addWidget(exportLogBtn);
|
||||
|
||||
auto *clearCacheBtn = new QPushButton("清除缓存", this);
|
||||
clearCacheBtn->setStyleSheet(BUTTON_STYLE);
|
||||
clearCacheBtn->setFixedHeight(44);
|
||||
clearCacheBtn->setCursor(Qt::PointingHandCursor);
|
||||
connect(clearCacheBtn, &QPushButton::clicked, this, &SettingsWidget::onClearCacheClicked);
|
||||
maintainLayout->addWidget(clearCacheBtn);
|
||||
|
||||
auto *factoryResetBtn = new QPushButton("恢复出厂设置", this);
|
||||
factoryResetBtn->setStyleSheet(BUTTON_DANGER_STYLE);
|
||||
factoryResetBtn->setFixedHeight(44);
|
||||
factoryResetBtn->setCursor(Qt::PointingHandCursor);
|
||||
connect(factoryResetBtn, &QPushButton::clicked, this, &SettingsWidget::onFactoryResetClicked);
|
||||
maintainLayout->addWidget(factoryResetBtn);
|
||||
|
||||
layout->addWidget(maintainGroup);
|
||||
|
||||
layout->addStretch();
|
||||
scrollArea->setWidget(content);
|
||||
return scrollArea;
|
||||
}
|
||||
|
||||
void SettingsWidget::onSaveClicked()
|
||||
{
|
||||
OverlayDialog::information(this, "保存成功", "系统设置已保存");
|
||||
}
|
||||
|
||||
void SettingsWidget::onResetClicked()
|
||||
{
|
||||
OverlayDialog::question(this, "恢复默认", "确定要恢复默认设置吗?",
|
||||
[this](bool confirmed)
|
||||
{
|
||||
if (confirmed)
|
||||
{
|
||||
m_languageCombo->setCurrentIndex(0);
|
||||
m_themeCombo->setCurrentIndex(0);
|
||||
m_brightnessSpinBox->setValue(80);
|
||||
m_volumeSpinBox->setValue(50);
|
||||
m_autoSleepCheck->setChecked(true);
|
||||
m_sleepTimeSpinBox->setValue(10);
|
||||
OverlayDialog::information(this, "已恢复", "设置已恢复为默认值");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void SettingsWidget::onCalibrateClicked()
|
||||
{
|
||||
OverlayDialog::question(this, "开始校准", "确定要开始校准吗?\n请确保已连接标准校准源。",
|
||||
[this](bool confirmed)
|
||||
{
|
||||
if (confirmed)
|
||||
{
|
||||
OverlayDialog::information(this, "校准", "校准向导功能开发中...");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void SettingsWidget::onExportLogClicked()
|
||||
{
|
||||
OverlayDialog::information(this, "导出日志", "日志已导出到: /sdcard/logs/");
|
||||
}
|
||||
|
||||
void SettingsWidget::onClearCacheClicked()
|
||||
{
|
||||
OverlayDialog::question(this, "清除缓存", "确定要清除缓存吗?",
|
||||
[this](bool confirmed)
|
||||
{
|
||||
if (confirmed)
|
||||
{
|
||||
OverlayDialog::information(this, "清除成功", "缓存已清除,释放空间: 128MB");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void SettingsWidget::onFactoryResetClicked()
|
||||
{
|
||||
OverlayDialog::question(this, "恢复出厂设置",
|
||||
"⚠️ 警告\n\n此操作将清除所有数据和设置,设备将恢复到出厂状态。\n\n确定要继续吗?",
|
||||
[this](bool confirmed)
|
||||
{
|
||||
if (confirmed)
|
||||
{
|
||||
OverlayDialog::warning(this, "恢复出厂", "此功能需要管理员权限");
|
||||
}
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user