Skip to content

Commit

Permalink
Collapsible widget: added a menu icon to the right (opencor#1426).
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Oct 25, 2017
1 parent bfff6da commit eddb371
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/plugins/miscellaneous/Core/src/collapsiblewidget.cpp
Expand Up @@ -96,27 +96,35 @@ CollapsibleHeaderWidget::CollapsibleHeaderWidget(const bool &pCollapsible,
static const QIcon NoIcon = QIcon();
static const QIcon DownIcon = QIcon(":/oxygen/actions/arrow-down.png");

static const QString IconStyleSheet = "QToolButton {"
" border: none;"
"}"
""
"QToolButton:pressed {"
" margin: 0px;"
"}";

mButton = new QToolButton(subWidget);
mTitle = new CollapsibleHeaderTitleWidget(subWidget);
mMenu = new QToolButton(subWidget);

int iconSize = 0.4*mTitle->height();

mButton->setIcon(pCollapsible?DownIcon:NoIcon);
mButton->setIconSize(QSize(iconSize, iconSize));
mButton->setStyleSheet("QToolButton {"
" border: none;"
"}"
""
"QToolButton:pressed {"
" margin: 0px;"
"}");
mButton->setStyleSheet(IconStyleSheet);

mTitle->setAlignment(Qt::AlignCenter);

mMenu->setIcon(NoIcon);
mMenu->setIconSize(QSize(iconSize, iconSize));
mMenu->setStyleSheet(IconStyleSheet);

// Add our button and title to our sub-layout

subLayout->addWidget(mButton);
subLayout->addWidget(mTitle);
subLayout->addWidget(mMenu);

// Add a top separator, our sub-widget and a bottom separator to our main
// layout
Expand Down
1 change: 1 addition & 0 deletions src/plugins/miscellaneous/Core/src/collapsiblewidget.h
Expand Up @@ -91,6 +91,7 @@ class CollapsibleHeaderWidget : public QWidget

QToolButton *mButton;
CollapsibleHeaderTitleWidget *mTitle;
QToolButton *mMenu;

void updateBottomSeparatorVisibleStatus();

Expand Down

0 comments on commit eddb371

Please sign in to comment.