# HG changeset patch # User Chris Cannam # Date 1588167997 -3600 # Node ID a798a7b5e215a94aed7d2282bafa066ccfc3a4be # Parent 4739a1b2266f22ea0efae08015e3f551dc0d51a4 Further removal of Qt 5.6+-only APIs diff -r 4739a1b2266f -r a798a7b5e215 widgets/AudioDial.cpp --- a/widgets/AudioDial.cpp Wed Apr 29 14:23:51 2020 +0100 +++ b/widgets/AudioDial.cpp Wed Apr 29 14:46:37 2020 +0100 @@ -117,14 +117,8 @@ MenuTitle::addTitle(m, m_title); } - m->addAction(tr("&Edit..."), - [=]() { - edit(); - }); - m->addAction(tr("&Reset to Default"), - [=]() { - setToDefault(); - }); + m->addAction(tr("&Edit..."), this, SLOT(edit())); + m->addAction(tr("&Reset to Default"), this, SLOT(setToDefault())); m->popup(mapToGlobal(pos)); } diff -r 4739a1b2266f -r a798a7b5e215 widgets/LevelPanToolButton.cpp --- a/widgets/LevelPanToolButton.cpp Wed Apr 29 14:23:51 2020 +0100 +++ b/widgets/LevelPanToolButton.cpp Wed Apr 29 14:46:37 2020 +0100 @@ -227,10 +227,7 @@ MenuTitle::addTitle(m, title); - m->addAction(tr("&Reset to Default"), - [=]() { - m_lpw->setToDefault(); - }); + m->addAction(tr("&Reset to Default"), m_lpw, SLOT(setToDefault())); m->popup(mapToGlobal(pos)); } diff -r 4739a1b2266f -r a798a7b5e215 widgets/PropertyBox.cpp --- a/widgets/PropertyBox.cpp Wed Apr 29 14:23:51 2020 +0100 +++ b/widgets/PropertyBox.cpp Wed Apr 29 14:46:37 2020 +0100 @@ -61,7 +61,8 @@ m_container(container), m_showButton(nullptr), m_playButton(nullptr), - m_lastContextMenu(nullptr) + m_lastContextMenu(nullptr), + m_contextMenuOn(nullptr) { #ifdef DEBUG_PROPERTY_BOX SVDEBUG << "PropertyBox[" << this << "(\"" << @@ -695,26 +696,24 @@ delete m_lastContextMenu; QMenu *m = new QMenu; + m_lastContextMenu = m; + m_contextMenuOn = obj; - if (auto button = qobject_cast(obj)) { + if (qobject_cast(obj)) { if (value > 0) { MenuTitle::addTitle(m, tr("%1: On").arg(label)); } else { MenuTitle::addTitle(m, tr("%1: Off").arg(label)); } - - m->addAction(tr("&Reset to Default"), - [=]() { - button->setChecked(deflt > 0); - }); + m->addAction(tr("&Reset to Default"), this, + SLOT(propertyControllerResetRequested())); } else if (auto cb = qobject_cast(obj)) { MenuTitle::addTitle(m, tr("%1: %2").arg(label).arg(cb->itemText(value))); - m->addAction(tr("&Reset to Default"), - [=]() { - cb->setCurrentIndex(deflt); - }); + m->addAction(tr("&Reset to Default"), this, + SLOT(propertyControllerResetRequested())); + } else { // AudioDial has its own context menu, we don't handle it here return; @@ -724,6 +723,24 @@ } void +PropertyBox::propertyControllerResetRequested() +{ + if (!m_contextMenuOn) return; + + QString name = m_contextMenuOn->objectName(); + + QString label = m_container->getPropertyLabel(name); + int min = 0, max = 0, value = 0, deflt = 0; + value = m_container->getPropertyRangeAndValue(name, &min, &max, &deflt); + + if (auto button = qobject_cast(m_contextMenuOn)) { + button->setChecked(deflt > 0); + } else if (auto cb = qobject_cast(m_contextMenuOn)) { + cb->setCurrentIndex(deflt); + } +} + +void PropertyBox::playAudibleChanged(bool audible) { m_playButton->setChecked(audible); diff -r 4739a1b2266f -r a798a7b5e215 widgets/PropertyBox.h --- a/widgets/PropertyBox.h Wed Apr 29 14:23:51 2020 +0100 +++ b/widgets/PropertyBox.h Wed Apr 29 14:46:37 2020 +0100 @@ -54,6 +54,7 @@ protected slots: void propertyControllerChanged(int); void propertyControllerChanged(bool); + void propertyControllerResetRequested(); void playAudibleChanged(bool); void playAudibleButtonChanged(bool); @@ -85,6 +86,7 @@ LEDButton *m_showButton; QToolButton *m_playButton; QMenu *m_lastContextMenu; + QObject *m_contextMenuOn; std::map m_groupLayouts; std::map m_propertyControllers; }; diff -r 4739a1b2266f -r a798a7b5e215 widgets/Thumbwheel.cpp --- a/widgets/Thumbwheel.cpp Wed Apr 29 14:23:51 2020 +0100 +++ b/widgets/Thumbwheel.cpp Wed Apr 29 14:46:37 2020 +0100 @@ -81,14 +81,8 @@ MenuTitle::addTitle(m, m_title); } - m->addAction(tr("&Edit..."), - [=]() { - edit(); - }); - m->addAction(tr("&Reset to Default"), - [=]() { - resetToDefault(); - }); + m->addAction(tr("&Edit..."), this, SLOT(edit())); + m->addAction(tr("&Reset to Default"), this, SLOT(resetToDefault())); m->popup(mapToGlobal(pos)); }