More consistent dock widget painting on Windows
Before we would draw dock widget handles on windows classic and no handles on XP, Vista and Windows 8. This would make it very hard to make a consistent look and feel across those styles. I also added a workaround to avoid the redundant toolbar borders when they are used outside of the toolbar areas. Change-Id: Ib703453677fcac8d51b2180abe45527297af0a80 Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com> Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
parent
b80216c9f3
commit
9bdd7e2239
@ -377,6 +377,9 @@ int QWindowsStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt, const QW
|
|||||||
case PM_MenuVMargin:
|
case PM_MenuVMargin:
|
||||||
ret = 1;
|
ret = 1;
|
||||||
break;
|
break;
|
||||||
|
case PM_DockWidgetSeparatorExtent:
|
||||||
|
ret = int(QStyleHelper::dpiScaled(4.));
|
||||||
|
break;
|
||||||
#ifndef QT_NO_TABBAR
|
#ifndef QT_NO_TABBAR
|
||||||
case PM_TabBarTabShiftHorizontal:
|
case PM_TabBarTabShiftHorizontal:
|
||||||
ret = 0;
|
ret = 0;
|
||||||
@ -1699,31 +1702,9 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
|
|||||||
qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
|
qDrawWinPanel(p, opt->rect, popupPal, opt->state & State_Sunken);
|
||||||
break; }
|
break; }
|
||||||
#ifndef QT_NO_DOCKWIDGET
|
#ifndef QT_NO_DOCKWIDGET
|
||||||
case PE_IndicatorDockWidgetResizeHandle: {
|
case PE_IndicatorDockWidgetResizeHandle:
|
||||||
QPen oldPen = p->pen();
|
break;
|
||||||
p->setPen(opt->palette.light().color());
|
case PE_FrameDockWidget:
|
||||||
if (opt->state & State_Horizontal) {
|
|
||||||
p->drawLine(opt->rect.left(), opt->rect.top(),
|
|
||||||
opt->rect.right(), opt->rect.top());
|
|
||||||
p->setPen(opt->palette.dark().color());
|
|
||||||
p->drawLine(opt->rect.left(), opt->rect.bottom() - 1,
|
|
||||||
opt->rect.right(), opt->rect.bottom() - 1);
|
|
||||||
p->setPen(opt->palette.shadow().color());
|
|
||||||
p->drawLine(opt->rect.left(), opt->rect.bottom(),
|
|
||||||
opt->rect.right(), opt->rect.bottom());
|
|
||||||
} else {
|
|
||||||
p->drawLine(opt->rect.left(), opt->rect.top(),
|
|
||||||
opt->rect.left(), opt->rect.bottom());
|
|
||||||
p->setPen(opt->palette.dark().color());
|
|
||||||
p->drawLine(opt->rect.right() - 1, opt->rect.top(),
|
|
||||||
opt->rect.right() - 1, opt->rect.bottom());
|
|
||||||
p->setPen(opt->palette.shadow().color());
|
|
||||||
p->drawLine(opt->rect.right(), opt->rect.top(),
|
|
||||||
opt->rect.right(), opt->rect.bottom());
|
|
||||||
}
|
|
||||||
p->setPen(oldPen);
|
|
||||||
break; }
|
|
||||||
case PE_FrameDockWidget:
|
|
||||||
if (qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
|
if (qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
|
||||||
proxy()->drawPrimitive(QStyle::PE_FrameWindow, opt, p, w);
|
proxy()->drawPrimitive(QStyle::PE_FrameWindow, opt, p, w);
|
||||||
}
|
}
|
||||||
@ -2286,8 +2267,11 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
|
|||||||
#ifndef QT_NO_TOOLBAR
|
#ifndef QT_NO_TOOLBAR
|
||||||
case CE_ToolBar:
|
case CE_ToolBar:
|
||||||
if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
|
if (const QStyleOptionToolBar *toolbar = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
|
||||||
QRect rect = opt->rect;
|
// Reserve the beveled appearance only for mainwindow toolbars
|
||||||
|
if (!(widget && qobject_cast<const QMainWindow*> (widget->parentWidget())))
|
||||||
|
break;
|
||||||
|
|
||||||
|
QRect rect = opt->rect;
|
||||||
bool paintLeftBorder = true;
|
bool paintLeftBorder = true;
|
||||||
bool paintRightBorder = true;
|
bool paintRightBorder = true;
|
||||||
bool paintBottomBorder = true;
|
bool paintBottomBorder = true;
|
||||||
@ -2513,11 +2497,6 @@ void QWindowsStyle::drawControl(ControlElement ce, const QStyleOption *opt, QPai
|
|||||||
}
|
}
|
||||||
p->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
|
p->fillRect(r.adjusted(0, 0, 0, -3), fillBrush);
|
||||||
}
|
}
|
||||||
p->setPen(dwOpt->palette.color(QPalette::Light));
|
|
||||||
if (!widget || !widget->isWindow()) {
|
|
||||||
p->drawLine(r.topLeft(), r.topRight());
|
|
||||||
p->setPen(dwOpt->palette.color(QPalette::Dark));
|
|
||||||
p->drawLine(r.bottomLeft(), r.bottomRight()); }
|
|
||||||
}
|
}
|
||||||
if (!dwOpt->title.isEmpty()) {
|
if (!dwOpt->title.isEmpty()) {
|
||||||
QFont oldFont = p->font();
|
QFont oldFont = p->font();
|
||||||
|
@ -1511,7 +1511,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
if (!dwOpt->title.isEmpty()) {
|
if (!dwOpt->title.isEmpty()) {
|
||||||
QString titleText = painter->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight,
|
QString titleText = painter->fontMetrics().elidedText(dwOpt->title, Qt::ElideRight,
|
||||||
verticalTitleBar ? titleRect.height() : titleRect.width());
|
verticalTitleBar ? titleRect.height() : titleRect.width());
|
||||||
const int indent = painter->fontMetrics().descent();
|
const int indent = 4;
|
||||||
drawItemText(painter, rect.adjusted(indent + 1, 1, -indent - 1, -1),
|
drawItemText(painter, rect.adjusted(indent + 1, 1, -indent - 1, -1),
|
||||||
Qt::AlignLeft | Qt::AlignVCenter, dwOpt->palette,
|
Qt::AlignLeft | Qt::AlignVCenter, dwOpt->palette,
|
||||||
dwOpt->state & State_Enabled, titleText,
|
dwOpt->state & State_Enabled, titleText,
|
||||||
@ -1524,6 +1524,7 @@ void QWindowsVistaStyle::drawControl(ControlElement element, const QStyleOption
|
|||||||
case CE_ItemViewItem:
|
case CE_ItemViewItem:
|
||||||
{
|
{
|
||||||
const QStyleOptionViewItem *vopt;
|
const QStyleOptionViewItem *vopt;
|
||||||
|
|
||||||
const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
|
const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
|
||||||
bool newStyle = true;
|
bool newStyle = true;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user