Skip to content

Commit 29dfa14

Browse files
authored
Merge pull request #1103 from ditcheshurt/master
Completed adding button monitor feedback for midi controllers
2 parents fa51c43 + 863c0ae commit 29dfa14

8 files changed

+97
-31
lines changed

engine/src/qlcinputsource.cpp

+10
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ void QLCInputSource::setRange(uchar lower, uchar upper)
126126
m_upper = upper;
127127
}
128128

129+
void QLCInputSource::setMonitor(uchar monitor)
130+
{
131+
m_monitor = monitor;
132+
}
133+
129134
uchar QLCInputSource::lowerValue() const
130135
{
131136
return m_lower;
@@ -136,6 +141,11 @@ uchar QLCInputSource::upperValue() const
136141
return m_upper;
137142
}
138143

144+
uchar QLCInputSource::monitorValue() const
145+
{
146+
return m_monitor;
147+
}
148+
139149
/*********************************************************************
140150
* Working mode
141151
*********************************************************************/

engine/src/qlcinputsource.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,11 @@ class QLCInputSource: public QThread
7979
void setRange(uchar lower, uchar upper);
8080
uchar lowerValue() const;
8181
uchar upperValue() const;
82+
void setMonitor(uchar monitor);
83+
uchar monitorValue() const;
8284

8385
protected:
84-
uchar m_lower, m_upper;
86+
uchar m_lower, m_upper, m_monitor;
8587

