25 |
25 |
26 IconedGroupBox::IconedGroupBox(QWidget * parent) |
26 IconedGroupBox::IconedGroupBox(QWidget * parent) |
27 { |
27 { |
28 // Has issues with border-radius on children |
28 // Has issues with border-radius on children |
29 // setAttribute(Qt::WA_PaintOnScreen, true); |
29 // setAttribute(Qt::WA_PaintOnScreen, true); |
30 titleLeftPadding = 82; |
30 titleLeftPadding = 82; |
31 contentTopPadding = 22; |
31 contentTopPadding = 22; |
32 } |
32 } |
33 |
33 |
34 void IconedGroupBox::setIcon(const QIcon & icon) |
34 void IconedGroupBox::setIcon(const QIcon & icon) |
35 { |
35 { |
36 if (this->icon.isNull()) |
36 if (this->icon.isNull()) |
37 setStyleSheet(QString( |
37 setStyleSheet(QString( |
38 "IconedGroupBox{" |
38 "IconedGroupBox{" |
39 "margin-top: 46px;" |
39 "margin-top: 46px;" |
40 "margin-left: 12px;" |
40 "margin-left: 12px;" |
41 "padding: %1px 2px 5px 2px;" |
41 "padding: %1px 2px 5px 2px;" |
42 "}" |
42 "}" |
43 "IconedGroupBox::title{" |
43 "IconedGroupBox::title{" |
44 "subcontrol-origin: margin;" |
44 "subcontrol-origin: margin;" |
45 "subcontrol-position: top left;" |
45 "subcontrol-position: top left;" |
46 "padding-left: %2px;" |
46 "padding-left: %2px;" |
47 "padding-top: 25px;" |
47 "padding-top: 25px;" |
48 "text-align: left;" |
48 "text-align: left;" |
49 "}" |
49 "}" |
50 ).arg(contentTopPadding).arg(titleLeftPadding) |
50 ).arg(contentTopPadding).arg(titleLeftPadding) |
51 ); |
51 ); |
52 |
52 |
53 this->icon = icon; |
53 this->icon = icon; |
54 repaint(); |
54 repaint(); |
55 } |
55 } |
56 |
56 |
57 void IconedGroupBox::paintEvent(QPaintEvent * event) |
57 void IconedGroupBox::paintEvent(QPaintEvent * event) |
58 { |
58 { |
59 QStylePainter painter(this); |
59 QStylePainter painter(this); |
60 |
60 |
61 QStyleOptionGroupBox option; |
61 QStyleOptionGroupBox option; |
62 initStyleOption(&option); |
62 initStyleOption(&option); |
63 painter.drawComplexControl(QStyle::CC_GroupBox, option); |
63 painter.drawComplexControl(QStyle::CC_GroupBox, option); |
64 |
64 |
65 icon.paint(&painter, QRect(QPoint(0, 0), icon.actualSize(size()))); |
65 icon.paint(&painter, QRect(QPoint(0, 0), icon.actualSize(size()))); |
66 } |
66 } |
67 |
67 |
68 void IconedGroupBox::setTitleTextPadding(int px) |
68 void IconedGroupBox::setTitleTextPadding(int px) |
69 { |
69 { |
70 titleLeftPadding = px; |
70 titleLeftPadding = px; |
71 } |
71 } |
72 |
72 |
73 void IconedGroupBox::setContentTopPadding(int px) |
73 void IconedGroupBox::setContentTopPadding(int px) |
74 { |
74 { |
75 contentTopPadding = px; |
75 contentTopPadding = px; |
76 } |
76 } |