Improve branch indicators in common style

The branch indicators in common style was painted based on motif
style, effectively making it useless.

Since most styles inherit from Windows style, I
moved that into common style. It was already duplicating
most of the code used in commonstyle.

Change-Id: I1a383d90254bb97aebc038fa058ec0f225cf9dab
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
Jens Bache-Wiig 2012-10-17 09:48:10 +02:00 committed by The Qt Project
parent 12d25f1a42
commit 9410b307af
3 changed files with 13 additions and 72 deletions

View File

@ -277,35 +277,38 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q
break; break;
#endif // QT_NO_PROGRESSBAR #endif // QT_NO_PROGRESSBAR
case PE_IndicatorBranch: { case PE_IndicatorBranch: {
static const int decoration_size = 9;
int mid_h = opt->rect.x() + opt->rect.width() / 2; int mid_h = opt->rect.x() + opt->rect.width() / 2;
int mid_v = opt->rect.y() + opt->rect.height() / 2; int mid_v = opt->rect.y() + opt->rect.height() / 2;
int bef_h = mid_h; int bef_h = mid_h;
int bef_v = mid_v; int bef_v = mid_v;
int aft_h = mid_h; int aft_h = mid_h;
int aft_v = mid_v; int aft_v = mid_v;
#ifndef QT_NO_IMAGEFORMAT_XPM
static const int decoration_size = 9;
static QPixmap open(tree_branch_open_xpm);
static QPixmap closed(tree_branch_closed_xpm);
if (opt->state & State_Children) { if (opt->state & State_Children) {
int delta = decoration_size / 2; int delta = decoration_size / 2;
bef_h -= delta; bef_h -= delta;
bef_v -= delta; bef_v -= delta;
aft_h += delta; aft_h += delta;
aft_v += delta; aft_v += delta;
p->drawPixmap(bef_h, bef_v, opt->state & State_Open ? open : closed); p->drawLine(bef_h + 2, bef_v + 4, bef_h + 6, bef_v + 4);
if (!(opt->state & State_Open))
p->drawLine(bef_h + 4, bef_v + 2, bef_h + 4, bef_v + 6);
QPen oldPen = p->pen();
p->setPen(opt->palette.dark().color());
p->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1);
p->setPen(oldPen);
} }
#endif // QT_NO_IMAGEFORMAT_XPM QBrush brush(opt->palette.dark().color(), Qt::Dense4Pattern);
if (opt->state & State_Item) { if (opt->state & State_Item) {
if (opt->direction == Qt::RightToLeft) if (opt->direction == Qt::RightToLeft)
p->drawLine(opt->rect.left(), mid_v, bef_h, mid_v); p->fillRect(opt->rect.left(), mid_v, bef_h - opt->rect.left(), 1, brush);
else else
p->drawLine(aft_h, mid_v, opt->rect.right(), mid_v); p->fillRect(aft_h, mid_v, opt->rect.right() - aft_h + 1, 1, brush);
} }
if (opt->state & State_Sibling) if (opt->state & State_Sibling)
p->drawLine(mid_h, aft_v, mid_h, opt->rect.bottom()); p->fillRect(mid_h, aft_v, 1, opt->rect.bottom() - aft_v + 1, brush);
if (opt->state & (State_Open | State_Children | State_Item | State_Sibling)) if (opt->state & (State_Open | State_Children | State_Item | State_Sibling))
p->drawLine(mid_h, opt->rect.y(), mid_h, bef_v); p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush);
break; } break; }
case PE_FrameStatusBarItem: case PE_FrameStatusBarItem:
qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, 0); qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, 0);

View File

@ -75,33 +75,6 @@ static const char * const check_list_controller_xpm[] = {
" ", " ",
" "}; " "};
static const char * const tree_branch_open_xpm[] = {
"9 9 2 1",
" c None",
"# c #000000",
"#########",
"# #",
"# ##### #",
"# ### #",
"# ### #",
"# # #",
"# # #",
"# #",
"#########"};
static const char * const tree_branch_closed_xpm[] = {
"9 9 2 1",
" c None",
"# c #000000",
"#########",
"# #",
"# # #",
"# ### #",
"# ##### #",
"# ### #",
"# # #",
"# #",
"#########"};
static const char * const tb_extension_arrow_v_xpm[] = { static const char * const tb_extension_arrow_v_xpm[] = {
"5 8 3 1", "5 8 3 1",

View File

@ -1459,41 +1459,6 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt,
} }
break; break;
#endif // QT_NO_FRAME #endif // QT_NO_FRAME
case PE_IndicatorBranch: {
// This is _way_ too similar to the common style.
static const int decoration_size = 9;
int mid_h = opt->rect.x() + opt->rect.width() / 2;
int mid_v = opt->rect.y() + opt->rect.height() / 2;
int bef_h = mid_h;
int bef_v = mid_v;
int aft_h = mid_h;
int aft_v = mid_v;
if (opt->state & State_Children) {
int delta = decoration_size / 2;
bef_h -= delta;
bef_v -= delta;
aft_h += delta;
aft_v += delta;
p->drawLine(bef_h + 2, bef_v + 4, bef_h + 6, bef_v + 4);
if (!(opt->state & State_Open))
p->drawLine(bef_h + 4, bef_v + 2, bef_h + 4, bef_v + 6);
QPen oldPen = p->pen();
p->setPen(opt->palette.dark().color());
p->drawRect(bef_h, bef_v, decoration_size - 1, decoration_size - 1);
p->setPen(oldPen);
}
QBrush brush(opt->palette.dark().color(), Qt::Dense4Pattern);
if (opt->state & State_Item) {
if (opt->direction == Qt::RightToLeft)
p->fillRect(opt->rect.left(), mid_v, bef_h - opt->rect.left(), 1, brush);
else
p->fillRect(aft_h, mid_v, opt->rect.right() - aft_h + 1, 1, brush);
}
if (opt->state & State_Sibling)
p->fillRect(mid_h, aft_v, 1, opt->rect.bottom() - aft_v + 1, brush);
if (opt->state & (State_Open | State_Children | State_Item | State_Sibling))
p->fillRect(mid_h, opt->rect.y(), 1, bef_v - opt->rect.y(), brush);
break; }
case PE_FrameButtonBevel: case PE_FrameButtonBevel:
case PE_PanelButtonBevel: { case PE_PanelButtonBevel: {
QBrush fill; QBrush fill;