8688
/*********************************************************************
8789
* Working mode

ui/src/inputselectionwidget.cpp

+14-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ InputSelectionWidget::InputSelectionWidget(Doc *doc, QWidget *parent)
4242
m_feedbackGroup->setVisible(false);
4343
m_lowerSpin->setEnabled(false);
4444
m_upperSpin->setEnabled(false);
45+
m_monitorSpin->setEnabled(false);
4546

4647
connect(m_attachKey, SIGNAL(clicked()), this, SLOT(slotAttachKey()));
4748
connect(m_detachKey, SIGNAL(clicked()), this, SLOT(slotDetachKey()));
@@ -57,6 +58,8 @@ InputSelectionWidget::InputSelectionWidget(Doc *doc, QWidget *parent)
5758
this, SLOT(slotLowerSpinValueChanged(int)));
5859
connect(m_upperSpin, SIGNAL(valueChanged(int)),
5960
this, SLOT(slotUpperSpinValueChanged(int)));
61+
connect(m_monitorSpin, SIGNAL(valueChanged(int)),
62+
this, SLOT(slotMonitorSpinValueChanged(int)));
6063
}
6164

6265
InputSelectionWidget::~InputSelectionWidget()
@@ -197,6 +200,11 @@ void InputSelectionWidget::slotUpperSpinValueChanged(int value)
197200
m_inputSource->setRange(uchar(m_lowerSpin->value()), uchar(value));
198201
}
199202

203+
void InputSelectionWidget::slotMonitorSpinValueChanged(int value)
204+
{
205+
m_inputSource->setMonitor(uchar(value));
206+
}
207+
200208
void InputSelectionWidget::updateInputSource()
201209
{
202210
QString uniName;
@@ -208,15 +216,17 @@ void InputSelectionWidget::updateInputSource()
208216
chName = KInputNone;
209217
m_lowerSpin->setEnabled(false);
210218
m_upperSpin->setEnabled(false);
219+
m_monitorSpin->setEnabled(false);
211220
m_customFbButton->setChecked(false);
212221
m_feedbackGroup->setVisible(false);
213222
}
214223
else
215224
{
216225
m_lowerSpin->blockSignals(true);
217226
m_upperSpin->blockSignals(true);
227+
m_monitorSpin->blockSignals(true);
218228

219-
uchar min = 0, max = UCHAR_MAX;
229+
uchar min = 0, max = UCHAR_MAX, mon = UCHAR_MAX;
220230

221231
InputPatch *ip = m_doc->inputOutputMap()->inputPatch(m_inputSource->universe());
222232
if (ip != NULL && ip->profile() != NULL)
@@ -230,6 +240,7 @@ void InputSelectionWidget::updateInputSource()
230240
}
231241
m_lowerSpin->setValue((m_inputSource->lowerValue() != 0) ? m_inputSource->lowerValue() : min);
232242
m_upperSpin->setValue((m_inputSource->upperValue() != UCHAR_MAX) ? m_inputSource->upperValue() : max);
243+
m_monitorSpin->setValue((m_inputSource->monitorValue() != UCHAR_MAX) ? m_inputSource->monitorValue() : mon);
233244
if (m_lowerSpin->value() != 0 || m_upperSpin->value() != UCHAR_MAX)
234245
{
235246
m_customFbButton->setChecked(true);
@@ -241,8 +252,10 @@ void InputSelectionWidget::updateInputSource()
241252
}
242253
m_lowerSpin->blockSignals(false);
243254
m_upperSpin->blockSignals(false);
255+
m_monitorSpin->blockSignals(false);
244256
m_lowerSpin->setEnabled(true);
245257
m_upperSpin->setEnabled(true);
258+
m_monitorSpin->setEnabled(true);
246259
}
247260

248261
m_inputUniverseEdit->setText(uniName);

ui/src/inputselectionwidget.h

+1
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ protected slots:
6161
void slotCustomFeedbackToggled(bool checked);
6262
void slotLowerSpinValueChanged(int value);
6363
void slotUpperSpinValueChanged(int value);
64+
void slotMonitorSpinValueChanged(int value);
6465

6566
signals:
6667
void autoDetectToggled(bool checked);

ui/src/inputselectionwidget.ui

+48-18
Original file line numberDiff line numberDiff line change
@@ -171,21 +171,39 @@
171171
<property name="title">
172172
<string>Custom feedback</string>
173173
</property>
174-
<layout class="QGridLayout" name="gridLayout_3">
175-
<property name="topMargin">
176-
<number>3</number>
177-
</property>
178-
<property name="bottomMargin">
179-
<number>3</number>
180-
</property>
181-
<item row="0" column="0">
174+
<layout class="QHBoxLayout" name="horizontalLayout_2">
175+
<item>
182176
<widget class="QLabel" name="label">
177+
<property name="font">
178+
<font>
179+
<pointsize>10</pointsize>
180+
</font>
181+
</property>
182+
<property name="text">
183+
<string>Lower</string>
184+
</property>
185+
</widget>
186+
</item>
187+
<item>
188+
<widget class="QSpinBox" name="m_lowerSpin">
189+
<property name="maximum">
190+
<number>255</number>
191+
</property>
192+
</widget>
193+
</item>
194+
<item>
195+
<widget class="QLabel" name="label_2">
196+
<property name="font">
197+
<font>
198+
<pointsize>10</pointsize>
199+
</font>
200+
</property>
183201
<property name="text">
184-
<string>Lower value</string>
202+
<string>Upper</string>
185203
</property>
186204
</widget>
187205
</item>
188-
<item row="0" column="3">
206+
<item>
189207
<widget class="QSpinBox" name="m_upperSpin">
190208
<property name="minimum">
191209
<number>0</number>
@@ -198,21 +216,33 @@
198216
</property>
199217
</widget>
200218
</item>
201-
<item row="0" column="1">
202-
<widget class="QSpinBox" name="m_lowerSpin">
203-
<property name="maximum">
204-
<number>255</number>
219+
<item>
220+
<widget class="QLabel" name="label_3">
221+
<property name="font">
222+
<font>
223+
<pointsize>10</pointsize>
224+
</font>
225+
</property>
226+
<property name="text">
227+
<string>Monitor</string>
205228
</property>
206229
</widget>
207230
</item>
208-
<item row="0" column="2">
209-
<widget class="QLabel" name="label_2">
210-
<property name="text">
211-
<string>Upper value</string>
231+
<item>
232+
<widget class="QSpinBox" name="m_monitorSpin">
233+
<property name="maximum">
234+
<number>255</number>
212235
</property>
213236
</widget>
214237
</item>
215238
</layout>
239+
<zorder>m_upperSpin</zorder>
240+
<zorder>m_lowerSpin</zorder>
241+
<zorder>label_2</zorder>
242+
<zorder>label</zorder>
243+
<zorder>m_monitorSpin</zorder>
244+
<zorder>label_3</zorder>
245+
<zorder>m_keyInputGroup</zorder>
216246
</widget>
217247
</item>
218248
<item row="1" column="1" colspan="4">

ui/src/virtualconsole/vcbutton.cpp

+7-4
Original file line numberDiff line numberDiff line change
@@ -516,16 +516,19 @@ void VCButton::slotKeyReleased(const QKeySequence& keySequence)
516516

517517
void VCButton::updateFeedback()
518518
{
519-
if (m_state == Monitoring)
520-
return;
519+
//if (m_state == Monitoring)
520+
// return;
521521

522522
QSharedPointer<QLCInputSource> src = inputSource();
523523
if (!src.isNull() && src->isValid() == true)
524524
{
525-
if (m_state == Inactive)
525+
if (m_state == Inactive) {
526526
sendFeedback(src->lowerValue());
527-
else
527+
} else if (m_state == Monitoring) {
528+
sendFeedback(src->monitorValue());
529+
} else {
528530
sendFeedback(src->upperValue());
531+
}
529532
}
530533
}
531534

ui/src/virtualconsole/vcwidget.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -885,15 +885,18 @@ QSharedPointer<QLCInputSource> VCWidget::getXMLInput(QXmlStreamReader &root)
885885

886886
quint32 uni = attrs.value(KXMLQLCVCWidgetInputUniverse).toString().toUInt();
887887
quint32 ch = attrs.value(KXMLQLCVCWidgetInputChannel).toString().toUInt();
888-
uchar min = 0, max = UCHAR_MAX;
888+
uchar min = 0, max = UCHAR_MAX, mon = UCHAR_MAX;
889889

890890
QSharedPointer<QLCInputSource>newSrc = QSharedPointer<QLCInputSource>(new QLCInputSource(uni, ch));
891891
if (attrs.hasAttribute(KXMLQLCVCWidgetInputLowerValue))
892892
min = uchar(attrs.value(KXMLQLCVCWidgetInputLowerValue).toString().toUInt());
893893
if (attrs.hasAttribute(KXMLQLCVCWidgetInputUpperValue))
894894
max = uchar(attrs.value(KXMLQLCVCWidgetInputUpperValue).toString().toUInt());
895+
if (attrs.hasAttribute(KXMLQLCVCWidgetInputMonitorValue))
896+
mon = uchar(attrs.value(KXMLQLCVCWidgetInputMonitorValue).toString().toUInt());
895897

896898
newSrc->setRange(min, max);
899+
newSrc->setMonitor(mon);
897900

898901
return newSrc;
899902
}
@@ -1041,6 +1044,9 @@ bool VCWidget::saveXMLInput(QXmlStreamWriter *doc,
10411044
doc->writeAttribute(KXMLQLCVCWidgetInputLowerValue, QString::number(src->lowerValue()));
10421045
if (src->upperValue() != UCHAR_MAX)
10431046
doc->writeAttribute(KXMLQLCVCWidgetInputUpperValue, QString::number(src->upperValue()));
1047+
if (src->monitorValue() != UCHAR_MAX)
1048+
doc->writeAttribute(KXMLQLCVCWidgetInputMonitorValue, QString::number(src->monitorValue()));
1049+
10441050
doc->writeEndElement();
10451051
}
10461052

ui/src/virtualconsole/vcwidget.h

+7-6
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,13 @@ class QFile;
5959
#define KVCFrameStyleRaised (QFrame::Panel | QFrame::Raised)
6060
#define KVCFrameStyleNone (QFrame::NoFrame)
6161

62-
#define KXMLQLCVCWidgetKey QString("Key")
63-
#define KXMLQLCVCWidgetInput QString("Input")
64-
#define KXMLQLCVCWidgetInputUniverse QString("Universe")
65-
#define KXMLQLCVCWidgetInputChannel QString("Channel")
66-
#define KXMLQLCVCWidgetInputLowerValue QString("LowerValue")
67-
#define KXMLQLCVCWidgetInputUpperValue QString("UpperValue")
62+
#define KXMLQLCVCWidgetKey QString("Key")
63+
#define KXMLQLCVCWidgetInput QString("Input")
64+
#define KXMLQLCVCWidgetInputUniverse QString("Universe")
65+
#define KXMLQLCVCWidgetInputChannel QString("Channel")
66+
#define KXMLQLCVCWidgetInputLowerValue QString("LowerValue")
67+
#define KXMLQLCVCWidgetInputUpperValue QString("UpperValue")
68+
#define KXMLQLCVCWidgetInputMonitorValue QString("MonitorValue")
6869

6970
#define KXMLQLCWindowState QString("WindowState")
7071
#define KXMLQLCWindowStateVisible QString("Visible")

0 commit comments

Comments
 (0)