54{
56 QToolButton::paintEvent(event);
57 return;
58 }
59 QStylePainter painter(this);
60 QStyleOptionToolButton opt;
61 initStyleOption(&opt);
62 QStyleOptionToolButton panelOpt = opt;
63
64
65 QRect& panelRect = panelOpt.rect;
68 panelRect.setWidth(panelRect.width() * 2);
69 break;
71 panelRect.setLeft(panelRect.left() - panelRect.width());
72 panelRect.setWidth(panelRect.width() * 3);
73 break;
75 panelRect.setLeft(panelRect.left() - panelRect.width());
76 break;
78 Q_ASSERT(0);
79 }
80 if (autoRaise()) {
81 if (!isChecked() && !isDown() && !(panelOpt.state & QStyle::State_MouseOver)) {
82
83
84 panelOpt.state |= (QStyle::State_On | QStyle::State_Sunken);
85 QPalette panelPal(panelOpt.palette);
86 QColor c;
87 c = panelPal.color(QPalette::Button);
88 c.setAlpha(50);
89 panelPal.setColor(QPalette::Button, c);
90 c = panelPal.color(QPalette::Window);
91 c.setAlpha(50);
92 panelPal.setColor(QPalette::Window, c);
93 panelOpt.palette = panelPal;
94 painter.setOpacity(0.5);
95 }
96 } else {
97
98 if (!isChecked() && !isDown() && !(panelOpt.state & QStyle::State_MouseOver)) {
99
100 } else {
101
102 panelOpt.state |= (QStyle::State_On | QStyle::State_Sunken);
103 QPalette panelPal(panelOpt.palette);
104 QColor c;
105 c = panelPal.color(QPalette::Button);
106 c.setAlpha(50);
107 panelPal.setColor(QPalette::Button, c);
108 c = panelPal.color(QPalette::Window);
109 c.setAlpha(50);
110 panelPal.setColor(QPalette::Window, c);
111 panelOpt.palette = panelPal;
112 painter.setOpacity(0.5);
113 }
114 }
115
116
117 painter.drawPrimitive(QStyle::PE_PanelButtonTool, panelOpt);
118 painter.setOpacity(1.0);
119
120
122 const int y1 = opt.rect.top() + 1;
123 const int y2 = opt.rect.bottom() - 1;
124 painter.setOpacity(0.4);
126 const int x = opt.rect.right();
127 painter.setPen(QPen(opt.palette.color(QPalette::Dark), 0));
128 painter.drawLine(x, y1, x, y2);
129 }
130 painter.setOpacity(1.0);
131
132
133 painter.drawControl(QStyle::CE_ToolButtonLabel, opt);
134
135
136
137
138
139
140
141
142
143
144 if (!actions().isEmpty()) {
145 QAction* action = actions().first();
146 setToolTip(i18nc("@info:tooltip of custom triple button", "%1", action->toolTip()));
147 }
148}