Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
929:20698aa6a517 | 930:86df7de08e03 |
---|---|
23 using std::cerr; | 23 using std::cerr; |
24 using std::endl; | 24 using std::endl; |
25 | 25 |
26 LevelPanToolButton::LevelPanToolButton(QWidget *parent) : | 26 LevelPanToolButton::LevelPanToolButton(QWidget *parent) : |
27 QToolButton(parent), | 27 QToolButton(parent), |
28 m_pixels(32) | 28 m_pixels(32), |
29 m_muted(false), | |
30 m_savedLevel(1.f) | |
29 { | 31 { |
30 m_lpw = new LevelPanWidget(); | 32 m_lpw = new LevelPanWidget(); |
31 | 33 |
32 connect(m_lpw, SIGNAL(levelChanged(float)), this, SIGNAL(levelChanged(float))); | 34 connect(m_lpw, SIGNAL(levelChanged(float)), this, SIGNAL(levelChanged(float))); |
33 connect(m_lpw, SIGNAL(levelChanged(float)), this, SLOT(redraw())); | 35 connect(m_lpw, SIGNAL(levelChanged(float)), this, SLOT(selfLevelChanged(float))); |
34 | 36 |
35 connect(m_lpw, SIGNAL(panChanged(float)), this, SIGNAL(panChanged(float))); | 37 connect(m_lpw, SIGNAL(panChanged(float)), this, SIGNAL(panChanged(float))); |
36 connect(m_lpw, SIGNAL(panChanged(float)), this, SLOT(redraw())); | 38 connect(m_lpw, SIGNAL(panChanged(float)), this, SLOT(redraw())); |
39 | |
40 connect(this, SIGNAL(clicked(bool)), this, SLOT(selfClicked())); | |
37 | 41 |
38 QMenu *menu = new QMenu(); | 42 QMenu *menu = new QMenu(); |
39 QWidgetAction *wa = new QWidgetAction(menu); | 43 QWidgetAction *wa = new QWidgetAction(menu); |
40 wa->setDefaultWidget(m_lpw); | 44 wa->setDefaultWidget(m_lpw); |
41 menu->addAction(wa); | 45 menu->addAction(wa); |
42 | 46 |
43 setPopupMode(MenuButtonPopup); | 47 setPopupMode(MenuButtonPopup); |
44 setMenu(menu); | 48 setMenu(menu); |
45 setCheckable(true); | |
46 | 49 |
47 redraw(); | 50 redraw(); |
48 } | 51 } |
49 | 52 |
50 LevelPanToolButton::~LevelPanToolButton() | 53 LevelPanToolButton::~LevelPanToolButton() |
72 | 75 |
73 void | 76 void |
74 LevelPanToolButton::setLevel(float level) | 77 LevelPanToolButton::setLevel(float level) |
75 { | 78 { |
76 m_lpw->setLevel(level); | 79 m_lpw->setLevel(level); |
80 redraw(); | |
77 } | 81 } |
78 | 82 |
79 void | 83 void |
80 LevelPanToolButton::setPan(float pan) | 84 LevelPanToolButton::setPan(float pan) |
81 { | 85 { |
82 m_lpw->setPan(pan); | 86 m_lpw->setPan(pan); |
87 redraw(); | |
88 } | |
89 | |
90 void | |
91 LevelPanToolButton::selfLevelChanged(float level) | |
92 { | |
93 if (level > 0.f) { | |
94 m_muted = false; | |
95 } else { | |
96 m_muted = true; | |
97 m_savedLevel = 1.f; | |
98 } | |
99 redraw(); | |
100 } | |
101 | |
102 void | |
103 LevelPanToolButton::selfClicked() | |
104 { | |
105 cerr << "selfClicked" << endl; | |
106 | |
107 if (m_muted) { | |
108 m_muted = false; | |
109 m_lpw->setLevel(m_savedLevel); | |
110 } else { | |
111 m_savedLevel = m_lpw->getLevel(); | |
112 m_muted = true; | |
113 m_lpw->setLevel(0.f); | |
114 } | |
115 redraw(); | |
83 } | 116 } |
84 | 117 |
85 void | 118 void |
86 LevelPanToolButton::redraw() | 119 LevelPanToolButton::redraw() |
87 { | 120 { |