Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion application/widgets/diskhealthdetectiondelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void DiskHealthDetectionDelegate::paint(QPainter *painter, const QStyleOptionVie
} else if (text == "U") {
painter->setPen(QColor("#777777"));
} else {
painter->setPen(m_color);
painter->setPen(option.palette.color(QPalette::Text));
}

painter->drawText(paintRect.x() + 15, paintRect.y() + 20, text);
Expand Down
34 changes: 0 additions & 34 deletions application/widgets/diskhealthdetectiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,45 +49,23 @@ void DiskHealthDetectionDialog::initUI()
DLabel *diskLabel = new DLabel;
diskLabel->setPixmap(iconDisk.pixmap(85, 85));

DPalette palette1;
palette1.setColor(DPalette::Text, "#666666");

DPalette palette2;
palette2.setColor(DPalette::Text, "#000000");

// 状态提示字体颜色
DPalette palette4;
palette4.setColor(DPalette::WindowText, QColor("#526A7F"));

// 表格内容颜色
DPalette palette5;
palette5.setColor(DPalette::Text, QColor("#001A2E"));

// 表头字体颜色
DPalette palette6;
palette6.setColor(DPalette::Text, QColor("#414D68"));

// 硬盘信息
HardDiskInfo hardDiskInfo = DMDbusHandler::instance()->getHardDiskInfo(m_devicePath);

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

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

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

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

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

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

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

// 状态颜色
DPalette paletteStateColor;

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

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

QVBoxLayout *temperatureLayout = new QVBoxLayout;
Expand Down Expand Up @@ -190,23 +164,16 @@ void DiskHealthDetectionDialog::initUI()
m_tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
m_tableView->setSelectionMode(QAbstractItemView::NoSelection);
m_tableView->setEditTriggers(QAbstractItemView::NoEditTriggers);
m_tableView->setPalette(palette5);

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

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


m_diskHealthDetectionDelegate = new DiskHealthDetectionDelegate(this);
m_tableView->setItemDelegate(m_diskHealthDetectionDelegate);
if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::DarkType) {
m_diskHealthDetectionDelegate->setTextColor(QColor("#C0C6D4"));
} else if (DGuiApplicationHelper::instance()->themeType() == DGuiApplicationHelper::LightType) {
m_diskHealthDetectionDelegate->setTextColor(QColor("#001A2E"));
}

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

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