Mercurial > hg > svgui
comparison widgets/LevelPanToolButton.cpp @ 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 | 77110abca8a1 |
comparison
equal
deleted
inserted
replaced
934:325a7aa69055 | 936:a61a779d73df |
---|---|
16 #include "LevelPanWidget.h" | 16 #include "LevelPanWidget.h" |
17 | 17 |
18 #include <QMenu> | 18 #include <QMenu> |
19 #include <QWidgetAction> | 19 #include <QWidgetAction> |
20 #include <QImage> | 20 #include <QImage> |
21 #include <QStylePainter> | |
22 #include <QStyleOptionToolButton> | |
21 | 23 |
22 #include <iostream> | 24 #include <iostream> |
23 using std::cerr; | 25 using std::cerr; |
24 using std::endl; | 26 using std::endl; |
25 | 27 |
42 QMenu *menu = new QMenu(); | 44 QMenu *menu = new QMenu(); |
43 QWidgetAction *wa = new QWidgetAction(menu); | 45 QWidgetAction *wa = new QWidgetAction(menu); |
44 wa->setDefaultWidget(m_lpw); | 46 wa->setDefaultWidget(m_lpw); |
45 menu->addAction(wa); | 47 menu->addAction(wa); |
46 | 48 |
47 setPopupMode(MenuButtonPopup); | 49 setPopupMode(InstantPopup); |
48 setMenu(menu); | 50 setMenu(menu); |
49 | 51 |
50 setImageSize(m_pixels); | 52 setImageSize(m_pixels); |
51 } | 53 } |
52 | 54 |
129 } | 131 } |
130 update(); | 132 update(); |
131 } | 133 } |
132 | 134 |
133 void | 135 void |
134 LevelPanToolButton::paintEvent(QPaintEvent *e) | 136 LevelPanToolButton::paintEvent(QPaintEvent *) |
135 { | 137 { |
136 QToolButton::paintEvent(e); | 138 QStylePainter p(this); |
139 QStyleOptionToolButton opt; | |
140 initStyleOption(&opt); | |
141 opt.features &= (~QStyleOptionToolButton::HasMenu); | |
142 p.drawComplexControl(QStyle::CC_ToolButton, opt); | |
143 | |
137 if (m_pixels >= height()) { | 144 if (m_pixels >= height()) { |
138 setImageSize(height()-1); | 145 setImageSize(height()-1); |
139 } | 146 } |
147 | |
140 double margin = (double(height()) - m_pixels) / 2.0; | 148 double margin = (double(height()) - m_pixels) / 2.0; |
141 m_lpw->renderTo(this, QRectF(margin, margin, m_pixels, m_pixels), false); | 149 m_lpw->renderTo(this, QRectF(margin, margin, m_pixels, m_pixels), false); |
142 } | 150 } |
143 | 151 |
144 | 152 |