close-cd#I73ZTU 修复切换为华文字体后计算机视图显示问题
This commit is contained in:
parent
edd230e511
commit
de31083031
|
@ -87,6 +87,9 @@ void ComputerItemDelegate::paintVolumeItem(QPainter *painter, const QStyleOption
|
|||
int v = bg.value();
|
||||
bg.setHsv(hue, 10, 127);
|
||||
|
||||
|
||||
qDebug() << "============" << opt.font << "text:" << opt.text;
|
||||
|
||||
opt.palette.setColor(QPalette::Highlight, bg);
|
||||
//qApp->style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &opt, painter, m_styleIconView);
|
||||
bool isHover = (option.state & QStyle::State_MouseOver) && (option.state & ~QStyle::State_Selected);
|
||||
|
@ -126,7 +129,9 @@ void ComputerItemDelegate::paintVolumeItem(QPainter *painter, const QStyleOption
|
|||
|
||||
//draw text
|
||||
auto textRect = option.rect;
|
||||
qDebug() << "===========" << textRect;
|
||||
textRect.adjust(84, 10, -5, -25);
|
||||
qDebug() << "===========last" << textRect;
|
||||
textRect.translate(0, -option.fontMetrics.ascent());
|
||||
auto elideText = opt.fontMetrics.elidedText(opt.text, Qt::ElideMiddle, textRect.width());
|
||||
qApp->style()->drawItemText(painter, textRect, Qt::AlignLeft|Qt::AlignVCenter, option.palette, enable, elideText, QPalette::Text);
|
||||
|
@ -156,8 +161,15 @@ void ComputerItemDelegate::paintVolumeItem(QPainter *painter, const QStyleOption
|
|||
}
|
||||
}
|
||||
|
||||
QRect spaceInfoArea = textRect.translated(0, 1.5 * option.fontMetrics.ascent());
|
||||
spaceInfoArea.setHeight (option.fontMetrics.height () + 2.5 * option.fontMetrics.ascent());
|
||||
QRect spaceInfoArea = textRect;
|
||||
if (option.fontMetrics.ascent() <= option.font.pointSize() + 4) {
|
||||
spaceInfoArea = textRect.translated(0, 2.0 * option.fontMetrics.ascent());
|
||||
spaceInfoArea.setHeight (option.fontMetrics.height () + 3.0 * option.fontMetrics.ascent());
|
||||
} else {
|
||||
spaceInfoArea = textRect.translated(0, 1.5 * option.fontMetrics.ascent());
|
||||
spaceInfoArea.setHeight (option.fontMetrics.height () + 2.5 * option.fontMetrics.ascent());
|
||||
}
|
||||
|
||||
qApp->style()->drawItemText(painter, spaceInfoArea, Qt::AlignLeft|Qt::AlignVCenter|Qt::TextWordWrap, option.palette, enable, spaceInfo, QPalette::PlaceholderText);
|
||||
|
||||
if (shouldDrawProgress) {
|
||||
|
|
Loading…
Reference in New Issue