fix(frontend):the search result item is align left while the layout direction is right to left.
This commit is contained in:
parent
f0e9982731
commit
bfcefe4ce1
|
@ -44,7 +44,8 @@ void ResultViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||||
{
|
{
|
||||||
QStyleOptionViewItem opt = option;
|
QStyleOptionViewItem opt = option;
|
||||||
initStyleOption(&opt, index);
|
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;
|
QString originalText = opt.text;
|
||||||
opt.text = QString();
|
opt.text = QString();
|
||||||
|
@ -87,7 +88,8 @@ void ResultViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &op
|
||||||
m_hightLightEffectHelper->setDocument(m_textDoc);
|
m_hightLightEffectHelper->setDocument(m_textDoc);
|
||||||
m_hightLightEffectHelper->rehighlight();
|
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);
|
m_textDoc->drawContents(painter);
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue