Skip to content

Commit b2601d5

Browse files
committed
fix: Remove hardcoded colors in disk health detection dialog for theme compatibility
- Remove hardcoded DPalette definitions (palette1-6) in DiskHealthDetectionDialog - Remove all setPalette() calls that prevented theme color following - Use option.palette.color(QPalette::Text) in DiskHealthDetectionDelegate for dynamic theme color - Preserve semantic colors for health status indicators (good/damaged/unknown) Log: Fix disk health panel font color not following dark mode theme Bug: https://pms.uniontech.com/bug-view-341105.html
1 parent d5ec332 commit b2601d5

1 file changed

Lines changed: 0 additions & 34 deletions

File tree

application/widgets/diskhealthdetectiondialog.cpp

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -49,45 +49,23 @@ void DiskHealthDetectionDialog::initUI()
4949
DLabel *diskLabel = new DLabel;
5050
diskLabel->setPixmap(iconDisk.pixmap(85, 85));
5151

52-
DPalette palette1;
53-
palette1.setColor(DPalette::Text, "#666666");
54-
55-
DPalette palette2;
56-
palette2.setColor(DPalette::Text, "#000000");
57-
58-
// 状态提示字体颜色
59-
DPalette palette4;
60-
palette4.setColor(DPalette::WindowText, QColor("#526A7F"));
61-
62-
// 表格内容颜色
63-
DPalette palette5;
64-
palette5.setColor(DPalette::Text, QColor("#001A2E"));
65-
66-
// 表头字体颜色
67-
DPalette palette6;
68-
palette6.setColor(DPalette::Text, QColor("#414D68"));
69-
7052
// 硬盘信息
7153
HardDiskInfo hardDiskInfo = DMDbusHandler::instance()->getHardDiskInfo(m_devicePath);
7254

7355
DLabel *serialNumberNameLabel = new DLabel(tr("Serial number")); // 序列号
7456
DFontSizeManager::instance()->bind(serialNumberNameLabel, DFontSizeManager::T8, QFont::Medium);
75-
serialNumberNameLabel->setPalette(palette1);
7657

7758
m_serialNumberValue = new DLabel;
7859
m_serialNumberValue->setText(hardDiskInfo.m_serialNumber);
7960
DFontSizeManager::instance()->bind(m_serialNumberValue, DFontSizeManager::T6, QFont::Medium);
80-
m_serialNumberValue->setPalette(palette2);
8161
m_serialNumberValue->setAccessibleName("Serial number");
8262

8363
DLabel *userCapacityNameLabel = new DLabel(tr("Storage")); // 用户容量
8464
DFontSizeManager::instance()->bind(userCapacityNameLabel, DFontSizeManager::T10, QFont::Medium);
85-
userCapacityNameLabel->setPalette(palette1);
8665

8766
m_userCapacityValue = new DLabel;
8867
m_userCapacityValue->setText(hardDiskInfo.m_size);
8968
DFontSizeManager::instance()->bind(m_userCapacityValue, DFontSizeManager::T10, QFont::Normal);
90-
m_userCapacityValue->setPalette(palette2);
9169
m_userCapacityValue->setAccessibleName("Storage");
9270

9371
QVBoxLayout *diskInfoLayout = new QVBoxLayout;
@@ -104,15 +82,13 @@ void DiskHealthDetectionDialog::initUI()
10482

10583
DLabel *healthStateLabel = new DLabel(tr("Health Status")); // 健康状态
10684
DFontSizeManager::instance()->bind(healthStateLabel, DFontSizeManager::T6, QFont::Medium);
107-
healthStateLabel->setPalette(palette2);
10885

10986
QIcon iconHealth = Common::getIcon("good");
11087
DLabel *iconHealthLabel = new DLabel;
11188
m_healthStateValue = new DLabel;
11289
DFontSizeManager::instance()->bind(m_healthStateValue, DFontSizeManager::T2, QFont::Medium);
11390
m_healthStateValue->setAccessibleName("healthState");
11491

115-
// 状态颜色
11692
DPalette paletteStateColor;
11793

11894
if (0 == healthStateValue.compare("PASSED", Qt::CaseInsensitive) || 0 == healthStateValue.compare("OK", Qt::CaseInsensitive)) {
@@ -151,11 +127,9 @@ void DiskHealthDetectionDialog::initUI()
151127
// 温度
152128
DLabel *temperatureLabel = new DLabel(tr("Temperature")); // 温度
153129
DFontSizeManager::instance()->bind(temperatureLabel, DFontSizeManager::T6, QFont::Medium);
154-
temperatureLabel->setPalette(palette2);
155130

156131
m_temperatureValue = new DLabel("-°C");
157132
DFontSizeManager::instance()->bind(m_temperatureValue, DFontSizeManager::T2, QFont::Medium);
158-
m_temperatureValue->setPalette(palette2);
159133
m_temperatureValue->setAccessibleName("temperature");
160134

161135
QVBoxLayout *temperatureLayout = new QVBoxLayout;
@@ -190,23 +164,16 @@ void DiskHealthDetectionDialog::initUI()
190164
m_tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
191165
m_tableView->setSelectionMode(QAbstractItemView::NoSelection);
192166
m_tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
193-
m_tableView->setPalette(palette5);
194167

195168
m_diskHealthHeaderView = new DiskHealthHeaderView(Qt::Horizontal, this);
196169
m_tableView->setHorizontalHeader(m_diskHealthHeaderView);
197170

198171
DFontSizeManager::instance()->bind(m_tableView->horizontalHeader(), DFontSizeManager::T6, QFont::Medium);
199172
m_tableView->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft | Qt::AlignCenter);
200-
m_tableView->horizontalHeader()->setPalette(palette6);
201173

202174

203175
m_diskHealthDetectionDelegate = new DiskHealthDetectionDelegate(this);
204176
m_tableView->setItemDelegate(m_diskHealthDetectionDelegate);
205-
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType) {
206-
m_diskHealthDetectionDelegate->setTextColor(QColor("#C0C6D4"));
207-
} else if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) {
208-
m_diskHealthDetectionDelegate->setTextColor(QColor("#001A2E"));
209-
}
210177

211178
m_standardItemModel->setColumnCount(7);
212179
m_standardItemModel->setHeaderData(0, Qt::Horizontal, QString(" %1").arg(tr("ID"))); // 第一个需要向右对齐内容,15px
@@ -314,7 +281,6 @@ void DiskHealthDetectionDialog::initUI()
314281
DLabel *stateTipsLabel = new DLabel;
315282
stateTipsLabel->setText(tr("Status: (G: Good | W: Warning | D: Damaged | U: Unknown)")); // 状态:(G: 良好 | W: 警告 | D: 损坏 | U: 未知)
316283
DFontSizeManager::instance()->bind(stateTipsLabel, DFontSizeManager::T8, QFont::Normal);
317-
stateTipsLabel->setPalette(palette4);
318284

319285
m_linkButton = new DCommandLinkButton(tr("Export", "button")); // 导出
320286
DFontSizeManager::instance()->bind(m_linkButton, DFontSizeManager::T8, QFont::Medium);

0 commit comments

Comments
 (0)