summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerran Pujol Camins <ferranpujolcamins@gmail.com>2023-06-10 16:35:39 +0200
committerFerran Pujol Camins <ferranpujolcamins@gmail.com>2023-06-10 16:35:39 +0200
commit6eed9dc13ab15021e811ad243b47cc70bb34286e (patch)
tree0631e0f90686a434633d8ea014f8855ecb79fe11
parent018cb521b27bc1e7b1abf37c039a8de179fd97da (diff)
Remove usage of ControlObject::getControl
-rw-r--r--src/controllers/controllerlearningeventfilter.cpp21
-rw-r--r--src/controllers/controllerlearningeventfilter.h2
-rw-r--r--src/controllers/dlgcontrollerlearning.cpp16
-rw-r--r--src/controllers/dlgcontrollerlearning.h2
4 files changed, 19 insertions, 22 deletions
diff --git a/src/controllers/controllerlearningeventfilter.cpp b/src/controllers/controllerlearningeventfilter.cpp
index 64828e53ac..4539d03e82 100644
--- a/src/controllers/controllerlearningeventfilter.cpp
+++ b/src/controllers/controllerlearningeventfilter.cpp
@@ -4,6 +4,7 @@
#include <QMouseEvent>
#include <QtDebug>
+#include "control/pollingcontrolproxy.h"
#include "moc_controllerlearningeventfilter.cpp"
#include "widget/wknob.h"
#include "widget/wknobcomposed.h"
@@ -19,7 +20,7 @@ ControllerLearningEventFilter::~ControllerLearningEventFilter() {
}
bool ControllerLearningEventFilter::eventFilter(QObject* pObject, QEvent* pEvent) {
- //qDebug() << "ControllerLearningEventFilter::eventFilter" << pObject << pEvent;
+ // qDebug() << "ControllerLearningEventFilter::eventFilter" << pObject << pEvent;
WWidget* pWidget = qobject_cast<WWidget*>(pObject);
if (!pWidget || !m_bListening) {
@@ -42,10 +43,10 @@ bool ControllerLearningEventFilter::eventFilter(QObject* pObject, QEvent* pEvent
if (info.leftClickControl) {
ConfigKey key = info.leftClickControl->getKey();
qDebug() << "Left-click maps MIDI to:" << key.group << key.item;
- emit controlClicked(info.leftClickControl);
+ emit controlClicked(key);
} else if (info.clickControl) {
ConfigKey key = info.clickControl->getKey();
- emit controlClicked(info.clickControl);
+ emit controlClicked(key);
qDebug() << "Default-click maps MIDI to:" << key.group << key.item;
} else {
qDebug() << "No control bound to left-click for" << pWidget;
@@ -55,7 +56,7 @@ bool ControllerLearningEventFilter::eventFilter(QObject* pObject, QEvent* pEvent
if (info.rightClickControl) {
ConfigKey key = info.rightClickControl->getKey();
qDebug() << "Right-click maps MIDI to:" << key.group << key.item;
- emit controlClicked(info.rightClickControl);
+ emit controlClicked(key);
} else if (has_right_click_reset && (info.leftClickControl || info.clickControl)) {
// WKnob and WSliderComposed emits a reset signal on
// right-click. For controls that are derived from
@@ -67,15 +68,15 @@ bool ControllerLearningEventFilter::eventFilter(QObject* pObject, QEvent* pEvent
}
ConfigKey key = pControl->getKey();
key.item = key.item + "_set_default";
- ControlObject* pResetControl = ControlObject::getControl(key);
- if (pResetControl) {
+ auto pResetControl = PollingControlProxy(key, ControlFlag::AllowMissingOrInvalid);
+ if (pResetControl.valid()) {
qDebug() << "Right-click reset maps MIDI to:" << key.group << key.item;
- emit controlClicked(pResetControl);
+ emit controlClicked(key);
}
} else if (info.clickControl) {
ConfigKey key = info.clickControl->getKey();
qDebug() << "Default-click maps MIDI to:" << key.group << key.item;
- emit controlClicked(info.clickControl);
+ emit controlClicked(key);
} else {
qDebug() << "No control bound to right-click for" << pWidget;
}
@@ -88,8 +89,8 @@ bool ControllerLearningEventFilter::eventFilter(QObject* pObject, QEvent* pEvent
return false;
}
-void ControllerLearningEventFilter::addWidgetClickInfo(
- QWidget* pWidget, Qt::MouseButton buttonState,
+void ControllerLearningEventFilter::addWidgetClickInfo(QWidget* pWidget,
+ Qt::MouseButton buttonState,
ControlObject* pControl,
ControlParameterWidgetConnection::EmitOption emitOption) {
ControlInfo& info = m_widgetControlInfo[pWidget];
diff --git a/src/controllers/controllerlearningeventfilter.h b/src/controllers/controllerlearningeventfilter.h
index dc22e36a53..9d2d51228d 100644
--- a/src/controllers/controllerlearningeventfilter.h
+++ b/src/controllers/controllerlearningeventfilter.h
@@ -41,7 +41,7 @@ class ControllerLearningEventFilter : public QObject {
void stopListening();
signals:
- void controlClicked(ControlObject* pControl);
+ void controlClicked(const ConfigKey& controlKey);
private:
QHash<QWidget*, ControlInfo> m_widgetControlInfo;
diff --git a/src/controllers/dlgcontrollerlearning.cpp b/src/controllers/dlgcontrollerlearning.cpp
index 1226856270..63c37ff848 100644
--- a/src/controllers/dlgcontrollerlearning.cpp
+++ b/src/controllers/dlgcontrollerlearning.cpp
@@ -487,15 +487,11 @@ void DlgControllerLearning::controlPicked(const ConfigKey& control) {
loadControl(control, title, description);
}
-void DlgControllerLearning::controlClicked(ControlObject* pControl) {
- if (!pControl) {
- return;
- }
-
- ConfigKey key = pControl->getKey();
- if (!m_pControlPickerMenu->controlExists(key)) {
+void DlgControllerLearning::controlClicked(const ConfigKey& controlKey) {
+ if (!m_pControlPickerMenu->controlExists(controlKey)) {
qWarning() << "Mixxx UI element clicked for which there is no "
- "learnable control " << key.group << " " << key.item;
+ "learnable control "
+ << controlKey.group << " " << controlKey.item;
QMessageBox::warning(
this,
VersionStore::applicationName(),
@@ -506,12 +502,12 @@ void DlgControllerLearning::controlClicked(ControlObject* pControl) {
" and can only be mapped to outputs like LEDs via"
" scripts.\n"
"\nYou tried to learn: %1,%2")
- .arg(key.group, key.item),
+ .arg(controlKey.group, controlKey.item),
QMessageBox::Ok,
QMessageBox::Ok);
return;
}
- controlPicked(key);
+ controlPicked(controlKey);
}
void DlgControllerLearning::comboboxIndexChanged(int index) {
diff --git a/src/controllers/dlgcontrollerlearning.h b/src/controllers/dlgcontrollerlearning.h
index d530a783b2..0f11922b19 100644
--- a/src/controllers/dlgcontrollerlearning.h
+++ b/src/controllers/dlgcontrollerlearning.h
@@ -49,7 +49,7 @@ class DlgControllerLearning : public QDialog,
// Triggered when the user picks a control from the menu.
void controlPicked(const ConfigKey& control);
// Triggered when user clicks a control from the GUI
- void controlClicked(ControlObject* pControl);
+ void controlClicked(const ConfigKey& controlKey);
void comboboxIndexChanged(int index);
void slotMessageReceived(unsigned char status,