Skip to content

Commit

Permalink
Add dropdown arrow to GroupedToolButton
Browse files Browse the repository at this point in the history
  • Loading branch information
callaa committed Apr 11, 2017
1 parent 45d7b03 commit bcfce08
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/desktop/widgets/groupedtoolbutton.cpp
Expand Up @@ -99,8 +99,25 @@ void GroupedToolButton::paintEvent(QPaintEvent* event)
painter.drawLine(x, y1, x, y2);
}

const bool showDropdownArrow = menu() != nullptr && !text().isEmpty();

QRect textRect = opt.rect;
QRect arrowRect;

if(showDropdownArrow) {
arrowRect = QRect(textRect.right() - 20, textRect.y(), 20, textRect.height());
textRect.setWidth(textRect.width() - arrowRect.width());
}

// Text
opt.rect = textRect;
painter.drawControl(QStyle::CE_ToolButtonLabel, opt);

// Dropdown arrow
if(showDropdownArrow) {
opt.rect = arrowRect;
painter.drawPrimitive(QStyle::PE_IndicatorArrowDown, opt);
}
}

#ifndef DESIGNER_PLUGIN
Expand Down

0 comments on commit bcfce08

Please sign in to comment.