fix(frontend):the search result item is align left while the layout direction is right to left.
This commit is contained in:
parent
fda53e91e3
commit
25baa9140e
|
@ -44,7 +44,8 @@ void ResultViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||
{
|
||||
QStyleOptionViewItem opt = option;
|
||||
initStyleOption(&opt, index);
|
||||
opt.displayAlignment = Qt::Alignment(Qt::AlignLeft|Qt::AlignVCenter);
|
||||
opt.displayAlignment = QApplication::isLeftToRight() ?
|
||||
Qt::Alignment(Qt::AlignLeft|Qt::AlignVCenter) : Qt::Alignment(Qt::AlignRight|Qt::AlignVCenter);
|
||||
|
||||
QString originalText = opt.text;
|
||||
opt.text = QString();
|
||||
|
@ -87,7 +88,8 @@ void ResultViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
|||
m_hightLightEffectHelper->setDocument(m_textDoc);
|
||||
m_hightLightEffectHelper->rehighlight();
|
||||
|
||||
painter->translate(textRect.x(), textRect.y() + (textRect.height() - fontMetrics.height()) / 2 - m_textDoc->documentMargin());
|
||||
int textRectX = QApplication::isLeftToRight() ? textRect.x() : textRect.width() - fontMetrics.horizontalAdvance(text) - m_textDoc->documentMargin();
|
||||
painter->translate(textRectX, textRect.y() + (textRect.height() - fontMetrics.height()) / 2 - m_textDoc->documentMargin());
|
||||
m_textDoc->drawContents(painter);
|
||||
painter->restore();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue