comparison widgets/PropertyBox.cpp @ 189:5b7472db612b

* Add large chunks of context help in the optional status bar * Add an extra overlay mode in which even the centre frame is disabled * Fixes to FTP retrieval
author Chris Cannam
date Fri, 19 Jan 2007 13:13:14 +0000
parents dd932fe5f3ff
children 53835534a9d3
comparison
equal deleted inserted replaced
188:dd573e090eed 189:5b7472db612b
27 #include "plugin/PluginXml.h" 27 #include "plugin/PluginXml.h"
28 28
29 #include "AudioDial.h" 29 #include "AudioDial.h"
30 #include "LEDButton.h" 30 #include "LEDButton.h"
31 31
32 #include "NotifyingCheckBox.h"
33 #include "NotifyingComboBox.h"
34
32 #include <QGridLayout> 35 #include <QGridLayout>
33 #include <QHBoxLayout> 36 #include <QHBoxLayout>
34 #include <QVBoxLayout> 37 #include <QVBoxLayout>
35 #include <QCheckBox>
36 #include <QComboBox>
37 #include <QPushButton> 38 #include <QPushButton>
38 #include <QLabel> 39 #include <QLabel>
39 #include <QFrame> 40 #include <QFrame>
40 41
41 #include <cassert> 42 #include <cassert>
44 45
45 //#define DEBUG_PROPERTY_BOX 1 46 //#define DEBUG_PROPERTY_BOX 1
46 47
47 PropertyBox::PropertyBox(PropertyContainer *container) : 48 PropertyBox::PropertyBox(PropertyContainer *container) :
48 m_container(container), 49 m_container(container),
49 m_showButton(0) 50 m_showButton(0),
51 m_playButton(0)
50 { 52 {
51 #ifdef DEBUG_PROPERTY_BOX 53 #ifdef DEBUG_PROPERTY_BOX
52 std::cerr << "PropertyBox[" << this << "(\"" << 54 std::cerr << "PropertyBox[" << this << "(\"" <<
53 container->getPropertyContainerName().toStdString() << "\")]::PropertyBox" << std::endl; 55 container->getPropertyContainerName().toStdString() << "\")]::PropertyBox" << std::endl;
54 #endif 56 #endif
143 145
144 m_showButton = new LEDButton(Qt::blue); 146 m_showButton = new LEDButton(Qt::blue);
145 layout->addWidget(m_showButton); 147 layout->addWidget(m_showButton);
146 connect(m_showButton, SIGNAL(stateChanged(bool)), 148 connect(m_showButton, SIGNAL(stateChanged(bool)),
147 this, SIGNAL(showLayer(bool))); 149 this, SIGNAL(showLayer(bool)));
150 connect(m_showButton, SIGNAL(mouseEntered()),
151 this, SLOT(mouseEnteredWidget()));
152 connect(m_showButton, SIGNAL(mouseLeft()),
153 this, SLOT(mouseLeftWidget()));
148 layout->setAlignment(m_showButton, Qt::AlignVCenter); 154 layout->setAlignment(m_showButton, Qt::AlignVCenter);
149 } 155 }
150 156
151 if (params) { 157 if (params) {
152 158
153 QLabel *playLabel = new QLabel(tr("Play")); 159 QLabel *playLabel = new QLabel(tr("Play"));
154 layout->addWidget(playLabel); 160 layout->addWidget(playLabel);
155 layout->setAlignment(playLabel, Qt::AlignVCenter); 161 layout->setAlignment(playLabel, Qt::AlignVCenter);
156 162
157 LEDButton *playButton = new LEDButton(Qt::darkGreen); 163 m_playButton = new LEDButton(Qt::darkGreen);
158 playButton->setState(!params->isPlayMuted()); 164 m_playButton->setState(!params->isPlayMuted());
159 layout->addWidget(playButton); 165 layout->addWidget(m_playButton);
160 connect(playButton, SIGNAL(stateChanged(bool)), 166 connect(m_playButton, SIGNAL(stateChanged(bool)),
161 params, SLOT(setPlayAudible(bool))); 167 params, SLOT(setPlayAudible(bool)));
168 connect(m_playButton, SIGNAL(mouseEntered()),
169 this, SLOT(mouseEnteredWidget()));
170 connect(m_playButton, SIGNAL(mouseLeft()),
171 this, SLOT(mouseLeftWidget()));
162 connect(params, SIGNAL(playAudibleChanged(bool)), 172 connect(params, SIGNAL(playAudibleChanged(bool)),
163 playButton, SLOT(setState(bool))); 173 m_playButton, SLOT(setState(bool)));
164 layout->setAlignment(playButton, Qt::AlignVCenter); 174 layout->setAlignment(m_playButton, Qt::AlignVCenter);
165 175
166 layout->insertStretch(-1, 10); 176 layout->insertStretch(-1, 10);
167 177
168 if (params->getPlayPluginId() != "") { 178 if (params->getPlayPluginId() != "") {
169 QPushButton *pluginButton = new QPushButton(QIcon(":icons/faders.png"), ""); 179 QPushButton *pluginButton = new QPushButton(QIcon(":icons/faders.png"), "");
194 this, SLOT(playGainChanged(float))); 204 this, SLOT(playGainChanged(float)));
195 connect(this, SIGNAL(changePlayGain(float)), 205 connect(this, SIGNAL(changePlayGain(float)),
196 params, SLOT(setPlayGain(float))); 206 params, SLOT(setPlayGain(float)));
197 connect(this, SIGNAL(changePlayGainDial(int)), 207 connect(this, SIGNAL(changePlayGainDial(int)),
198 gainDial, SLOT(setValue(int))); 208 gainDial, SLOT(setValue(int)));
209 connect(gainDial, SIGNAL(mouseEntered()),
210 this, SLOT(mouseEnteredWidget()));
211 connect(gainDial, SIGNAL(mouseLeft()),
212 this, SLOT(mouseLeftWidget()));
199 layout->setAlignment(gainDial, Qt::AlignVCenter); 213 layout->setAlignment(gainDial, Qt::AlignVCenter);
200 214
201 AudioDial *panDial = new AudioDial; 215 AudioDial *panDial = new AudioDial;
202 layout->addWidget(panDial); 216 layout->addWidget(panDial);
203 panDial->setMeterColor(Qt::darkGreen); 217 panDial->setMeterColor(Qt::darkGreen);
217 this, SLOT(playPanChanged(float))); 231 this, SLOT(playPanChanged(float)));
218 connect(this, SIGNAL(changePlayPan(float)), 232 connect(this, SIGNAL(changePlayPan(float)),
219 params, SLOT(setPlayPan(float))); 233 params, SLOT(setPlayPan(float)));
220 connect(this, SIGNAL(changePlayPanDial(int)), 234 connect(this, SIGNAL(changePlayPanDial(int)),
221 panDial, SLOT(setValue(int))); 235 panDial, SLOT(setValue(int)));
236 connect(panDial, SIGNAL(mouseEntered()),
237 this, SLOT(mouseEnteredWidget()));
238 connect(panDial, SIGNAL(mouseLeft()),
239 this, SLOT(mouseLeftWidget()));
222 layout->setAlignment(panDial, Qt::AlignVCenter); 240 layout->setAlignment(panDial, Qt::AlignVCenter);
223 241
224 } else { 242 } else {
225 243
226 layout->insertStretch(-1, 10); 244 layout->insertStretch(-1, 10);
276 294
277 switch (type) { 295 switch (type) {
278 296
279 case PropertyContainer::ToggleProperty: 297 case PropertyContainer::ToggleProperty:
280 { 298 {
281 QCheckBox *cb; 299 NotifyingCheckBox *cb;
282 300
283 if (have) { 301 if (have) {
284 cb = dynamic_cast<QCheckBox *>(m_propertyControllers[name]); 302 cb = dynamic_cast<NotifyingCheckBox *>(m_propertyControllers[name]);
285 assert(cb); 303 assert(cb);
286 } else { 304 } else {
287 #ifdef DEBUG_PROPERTY_BOX 305 #ifdef DEBUG_PROPERTY_BOX
288 std::cerr << "PropertyBox: creating new checkbox" << std::endl; 306 std::cerr << "PropertyBox: creating new checkbox" << std::endl;
289 #endif 307 #endif
290 cb = new QCheckBox(); 308 cb = new NotifyingCheckBox();
291 cb->setObjectName(name); 309 cb->setObjectName(name);
292 connect(cb, SIGNAL(stateChanged(int)), 310 connect(cb, SIGNAL(stateChanged(int)),
293 this, SLOT(propertyControllerChanged(int))); 311 this, SLOT(propertyControllerChanged(int)));
312 connect(cb, SIGNAL(mouseEntered()),
313 this, SLOT(mouseEnteredWidget()));
314 connect(cb, SIGNAL(mouseLeft()),
315 this, SLOT(mouseLeftWidget()));
294 if (inGroup) { 316 if (inGroup) {
295 cb->setToolTip(propertyLabel); 317 cb->setToolTip(propertyLabel);
296 m_groupLayouts[groupName]->addWidget(cb); 318 m_groupLayouts[groupName]->addWidget(cb);
297 } else { 319 } else {
298 m_layout->addWidget(cb, row, 1, 1, 2); 320 m_layout->addWidget(cb, row, 1, 1, 2);
328 dial->setDefaultValue(value); 350 dial->setDefaultValue(value);
329 dial->setRangeMapper(m_container->getNewPropertyRangeMapper(name)); 351 dial->setRangeMapper(m_container->getNewPropertyRangeMapper(name));
330 dial->setShowToolTip(true); 352 dial->setShowToolTip(true);
331 connect(dial, SIGNAL(valueChanged(int)), 353 connect(dial, SIGNAL(valueChanged(int)),
332 this, SLOT(propertyControllerChanged(int))); 354 this, SLOT(propertyControllerChanged(int)));
355 connect(dial, SIGNAL(mouseEntered()),
356 this, SLOT(mouseEnteredWidget()));
357 connect(dial, SIGNAL(mouseLeft()),
358 this, SLOT(mouseLeftWidget()));
333 359
334 if (inGroup) { 360 if (inGroup) {
335 dial->setFixedWidth(24); 361 dial->setFixedWidth(24);
336 dial->setFixedHeight(24); 362 dial->setFixedHeight(24);
337 m_groupLayouts[groupName]->addWidget(dial); 363 m_groupLayouts[groupName]->addWidget(dial);
358 } 384 }
359 385
360 case PropertyContainer::ValueProperty: 386 case PropertyContainer::ValueProperty:
361 case PropertyContainer::UnitsProperty: 387 case PropertyContainer::UnitsProperty:
362 { 388 {
363 QComboBox *cb; 389 NotifyingComboBox *cb;
364 390
365 if (have) { 391 if (have) {
366 cb = dynamic_cast<QComboBox *>(m_propertyControllers[name]); 392 cb = dynamic_cast<NotifyingComboBox *>(m_propertyControllers[name]);
367 assert(cb); 393 assert(cb);
368 } else { 394 } else {
369 #ifdef DEBUG_PROPERTY_BOX 395 #ifdef DEBUG_PROPERTY_BOX
370 std::cerr << "PropertyBox: creating new combobox" << std::endl; 396 std::cerr << "PropertyBox: creating new combobox" << std::endl;
371 #endif 397 #endif
372 398
373 cb = new QComboBox(); 399 cb = new NotifyingComboBox();
374 cb->setObjectName(name); 400 cb->setObjectName(name);
375 cb->setDuplicatesEnabled(false); 401 cb->setDuplicatesEnabled(false);
376 402
377 if (type == PropertyContainer::ValueProperty) { 403 if (type == PropertyContainer::ValueProperty) {
378 for (int i = min; i <= max; ++i) { 404 for (int i = min; i <= max; ++i) {
387 cb->setEditable(true); 413 cb->setEditable(true);
388 } 414 }
389 415
390 connect(cb, SIGNAL(activated(int)), 416 connect(cb, SIGNAL(activated(int)),
391 this, SLOT(propertyControllerChanged(int))); 417 this, SLOT(propertyControllerChanged(int)));
418 connect(cb, SIGNAL(mouseEntered()),
419 this, SLOT(mouseEnteredWidget()));
420 connect(cb, SIGNAL(mouseLeft()),
421 this, SLOT(mouseLeftWidget()));
392 422
393 if (inGroup) { 423 if (inGroup) {
394 cb->setToolTip(propertyLabel); 424 cb->setToolTip(propertyLabel);
395 m_groupLayouts[groupName]->addWidget(cb); 425 m_groupLayouts[groupName]->addWidget(cb);
396 } else { 426 } else {
476 #endif 506 #endif
477 507
478 PropertyContainer::PropertyType type = m_container->getPropertyType(name); 508 PropertyContainer::PropertyType type = m_container->getPropertyType(name);
479 509
480 if (type == PropertyContainer::UnitsProperty) { 510 if (type == PropertyContainer::UnitsProperty) {
481 QComboBox *cb = dynamic_cast<QComboBox *>(obj); 511 NotifyingComboBox *cb = dynamic_cast<NotifyingComboBox *>(obj);
482 if (cb) { 512 if (cb) {
483 QString unit = cb->currentText(); 513 QString unit = cb->currentText();
484 m_container->setPropertyWithCommand 514 m_container->setPropertyWithCommand
485 (name, UnitDatabase::getInstance()->getUnitId(unit)); 515 (name, UnitDatabase::getInstance()->getUnitId(unit));
486 } 516 }
487 } else if (type != PropertyContainer::InvalidProperty) { 517 } else if (type != PropertyContainer::InvalidProperty) {
488 m_container->setPropertyWithCommand(name, value); 518 m_container->setPropertyWithCommand(name, value);
489 } 519 }
490
491 // if (type == PropertyContainer::RangeProperty) {
492 // AudioDial *dial = dynamic_cast<AudioDial *>(m_propertyControllers[name]);
493 //!!! if (dial) {
494 // dial->setToolTip(QString("%1: %2").arg(name).arg(value));
495 // //!!! unfortunately this doesn't update an already-visible tooltip
496 // }
497 // }
498 } 520 }
499 521
500 void 522 void
501 PropertyBox::playGainChanged(float gain) 523 PropertyBox::playGainChanged(float gain)
502 { 524 {
580 void 602 void
581 PropertyBox::layerVisibilityChanged(bool visible) 603 PropertyBox::layerVisibilityChanged(bool visible)
582 { 604 {
583 if (m_showButton) m_showButton->setState(visible); 605 if (m_showButton) m_showButton->setState(visible);
584 } 606 }
585 607
608 void
609 PropertyBox::mouseEnteredWidget()
610 {
611 QWidget *w = dynamic_cast<QWidget *>(sender());
612 if (!w) return;
613
614 if (!m_container) return;
615 QString cname = m_container->objectName();
616 if (cname == "") return;
617
618 QString wname = w->objectName();
619
620 if (w == m_showButton) {
621 emit contextHelpChanged(tr("Toggle Visibility of %1 layer").arg(cname));
622 } else if (w == m_playButton) {
623 emit contextHelpChanged(tr("Toggle Playback of %1 layer").arg(cname));
624 } else if (wname == "") {
625 return;
626 } else if (dynamic_cast<NotifyingCheckBox *>(w)) {
627 emit contextHelpChanged(tr("Toggle %1 property of %2 layer")
628 .arg(wname).arg(cname));
629 } else {
630 emit contextHelpChanged(tr("Adjust %1 property of %2 layer")
631 .arg(wname).arg(cname));
632 }
633 }
634
635 void
636 PropertyBox::mouseLeftWidget()
637 {
638 emit contextHelpChanged("");
639 }
640
586 641
587 #ifdef INCLUDE_MOCFILES 642 #ifdef INCLUDE_MOCFILES
588 #include "PropertyBox.moc.cpp" 643 #include "PropertyBox.moc.cpp"
589 #endif 644 #endif
590 645