Mercurial > hg > svgui
changeset 1180:6a6a63506e3f levelpanwidget
Some work on play parameters and level controls in property box
author | Chris Cannam |
---|---|
date | Tue, 06 Dec 2016 09:47:27 +0000 |
parents | 7c31eb5bc77d |
children | 8665e0ffa0d8 |
files | widgets/LevelPanToolButton.cpp widgets/LevelPanToolButton.h widgets/LevelPanWidget.cpp widgets/LevelPanWidget.h widgets/NotifyingPushButton.h widgets/PropertyBox.cpp widgets/PropertyBox.h |
diffstat | 7 files changed, 85 insertions(+), 24 deletions(-) [+] |
line wrap: on
line diff
--- a/widgets/LevelPanToolButton.cpp Tue Dec 06 09:20:10 2016 +0000 +++ b/widgets/LevelPanToolButton.cpp Tue Dec 06 09:47:27 2016 +0000 @@ -170,4 +170,18 @@ m_lpw->renderTo(this, QRectF(margin, margin, m_pixels, m_pixels), false); } +void +LevelPanToolButton::enterEvent(QEvent *e) +{ + QToolButton::enterEvent(e); + emit mouseEntered(); +} +void +LevelPanToolButton::leaveEvent(QEvent *e) +{ + QToolButton::enterEvent(e); + emit mouseLeft(); +} + +
--- a/widgets/LevelPanToolButton.h Tue Dec 06 09:20:10 2016 +0000 +++ b/widgets/LevelPanToolButton.h Tue Dec 06 09:47:27 2016 +0000 @@ -56,12 +56,17 @@ void levelChanged(float); void panChanged(float); + void mouseEntered(); + void mouseLeft(); + private slots: void selfLevelChanged(float); void selfClicked(); protected: - void paintEvent(QPaintEvent *); + virtual void paintEvent(QPaintEvent *); + virtual void enterEvent(QEvent *); + virtual void leaveEvent(QEvent *); LevelPanWidget *m_lpw; int m_pixels;
--- a/widgets/LevelPanWidget.cpp Tue Dec 06 09:20:10 2016 +0000 +++ b/widgets/LevelPanWidget.cpp Tue Dec 06 09:47:27 2016 +0000 @@ -432,5 +432,17 @@ renderTo(this, rect(), m_editable); } +void +LevelPanWidget::enterEvent(QEvent *e) +{ + QWidget::enterEvent(e); + emit mouseEntered(); +} +void +LevelPanWidget::leaveEvent(QEvent *e) +{ + QWidget::enterEvent(e); + emit mouseLeft(); +}
--- a/widgets/LevelPanWidget.h Tue Dec 06 09:20:10 2016 +0000 +++ b/widgets/LevelPanWidget.h Tue Dec 06 09:47:27 2016 +0000 @@ -66,12 +66,17 @@ void levelChanged(float); // range [0,1] void panChanged(float); // range [-1,1] + void mouseEntered(); + void mouseLeft(); + protected: virtual void mousePressEvent(QMouseEvent *ev); virtual void mouseMoveEvent(QMouseEvent *ev); virtual void mouseReleaseEvent(QMouseEvent *ev); virtual void wheelEvent(QWheelEvent *ev); virtual void paintEvent(QPaintEvent *ev); + virtual void enterEvent(QEvent *); + virtual void leaveEvent(QEvent *); void emitLevelChanged(); void emitPanChanged();
--- a/widgets/NotifyingPushButton.h Tue Dec 06 09:20:10 2016 +0000 +++ b/widgets/NotifyingPushButton.h Tue Dec 06 09:47:27 2016 +0000 @@ -26,8 +26,8 @@ class NotifyingPushButton : public QPushButton { Q_OBJECT + public: - NotifyingPushButton(QWidget *parent = 0) : QPushButton(parent) { }
--- a/widgets/PropertyBox.cpp Tue Dec 06 09:20:10 2016 +0000 +++ b/widgets/PropertyBox.cpp Tue Dec 06 09:47:27 2016 +0000 @@ -177,33 +177,21 @@ if (params) { - QLabel *playLabel = new QLabel(tr("Play")); - layout->addWidget(playLabel); - layout->setAlignment(playLabel, Qt::AlignVCenter); - - m_playButton = new LEDButton(Qt::darkGreen); - m_playButton->setState(!params->isPlayMuted()); - layout->addWidget(m_playButton); - connect(m_playButton, SIGNAL(stateChanged(bool)), - this, SLOT(playAudibleButtonChanged(bool))); - connect(m_playButton, SIGNAL(mouseEntered()), - this, SLOT(mouseEnteredWidget())); - connect(m_playButton, SIGNAL(mouseLeft()), - this, SLOT(mouseLeftWidget())); - connect(params, SIGNAL(playAudibleChanged(bool)), - this, SLOT(playAudibleChanged(bool))); - layout->setAlignment(m_playButton, Qt::AlignVCenter); - layout->insertStretch(-1, 10); if (params->getPlayClipId() != "") { - QPushButton *playParamButton = - new QPushButton(QIcon(":icons/faders.png"), ""); + NotifyingPushButton *playParamButton = new NotifyingPushButton; + playParamButton->setObjectName("playParamButton"); + playParamButton->setIcon(IconLoader().load("faders")); playParamButton->setFixedWidth(WidgetScale::scalePixelSize(24)); playParamButton->setFixedHeight(WidgetScale::scalePixelSize(24)); layout->addWidget(playParamButton); connect(playParamButton, SIGNAL(clicked()), this, SLOT(editPlayParameters())); + connect(playParamButton, SIGNAL(mouseEntered()), + this, SLOT(mouseEnteredWidget())); + connect(playParamButton, SIGNAL(mouseLeft()), + this, SLOT(mouseLeftWidget())); } LevelPanToolButton *levelPan = new LevelPanToolButton; @@ -216,6 +204,25 @@ levelPan, SLOT(setLevel(float))); connect(params, SIGNAL(playPanChanged(float)), levelPan, SLOT(setPan(float))); + connect(levelPan, SIGNAL(mouseEntered()), + this, SLOT(mouseEnteredWidget())); + connect(levelPan, SIGNAL(mouseLeft()), + this, SLOT(mouseLeftWidget())); + + m_playButton = new NotifyingPushButton; + m_playButton->setCheckable(true); + m_playButton->setIcon(IconLoader().load("speaker")); + m_playButton->setChecked(!params->isPlayMuted()); + layout->addWidget(m_playButton); + connect(m_playButton, SIGNAL(toggled(bool)), + this, SLOT(playAudibleButtonChanged(bool))); + connect(m_playButton, SIGNAL(mouseEntered()), + this, SLOT(mouseEnteredWidget())); + connect(m_playButton, SIGNAL(mouseLeft()), + this, SLOT(mouseLeftWidget())); + connect(params, SIGNAL(playAudibleChanged(bool)), + this, SLOT(playAudibleChanged(bool))); + layout->setAlignment(m_playButton, Qt::AlignVCenter); } else { @@ -652,7 +659,7 @@ void PropertyBox::playAudibleChanged(bool audible) { - m_playButton->setState(audible); + m_playButton->setChecked(audible); } void @@ -786,10 +793,27 @@ QString cname = m_container->getPropertyContainerName(); if (cname == "") return; + LevelPanToolButton *lp = qobject_cast<LevelPanToolButton *>(w); + if (lp) { + emit contextHelpChanged(tr("Adjust playback level and pan of %1").arg(cname)); + return; + } + QString wname = w->objectName(); + if (wname == "playParamButton") { + PlayParameters *params = m_container->getPlayParameters(); + if (params) { + emit contextHelpChanged + (tr("Change sound used for playback (currently \"%1\")") + .arg(params->getPlayClipId())); + return; + } + } + QString extraText; - AudioDial *dial = dynamic_cast<AudioDial *>(w); + + AudioDial *dial = qobject_cast<AudioDial *>(w); if (dial) { double mv = dial->mappedValue(); QString unit = "";
--- a/widgets/PropertyBox.h Tue Dec 06 09:20:10 2016 +0000 +++ b/widgets/PropertyBox.h Tue Dec 06 09:47:27 2016 +0000 @@ -27,6 +27,7 @@ class QVBoxLayout; class QLabel; class LEDButton; +class NotifyingPushButton; class PropertyBox : public QFrame { @@ -80,7 +81,7 @@ QFrame *m_viewPlayFrame; QVBoxLayout *m_mainBox; LEDButton *m_showButton; - LEDButton *m_playButton; + NotifyingPushButton *m_playButton; std::map<QString, QGridLayout *> m_groupLayouts; std::map<QString, QWidget *> m_propertyControllers; };