初步重构
This commit is contained in:
@@ -17,13 +17,13 @@ void CustomFileDelegate::paint(QPainter* painter, const QStyleOptionViewItem& op
|
||||
QIcon fileIcon = model->fileIcon(index); // 文件/文件夹图标
|
||||
|
||||
// 设置选中和未选中背景颜色
|
||||
QColor backgroundColor = fileInfo.isDir() ? QColor(220, 240, 255) : QColor(255, 255, 220); // 文件夹和文件的不同背景色
|
||||
QColor background_color = fileInfo.isDir() ? QColor(220, 240, 255) : QColor(255, 255, 220); // 文件夹和文件的不同背景色
|
||||
if (option.state & QStyle::State_Selected) {
|
||||
backgroundColor = QColor(0, 120, 215); // 选中的背景色
|
||||
background_color = QColor(0, 120, 215); // 选中的背景色
|
||||
}
|
||||
|
||||
// 绘制背景
|
||||
painter->fillRect(option.rect, backgroundColor);
|
||||
painter->fillRect(option.rect, background_color);
|
||||
|
||||
// 设置文本颜色
|
||||
QColor textColor = (option.state & QStyle::State_Selected) ? Qt::white : Qt::black;
|
||||
|
||||
Reference in New Issue
Block a user