diff options
author | Liang Qi <liang.qi@qt.io> | 2019-01-26 08:35:40 +0100 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2019-01-26 08:35:40 +0100 |
commit | 980567b3a32b2e2f00c86f2d627cd82b5230dd0f (patch) | |
tree | bc8cc4005b2e07cbc5cad8ba30f8c9fa4f236c3d /src/widgets/styles | |
parent | e81acde7d0cf5fb44a3fb2cf0bf7aaa2c65f807e (diff) | |
parent | 730cbad8824bcfcb7ab60371a6563cfb6dd5658d (diff) |
Merge remote-tracking branch 'origin/5.12' into dev
Conflicts:
src/android/templates/AndroidManifest.xml
tests/auto/widgets/styles/qstylesheetstyle/tst_qstylesheetstyle.cpp
Change-Id: I4c9679e3a8ebba118fbf4772301ff8fde60455b9
Diffstat (limited to 'src/widgets/styles')
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 36 | ||||
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 11 |
2 files changed, 30 insertions, 17 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index 49543061cc..2bfc1acc26 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -946,17 +946,20 @@ void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewIt const QRectF boundingRect = textLayout.boundingRect(); const QRect layoutRect = QStyle::alignedRect(option->direction, option->displayAlignment, boundingRect.size().toSize(), textRect); - const QPointF position = layoutRect.topLeft(); - const int lineCount = textLayout.lineCount(); + QPointF paintPosition = QPointF(textRect.x(), layoutRect.top()); + QString newText; qreal height = 0; + const int lineCount = textLayout.lineCount(); for (int i = 0; i < lineCount; ++i) { const QTextLine line = textLayout.lineAt(i); height += line.height(); // above visible rect - if (height + layoutRect.top() <= textRect.top()) + if (height + layoutRect.top() <= textRect.top()) { + paintPosition.ry() += line.height(); continue; + } const int start = line.textStart(); const int length = line.textLength(); @@ -971,26 +974,33 @@ void QCommonStylePrivate::viewItemDrawText(QPainter *p, const QStyleOptionViewIt elideLastVisibleLine = true; } + QString text = textLayout.text().mid(start, length); if (drawElided || elideLastVisibleLine) { - QString text = textLayout.text().mid(start, length); - if (elideLastVisibleLine) + if (elideLastVisibleLine) { + if (text.endsWith(QChar::LineSeparator)) + text.chop(1); text += QChar(0x2026); + } const QStackTextEngine engine(text, option->font); - const QString elidedText = engine.elidedText(option->textElideMode, textRect.width()); - const QPointF pos(position.x() + line.x(), - position.y() + line.y() + line.ascent()); - p->save(); - p->setFont(option->font); - p->drawText(pos, elidedText); - p->restore(); + newText += engine.elidedText(option->textElideMode, textRect.width()); + // sometimes drawElided is true but no eliding is done so the text ends + // with QChar::LineSeparator - don't add another one. This happened with + // arabic text in the testcase for QTBUG-72805 + if (i < lineCount - 1 && + !newText.endsWith(QChar::LineSeparator)) + newText += QChar::LineSeparator; } else { - line.draw(p, position); + newText += text; } // below visible text, can stop if (height + layoutRect.top() >= textRect.bottom()) break; } + + textLayout.setText(newText); + viewItemTextLayout(textLayout, textRect.width()); + textLayout.draw(p, paintPosition); } /*! \internal diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index e261055c3c..e73d019408 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -2645,7 +2645,7 @@ void QStyleSheetStyle::setPalette(QWidget *w) QRenderRule rule = renderRule(w, PseudoElement_None, map[i].state | extendedPseudoClass(w)); if (i == 0) { if (!w->property("_q_styleSheetWidgetFont").isValid()) { - saveWidgetFont(w, w->font()); + saveWidgetFont(w, w->d_func()->localFont()); } updateStyleSheetFont(w); if (ew != w) @@ -6033,7 +6033,7 @@ void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const unsetStyleSheetFont(w); if (rule.font.resolve()) { - QFont wf = w->font(); + QFont wf = w->d_func()->localFont(); styleSheetCaches->customFontWidgets.insert(w, {wf, rule.font.resolve()}); QFont font = rule.font.resolve(wf); @@ -6041,7 +6041,9 @@ void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const w->setFont(font); } } else { - QFont font = rule.font.resolve(w->font()); + QFont wf = w->d_func()->localFont(); + QFont font = rule.font.resolve(wf); + font.resolve(wf.resolve() | rule.font.resolve()); if ((!w->isWindow() || w->testAttribute(Qt::WA_WindowPropagation)) && isNaturalChild(w) && qobject_cast<QWidget *>(w->parent())) { @@ -6049,10 +6051,11 @@ void QStyleSheetStyle::updateStyleSheetFont(QWidget* w) const font = font.resolve(static_cast<QWidget *>(w->parent())->font()); } - if (w->data->fnt == font) + if (wf.resolve() == font.resolve() && wf == font) return; w->data->fnt = font; + w->d_func()->directFontResolveMask = font.resolve(); QEvent e(QEvent::FontChange); QApplication::sendEvent(w, &e); |