Mercurial > hg > svgui
changeset 937:5a978d540d55 tonioni
Merge
author | Chris Cannam |
---|---|
date | Mon, 30 Mar 2015 14:28:37 +0100 |
parents | a61a779d73df (diff) 1c529a22a6a7 (current diff) |
children | 2564d0865feb |
files | |
diffstat | 1 files changed, 11 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/widgets/LevelPanToolButton.cpp Mon Mar 30 14:14:33 2015 +0100 +++ b/widgets/LevelPanToolButton.cpp Mon Mar 30 14:28:37 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); }