Fix styled vertical dockwidget title cut off bug and elide text if long
Change common stylesheet to elide text correctly for both direction. Change-Id: I045f6f74733ca8fa67b3e4fbb9d3845a1bea777d Task-number: QTBUG-41466 Reviewed-by: Jens Bache-Wiig <jensbw@gmail.com>
This commit is contained in:
parent
c399e4b7ea
commit
3056b825bd
@ -4047,26 +4047,28 @@ void QStyleSheetStyle::drawControl(ControlElement ce, const QStyleOption *opt, Q
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!dwOpt->title.isEmpty()) {
|
if (!dwOpt->title.isEmpty()) {
|
||||||
QRect r = opt->rect;
|
QRect r = subElementRect(SE_DockWidgetTitleBarText, opt, w);
|
||||||
if (dwOpt->verticalTitleBar) {
|
if (dwOpt->verticalTitleBar) {
|
||||||
QSize s = r.size();
|
QSize s = r.size();
|
||||||
s.transpose();
|
s.transpose();
|
||||||
r.setSize(s);
|
r.setSize(s);
|
||||||
|
|
||||||
p->save();
|
p->save();
|
||||||
p->translate(r.left(), r.top() + r.width());
|
p->translate(r.left(), r.top() + r.width());
|
||||||
p->rotate(-90);
|
p->rotate(-90);
|
||||||
p->translate(-r.left(), -r.top());
|
p->translate(-r.left(), -r.top());
|
||||||
}
|
}
|
||||||
|
r = subRule.contentsRect(r);
|
||||||
|
|
||||||
Qt::Alignment alignment = 0;
|
Qt::Alignment alignment = 0;
|
||||||
if (subRule.hasPosition())
|
if (subRule.hasPosition())
|
||||||
alignment = subRule.position()->textAlignment;
|
alignment = subRule.position()->textAlignment;
|
||||||
if (alignment == 0)
|
if (alignment == 0)
|
||||||
alignment = Qt::AlignLeft;
|
alignment = Qt::AlignLeft;
|
||||||
drawItemText(p, subRule.contentsRect(opt->rect),
|
|
||||||
|
QString titleText = p->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight, r.width());
|
||||||
|
drawItemText(p, r,
|
||||||
alignment | Qt::TextShowMnemonic, dwOpt->palette,
|
alignment | Qt::TextShowMnemonic, dwOpt->palette,
|
||||||
dwOpt->state & State_Enabled, dwOpt->title,
|
dwOpt->state & State_Enabled, titleText,
|
||||||
QPalette::WindowText);
|
QPalette::WindowText);
|
||||||
|
|
||||||
if (dwOpt->verticalTitleBar)
|
if (dwOpt->verticalTitleBar)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user