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