Chris@58
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@59
|
4 Sonic Visualiser
|
Chris@59
|
5 An audio file viewer and annotation editor.
|
Chris@59
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@182
|
7 This file copyright 2006 Chris Cannam and QMUL.
|
Chris@0
|
8
|
Chris@59
|
9 This program is free software; you can redistribute it and/or
|
Chris@59
|
10 modify it under the terms of the GNU General Public License as
|
Chris@59
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@59
|
12 License, or (at your option) any later version. See the file
|
Chris@59
|
13 COPYING included with this distribution for more information.
|
Chris@0
|
14 */
|
Chris@0
|
15
|
Chris@0
|
16 #include "PropertyBox.h"
|
Chris@63
|
17 #include "PluginParameterDialog.h"
|
Chris@0
|
18
|
Chris@0
|
19 #include "base/PropertyContainer.h"
|
Chris@33
|
20 #include "base/PlayParameters.h"
|
Chris@377
|
21 #include "base/PlayParameterRepository.h"
|
Chris@128
|
22 #include "layer/Layer.h"
|
Chris@376
|
23 #include "layer/ColourDatabase.h"
|
Chris@100
|
24 #include "base/UnitDatabase.h"
|
Chris@167
|
25 #include "base/RangeMapper.h"
|
Chris@0
|
26
|
Chris@63
|
27 #include "plugin/RealTimePluginFactory.h"
|
Chris@63
|
28 #include "plugin/RealTimePluginInstance.h"
|
Chris@71
|
29 #include "plugin/PluginXml.h"
|
Chris@63
|
30
|
Chris@0
|
31 #include "AudioDial.h"
|
Chris@33
|
32 #include "LEDButton.h"
|
Chris@335
|
33 #include "IconLoader.h"
|
Chris@0
|
34
|
Chris@189
|
35 #include "NotifyingCheckBox.h"
|
Chris@189
|
36 #include "NotifyingComboBox.h"
|
Chris@335
|
37 #include "NotifyingPushButton.h"
|
Chris@285
|
38 #include "ColourNameDialog.h"
|
Chris@189
|
39
|
Chris@0
|
40 #include <QGridLayout>
|
Chris@0
|
41 #include <QHBoxLayout>
|
Chris@33
|
42 #include <QVBoxLayout>
|
Chris@63
|
43 #include <QPushButton>
|
Chris@0
|
44 #include <QLabel>
|
Chris@33
|
45 #include <QFrame>
|
Chris@218
|
46 #include <QApplication>
|
Chris@285
|
47 #include <QColorDialog>
|
Chris@285
|
48 #include <QInputDialog>
|
Chris@0
|
49
|
Chris@0
|
50 #include <cassert>
|
Chris@0
|
51 #include <iostream>
|
Martin@46
|
52 #include <cmath>
|
Chris@0
|
53
|
Chris@675
|
54 #include "Fader.h"
|
Chris@456
|
55 //#define DEBUG_PROPERTY_BOX 1
|
Chris@0
|
56
|
Chris@675
|
57 QHBoxLayout *layout1 = new QHBoxLayout;
|
Chris@675
|
58 int tracks=0;
|
Chris@677
|
59 extern bool isIMAF;
|
Chris@675
|
60 //#include "C:/Users/Paco/Desktop/SV mio/sonic-visualiser/main/imafdecoder.h"
|
Chris@0
|
61 PropertyBox::PropertyBox(PropertyContainer *container) :
|
Chris@185
|
62 m_container(container),
|
Chris@189
|
63 m_showButton(0),
|
Chris@189
|
64 m_playButton(0)
|
Chris@0
|
65 {
|
Chris@0
|
66 #ifdef DEBUG_PROPERTY_BOX
|
Chris@682
|
67 cerr << "PropertyBox[" << this << "(\"" <<
|
Chris@682
|
68 container->getPropertyContainerName() << "\" at " << container << ")]::PropertyBox" << endl;
|
Chris@0
|
69 #endif
|
Chris@0
|
70
|
Chris@34
|
71 m_mainBox = new QVBoxLayout;
|
Chris@34
|
72 setLayout(m_mainBox);
|
Chris@33
|
73
|
Chris@107
|
74 // m_nameWidget = new QLabel;
|
Chris@107
|
75 // m_mainBox->addWidget(m_nameWidget);
|
Chris@107
|
76 // m_nameWidget->setText(container->objectName());
|
Chris@107
|
77
|
Chris@34
|
78 m_mainWidget = new QWidget;
|
Chris@34
|
79 m_mainBox->addWidget(m_mainWidget);
|
Chris@107
|
80 m_mainBox->insertStretch(2, 10);
|
Chris@33
|
81
|
Chris@34
|
82 m_viewPlayFrame = 0;
|
Chris@34
|
83 populateViewPlayFrame();
|
Chris@33
|
84
|
Chris@0
|
85 m_layout = new QGridLayout;
|
Chris@34
|
86 m_layout->setMargin(0);
|
Chris@33
|
87 m_mainWidget->setLayout(m_layout);
|
Chris@0
|
88
|
Chris@34
|
89 PropertyContainer::PropertyList properties = m_container->getProperties();
|
Chris@0
|
90
|
Chris@0
|
91 blockSignals(true);
|
Chris@0
|
92
|
Chris@0
|
93 size_t i;
|
Chris@0
|
94
|
Chris@0
|
95 for (i = 0; i < properties.size(); ++i) {
|
Chris@0
|
96 updatePropertyEditor(properties[i]);
|
Chris@0
|
97 }
|
Chris@0
|
98
|
Chris@0
|
99 blockSignals(false);
|
Chris@0
|
100
|
Chris@0
|
101 m_layout->setRowStretch(m_layout->rowCount(), 10);
|
Chris@0
|
102
|
Chris@100
|
103 connect(UnitDatabase::getInstance(), SIGNAL(unitDatabaseChanged()),
|
Chris@100
|
104 this, SLOT(unitDatabaseChanged()));
|
Chris@100
|
105
|
Chris@285
|
106 connect(ColourDatabase::getInstance(), SIGNAL(colourDatabaseChanged()),
|
Chris@285
|
107 this, SLOT(colourDatabaseChanged()));
|
Chris@285
|
108
|
Chris@0
|
109 #ifdef DEBUG_PROPERTY_BOX
|
Chris@682
|
110 cerr << "PropertyBox[" << this << "]::PropertyBox returning" << endl;
|
Chris@0
|
111 #endif
|
Chris@0
|
112 }
|
Chris@0
|
113
|
Chris@0
|
114 PropertyBox::~PropertyBox()
|
Chris@0
|
115 {
|
Chris@0
|
116 #ifdef DEBUG_PROPERTY_BOX
|
Chris@682
|
117 cerr << "PropertyBox[" << this << "]::~PropertyBox" << endl;
|
Chris@0
|
118 #endif
|
Chris@0
|
119 }
|
Chris@0
|
120
|
Chris@675
|
121
|
Chris@0
|
122 void
|
Chris@34
|
123 PropertyBox::populateViewPlayFrame()
|
Chris@33
|
124 {
|
Chris@36
|
125 #ifdef DEBUG_PROPERTY_BOX
|
Chris@682
|
126 cerr << "PropertyBox(" << m_container << ")::populateViewPlayFrame" << endl;
|
Chris@36
|
127 #endif
|
Chris@34
|
128
|
Chris@34
|
129 if (m_viewPlayFrame) {
|
Chris@34
|
130 delete m_viewPlayFrame;
|
Chris@34
|
131 m_viewPlayFrame = 0;
|
Chris@34
|
132 }
|
Chris@34
|
133
|
Chris@34
|
134 if (!m_container) return;
|
Chris@34
|
135
|
Chris@34
|
136 Layer *layer = dynamic_cast<Layer *>(m_container);
|
Chris@34
|
137 if (layer) {
|
Chris@193
|
138 disconnect(layer, SIGNAL(modelReplaced()),
|
Chris@193
|
139 this, SLOT(populateViewPlayFrame()));
|
Chris@34
|
140 connect(layer, SIGNAL(modelReplaced()),
|
Chris@34
|
141 this, SLOT(populateViewPlayFrame()));
|
Chris@34
|
142 }
|
Chris@34
|
143
|
Chris@34
|
144 PlayParameters *params = m_container->getPlayParameters();
|
Chris@33
|
145 if (!params && !layer) return;
|
Chris@33
|
146
|
Chris@34
|
147 m_viewPlayFrame = new QFrame;
|
Chris@34
|
148 m_viewPlayFrame->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken);
|
Chris@34
|
149 m_mainBox->addWidget(m_viewPlayFrame);
|
Chris@34
|
150
|
Chris@34
|
151 QHBoxLayout *layout = new QHBoxLayout;
|
Chris@34
|
152 m_viewPlayFrame->setLayout(layout);
|
Chris@34
|
153
|
Chris@34
|
154 layout->setMargin(layout->margin() / 2);
|
Chris@34
|
155
|
Chris@36
|
156 #ifdef DEBUG_PROPERTY_BOX
|
Chris@587
|
157 SVDEBUG << "PropertyBox::populateViewPlayFrame: container " << m_container << " (name " << m_container->getPropertyContainerName() << ") params " << params << endl;
|
Chris@36
|
158 #endif
|
Chris@36
|
159
|
Chris@33
|
160 if (layer) {
|
Chris@34
|
161 QLabel *showLabel = new QLabel(tr("Show"));
|
Chris@34
|
162 layout->addWidget(showLabel);
|
Chris@34
|
163 layout->setAlignment(showLabel, Qt::AlignVCenter);
|
Chris@34
|
164
|
Chris@185
|
165 m_showButton = new LEDButton(Qt::blue);
|
Chris@185
|
166 layout->addWidget(m_showButton);
|
Chris@185
|
167 connect(m_showButton, SIGNAL(stateChanged(bool)),
|
Chris@47
|
168 this, SIGNAL(showLayer(bool)));
|
Chris@189
|
169 connect(m_showButton, SIGNAL(mouseEntered()),
|
Chris@189
|
170 this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
171 connect(m_showButton, SIGNAL(mouseLeft()),
|
Chris@189
|
172 this, SLOT(mouseLeftWidget()));
|
Chris@185
|
173 layout->setAlignment(m_showButton, Qt::AlignVCenter);
|
Chris@33
|
174 }
|
Chris@33
|
175
|
Chris@33
|
176 if (params) {
|
Chris@34
|
177
|
Chris@34
|
178 QLabel *playLabel = new QLabel(tr("Play"));
|
Chris@34
|
179 layout->addWidget(playLabel);
|
Chris@34
|
180 layout->setAlignment(playLabel, Qt::AlignVCenter);
|
Chris@34
|
181
|
Chris@189
|
182 m_playButton = new LEDButton(Qt::darkGreen);
|
Chris@189
|
183 m_playButton->setState(!params->isPlayMuted());
|
Chris@189
|
184 layout->addWidget(m_playButton);
|
Chris@189
|
185 connect(m_playButton, SIGNAL(stateChanged(bool)),
|
Chris@377
|
186 this, SLOT(playAudibleButtonChanged(bool)));
|
Chris@189
|
187 connect(m_playButton, SIGNAL(mouseEntered()),
|
Chris@189
|
188 this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
189 connect(m_playButton, SIGNAL(mouseLeft()),
|
Chris@189
|
190 this, SLOT(mouseLeftWidget()));
|
Chris@34
|
191 connect(params, SIGNAL(playAudibleChanged(bool)),
|
Chris@377
|
192 this, SLOT(playAudibleChanged(bool)));
|
Chris@189
|
193 layout->setAlignment(m_playButton, Qt::AlignVCenter);
|
Chris@34
|
194
|
Chris@34
|
195 layout->insertStretch(-1, 10);
|
Chris@34
|
196
|
Chris@63
|
197 if (params->getPlayPluginId() != "") {
|
Chris@64
|
198 QPushButton *pluginButton = new QPushButton(QIcon(":icons/faders.png"), "");
|
Chris@64
|
199 pluginButton->setFixedWidth(24);
|
Chris@64
|
200 pluginButton->setFixedHeight(24);
|
Chris@63
|
201 layout->addWidget(pluginButton);
|
Chris@63
|
202 connect(pluginButton, SIGNAL(clicked()),
|
Chris@63
|
203 this, SLOT(editPlugin()));
|
Chris@63
|
204 }
|
Chris@63
|
205
|
Chris@34
|
206 AudioDial *gainDial = new AudioDial;
|
Chris@675
|
207 layout->addWidget(gainDial);
|
Chris@34
|
208 gainDial->setMeterColor(Qt::darkRed);
|
Chris@34
|
209 gainDial->setMinimum(-50);
|
Chris@34
|
210 gainDial->setMaximum(50);
|
Chris@34
|
211 gainDial->setPageStep(1);
|
Chris@675
|
212 gainDial->setFixedWidth(24);
|
Chris@675
|
213 gainDial->setFixedHeight(24);
|
Chris@34
|
214 gainDial->setNotchesVisible(false);
|
Chris@34
|
215 gainDial->setDefaultValue(0);
|
Chris@168
|
216 gainDial->setObjectName(tr("Playback Gain"));
|
Chris@167
|
217 gainDial->setRangeMapper(new LinearRangeMapper
|
Chris@167
|
218 (-50, 50, -25, 25, tr("dB")));
|
Chris@168
|
219 gainDial->setShowToolTip(true);
|
Chris@34
|
220 connect(gainDial, SIGNAL(valueChanged(int)),
|
Chris@34
|
221 this, SLOT(playGainDialChanged(int)));
|
Chris@34
|
222 connect(params, SIGNAL(playGainChanged(float)),
|
Chris@34
|
223 this, SLOT(playGainChanged(float)));
|
Chris@34
|
224 connect(this, SIGNAL(changePlayGainDial(int)),
|
Chris@34
|
225 gainDial, SLOT(setValue(int)));
|
Chris@189
|
226 connect(gainDial, SIGNAL(mouseEntered()),
|
Chris@189
|
227 this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
228 connect(gainDial, SIGNAL(mouseLeft()),
|
Chris@189
|
229 this, SLOT(mouseLeftWidget()));
|
Chris@377
|
230 playGainChanged(params->getPlayGain());
|
Chris@34
|
231 layout->setAlignment(gainDial, Qt::AlignVCenter);
|
Chris@34
|
232
|
alo@994
|
233
|
alo@994
|
234 /*
|
Chris@675
|
235 //code added by Jesus
|
Chris@675
|
236
|
Chris@677
|
237 if (isIMAF){
|
Chris@675
|
238 QString property_container_name; // the name could be : Waveform, Time Instants, etc
|
Chris@675
|
239 property_container_name = layer->getPropertyContainerName();// obtain the name
|
Chris@676
|
240 bool isWaveform;
|
Chris@675
|
241
|
Chris@675
|
242 isWaveform = property_container_name.contains("Waveform", Qt::CaseInsensitive);//if QString contains "Waveform"
|
Chris@675
|
243
|
Chris@675
|
244 if (isWaveform == true){
|
Chris@675
|
245 tracks++;
|
Chris@675
|
246
|
Chris@675
|
247 AudioDial *gainDial1 = new AudioDial;
|
Chris@675
|
248 gainDial1->setMeterColor(Qt::darkRed);
|
Chris@675
|
249 gainDial1->setMinimum(-63);
|
Chris@675
|
250 gainDial1->setMaximum(10);
|
Chris@675
|
251 gainDial1->setPageStep(1);
|
Chris@675
|
252 gainDial1->setFixedWidth(60);
|
Chris@675
|
253 gainDial1->setFixedHeight(60);
|
Chris@675
|
254 gainDial1->setNotchesVisible(false);
|
Chris@675
|
255 gainDial1->setDefaultValue(0);
|
Chris@675
|
256 gainDial1->setObjectName(tr("Playback Gain"));
|
Chris@675
|
257 gainDial1->setRangeMapper(new LinearRangeMapper
|
Chris@675
|
258 (-50, 50, -25, 25, tr("dB")));
|
Chris@675
|
259 gainDial1->setShowToolTip(true);
|
Chris@675
|
260 connect(gainDial1, SIGNAL(valueChanged(int)),
|
Chris@675
|
261 this, SLOT(playGainDialChanged(int)));
|
Chris@675
|
262 connect(params, SIGNAL(playGainChanged(float)),
|
Chris@675
|
263 this, SLOT(playGainChanged(float)));
|
Chris@675
|
264 connect(this, SIGNAL(changePlayGainDial(int)),
|
Chris@675
|
265 gainDial1, SLOT(setValue(int)));
|
Chris@675
|
266 connect(gainDial1, SIGNAL(mouseEntered()),
|
Chris@675
|
267 this, SLOT(mouseEnteredWidget()));
|
Chris@675
|
268 connect(gainDial1, SIGNAL(mouseLeft()),
|
Chris@675
|
269 this, SLOT(mouseLeftWidget()));
|
Chris@675
|
270 playGainChanged(params->getPlayGain());
|
Chris@675
|
271 layout1->setAlignment(gainDial1, Qt::AlignVCenter);
|
Chris@675
|
272
|
Chris@675
|
273 QWidget *window = new QWidget;
|
Chris@675
|
274
|
Chris@675
|
275
|
Chris@675
|
276 // QLabel *showLabel1 = new QLabel(tr("Track"));
|
Chris@675
|
277 // layout1->addWidget(showLabel1);
|
Chris@675
|
278 // layout1->setAlignment(showLabel1, Qt::AlignVCenter);
|
Chris@675
|
279
|
Chris@675
|
280 layout1->addWidget(gainDial1);
|
Chris@675
|
281 if (tracks==3){
|
Chris@675
|
282 window->setLayout(layout1);
|
Chris@675
|
283 window ->showNormal();
|
Chris@675
|
284 }
|
Chris@677
|
285 } // end if isWaveform
|
Chris@677
|
286 } // end if isIMAF
|
Chris@675
|
287 // end code added by Jesus
|
alo@994
|
288 */
|
Chris@675
|
289
|
Chris@34
|
290 AudioDial *panDial = new AudioDial;
|
Chris@34
|
291 layout->addWidget(panDial);
|
Chris@34
|
292 panDial->setMeterColor(Qt::darkGreen);
|
Chris@34
|
293 panDial->setMinimum(-50);
|
Chris@34
|
294 panDial->setMaximum(50);
|
Chris@34
|
295 panDial->setPageStep(1);
|
Chris@34
|
296 panDial->setFixedWidth(24);
|
Chris@34
|
297 panDial->setFixedHeight(24);
|
Chris@34
|
298 panDial->setNotchesVisible(false);
|
Chris@57
|
299 panDial->setToolTip(tr("Playback Pan / Balance"));
|
Chris@34
|
300 panDial->setDefaultValue(0);
|
Chris@168
|
301 panDial->setObjectName(tr("Playback Pan / Balance"));
|
Chris@168
|
302 panDial->setShowToolTip(true);
|
Chris@34
|
303 connect(panDial, SIGNAL(valueChanged(int)),
|
Chris@34
|
304 this, SLOT(playPanDialChanged(int)));
|
Chris@34
|
305 connect(params, SIGNAL(playPanChanged(float)),
|
Chris@34
|
306 this, SLOT(playPanChanged(float)));
|
Chris@34
|
307 connect(this, SIGNAL(changePlayPanDial(int)),
|
Chris@34
|
308 panDial, SLOT(setValue(int)));
|
Chris@189
|
309 connect(panDial, SIGNAL(mouseEntered()),
|
Chris@189
|
310 this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
311 connect(panDial, SIGNAL(mouseLeft()),
|
Chris@189
|
312 this, SLOT(mouseLeftWidget()));
|
Chris@377
|
313 playPanChanged(params->getPlayPan());
|
Chris@34
|
314 layout->setAlignment(panDial, Qt::AlignVCenter);
|
Chris@34
|
315
|
Chris@34
|
316 } else {
|
Chris@34
|
317
|
Chris@34
|
318 layout->insertStretch(-1, 10);
|
Chris@33
|
319 }
|
Chris@33
|
320 }
|
Chris@33
|
321
|
Chris@33
|
322 void
|
Chris@197
|
323 PropertyBox::updatePropertyEditor(PropertyContainer::PropertyName name,
|
Chris@197
|
324 bool rangeChanged)
|
Chris@0
|
325 {
|
Chris@0
|
326 PropertyContainer::PropertyType type = m_container->getPropertyType(name);
|
Chris@0
|
327 int row = m_layout->rowCount();
|
Chris@0
|
328
|
Chris@216
|
329 int min = 0, max = 0, value = 0, deflt = 0;
|
Chris@216
|
330 value = m_container->getPropertyRangeAndValue(name, &min, &max, &deflt);
|
Chris@0
|
331
|
Chris@0
|
332 bool have = (m_propertyControllers.find(name) !=
|
Chris@0
|
333 m_propertyControllers.end());
|
Chris@0
|
334
|
Chris@0
|
335 QString groupName = m_container->getPropertyGroupName(name);
|
Chris@87
|
336 QString propertyLabel = m_container->getPropertyLabel(name);
|
Chris@335
|
337 QString iconName = m_container->getPropertyIconName(name);
|
Chris@0
|
338
|
Chris@0
|
339 #ifdef DEBUG_PROPERTY_BOX
|
Chris@682
|
340 cerr << "PropertyBox[" << this
|
Chris@683
|
341 << "(\"" << m_container->getPropertyContainerName()
|
Chris@0
|
342 << "\")]";
|
Chris@682
|
343 cerr << "::updatePropertyEditor(\"" << name << "\"):";
|
Chris@682
|
344 cerr << " value " << value << ", have " << have << ", group \""
|
Chris@682
|
345 << groupName << "\"" << endl;
|
Chris@0
|
346 #endif
|
Chris@0
|
347
|
Chris@0
|
348 bool inGroup = (groupName != QString());
|
Chris@0
|
349
|
Chris@0
|
350 if (!have) {
|
Chris@0
|
351 if (inGroup) {
|
Chris@0
|
352 if (m_groupLayouts.find(groupName) == m_groupLayouts.end()) {
|
Chris@0
|
353 #ifdef DEBUG_PROPERTY_BOX
|
Chris@682
|
354 cerr << "PropertyBox: adding label \"" << groupName << "\" and frame for group for \"" << name << "\"" << endl;
|
Chris@0
|
355 #endif
|
Chris@33
|
356 m_layout->addWidget(new QLabel(groupName, m_mainWidget), row, 0);
|
Chris@33
|
357 QFrame *frame = new QFrame(m_mainWidget);
|
Chris@0
|
358 m_layout->addWidget(frame, row, 1, 1, 2);
|
Chris@493
|
359 m_groupLayouts[groupName] = new QGridLayout;
|
Chris@0
|
360 m_groupLayouts[groupName]->setMargin(0);
|
Chris@0
|
361 frame->setLayout(m_groupLayouts[groupName]);
|
Chris@0
|
362 }
|
Chris@0
|
363 } else {
|
Chris@0
|
364 #ifdef DEBUG_PROPERTY_BOX
|
Chris@682
|
365 cerr << "PropertyBox: adding label \"" << propertyLabel << "\"" << endl;
|
Chris@0
|
366 #endif
|
Chris@87
|
367 m_layout->addWidget(new QLabel(propertyLabel, m_mainWidget), row, 0);
|
Chris@0
|
368 }
|
Chris@0
|
369 }
|
Chris@0
|
370
|
Chris@0
|
371 switch (type) {
|
Chris@0
|
372
|
Chris@0
|
373 case PropertyContainer::ToggleProperty:
|
Chris@0
|
374 {
|
Chris@335
|
375 QAbstractButton *button = 0;
|
Chris@0
|
376
|
Chris@0
|
377 if (have) {
|
Chris@335
|
378 button = dynamic_cast<QAbstractButton *>(m_propertyControllers[name]);
|
Chris@335
|
379 assert(button);
|
Chris@0
|
380 } else {
|
Chris@0
|
381 #ifdef DEBUG_PROPERTY_BOX
|
Chris@682
|
382 cerr << "PropertyBox: creating new checkbox" << endl;
|
Chris@0
|
383 #endif
|
Chris@335
|
384 if (iconName != "") {
|
Chris@335
|
385 button = new NotifyingPushButton();
|
Chris@335
|
386 button->setCheckable(true);
|
Chris@335
|
387 QIcon icon(IconLoader().load(iconName));
|
Chris@335
|
388 button->setIcon(icon);
|
Chris@335
|
389 button->setObjectName(name);
|
Chris@335
|
390 button->setFixedSize(QSize(18, 18));
|
Chris@335
|
391 } else {
|
Chris@335
|
392 button = new NotifyingCheckBox();
|
Chris@335
|
393 button->setObjectName(name);
|
Chris@335
|
394 }
|
Chris@335
|
395 connect(button, SIGNAL(toggled(bool)),
|
Chris@335
|
396 this, SLOT(propertyControllerChanged(bool)));
|
Chris@335
|
397 connect(button, SIGNAL(mouseEntered()),
|
Chris@189
|
398 this, SLOT(mouseEnteredWidget()));
|
Chris@335
|
399 connect(button, SIGNAL(mouseLeft()),
|
Chris@189
|
400 this, SLOT(mouseLeftWidget()));
|
Chris@0
|
401 if (inGroup) {
|
Chris@335
|
402 button->setToolTip(propertyLabel);
|
Chris@493
|
403 m_groupLayouts[groupName]->addWidget
|
Chris@493
|
404 (button, 0, m_groupLayouts[groupName]->columnCount());
|
Chris@0
|
405 } else {
|
Chris@335
|
406 m_layout->addWidget(button, row, 1, 1, 2);
|
Chris@0
|
407 }
|
Chris@335
|
408 m_propertyControllers[name] = button;
|
Chris@0
|
409 }
|
Chris@0
|
410
|
Chris@335
|
411 if (button->isChecked() != (value > 0)) {
|
Chris@335
|
412 button->blockSignals(true);
|
Chris@335
|
413 button->setChecked(value > 0);
|
Chris@335
|
414 button->blockSignals(false);
|
Chris@55
|
415 }
|
Chris@0
|
416 break;
|
Chris@0
|
417 }
|
Chris@0
|
418
|
Chris@0
|
419 case PropertyContainer::RangeProperty:
|
Chris@0
|
420 {
|
Chris@0
|
421 AudioDial *dial;
|
Chris@0
|
422
|
Chris@0
|
423 if (have) {
|
Chris@0
|
424 dial = dynamic_cast<AudioDial *>(m_propertyControllers[name]);
|
Chris@0
|
425 assert(dial);
|
Chris@197
|
426 if (rangeChanged) {
|
Chris@197
|
427 dial->blockSignals(true);
|
Chris@197
|
428 dial->setMinimum(min);
|
Chris@197
|
429 dial->setMaximum(max);
|
Chris@197
|
430 dial->setRangeMapper(m_container->getNewPropertyRangeMapper(name));
|
Chris@197
|
431 dial->blockSignals(false);
|
Chris@197
|
432 }
|
Chris@197
|
433
|
Chris@0
|
434 } else {
|
Chris@0
|
435 #ifdef DEBUG_PROPERTY_BOX
|
Chris@682
|
436 cerr << "PropertyBox: creating new dial" << endl;
|
Chris@0
|
437 #endif
|
Chris@0
|
438 dial = new AudioDial();
|
Chris@0
|
439 dial->setObjectName(name);
|
Chris@0
|
440 dial->setMinimum(min);
|
Chris@0
|
441 dial->setMaximum(max);
|
Chris@0
|
442 dial->setPageStep(1);
|
Chris@34
|
443 dial->setNotchesVisible((max - min) <= 12);
|
Chris@216
|
444 dial->setDefaultValue(deflt);
|
Chris@167
|
445 dial->setRangeMapper(m_container->getNewPropertyRangeMapper(name));
|
Chris@168
|
446 dial->setShowToolTip(true);
|
Chris@0
|
447 connect(dial, SIGNAL(valueChanged(int)),
|
Chris@0
|
448 this, SLOT(propertyControllerChanged(int)));
|
Chris@189
|
449 connect(dial, SIGNAL(mouseEntered()),
|
Chris@189
|
450 this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
451 connect(dial, SIGNAL(mouseLeft()),
|
Chris@189
|
452 this, SLOT(mouseLeftWidget()));
|
Chris@0
|
453
|
Chris@0
|
454 if (inGroup) {
|
Chris@0
|
455 dial->setFixedWidth(24);
|
Chris@0
|
456 dial->setFixedHeight(24);
|
Chris@493
|
457 m_groupLayouts[groupName]->addWidget
|
Chris@493
|
458 (dial, 0, m_groupLayouts[groupName]->columnCount());
|
Chris@0
|
459 } else {
|
Chris@0
|
460 dial->setFixedWidth(32);
|
Chris@0
|
461 dial->setFixedHeight(32);
|
Chris@0
|
462 m_layout->addWidget(dial, row, 1);
|
Chris@33
|
463 QLabel *label = new QLabel(m_mainWidget);
|
Chris@0
|
464 connect(dial, SIGNAL(valueChanged(int)),
|
Chris@0
|
465 label, SLOT(setNum(int)));
|
Chris@0
|
466 label->setNum(value);
|
Chris@0
|
467 m_layout->addWidget(label, row, 2);
|
Chris@0
|
468 }
|
Chris@0
|
469
|
Chris@0
|
470 m_propertyControllers[name] = dial;
|
Chris@0
|
471 }
|
Chris@0
|
472
|
Chris@55
|
473 if (dial->value() != value) {
|
Chris@55
|
474 dial->blockSignals(true);
|
Chris@55
|
475 dial->setValue(value);
|
Chris@55
|
476 dial->blockSignals(false);
|
Chris@55
|
477 }
|
Chris@0
|
478 break;
|
Chris@0
|
479 }
|
Chris@0
|
480
|
Chris@0
|
481 case PropertyContainer::ValueProperty:
|
Chris@100
|
482 case PropertyContainer::UnitsProperty:
|
Chris@285
|
483 case PropertyContainer::ColourProperty:
|
Chris@0
|
484 {
|
Chris@189
|
485 NotifyingComboBox *cb;
|
Chris@0
|
486
|
Chris@0
|
487 if (have) {
|
Chris@189
|
488 cb = dynamic_cast<NotifyingComboBox *>(m_propertyControllers[name]);
|
Chris@0
|
489 assert(cb);
|
Chris@0
|
490 } else {
|
Chris@0
|
491 #ifdef DEBUG_PROPERTY_BOX
|
Chris@682
|
492 cerr << "PropertyBox: creating new combobox" << endl;
|
Chris@0
|
493 #endif
|
Chris@0
|
494
|
Chris@189
|
495 cb = new NotifyingComboBox();
|
Chris@0
|
496 cb->setObjectName(name);
|
Chris@100
|
497 cb->setDuplicatesEnabled(false);
|
Chris@197
|
498 }
|
Chris@100
|
499
|
Chris@197
|
500 if (!have || rangeChanged) {
|
Chris@285
|
501
|
Chris@197
|
502 cb->blockSignals(true);
|
Chris@197
|
503 cb->clear();
|
Chris@285
|
504 cb->setEditable(false);
|
Chris@285
|
505
|
Chris@100
|
506 if (type == PropertyContainer::ValueProperty) {
|
Chris@285
|
507
|
Chris@100
|
508 for (int i = min; i <= max; ++i) {
|
Chris@100
|
509 cb->addItem(m_container->getPropertyValueLabel(name, i));
|
Chris@100
|
510 }
|
Chris@285
|
511
|
Chris@285
|
512 } else if (type == PropertyContainer::UnitsProperty) {
|
Chris@285
|
513
|
Chris@100
|
514 QStringList units = UnitDatabase::getInstance()->getKnownUnits();
|
Chris@100
|
515 for (int i = 0; i < units.size(); ++i) {
|
Chris@100
|
516 cb->addItem(units[i]);
|
Chris@100
|
517 }
|
Chris@285
|
518
|
Chris@100
|
519 cb->setEditable(true);
|
Chris@285
|
520
|
Chris@285
|
521 } else { // ColourProperty
|
Chris@290
|
522
|
Chris@290
|
523 //!!! should be a proper colour combobox class that
|
Chris@290
|
524 // manages its own Add New Colour entry...
|
Chris@285
|
525
|
Chris@285
|
526 ColourDatabase *db = ColourDatabase::getInstance();
|
Chris@285
|
527 for (size_t i = 0; i < db->getColourCount(); ++i) {
|
Chris@285
|
528 QString name = db->getColourName(i);
|
Chris@287
|
529 cb->addItem(db->getExamplePixmap(i, QSize(12, 12)), name);
|
Chris@285
|
530 }
|
Chris@285
|
531 cb->addItem(tr("Add New Colour..."));
|
Chris@285
|
532 }
|
Chris@285
|
533
|
Chris@197
|
534 cb->blockSignals(false);
|
Chris@280
|
535 if (cb->count() < 20 && cb->count() > cb->maxVisibleItems()) {
|
Chris@280
|
536 cb->setMaxVisibleItems(cb->count());
|
Chris@280
|
537 }
|
Chris@197
|
538 }
|
Chris@100
|
539
|
Chris@197
|
540 if (!have) {
|
Chris@0
|
541 connect(cb, SIGNAL(activated(int)),
|
Chris@0
|
542 this, SLOT(propertyControllerChanged(int)));
|
Chris@189
|
543 connect(cb, SIGNAL(mouseEntered()),
|
Chris@189
|
544 this, SLOT(mouseEnteredWidget()));
|
Chris@189
|
545 connect(cb, SIGNAL(mouseLeft()),
|
Chris@189
|
546 this, SLOT(mouseLeftWidget()));
|
Chris@100
|
547
|
Chris@0
|
548 if (inGroup) {
|
Chris@108
|
549 cb->setToolTip(propertyLabel);
|
Chris@493
|
550 m_groupLayouts[groupName]->addWidget
|
Chris@493
|
551 (cb, 0, m_groupLayouts[groupName]->columnCount());
|
Chris@0
|
552 } else {
|
Chris@0
|
553 m_layout->addWidget(cb, row, 1, 1, 2);
|
Chris@0
|
554 }
|
Chris@0
|
555 m_propertyControllers[name] = cb;
|
Chris@0
|
556 }
|
Chris@0
|
557
|
Chris@100
|
558 cb->blockSignals(true);
|
Chris@285
|
559 if (type == PropertyContainer::ValueProperty ||
|
Chris@285
|
560 type == PropertyContainer::ColourProperty) {
|
Chris@100
|
561 if (cb->currentIndex() != value) {
|
Chris@100
|
562 cb->setCurrentIndex(value);
|
Chris@100
|
563 }
|
Chris@100
|
564 } else {
|
Chris@100
|
565 QString unit = UnitDatabase::getInstance()->getUnitById(value);
|
Chris@100
|
566 if (cb->currentText() != unit) {
|
Chris@100
|
567 for (int i = 0; i < cb->count(); ++i) {
|
Chris@100
|
568 if (cb->itemText(i) == unit) {
|
Chris@100
|
569 cb->setCurrentIndex(i);
|
Chris@100
|
570 break;
|
Chris@100
|
571 }
|
Chris@100
|
572 }
|
Chris@100
|
573 }
|
Chris@100
|
574 }
|
Chris@100
|
575 cb->blockSignals(false);
|
Chris@0
|
576
|
Chris@681
|
577 #ifdef Q_OS_MAC
|
Chris@0
|
578 // Crashes on startup without this, for some reason
|
Chris@0
|
579 cb->setMinimumSize(QSize(10, 10));
|
Chris@0
|
580 #endif
|
Chris@0
|
581
|
Chris@0
|
582 break;
|
Chris@0
|
583 }
|
Chris@0
|
584
|
Chris@0
|
585 default:
|
Chris@0
|
586 break;
|
Chris@0
|
587 }
|
Chris@0
|
588 }
|
Chris@0
|
589
|
Chris@0
|
590 void
|
Chris@0
|
591 PropertyBox::propertyContainerPropertyChanged(PropertyContainer *pc)
|
Chris@0
|
592 {
|
Chris@0
|
593 if (pc != m_container) return;
|
Chris@0
|
594
|
Chris@55
|
595 #ifdef DEBUG_PROPERTY_BOX
|
Chris@587
|
596 SVDEBUG << "PropertyBox::propertyContainerPropertyChanged" << endl;
|
Chris@55
|
597 #endif
|
Chris@55
|
598
|
Chris@0
|
599 PropertyContainer::PropertyList properties = m_container->getProperties();
|
Chris@0
|
600 size_t i;
|
Chris@0
|
601
|
Chris@0
|
602 blockSignals(true);
|
Chris@0
|
603
|
Chris@0
|
604 for (i = 0; i < properties.size(); ++i) {
|
Chris@0
|
605 updatePropertyEditor(properties[i]);
|
Chris@0
|
606 }
|
Chris@0
|
607
|
Chris@0
|
608 blockSignals(false);
|
Chris@0
|
609 }
|
Chris@0
|
610
|
Chris@0
|
611 void
|
Chris@249
|
612 PropertyBox::propertyContainerPropertyRangeChanged(PropertyContainer *)
|
Chris@197
|
613 {
|
Chris@197
|
614 blockSignals(true);
|
Chris@197
|
615
|
Chris@197
|
616 PropertyContainer::PropertyList properties = m_container->getProperties();
|
Chris@197
|
617 for (size_t i = 0; i < properties.size(); ++i) {
|
Chris@197
|
618 updatePropertyEditor(properties[i], true);
|
Chris@197
|
619 }
|
Chris@197
|
620
|
Chris@197
|
621 blockSignals(false);
|
Chris@197
|
622 }
|
Chris@197
|
623
|
Chris@197
|
624 void
|
Chris@100
|
625 PropertyBox::unitDatabaseChanged()
|
Chris@100
|
626 {
|
Chris@682
|
627 cerr << "PropertyBox[" << this << "]: unitDatabaseChanged" << endl;
|
Chris@100
|
628 blockSignals(true);
|
Chris@100
|
629
|
Chris@682
|
630 // cerr << "my container is " << m_container << endl;
|
Chris@682
|
631 // cerr << "my container's name is... " << endl;
|
Chris@682
|
632 // cerr << m_container->objectName() << endl;
|
Chris@456
|
633
|
Chris@100
|
634 PropertyContainer::PropertyList properties = m_container->getProperties();
|
Chris@100
|
635 for (size_t i = 0; i < properties.size(); ++i) {
|
Chris@285
|
636 if (m_container->getPropertyType(properties[i]) ==
|
Chris@285
|
637 PropertyContainer::UnitsProperty) {
|
Chris@285
|
638 updatePropertyEditor(properties[i]);
|
Chris@285
|
639 }
|
Chris@285
|
640 }
|
Chris@285
|
641
|
Chris@285
|
642 blockSignals(false);
|
Chris@285
|
643 }
|
Chris@285
|
644
|
Chris@285
|
645 void
|
Chris@285
|
646 PropertyBox::colourDatabaseChanged()
|
Chris@285
|
647 {
|
Chris@285
|
648 blockSignals(true);
|
Chris@285
|
649
|
Chris@285
|
650 PropertyContainer::PropertyList properties = m_container->getProperties();
|
Chris@285
|
651 for (size_t i = 0; i < properties.size(); ++i) {
|
Chris@285
|
652 if (m_container->getPropertyType(properties[i]) ==
|
Chris@285
|
653 PropertyContainer::ColourProperty) {
|
Chris@285
|
654 updatePropertyEditor(properties[i], true);
|
Chris@285
|
655 }
|
Chris@100
|
656 }
|
Chris@100
|
657
|
Chris@100
|
658 blockSignals(false);
|
Chris@100
|
659 }
|
Chris@100
|
660
|
Chris@100
|
661 void
|
Chris@335
|
662 PropertyBox::propertyControllerChanged(bool on)
|
Chris@335
|
663 {
|
Chris@335
|
664 propertyControllerChanged(on ? 1 : 0);
|
Chris@335
|
665 }
|
Chris@335
|
666
|
Chris@335
|
667 void
|
Chris@0
|
668 PropertyBox::propertyControllerChanged(int value)
|
Chris@0
|
669 {
|
Chris@0
|
670 QObject *obj = sender();
|
Chris@0
|
671 QString name = obj->objectName();
|
Chris@0
|
672
|
Chris@34
|
673 #ifdef DEBUG_PROPERTY_BOX
|
Chris@587
|
674 SVDEBUG << "PropertyBox::propertyControllerChanged(" << name << ", " << value << ")" << endl;
|
Chris@34
|
675 #endif
|
Chris@0
|
676
|
Chris@0
|
677 PropertyContainer::PropertyType type = m_container->getPropertyType(name);
|
Chris@100
|
678
|
Chris@376
|
679 Command *c = 0;
|
Chris@376
|
680
|
Chris@100
|
681 if (type == PropertyContainer::UnitsProperty) {
|
Chris@285
|
682
|
Chris@189
|
683 NotifyingComboBox *cb = dynamic_cast<NotifyingComboBox *>(obj);
|
Chris@100
|
684 if (cb) {
|
Chris@100
|
685 QString unit = cb->currentText();
|
Chris@376
|
686 c = m_container->getSetPropertyCommand
|
Chris@100
|
687 (name, UnitDatabase::getInstance()->getUnitId(unit));
|
Chris@100
|
688 }
|
Chris@285
|
689
|
Chris@285
|
690 } else if (type == PropertyContainer::ColourProperty) {
|
Chris@285
|
691
|
Chris@285
|
692 if (value == int(ColourDatabase::getInstance()->getColourCount())) {
|
Chris@285
|
693 addNewColour();
|
Chris@285
|
694 if (value == int(ColourDatabase::getInstance()->getColourCount())) {
|
Chris@285
|
695 propertyContainerPropertyChanged(m_container);
|
Chris@285
|
696 return;
|
Chris@285
|
697 }
|
Chris@285
|
698 }
|
Chris@376
|
699 c = m_container->getSetPropertyCommand(name, value);
|
Chris@285
|
700
|
Chris@100
|
701 } else if (type != PropertyContainer::InvalidProperty) {
|
Chris@285
|
702
|
Chris@376
|
703 c = m_container->getSetPropertyCommand(name, value);
|
Chris@0
|
704 }
|
Chris@376
|
705
|
Chris@376
|
706 if (c) CommandHistory::getInstance()->addCommand(c, true, true);
|
Chris@218
|
707
|
Chris@218
|
708 updateContextHelp(obj);
|
Chris@0
|
709 }
|
Chris@285
|
710
|
Chris@285
|
711 void
|
Chris@285
|
712 PropertyBox::addNewColour()
|
Chris@285
|
713 {
|
Chris@285
|
714 QColor newColour = QColorDialog::getColor();
|
Chris@285
|
715 if (!newColour.isValid()) return;
|
Chris@285
|
716
|
Chris@285
|
717 ColourNameDialog dialog(tr("Name New Colour"),
|
Chris@361
|
718 tr("Enter a name for the new colour:"),
|
Chris@361
|
719 newColour, newColour.name(), this);
|
Chris@285
|
720 dialog.showDarkBackgroundCheckbox(tr("Prefer black background for this colour"));
|
Chris@285
|
721 if (dialog.exec() == QDialog::Accepted) {
|
Chris@285
|
722 //!!! command
|
Chris@285
|
723 ColourDatabase *db = ColourDatabase::getInstance();
|
Chris@285
|
724 int index = db->addColour(newColour, dialog.getColourName());
|
Chris@285
|
725 db->setUseDarkBackground(index, dialog.isDarkBackgroundChecked());
|
Chris@285
|
726 }
|
Chris@285
|
727 }
|
Chris@377
|
728
|
Chris@377
|
729 void
|
Chris@377
|
730 PropertyBox::playAudibleChanged(bool audible)
|
Chris@377
|
731 {
|
Chris@377
|
732 m_playButton->setState(audible);
|
Chris@377
|
733 }
|
Chris@377
|
734
|
Chris@377
|
735 void
|
Chris@377
|
736 PropertyBox::playAudibleButtonChanged(bool audible)
|
Chris@377
|
737 {
|
Chris@377
|
738 PlayParameters *params = m_container->getPlayParameters();
|
Chris@377
|
739 if (!params) return;
|
Chris@377
|
740
|
Chris@377
|
741 if (params->isPlayAudible() != audible) {
|
Chris@377
|
742 PlayParameterRepository::EditCommand *command =
|
Chris@377
|
743 new PlayParameterRepository::EditCommand(params);
|
Chris@377
|
744 command->setPlayAudible(audible);
|
Chris@377
|
745 CommandHistory::getInstance()->addCommand(command, true, true);
|
Chris@377
|
746 }
|
Chris@377
|
747 }
|
Chris@0
|
748
|
Chris@34
|
749 void
|
Chris@34
|
750 PropertyBox::playGainChanged(float gain)
|
Chris@34
|
751 {
|
Chris@34
|
752 int dialValue = lrint(log10(gain) * 20.0);
|
Chris@34
|
753 if (dialValue < -50) dialValue = -50;
|
Chris@34
|
754 if (dialValue > 50) dialValue = 50;
|
Chris@34
|
755 emit changePlayGainDial(dialValue);
|
Chris@34
|
756 }
|
Chris@34
|
757
|
Chris@34
|
758 void
|
Chris@34
|
759 PropertyBox::playGainDialChanged(int dialValue)
|
Chris@34
|
760 {
|
Chris@218
|
761 QObject *obj = sender();
|
Chris@377
|
762
|
Chris@377
|
763 PlayParameters *params = m_container->getPlayParameters();
|
Chris@377
|
764 if (!params) return;
|
Chris@377
|
765
|
Chris@34
|
766 float gain = pow(10, float(dialValue) / 20.0);
|
Chris@377
|
767
|
Chris@377
|
768 if (params->getPlayGain() != gain) {
|
Chris@377
|
769 PlayParameterRepository::EditCommand *command =
|
Chris@377
|
770 new PlayParameterRepository::EditCommand(params);
|
Chris@377
|
771 command->setPlayGain(gain);
|
Chris@377
|
772 CommandHistory::getInstance()->addCommand(command, true, true);
|
Chris@377
|
773 }
|
Chris@377
|
774
|
Chris@218
|
775 updateContextHelp(obj);
|
Chris@34
|
776 }
|
Chris@34
|
777
|
Chris@34
|
778 void
|
Chris@34
|
779 PropertyBox::playPanChanged(float pan)
|
Chris@34
|
780 {
|
Chris@34
|
781 int dialValue = lrint(pan * 50.0);
|
Chris@34
|
782 if (dialValue < -50) dialValue = -50;
|
Chris@34
|
783 if (dialValue > 50) dialValue = 50;
|
Chris@34
|
784 emit changePlayPanDial(dialValue);
|
Chris@34
|
785 }
|
Chris@34
|
786
|
Chris@34
|
787 void
|
Chris@34
|
788 PropertyBox::playPanDialChanged(int dialValue)
|
Chris@34
|
789 {
|
Chris@218
|
790 QObject *obj = sender();
|
Chris@377
|
791
|
Chris@377
|
792 PlayParameters *params = m_container->getPlayParameters();
|
Chris@377
|
793 if (!params) return;
|
Chris@377
|
794
|
Chris@34
|
795 float pan = float(dialValue) / 50.0;
|
Chris@34
|
796 if (pan < -1.0) pan = -1.0;
|
Chris@34
|
797 if (pan > 1.0) pan = 1.0;
|
Chris@377
|
798
|
Chris@377
|
799 if (params->getPlayPan() != pan) {
|
Chris@377
|
800 PlayParameterRepository::EditCommand *command =
|
Chris@377
|
801 new PlayParameterRepository::EditCommand(params);
|
Chris@377
|
802 command->setPlayPan(pan);
|
Chris@377
|
803 CommandHistory::getInstance()->addCommand(command, true, true);
|
Chris@377
|
804 }
|
Chris@377
|
805
|
Chris@218
|
806 updateContextHelp(obj);
|
Chris@34
|
807 }
|
Chris@0
|
808
|
Chris@63
|
809 void
|
Chris@63
|
810 PropertyBox::editPlugin()
|
Chris@63
|
811 {
|
Chris@63
|
812 //!!! should probably just emit and let something else do this
|
Chris@63
|
813
|
Chris@63
|
814 PlayParameters *params = m_container->getPlayParameters();
|
Chris@63
|
815 if (!params) return;
|
Chris@63
|
816
|
Chris@63
|
817 QString pluginId = params->getPlayPluginId();
|
Chris@63
|
818 QString configurationXml = params->getPlayPluginConfiguration();
|
Chris@377
|
819
|
Chris@377
|
820 PlayParameterRepository::EditCommand *command =
|
Chris@377
|
821 new PlayParameterRepository::EditCommand(params);
|
Chris@63
|
822
|
Chris@63
|
823 RealTimePluginFactory *factory =
|
Chris@63
|
824 RealTimePluginFactory::instanceFor(pluginId);
|
Chris@63
|
825 if (!factory) return;
|
Chris@63
|
826
|
Chris@63
|
827 RealTimePluginInstance *instance =
|
Chris@63
|
828 factory->instantiatePlugin(pluginId, 0, 0, 48000, 1024, 1);
|
Chris@63
|
829 if (!instance) return;
|
Chris@63
|
830
|
Chris@71
|
831 PluginXml(instance).setParametersFromXml(configurationXml);
|
Chris@63
|
832
|
Chris@163
|
833 PluginParameterDialog *dialog = new PluginParameterDialog(instance);
|
Chris@64
|
834 connect(dialog, SIGNAL(pluginConfigurationChanged(QString)),
|
Chris@64
|
835 this, SLOT(pluginConfigurationChanged(QString)));
|
Chris@64
|
836
|
Chris@63
|
837 if (dialog->exec() == QDialog::Accepted) {
|
Chris@377
|
838 QString newConfiguration = PluginXml(instance).toXmlString();
|
Chris@377
|
839 command->setPlayPluginConfiguration(newConfiguration);
|
Chris@377
|
840 CommandHistory::getInstance()->addCommand(command, true);
|
Chris@64
|
841 } else {
|
Chris@377
|
842 delete command;
|
Chris@64
|
843 // restore in case we mucked about with the configuration
|
Chris@64
|
844 // as a consequence of signals from the dialog
|
Chris@64
|
845 params->setPlayPluginConfiguration(configurationXml);
|
Chris@63
|
846 }
|
Chris@63
|
847
|
Chris@63
|
848 delete dialog;
|
Chris@63
|
849 delete instance;
|
Chris@63
|
850 }
|
Chris@63
|
851
|
Chris@64
|
852 void
|
Chris@64
|
853 PropertyBox::pluginConfigurationChanged(QString configurationXml)
|
Chris@64
|
854 {
|
Chris@64
|
855 PlayParameters *params = m_container->getPlayParameters();
|
Chris@64
|
856 if (!params) return;
|
Chris@64
|
857
|
Chris@64
|
858 params->setPlayPluginConfiguration(configurationXml);
|
Chris@64
|
859 }
|
Chris@185
|
860
|
Chris@185
|
861 void
|
Chris@185
|
862 PropertyBox::layerVisibilityChanged(bool visible)
|
Chris@185
|
863 {
|
Chris@185
|
864 if (m_showButton) m_showButton->setState(visible);
|
Chris@185
|
865 }
|
Chris@189
|
866
|
Chris@189
|
867 void
|
Chris@189
|
868 PropertyBox::mouseEnteredWidget()
|
Chris@189
|
869 {
|
Chris@218
|
870 updateContextHelp(sender());
|
Chris@218
|
871 }
|
Chris@218
|
872
|
Chris@218
|
873 void
|
Chris@218
|
874 PropertyBox::updateContextHelp(QObject *o)
|
Chris@218
|
875 {
|
Chris@218
|
876 QWidget *w = dynamic_cast<QWidget *>(o);
|
Chris@189
|
877 if (!w) return;
|
Chris@218
|
878
|
Chris@189
|
879 if (!m_container) return;
|
Chris@190
|
880 QString cname = m_container->getPropertyContainerName();
|
Chris@189
|
881 if (cname == "") return;
|
Chris@189
|
882
|
Chris@189
|
883 QString wname = w->objectName();
|
Chris@189
|
884
|
Chris@218
|
885 QString extraText;
|
Chris@218
|
886 AudioDial *dial = dynamic_cast<AudioDial *>(w);
|
Chris@218
|
887 if (dial) {
|
Chris@218
|
888 float mv = dial->mappedValue();
|
Chris@218
|
889 QString unit = "";
|
Chris@218
|
890 if (dial->rangeMapper()) unit = dial->rangeMapper()->getUnit();
|
Chris@218
|
891 if (unit != "") {
|
Chris@218
|
892 extraText = tr(" (current value: %1%2)").arg(mv).arg(unit);
|
Chris@218
|
893 } else {
|
Chris@218
|
894 extraText = tr(" (current value: %1)").arg(mv);
|
Chris@218
|
895 }
|
Chris@218
|
896 }
|
Chris@218
|
897
|
Chris@189
|
898 if (w == m_showButton) {
|
Chris@190
|
899 emit contextHelpChanged(tr("Toggle Visibility of %1").arg(cname));
|
Chris@189
|
900 } else if (w == m_playButton) {
|
Chris@190
|
901 emit contextHelpChanged(tr("Toggle Playback of %1").arg(cname));
|
Chris@189
|
902 } else if (wname == "") {
|
Chris@189
|
903 return;
|
Chris@335
|
904 } else if (dynamic_cast<QAbstractButton *>(w)) {
|
Chris@190
|
905 emit contextHelpChanged(tr("Toggle %1 property of %2")
|
Chris@189
|
906 .arg(wname).arg(cname));
|
Chris@189
|
907 } else {
|
Chris@218
|
908 emit contextHelpChanged(tr("Adjust %1 property of %2%3")
|
Chris@218
|
909 .arg(wname).arg(cname).arg(extraText));
|
Chris@189
|
910 }
|
Chris@189
|
911 }
|
Chris@189
|
912
|
Chris@189
|
913 void
|
Chris@189
|
914 PropertyBox::mouseLeftWidget()
|
Chris@189
|
915 {
|
Chris@218
|
916 if (!(QApplication::mouseButtons() & Qt::LeftButton)) {
|
Chris@218
|
917 emit contextHelpChanged("");
|
Chris@218
|
918 }
|
Chris@189
|
919 }
|
Chris@189
|
920
|
Chris@64
|
921
|