-void ColorButton::paintEvent(QPaintEvent *event) {
- //TODO: work on a good button style solution
- QPushButton::paintEvent(event);
- QPainter painter(this);
- int border = QApplication::style()->pixelMetric(QStyle::PM_ButtonMargin);
-
- // if twice buttonMargin (+2 px from the adjust) is greater than the button height
- // then set the border to a third of the button height.
- if(2*border+2 >= event->rect().height()) border = event->rect().height()/3;
-
- QBrush brush;
- if(isEnabled()) {
- brush = QBrush(_color);
- } else {
- brush = QBrush(_color, Qt::Dense4Pattern);
- }
- painter.fillRect(rect().adjusted(border+1, border+1, -border-1, -border-1), brush);
- QStyleOptionFrame option;
- option.state = QStyle::State_Sunken;
- option.rect = rect().adjusted(border, border, -border, -border);