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