Mercurial > hg > svgui
changeset 936:a61a779d73df tonioni
Experiment with simple button logic for LevelPanWidget (separating out playback toggle again)
author | Chris Cannam |
---|---|
date | Mon, 30 Mar 2015 14:28:04 +0100 |
parents | 325a7aa69055 |
children | 5a978d540d55 |
files | widgets/LevelPanToolButton.cpp |
diffstat | 1 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/widgets/LevelPanToolButton.cpp Wed Mar 25 11:48:33 2015 +0000 +++ b/widgets/LevelPanToolButton.cpp Mon Mar 30 14:28:04 2015 +0100 @@ -18,6 +18,8 @@ #include <QMenu> #include <QWidgetAction> #include <QImage> +#include <QStylePainter> +#include <QStyleOptionToolButton> #include <iostream> using std::cerr; @@ -44,7 +46,7 @@ wa->setDefaultWidget(m_lpw); menu->addAction(wa); - setPopupMode(MenuButtonPopup); + setPopupMode(InstantPopup); setMenu(menu); setImageSize(m_pixels); @@ -131,12 +133,18 @@ } void -LevelPanToolButton::paintEvent(QPaintEvent *e) +LevelPanToolButton::paintEvent(QPaintEvent *) { - QToolButton::paintEvent(e); + QStylePainter p(this); + QStyleOptionToolButton opt; + initStyleOption(&opt); + opt.features &= (~QStyleOptionToolButton::HasMenu); + p.drawComplexControl(QStyle::CC_ToolButton, opt); + if (m_pixels >= height()) { setImageSize(height()-1); } + double margin = (double(height()) - m_pixels) / 2.0; m_lpw->renderTo(this, QRectF(margin, margin, m_pixels, m_pixels), false); }