comparison widgets/LevelPanToolButton.cpp @ 1324:13d9b422f7fe zoom

Merge from default branch
author Chris Cannam
date Mon, 17 Sep 2018 13:51:31 +0100
parents 1589bc7528b7
children 27ea5d61b402
comparison
equal deleted inserted replaced
1183:57d192e26331 1324:13d9b422f7fe
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 <QMouseEvent>
21 #include <QStylePainter> 22 #include <QStylePainter>
22 #include <QStyleOptionToolButton> 23 #include <QStyleOptionToolButton>
24
25 #include "base/Debug.h"
23 26
24 #include <iostream> 27 #include <iostream>
25 using std::cerr; 28 using std::cerr;
26 using std::endl; 29 using std::endl;
27 30
47 wa->setDefaultWidget(m_lpw); 50 wa->setDefaultWidget(m_lpw);
48 menu->addAction(wa); 51 menu->addAction(wa);
49 52
50 setPopupMode(InstantPopup); 53 setPopupMode(InstantPopup);
51 setMenu(menu); 54 setMenu(menu);
55 setToolTip(tr("Click to adjust level and pan"));
52 56
53 setImageSize(m_pixels); 57 setImageSize(m_pixels);
54 setBigImageSize(m_pixelsBig); 58 setBigImageSize(m_pixelsBig);
55 } 59 }
56 60
57 LevelPanToolButton::~LevelPanToolButton() 61 LevelPanToolButton::~LevelPanToolButton()
58 { 62 {
63 }
64
65 void
66 LevelPanToolButton::mousePressEvent(QMouseEvent *e)
67 {
68 if (e->button() == Qt::MidButton ||
69 ((e->button() == Qt::LeftButton) &&
70 (e->modifiers() & Qt::ControlModifier))) {
71 m_lpw->setToDefault();
72 e->accept();
73 } else {
74 QToolButton::mousePressEvent(e);
75 }
76 }
77
78 void
79 LevelPanToolButton::wheelEvent(QWheelEvent *e)
80 {
81 m_lpw->wheelEvent(e);
59 } 82 }
60 83
61 float 84 float
62 LevelPanToolButton::getLevel() const 85 LevelPanToolButton::getLevel() const
63 { 86 {
108 m_lpw->setPan(pan); 131 m_lpw->setPan(pan);
109 update(); 132 update();
110 } 133 }
111 134
112 void 135 void
136 LevelPanToolButton::setMonitoringLevels(float left, float right)
137 {
138 m_lpw->setMonitoringLevels(left, right);
139 update();
140 }
141
142 void
113 LevelPanToolButton::setIncludeMute(bool include) 143 LevelPanToolButton::setIncludeMute(bool include)
114 { 144 {
115 m_lpw->setIncludeMute(include); 145 m_lpw->setIncludeMute(include);
116 update(); 146 update();
117 } 147 }
125 155
126 void 156 void
127 LevelPanToolButton::selfLevelChanged(float level) 157 LevelPanToolButton::selfLevelChanged(float level)
128 { 158 {
129 if (level > 0.f) { 159 if (level > 0.f) {
130 m_muted = false; 160 m_muted = false;
131 } else { 161 } else {
132 m_muted = true; 162 m_muted = true;
133 m_savedLevel = 1.f; 163 m_savedLevel = 1.f;
134 } 164 }
135 update(); 165 update();
136 } 166 }
137 167
138 void 168 void
139 LevelPanToolButton::selfClicked() 169 LevelPanToolButton::selfClicked()
140 { 170 {
141 cerr << "selfClicked" << endl;
142
143 if (m_muted) { 171 if (m_muted) {
144 m_muted = false; 172 m_muted = false;
145 m_lpw->setLevel(m_savedLevel); 173 m_lpw->setLevel(m_savedLevel);
146 emit levelChanged(m_savedLevel); 174 emit levelChanged(m_savedLevel);
147 } else { 175 } else {
148 m_savedLevel = m_lpw->getLevel(); 176 m_savedLevel = m_lpw->getLevel();
149 m_muted = true; 177 m_muted = true;
150 m_lpw->setLevel(0.f); 178 m_lpw->setLevel(0.f);
151 emit levelChanged(0.f); 179 emit levelChanged(0.f);
152 } 180 }
153 update(); 181 update();
154 } 182 }
155 183
156 void 184 void
168 196
169 double margin = (double(height()) - m_pixels) / 2.0; 197 double margin = (double(height()) - m_pixels) / 2.0;
170 m_lpw->renderTo(this, QRectF(margin, margin, m_pixels, m_pixels), false); 198 m_lpw->renderTo(this, QRectF(margin, margin, m_pixels, m_pixels), false);
171 } 199 }
172 200
173 201 void
202 LevelPanToolButton::enterEvent(QEvent *e)
203 {
204 QToolButton::enterEvent(e);
205 emit mouseEntered();
206 }
207
208 void
209 LevelPanToolButton::leaveEvent(QEvent *e)
210 {
211 QToolButton::enterEvent(e);
212 emit mouseLeft();
213 }
214
215