diff options
author | Jens Bache-Wiig <jens.bache-wiig@digia.com> | 2012-10-17 09:48:10 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-18 00:14:48 +0200 |
commit | 9410b307afc2fec43a5f05ef3761d619f50e4d20 (patch) | |
tree | 5c4d37758a82d14dadd0a84b94a1c6f34bc63a13 | |
parent | 12d25f1a42d03c2d126d0fcf60622aa9b7dac6db (diff) |
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>
-rw-r--r-- | src/widgets/styles/qcommonstyle.cpp | 23 | ||||
-rw-r--r-- | src/widgets/styles/qcommonstylepixmaps_p.h | 27 | ||||
-rw-r--r-- | src/widgets/styles/qwindowsstyle.cpp | 35 |
3 files changed, 13 insertions, 72 deletions
diff --git a/src/widgets/styles/qcommonstyle.cpp b/src/widgets/styles/qcommonstyle.cpp index dd75870437..e6e2e75c4e 100644 --- a/src/widgets/styles/qcommonstyle.cpp +++ b/src/widgets/styles/qcommonstyle.cpp @@ -277,35 +277,38 @@ void QCommonStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, Q break; #endif // QT_NO_PROGRESSBAR case PE_IndicatorBranch: { + 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; -#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) { int delta = decoration_size / 2; bef_h -= delta; bef_v -= delta; aft_h += 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->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 - 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) - 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)) - 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; } case PE_FrameStatusBarItem: qDrawShadeRect(p, opt->rect, opt->palette, true, 1, 0, 0); diff --git a/src/widgets/styles/qcommonstylepixmaps_p.h b/src/widgets/styles/qcommonstylepixmaps_p.h index 4dcbe86ada..5e63302f35 100644 --- a/src/widgets/styles/qcommonstylepixmaps_p.h +++ b/src/widgets/styles/qcommonstylepixmaps_p.h @@ -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[] = { "5 8 3 1", diff --git a/src/widgets/styles/qwindowsstyle.cpp b/src/widgets/styles/qwindowsstyle.cpp index eb39790e36..4df68a76ad 100644 --- a/src/widgets/styles/qwindowsstyle.cpp +++ b/src/widgets/styles/qwindowsstyle.cpp @@ -1459,41 +1459,6 @@ void QWindowsStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, } break; #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_PanelButtonBevel: { QBrush fill; |