|
|
|
@ -62,34 +62,37 @@ DeviceCard::~DeviceCard()
|
|
|
|
|
|
|
|
|
|
void DeviceCard::setupUI()
|
|
|
|
|
{
|
|
|
|
|
// 创建主布局 - 更紧凑的间距
|
|
|
|
|
// 创建主布局 - 增加垂直间距
|
|
|
|
|
m_mainLayout = new QVBoxLayout(this);
|
|
|
|
|
m_mainLayout->setContentsMargins(PADDING, PADDING, PADDING, PADDING);
|
|
|
|
|
m_mainLayout->setSpacing(6); // 减小间距
|
|
|
|
|
m_mainLayout->setSpacing(15); // 增加间距
|
|
|
|
|
|
|
|
|
|
// === 头部区域 ===
|
|
|
|
|
m_headerLayout = new QHBoxLayout();
|
|
|
|
|
m_headerLayout->setSpacing(8);
|
|
|
|
|
m_headerLayout->setSpacing(12);
|
|
|
|
|
|
|
|
|
|
// 设备图标
|
|
|
|
|
// 设备图标 - 增大尺寸
|
|
|
|
|
m_deviceIconLabel = new QLabel();
|
|
|
|
|
m_deviceIconLabel->setFixedSize(24, 24);
|
|
|
|
|
m_deviceIconLabel->setFixedSize(40, 40);
|
|
|
|
|
m_deviceIconLabel->setScaledContents(true);
|
|
|
|
|
updateDeviceIcon();
|
|
|
|
|
|
|
|
|
|
// 设备名称
|
|
|
|
|
// 设备名称 - 增大字体
|
|
|
|
|
m_deviceNameLabel = new QLabel(m_deviceInfo.name);
|
|
|
|
|
m_deviceNameLabel->setFont(QFont("Arial", 12, QFont::Bold));
|
|
|
|
|
m_deviceNameLabel->setFont(QFont("Arial", 16, QFont::Bold));
|
|
|
|
|
m_deviceNameLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
m_deviceNameLabel->setWordWrap(true);
|
|
|
|
|
m_deviceNameLabel->setMinimumWidth(150);
|
|
|
|
|
|
|
|
|
|
// 状态指示器(圆点)
|
|
|
|
|
// 状态指示器(圆点)- 增大尺寸
|
|
|
|
|
m_statusIndicator = new QLabel("●");
|
|
|
|
|
m_statusIndicator->setFixedSize(16, 16);
|
|
|
|
|
m_statusIndicator->setFixedSize(24, 24);
|
|
|
|
|
m_statusIndicator->setAlignment(Qt::AlignCenter);
|
|
|
|
|
m_statusIndicator->setFont(QFont("Arial", 18));
|
|
|
|
|
|
|
|
|
|
// 状态文本
|
|
|
|
|
// 状态文本 - 增大字体
|
|
|
|
|
m_statusLabel = new QLabel(getStatusText(m_currentStatus));
|
|
|
|
|
m_statusLabel->setFont(QFont("Arial", 9));
|
|
|
|
|
m_statusLabel->setFont(QFont("Arial", 13, QFont::Bold));
|
|
|
|
|
|
|
|
|
|
m_headerLayout->addWidget(m_deviceIconLabel);
|
|
|
|
|
m_headerLayout->addWidget(m_deviceNameLabel);
|
|
|
|
@ -99,44 +102,48 @@ void DeviceCard::setupUI()
|
|
|
|
|
|
|
|
|
|
// === 信息区域 ===
|
|
|
|
|
m_infoLayout = new QGridLayout();
|
|
|
|
|
m_infoLayout->setSpacing(4);
|
|
|
|
|
m_infoLayout->setSpacing(12); // 增加间距
|
|
|
|
|
|
|
|
|
|
// 位置信息 - 简化显示
|
|
|
|
|
// 位置信息 - 增大显示
|
|
|
|
|
QLabel *locationIcon = new QLabel("📍");
|
|
|
|
|
locationIcon->setFixedSize(14, 14);
|
|
|
|
|
locationIcon->setFixedSize(22, 22);
|
|
|
|
|
locationIcon->setAlignment(Qt::AlignCenter);
|
|
|
|
|
locationIcon->setFont(QFont("Arial", 14));
|
|
|
|
|
m_locationLabel = new QLabel(QString("%1,%2").arg(m_deviceInfo.longitude, 0, 'f', 2).arg(m_deviceInfo.latitude, 0, 'f', 2));
|
|
|
|
|
m_locationLabel->setFont(QFont("Arial", 8));
|
|
|
|
|
m_locationLabel->setFont(QFont("Arial", 11));
|
|
|
|
|
|
|
|
|
|
// 网络信息 - 简化显示
|
|
|
|
|
// 网络信息 - 增大显示
|
|
|
|
|
QLabel *networkIcon = new QLabel("🌐");
|
|
|
|
|
networkIcon->setFixedSize(14, 14);
|
|
|
|
|
networkIcon->setFixedSize(22, 22);
|
|
|
|
|
networkIcon->setAlignment(Qt::AlignCenter);
|
|
|
|
|
networkIcon->setFont(QFont("Arial", 14));
|
|
|
|
|
m_networkLabel = new QLabel(m_deviceInfo.ipAddress);
|
|
|
|
|
m_networkLabel->setFont(QFont("Arial", 8));
|
|
|
|
|
m_networkLabel->setFont(QFont("Arial", 11));
|
|
|
|
|
|
|
|
|
|
// 信号强度 - 更紧凑
|
|
|
|
|
// 信号强度 - 增大显示
|
|
|
|
|
QLabel *signalIcon = new QLabel("📶");
|
|
|
|
|
signalIcon->setFixedSize(14, 14);
|
|
|
|
|
signalIcon->setFixedSize(22, 22);
|
|
|
|
|
signalIcon->setAlignment(Qt::AlignCenter);
|
|
|
|
|
signalIcon->setFont(QFont("Arial", 14));
|
|
|
|
|
m_signalLabel = new QLabel(QString("%1%").arg(m_deviceInfo.signalStrength));
|
|
|
|
|
m_signalLabel->setFont(QFont("Arial", 8));
|
|
|
|
|
m_signalLabel->setFont(QFont("Arial", 11, QFont::Bold));
|
|
|
|
|
m_signalProgressBar = new QProgressBar();
|
|
|
|
|
m_signalProgressBar->setRange(0, 100);
|
|
|
|
|
m_signalProgressBar->setValue(m_deviceInfo.signalStrength);
|
|
|
|
|
m_signalProgressBar->setFixedHeight(6);
|
|
|
|
|
m_signalProgressBar->setFixedHeight(16); // 增加进度条高度
|
|
|
|
|
m_signalProgressBar->setTextVisible(false);
|
|
|
|
|
|
|
|
|
|
// 电量水平 - 更紧凑
|
|
|
|
|
// 电量水平 - 增大显示
|
|
|
|
|
QLabel *batteryIcon = new QLabel("🔋");
|
|
|
|
|
batteryIcon->setFixedSize(14, 14);
|
|
|
|
|
batteryIcon->setFixedSize(22, 22);
|
|
|
|
|
batteryIcon->setAlignment(Qt::AlignCenter);
|
|
|
|
|
batteryIcon->setFont(QFont("Arial", 14));
|
|
|
|
|
m_batteryLabel = new QLabel(QString("%1%").arg(m_deviceInfo.batteryLevel));
|
|
|
|
|
m_batteryLabel->setFont(QFont("Arial", 8));
|
|
|
|
|
m_batteryLabel->setFont(QFont("Arial", 11, QFont::Bold));
|
|
|
|
|
m_batteryProgressBar = new QProgressBar();
|
|
|
|
|
m_batteryProgressBar->setRange(0, 100);
|
|
|
|
|
m_batteryProgressBar->setValue(m_deviceInfo.batteryLevel);
|
|
|
|
|
m_batteryProgressBar->setFixedHeight(6);
|
|
|
|
|
m_batteryProgressBar->setFixedHeight(16); // 增加进度条高度
|
|
|
|
|
m_batteryProgressBar->setTextVisible(false);
|
|
|
|
|
|
|
|
|
|
// 添加到网格布局
|
|
|
|
@ -153,22 +160,22 @@ void DeviceCard::setupUI()
|
|
|
|
|
|
|
|
|
|
// === 操作按钮区域 ===
|
|
|
|
|
m_buttonLayout = new QHBoxLayout();
|
|
|
|
|
m_buttonLayout->setSpacing(4);
|
|
|
|
|
m_buttonLayout->setSpacing(8);
|
|
|
|
|
|
|
|
|
|
m_detailsButton = new QPushButton("详");
|
|
|
|
|
m_detailsButton->setFixedSize(32, 20);
|
|
|
|
|
m_detailsButton = new QPushButton("详情");
|
|
|
|
|
m_detailsButton->setFixedSize(62, 35);
|
|
|
|
|
m_detailsButton->setToolTip("设备详情");
|
|
|
|
|
m_detailsButton->setFont(QFont("Arial", 8));
|
|
|
|
|
m_detailsButton->setFont(QFont("Arial", 11, QFont::Bold));
|
|
|
|
|
|
|
|
|
|
m_controlButton = new QPushButton("控");
|
|
|
|
|
m_controlButton->setFixedSize(32, 20);
|
|
|
|
|
m_controlButton = new QPushButton("控制");
|
|
|
|
|
m_controlButton->setFixedSize(62, 35);
|
|
|
|
|
m_controlButton->setToolTip("设备控制");
|
|
|
|
|
m_controlButton->setFont(QFont("Arial", 8));
|
|
|
|
|
m_controlButton->setFont(QFont("Arial", 11, QFont::Bold));
|
|
|
|
|
|
|
|
|
|
m_locationButton = new QPushButton("位");
|
|
|
|
|
m_locationButton->setFixedSize(32, 20);
|
|
|
|
|
m_locationButton = new QPushButton("定位");
|
|
|
|
|
m_locationButton->setFixedSize(62, 35);
|
|
|
|
|
m_locationButton->setToolTip("设备定位");
|
|
|
|
|
m_locationButton->setFont(QFont("Arial", 8));
|
|
|
|
|
m_locationButton->setFont(QFont("Arial", 11, QFont::Bold));
|
|
|
|
|
|
|
|
|
|
m_buttonLayout->addWidget(m_detailsButton);
|
|
|
|
|
m_buttonLayout->addWidget(m_controlButton);
|
|
|
|
@ -180,8 +187,8 @@ void DeviceCard::setupUI()
|
|
|
|
|
|
|
|
|
|
// 添加分隔线
|
|
|
|
|
QLabel *separatorLine = new QLabel();
|
|
|
|
|
separatorLine->setFixedHeight(1);
|
|
|
|
|
separatorLine->setStyleSheet("background-color: rgba(82, 194, 242, 0.3);");
|
|
|
|
|
separatorLine->setFixedHeight(3);
|
|
|
|
|
separatorLine->setStyleSheet("background-color: rgba(82, 194, 242, 0.6); margin: 4px 0px; border-radius: 1px;");
|
|
|
|
|
m_mainLayout->addWidget(separatorLine);
|
|
|
|
|
|
|
|
|
|
m_mainLayout->addLayout(m_infoLayout);
|
|
|
|
@ -217,6 +224,8 @@ void DeviceCard::setupStyle()
|
|
|
|
|
" font-weight: bold;"
|
|
|
|
|
" background: transparent;"
|
|
|
|
|
" border: none;"
|
|
|
|
|
" padding: 2px;"
|
|
|
|
|
" min-height: 20px;"
|
|
|
|
|
"}"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
@ -242,38 +251,51 @@ void DeviceCard::setupStyle()
|
|
|
|
|
m_signalLabel->setStyleSheet(infoLabelStyle);
|
|
|
|
|
m_batteryLabel->setStyleSheet(infoLabelStyle);
|
|
|
|
|
|
|
|
|
|
// 进度条样式
|
|
|
|
|
// 进度条样式 - 优化为更清晰的显示
|
|
|
|
|
QString progressBarStyle =
|
|
|
|
|
"QProgressBar {"
|
|
|
|
|
" border: 1px solid rgba(82, 194, 242, 0.5);"
|
|
|
|
|
" border-radius: 3px;"
|
|
|
|
|
" background-color: rgba(25, 35, 45, 0.8);"
|
|
|
|
|
" border: 2px solid rgba(82, 194, 242, 0.7);"
|
|
|
|
|
" border-radius: 8px;"
|
|
|
|
|
" background-color: rgba(25, 35, 45, 0.9);"
|
|
|
|
|
" text-align: center;"
|
|
|
|
|
" font-weight: bold;"
|
|
|
|
|
" color: white;"
|
|
|
|
|
" font-size: 10px;"
|
|
|
|
|
"}"
|
|
|
|
|
"QProgressBar::chunk {"
|
|
|
|
|
" background: qlineargradient(x1:0, y1:0, x2:1, y2:0,"
|
|
|
|
|
" stop:0 #00FF7F, stop:0.7 #FFD700, stop:1 #FF4444);"
|
|
|
|
|
" border-radius: 3px;"
|
|
|
|
|
" border-radius: 6px;"
|
|
|
|
|
" margin: 2px;"
|
|
|
|
|
"}";
|
|
|
|
|
|
|
|
|
|
m_signalProgressBar->setStyleSheet(progressBarStyle);
|
|
|
|
|
m_batteryProgressBar->setStyleSheet(progressBarStyle);
|
|
|
|
|
|
|
|
|
|
// 按钮样式
|
|
|
|
|
// 按钮样式 - 优化为更清晰的显示
|
|
|
|
|
QString buttonStyle =
|
|
|
|
|
"QPushButton {"
|
|
|
|
|
" background: rgba(82, 194, 242, 0.2);"
|
|
|
|
|
" color: rgb(220, 230, 242);"
|
|
|
|
|
" border: 1px solid rgba(82, 194, 242, 0.4);"
|
|
|
|
|
" border-radius: 4px;"
|
|
|
|
|
" font-size: 12px;"
|
|
|
|
|
" background: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
|
|
|
|
|
" stop:0 rgba(82, 194, 242, 0.3),"
|
|
|
|
|
" stop:1 rgba(45, 120, 180, 0.3));"
|
|
|
|
|
" color: rgb(230, 240, 250);"
|
|
|
|
|
" border: 2px solid rgba(82, 194, 242, 0.5);"
|
|
|
|
|
" border-radius: 8px;"
|
|
|
|
|
" font-size: 11px;"
|
|
|
|
|
" font-weight: bold;"
|
|
|
|
|
" padding: 4px;"
|
|
|
|
|
"}"
|
|
|
|
|
"QPushButton:hover {"
|
|
|
|
|
" background: rgba(82, 194, 242, 0.4);"
|
|
|
|
|
" border-color: rgba(82, 194, 242, 0.8);"
|
|
|
|
|
" background: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
|
|
|
|
|
" stop:0 rgba(82, 194, 242, 0.6),"
|
|
|
|
|
" stop:1 rgba(45, 120, 180, 0.6));"
|
|
|
|
|
" border-color: rgba(82, 194, 242, 0.9);"
|
|
|
|
|
" color: white;"
|
|
|
|
|
"}"
|
|
|
|
|
"QPushButton:pressed {"
|
|
|
|
|
" background: rgba(82, 194, 242, 0.6);"
|
|
|
|
|
" background: qlineargradient(x1:0, y1:0, x2:0, y2:1,"
|
|
|
|
|
" stop:0 rgba(82, 194, 242, 0.8),"
|
|
|
|
|
" stop:1 rgba(45, 120, 180, 0.8));"
|
|
|
|
|
"}";
|
|
|
|
|
|
|
|
|
|
m_detailsButton->setStyleSheet(buttonStyle);
|
|
|
|
|