修复在windows中字体颜色不对的问题

This commit is contained in:
zzh 2025-09-11 16:25:25 +08:00
parent 8802762a9a
commit e098025c47
2 changed files with 313 additions and 28 deletions

View File

@ -620,10 +620,33 @@ void LightStripManager::onClearSnListClicked()
return; return;
} }
int ret = QMessageBox::question(this, "确认清空", QMessageBox msgBox;
QString("确定要清空所有 %1 个灯条SN吗").arg(uniqueSnSet.size()), msgBox.setWindowTitle("确认清空");
QMessageBox::Yes | QMessageBox::No, msgBox.setText(QString("确定要清空所有 %1 个灯条SN吗").arg(uniqueSnSet.size()));
QMessageBox::No); msgBox.setIcon(QMessageBox::Question);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
msgBox.setStyleSheet(
"QMessageBox { "
" color: #000000; " // 消息文本颜色设为黑色
"} "
"QPushButton { "
" color: #000000; " // 按钮文字颜色设为黑色
" background-color: #f0f0f0; "
" border: 1px solid #ccc; "
" border-radius: 4px; "
" padding: 6px 12px; "
" min-width: 60px; "
"} "
"QPushButton:hover { "
" background-color: #e0e0e0; "
"} "
"QPushButton:pressed { "
" background-color: #d0d0d0; "
"}"
);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes) { if (ret == QMessageBox::Yes) {
// 清空所有灯条widget // 清空所有灯条widget
@ -665,14 +688,60 @@ void LightStripManager::onDeleteSelectedClicked()
{ {
QStringList selectedSns = getSelectedSns(); QStringList selectedSns = getSelectedSns();
if (selectedSns.isEmpty()) { if (selectedSns.isEmpty()) {
QMessageBox::information(this, "提示", "请先选择要删除的灯条SN。"); QMessageBox msgBox;
msgBox.setWindowTitle("提示");
msgBox.setText("请先选择要删除的灯条SN。");
msgBox.setIcon(QMessageBox::Information);
msgBox.setStyleSheet(
"QMessageBox { "
" color: #000000; " // 消息文本颜色设为黑色
"} "
"QPushButton { "
" color: #000000; " // 按钮文字颜色设为黑色
" background-color: #f0f0f0; "
" border: 1px solid #ccc; "
" border-radius: 4px; "
" padding: 6px 12px; "
" min-width: 60px; "
"} "
"QPushButton:hover { "
" background-color: #e0e0e0; "
"} "
"QPushButton:pressed { "
" background-color: #d0d0d0; "
"}"
);
msgBox.exec();
return; return;
} }
int ret = QMessageBox::question(this, "确认删除", QMessageBox msgBox;
QString("确定要删除选中的 %1 个灯条SN吗").arg(selectedSns.size()), msgBox.setWindowTitle("确认删除");
QMessageBox::Yes | QMessageBox::No, msgBox.setText(QString("确定要删除选中的 %1 个灯条SN吗").arg(selectedSns.size()));
QMessageBox::No); msgBox.setIcon(QMessageBox::Question);
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);
msgBox.setDefaultButton(QMessageBox::No);
msgBox.setStyleSheet(
"QMessageBox { "
" color: #000000; " // 消息文本颜色设为黑色
"} "
"QPushButton { "
" color: #000000; " // 按钮文字颜色设为黑色
" background-color: #f0f0f0; "
" border: 1px solid #ccc; "
" border-radius: 4px; "
" padding: 6px 12px; "
" min-width: 60px; "
"} "
"QPushButton:hover { "
" background-color: #e0e0e0; "
"} "
"QPushButton:pressed { "
" background-color: #d0d0d0; "
"}"
);
int ret = msgBox.exec();
if (ret == QMessageBox::Yes) { if (ret == QMessageBox::Yes) {
// 从后往前删除,避免索引问题 // 从后往前删除,避免索引问题
@ -800,7 +869,30 @@ void LightStripManager::onSendLightSelectedClicked()
{ {
QStringList selectedSns = getSelectedSns(); QStringList selectedSns = getSelectedSns();
if (selectedSns.isEmpty()) { if (selectedSns.isEmpty()) {
QMessageBox::information(this, "提示", "请先选择要点亮的灯条。"); QMessageBox msgBox;
msgBox.setWindowTitle("提示");
msgBox.setText("请先选择要点亮的灯条。");
msgBox.setIcon(QMessageBox::Information);
msgBox.setStyleSheet(
"QMessageBox { "
" color: #000000; " // 消息文本颜色设为黑色
"} "
"QPushButton { "
" color: #000000; " // 按钮文字颜色设为黑色
" background-color: #f0f0f0; "
" border: 1px solid #ccc; "
" border-radius: 4px; "
" padding: 6px 12px; "
" min-width: 60px; "
"} "
"QPushButton:hover { "
" background-color: #e0e0e0; "
"} "
"QPushButton:pressed { "
" background-color: #d0d0d0; "
"}"
);
msgBox.exec();
return; return;
} }
@ -812,14 +904,59 @@ void LightStripManager::onSendLightSelectedClicked()
emit lightControlRequested(selectedSns, color, flash, interval, duration, sound); emit lightControlRequested(selectedSns, color, flash, interval, duration, sound);
QMessageBox::information(this, "发送成功", QMessageBox msgBox;
QString("已向 %1 个选中的灯条发送点亮指令。").arg(selectedSns.size())); msgBox.setWindowTitle("发送成功");
msgBox.setText(QString("已向 %1 个选中的灯条发送点亮指令。").arg(selectedSns.size()));
msgBox.setIcon(QMessageBox::Information);
msgBox.setStyleSheet(
"QMessageBox { "
" color: #000000; " // 消息文本颜色设为黑色
"} "
"QPushButton { "
" color: #000000; " // 按钮文字颜色设为黑色
" background-color: #f0f0f0; "
" border: 1px solid #ccc; "
" border-radius: 4px; "
" padding: 6px 12px; "
" min-width: 60px; "
"} "
"QPushButton:hover { "
" background-color: #e0e0e0; "
"} "
"QPushButton:pressed { "
" background-color: #d0d0d0; "
"}"
);
msgBox.exec();
} }
void LightStripManager::onSendLightAllClicked() void LightStripManager::onSendLightAllClicked()
{ {
if (uniqueSnSet.isEmpty()) { if (uniqueSnSet.isEmpty()) {
QMessageBox::information(this, "提示", "没有可点亮的灯条。"); QMessageBox msgBox;
msgBox.setWindowTitle("提示");
msgBox.setText("没有可点亮的灯条。");
msgBox.setIcon(QMessageBox::Information);
msgBox.setStyleSheet(
"QMessageBox { "
" color: #000000; " // 消息文本颜色设为黑色
"} "
"QPushButton { "
" color: #000000; " // 按钮文字颜色设为黑色
" background-color: #f0f0f0; "
" border: 1px solid #ccc; "
" border-radius: 4px; "
" padding: 6px 12px; "
" min-width: 60px; "
"} "
"QPushButton:hover { "
" background-color: #e0e0e0; "
"} "
"QPushButton:pressed { "
" background-color: #d0d0d0; "
"}"
);
msgBox.exec();
return; return;
} }
@ -849,8 +986,30 @@ void LightStripManager::onSendLightAllClicked()
} }
// 显示总数量的提示信息 // 显示总数量的提示信息
QMessageBox::information(this, "发送成功", QMessageBox msgBox;
QString("已向所有灯条发送点亮指令。")); msgBox.setWindowTitle("发送成功");
msgBox.setText("已向所有灯条发送点亮指令。");
msgBox.setIcon(QMessageBox::Information);
msgBox.setStyleSheet(
"QMessageBox { "
" color: #000000; " // 消息文本颜色设为黑色
"} "
"QPushButton { "
" color: #000000; " // 按钮文字颜色设为黑色
" background-color: #f0f0f0; "
" border: 1px solid #ccc; "
" border-radius: 4px; "
" padding: 6px 12px; "
" min-width: 60px; "
"} "
"QPushButton:hover { "
" background-color: #e0e0e0; "
"} "
"QPushButton:pressed { "
" background-color: #d0d0d0; "
"}"
);
msgBox.exec();
} }
void LightStripManager::onCheckBoxStateChanged() void LightStripManager::onCheckBoxStateChanged()
@ -869,7 +1028,30 @@ void LightStripManager::onRefreshClicked()
updateSnCount(); updateSnCount();
updateControlButtons(); updateControlButtons();
QMessageBox::information(this, "刷新完成", "界面已刷新。"); QMessageBox msgBox;
msgBox.setWindowTitle("刷新完成");
msgBox.setText("界面已刷新。");
msgBox.setIcon(QMessageBox::Information);
msgBox.setStyleSheet(
"QMessageBox { "
" color: #000000; " // 消息文本颜色设为黑色
"} "
"QPushButton { "
" color: #000000; " // 按钮文字颜色设为黑色
" background-color: #f0f0f0; "
" border: 1px solid #ccc; "
" border-radius: 4px; "
" padding: 6px 12px; "
" min-width: 60px; "
"} "
"QPushButton:hover { "
" background-color: #e0e0e0; "
"} "
"QPushButton:pressed { "
" background-color: #d0d0d0; "
"}"
);
msgBox.exec();
} }
// 删除整个函数实现: // 删除整个函数实现:
@ -974,7 +1156,30 @@ void LightStripManager::onBindIdentitySelectedClicked()
" padding: 5px; " " padding: 5px; "
"}" "}"
); );
QMessageBox::warning(this, "警告", "请先选择要绑定身份信息的灯条"); QMessageBox msgBox;
msgBox.setWindowTitle("警告");
msgBox.setText("请先选择要绑定身份信息的灯条");
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStyleSheet(
"QMessageBox { "
" color: #000000; " // 消息文本颜色设为黑色
"} "
"QPushButton { "
" color: #000000; " // 按钮文字颜色设为黑色
" background-color: #f0f0f0; "
" border: 1px solid #ccc; "
" border-radius: 4px; "
" padding: 6px 12px; "
" min-width: 60px; "
"} "
"QPushButton:hover { "
" background-color: #e0e0e0; "
"} "
"QPushButton:pressed { "
" background-color: #d0d0d0; "
"}"
);
msgBox.exec();
return; return;
} }
@ -989,7 +1194,30 @@ void LightStripManager::onBindIdentitySelectedClicked()
" padding: 5px; " " padding: 5px; "
"}" "}"
); );
QMessageBox::warning(this, "警告", "请填写完整的Label1、Label2、Label3参数"); QMessageBox msgBox;
msgBox.setWindowTitle("警告");
msgBox.setText("请填写完整的Label1、Label2、Label3参数");
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStyleSheet(
"QMessageBox { "
" color: #000000; " // 消息文本颜色设为黑色
"} "
"QPushButton { "
" color: #000000; " // 按钮文字颜色设为黑色
" background-color: #f0f0f0; "
" border: 1px solid #ccc; "
" border-radius: 4px; "
" padding: 6px 12px; "
" min-width: 60px; "
"} "
"QPushButton:hover { "
" background-color: #e0e0e0; "
"} "
"QPushButton:pressed { "
" background-color: #d0d0d0; "
"}"
);
msgBox.exec();
return; return;
} }
@ -1032,7 +1260,30 @@ void LightStripManager::onBindIdentityAllClicked()
" padding: 5px; " " padding: 5px; "
"}" "}"
); );
QMessageBox::warning(this, "警告", "没有可绑定身份信息的灯条"); QMessageBox msgBox;
msgBox.setWindowTitle("警告");
msgBox.setText("没有可绑定身份信息的灯条");
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStyleSheet(
"QMessageBox { "
" color: #000000; " // 消息文本颜色设为黑色
"} "
"QPushButton { "
" color: #000000; " // 按钮文字颜色设为黑色
" background-color: #f0f0f0; "
" border: 1px solid #ccc; "
" border-radius: 4px; "
" padding: 6px 12px; "
" min-width: 60px; "
"} "
"QPushButton:hover { "
" background-color: #e0e0e0; "
"} "
"QPushButton:pressed { "
" background-color: #d0d0d0; "
"}"
);
msgBox.exec();
return; return;
} }
@ -1144,7 +1395,30 @@ void LightStripManager::onGroupLightClicked()
{ {
// 检查身份信息配置 // 检查身份信息配置
if (label1Edit->text().isEmpty() || label2Edit->text().isEmpty() || label3Edit->text().isEmpty()) { if (label1Edit->text().isEmpty() || label2Edit->text().isEmpty() || label3Edit->text().isEmpty()) {
QMessageBox::warning(this, "警告", "请先配置完整的身份信息label1、label2、label3"); QMessageBox msgBox;
msgBox.setWindowTitle("警告");
msgBox.setText("请先配置完整的身份信息label1、label2、label3");
msgBox.setIcon(QMessageBox::Warning);
msgBox.setStyleSheet(
"QMessageBox { "
" color: #000000; " // 消息文本颜色设为黑色
"} "
"QPushButton { "
" color: #000000; " // 按钮文字颜色设为黑色
" background-color: #f0f0f0; "
" border: 1px solid #ccc; "
" border-radius: 4px; "
" padding: 6px 12px; "
" min-width: 60px; "
"} "
"QPushButton:hover { "
" background-color: #e0e0e0; "
"} "
"QPushButton:pressed { "
" background-color: #d0d0d0; "
"}"
);
msgBox.exec();
return; return;
} }
@ -1173,6 +1447,7 @@ void LightStripManager::setupIdentityBindingArea()
identityBindingGroup = new QGroupBox("身份信息绑定", this); identityBindingGroup = new QGroupBox("身份信息绑定", this);
identityBindingGroup->setStyleSheet( identityBindingGroup->setStyleSheet(
"QGroupBox { " "QGroupBox { "
" color: #000000; "
" font-weight: bold; " " font-weight: bold; "
" font-size: 14px; " " font-size: 14px; "
" border: 2px solid #cccccc; " " border: 2px solid #cccccc; "
@ -1181,6 +1456,7 @@ void LightStripManager::setupIdentityBindingArea()
" padding-top: 10px; " " padding-top: 10px; "
"} " "} "
"QGroupBox::title { " "QGroupBox::title { "
" color: #000000; "
" subcontrol-origin: margin; " " subcontrol-origin: margin; "
" left: 10px; " " left: 10px; "
" padding: 0 5px 0 5px; " " padding: 0 5px 0 5px; "
@ -1195,9 +1471,9 @@ void LightStripManager::setupIdentityBindingArea()
label1Label->setMinimumWidth(60); label1Label->setMinimumWidth(60);
label1Label->setStyleSheet( label1Label->setStyleSheet(
"QLabel { " "QLabel { "
" color: #000000; "
" font-weight: bold; " " font-weight: bold; "
" font-size: 12px; " " font-size: 12px; "
" color: #333; "
" padding: 5px; " " padding: 5px; "
"}" "}"
); );
@ -1208,6 +1484,7 @@ void LightStripManager::setupIdentityBindingArea()
label1Edit->setMinimumHeight(35); label1Edit->setMinimumHeight(35);
label1Edit->setStyleSheet( label1Edit->setStyleSheet(
"QLineEdit { " "QLineEdit { "
" color: #000000; "
" padding: 8px; " " padding: 8px; "
" border: 2px solid #ddd; " " border: 2px solid #ddd; "
" border-radius: 4px; " " border-radius: 4px; "
@ -1227,13 +1504,15 @@ void LightStripManager::setupIdentityBindingArea()
rule1ComboBox->setMinimumWidth(120); rule1ComboBox->setMinimumWidth(120);
rule1ComboBox->setStyleSheet( rule1ComboBox->setStyleSheet(
"QComboBox { " "QComboBox { "
" color: #000000; "
" padding: 8px; " " padding: 8px; "
" border: 2px solid #ddd; " " border: 2px solid #ddd; "
" border-radius: 4px; " " border-radius: 4px; "
" font-size: 12px; " " font-size: 12px; "
" background-color: white; " " background-color: white; "
"} " "} "
"QComboBox:focus { border-color: #2196F3; }" "QComboBox:focus { border-color: #2196F3; } "
"QComboBox QAbstractItemView { color: #000000; }"
); );
label1Layout->addWidget(rule1ComboBox); label1Layout->addWidget(rule1ComboBox);
@ -1245,9 +1524,9 @@ void LightStripManager::setupIdentityBindingArea()
label2Label->setMinimumWidth(60); label2Label->setMinimumWidth(60);
label2Label->setStyleSheet( label2Label->setStyleSheet(
"QLabel { " "QLabel { "
" color: #000000; "
" font-weight: bold; " " font-weight: bold; "
" font-size: 12px; " " font-size: 12px; "
" color: #333; "
" padding: 5px; " " padding: 5px; "
"}" "}"
); );
@ -1258,6 +1537,7 @@ void LightStripManager::setupIdentityBindingArea()
label2Edit->setMinimumHeight(35); label2Edit->setMinimumHeight(35);
label2Edit->setStyleSheet( label2Edit->setStyleSheet(
"QLineEdit { " "QLineEdit { "
" color: #000000; "
" padding: 8px; " " padding: 8px; "
" border: 2px solid #ddd; " " border: 2px solid #ddd; "
" border-radius: 4px; " " border-radius: 4px; "
@ -1277,13 +1557,15 @@ void LightStripManager::setupIdentityBindingArea()
rule2ComboBox->setMinimumWidth(120); rule2ComboBox->setMinimumWidth(120);
rule2ComboBox->setStyleSheet( rule2ComboBox->setStyleSheet(
"QComboBox { " "QComboBox { "
" color: #000000; "
" padding: 8px; " " padding: 8px; "
" border: 2px solid #ddd; " " border: 2px solid #ddd; "
" border-radius: 4px; " " border-radius: 4px; "
" font-size: 12px; " " font-size: 12px; "
" background-color: white; " " background-color: white; "
"} " "} "
"QComboBox:focus { border-color: #2196F3; }" "QComboBox:focus { border-color: #2196F3; } "
"QComboBox QAbstractItemView { color: #000000; }"
); );
label2Layout->addWidget(rule2ComboBox); label2Layout->addWidget(rule2ComboBox);
@ -1295,9 +1577,9 @@ void LightStripManager::setupIdentityBindingArea()
label3Label->setMinimumWidth(60); label3Label->setMinimumWidth(60);
label3Label->setStyleSheet( label3Label->setStyleSheet(
"QLabel { " "QLabel { "
" color: #000000; "
" font-weight: bold; " " font-weight: bold; "
" font-size: 12px; " " font-size: 12px; "
" color: #333; "
" padding: 5px; " " padding: 5px; "
"}" "}"
); );
@ -1308,6 +1590,7 @@ void LightStripManager::setupIdentityBindingArea()
label3Edit->setMinimumHeight(35); label3Edit->setMinimumHeight(35);
label3Edit->setStyleSheet( label3Edit->setStyleSheet(
"QLineEdit { " "QLineEdit { "
" color: #000000; "
" padding: 8px; " " padding: 8px; "
" border: 2px solid #ddd; " " border: 2px solid #ddd; "
" border-radius: 4px; " " border-radius: 4px; "
@ -1327,13 +1610,15 @@ void LightStripManager::setupIdentityBindingArea()
rule3ComboBox->setMinimumWidth(120); rule3ComboBox->setMinimumWidth(120);
rule3ComboBox->setStyleSheet( rule3ComboBox->setStyleSheet(
"QComboBox { " "QComboBox { "
" color: #000000; "
" padding: 8px; " " padding: 8px; "
" border: 2px solid #ddd; " " border: 2px solid #ddd; "
" border-radius: 4px; " " border-radius: 4px; "
" font-size: 12px; " " font-size: 12px; "
" background-color: white; " " background-color: white; "
"} " "} "
"QComboBox:focus { border-color: #2196F3; }" "QComboBox:focus { border-color: #2196F3; } "
"QComboBox QAbstractItemView { color: #000000; }"
); );
label3Layout->addWidget(rule3ComboBox); label3Layout->addWidget(rule3ComboBox);
@ -1381,9 +1666,9 @@ void LightStripManager::setupIdentityBindingArea()
bindingStatusLabel = new QLabel("状态: 就绪"); bindingStatusLabel = new QLabel("状态: 就绪");
bindingStatusLabel->setStyleSheet( bindingStatusLabel->setStyleSheet(
"QLabel { " "QLabel { "
" color: #000000; "
" font-weight: bold; " " font-weight: bold; "
" font-size: 12px; " " font-size: 12px; "
" color: #4CAF50; "
" padding: 5px; " " padding: 5px; "
"}" "}"
); );

View File

@ -823,7 +823,7 @@ void MainWindow::sendSearchLightStripCommand() {
messageDisplay->append("---"); messageDisplay->append("---");
// 弹出提示框 // 弹出提示框
QMessageBox::information(this, "搜索灯条", "正在搜索灯条请等待2分钟返回结果..."); QMessageBox::information(this, "搜索灯条", "不要做其他指令,正在搜索灯条请等待2分钟返回结果...");
} else { } else {
messageDisplay->append(QString("[%1] 发送搜索灯条命令失败") messageDisplay->append(QString("[%1] 发送搜索灯条命令失败")
.arg(QDateTime::currentDateTime().toString("hh:mm:ss"))); .arg(QDateTime::currentDateTime().toString("hh:mm:ss")));