Mercurial > hg > svgui
diff widgets/LevelPanToolButton.cpp @ 930:86df7de08e03 tonioni
A number of fixes to level-pan button (including mute toggle)
author | Chris Cannam |
---|---|
date | Wed, 25 Mar 2015 10:55:09 +0000 |
parents | 20698aa6a517 |
children | 7cf497b72da3 |
line wrap: on
line diff
--- a/widgets/LevelPanToolButton.cpp Wed Mar 25 10:33:19 2015 +0000 +++ b/widgets/LevelPanToolButton.cpp Wed Mar 25 10:55:09 2015 +0000 @@ -25,15 +25,19 @@ LevelPanToolButton::LevelPanToolButton(QWidget *parent) : QToolButton(parent), - m_pixels(32) + m_pixels(32), + m_muted(false), + m_savedLevel(1.f) { m_lpw = new LevelPanWidget(); connect(m_lpw, SIGNAL(levelChanged(float)), this, SIGNAL(levelChanged(float))); - connect(m_lpw, SIGNAL(levelChanged(float)), this, SLOT(redraw())); + connect(m_lpw, SIGNAL(levelChanged(float)), this, SLOT(selfLevelChanged(float))); connect(m_lpw, SIGNAL(panChanged(float)), this, SIGNAL(panChanged(float))); connect(m_lpw, SIGNAL(panChanged(float)), this, SLOT(redraw())); + + connect(this, SIGNAL(clicked(bool)), this, SLOT(selfClicked())); QMenu *menu = new QMenu(); QWidgetAction *wa = new QWidgetAction(menu); @@ -42,7 +46,6 @@ setPopupMode(MenuButtonPopup); setMenu(menu); - setCheckable(true); redraw(); } @@ -74,12 +77,42 @@ LevelPanToolButton::setLevel(float level) { m_lpw->setLevel(level); + redraw(); } void LevelPanToolButton::setPan(float pan) { m_lpw->setPan(pan); + redraw(); +} + +void +LevelPanToolButton::selfLevelChanged(float level) +{ + if (level > 0.f) { + m_muted = false; + } else { + m_muted = true; + m_savedLevel = 1.f; + } + redraw(); +} + +void +LevelPanToolButton::selfClicked() +{ + cerr << "selfClicked" << endl; + + if (m_muted) { + m_muted = false; + m_lpw->setLevel(m_savedLevel); + } else { + m_savedLevel = m_lpw->getLevel(); + m_muted = true; + m_lpw->setLevel(0.f); + } + redraw(); } void