# HG changeset patch # User Chris Cannam # Date 1427722084 -3600 # Node ID a61a779d73dfe483c7c0fc2f52c38e6ab3bc49c1 # Parent 325a7aa6905538d36e9624fb5caa182d26e0f760 Experiment with simple button logic for LevelPanWidget (separating out playback toggle again) diff -r 325a7aa69055 -r a61a779d73df widgets/LevelPanToolButton.cpp --- 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 #include #include +#include +#include #include 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); }