• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mcallegari / qlcplus / 6683238402

29 Oct 2023 12:10PM UTC coverage: 28.07%. Remained the same
6683238402

push

github

mcallegari
engine: fix build

15385 of 54809 relevant lines covered (28.07%)

20267.63 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

41.6
/ui/src/inputselectionwidget.cpp
1
/*
2
  Q Light Controller Plus
3
  inputselectionwidget.cpp
4

5
  Copyright (c) Massimo Callegari
6

7
  Licensed under the Apache License, Version 2.0 (the "License");
8
  you may not use this file except in compliance with the License.
9
  You may obtain a copy of the License at
10

11
      http://www.apache.org/licenses/LICENSE-2.0.txt
12

13
  Unless required by applicable law or agreed to in writing, software
14
  distributed under the License is distributed on an "AS IS" BASIS,
15
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
  See the License for the specific language governing permissions and
17
  limitations under the License.
18
*/
19

20
#include <QDebug>
21

22
#include "inputselectionwidget.h"
23
#include "selectinputchannel.h"
24
#include "qlcinputchannel.h"
25
#include "assignhotkey.h"
26
#include "inputpatch.h"
27
#include "doc.h"
28

29

30
InputSelectionWidget::InputSelectionWidget(Doc *doc, QWidget *parent)
4✔
31
    : QWidget(parent)
32
    , m_doc(doc)
33
    , m_widgetPage(0)
34
    , m_emitOdd(false)
35
    , m_signalsReceived(0)
4✔
36
{
37
    Q_ASSERT(doc != NULL);
4✔
38

39
    setupUi(this);
4✔
40

41
    m_customFbButton->setVisible(false);
4✔
42
    m_feedbackGroup->setVisible(false);
4✔
43
    m_lowerSpin->setEnabled(false);
4✔
44
    m_upperSpin->setEnabled(false);
4✔
45

46
    connect(m_attachKey, SIGNAL(clicked()), this, SLOT(slotAttachKey()));
4✔
47
    connect(m_detachKey, SIGNAL(clicked()), this, SLOT(slotDetachKey()));
4✔
48

49
    connect(m_autoDetectInputButton, SIGNAL(toggled(bool)),
4✔
50
            this, SLOT(slotAutoDetectInputToggled(bool)));
51
    connect(m_chooseInputButton, SIGNAL(clicked()),
4✔
52
            this, SLOT(slotChooseInputClicked()));
53

54
    connect(m_customFbButton, SIGNAL(toggled(bool)),
4✔
55
            this, SLOT(slotCustomFeedbackToggled(bool)));
56
    connect(m_lowerSpin, SIGNAL(valueChanged(int)),
4✔
57
            this, SLOT(slotLowerSpinValueChanged(int)));
58
    connect(m_upperSpin, SIGNAL(valueChanged(int)),
4✔
59
            this, SLOT(slotUpperSpinValueChanged(int)));
60
}
4✔
61

62
InputSelectionWidget::~InputSelectionWidget()
8✔
63
{
64
}
8✔
65

66
void InputSelectionWidget::setKeyInputVisibility(bool visible)
×
67
{
68
    m_keyInputGroup->setVisible(visible);
×
69
}
×
70

71
void InputSelectionWidget::setCustomFeedbackVisibility(bool visible)
4✔
72
{
73
    m_customFbButton->setVisible(visible);
4✔
74
}
4✔
75

76
void InputSelectionWidget::setTitle(QString title)
3✔
77
{
78
    m_extInputGroup->setTitle(title);
3✔
79
}
3✔
80

81
void InputSelectionWidget::setWidgetPage(int page)
4✔
82
{
83
    m_widgetPage = page;
4✔
84
}
4✔
85

86
bool InputSelectionWidget::isAutoDetecting()
×
87
{
88
   return m_autoDetectInputButton->isChecked();
×
89
}
90

91
void InputSelectionWidget::stopAutoDetection()
×
92
{
93
    if (m_autoDetectInputButton->isChecked())
×
94
        m_autoDetectInputButton->toggle();
×
95
}
×
96

97
void InputSelectionWidget::emitOddValues(bool enable)
×
98
{
99
    m_emitOdd = enable;
×
100
}
×
101

102
void InputSelectionWidget::setKeySequence(const QKeySequence &keySequence)
3✔
103
{
104
    m_keySequence = QKeySequence(keySequence);
3✔
105
    m_keyEdit->setText(m_keySequence.toString(QKeySequence::NativeText));
3✔
106
}
3✔
107

108
QKeySequence InputSelectionWidget::keySequence() const
3✔
109
{
110
    return m_keySequence;
3✔
111
}
112

113
void InputSelectionWidget::setInputSource(const QSharedPointer<QLCInputSource> &source)
3✔
114
{
115
    m_inputSource = source;
3✔
116
    updateInputSource();
3✔
117
}
3✔
118

119
QSharedPointer<QLCInputSource> InputSelectionWidget::inputSource() const
3✔
120
{
121
    return m_inputSource;
3✔
122
}
123

124
void InputSelectionWidget::slotAttachKey()
×
125
{
126
    AssignHotKey ahk(this, m_keySequence);
×
127
    if (ahk.exec() == QDialog::Accepted)
×
128
    {
129
        setKeySequence(QKeySequence(ahk.keySequence()));
×
130
        emit keySequenceChanged(m_keySequence);
×
131
    }
132
}
×
133

134
void InputSelectionWidget::slotDetachKey()
×
135
{
136
    setKeySequence(QKeySequence());
×
137
    emit keySequenceChanged(m_keySequence);
×
138
}
×
139

140
void InputSelectionWidget::slotAutoDetectInputToggled(bool checked)
×
141
{
142
    if (checked == true)
×
143
    {
144
        connect(m_doc->inputOutputMap(),
×
145
                SIGNAL(inputValueChanged(quint32,quint32,uchar)),
146
                this, SLOT(slotInputValueChanged(quint32,quint32)));
147
    }
148
    else
149
    {
150
        disconnect(m_doc->inputOutputMap(),
×
151
                   SIGNAL(inputValueChanged(quint32,quint32,uchar)),
152
                   this, SLOT(slotInputValueChanged(quint32,quint32)));
153
    }
154
    emit autoDetectToggled(checked);
×
155
}
×
156

157
void InputSelectionWidget::slotInputValueChanged(quint32 universe, quint32 channel)
×
158
{
159
    if (m_emitOdd == true && m_signalsReceived % 2)
×
160
    {
161
        emit inputValueChanged(universe, (m_widgetPage << 16) | channel);
×
162
        m_signalsReceived++;
×
163
        return;
×
164
    }
165

166
    m_inputSource = QSharedPointer<QLCInputSource>(new QLCInputSource(universe, (m_widgetPage << 16) | channel));
×
167
    updateInputSource();
×
168
    m_signalsReceived++;
×
169

170
    if (m_emitOdd == false)
×
171
        emit inputValueChanged(universe, (m_widgetPage << 16) | channel);
×
172
}
173

174
void InputSelectionWidget::slotChooseInputClicked()
×
175
{
176
    SelectInputChannel sic(this, m_doc->inputOutputMap());
×
177
    if (sic.exec() == QDialog::Accepted)
×
178
    {
179
        m_inputSource = QSharedPointer<QLCInputSource>(new QLCInputSource(sic.universe(), (m_widgetPage << 16) | sic.channel()));
×
180
        updateInputSource();
×
181
        emit inputValueChanged(sic.universe(), (m_widgetPage << 16) | sic.channel());
×
182
    }
183
}
×
184

185
void InputSelectionWidget::slotCustomFeedbackToggled(bool checked)
×
186
{
187
    m_feedbackGroup->setVisible(checked);
×
188
}
×
189

190
void InputSelectionWidget::slotLowerSpinValueChanged(int value)
×
191
{
192
    m_inputSource->setRange(uchar(value), uchar(m_upperSpin->value()));
×
193
}
×
194

195
void InputSelectionWidget::slotUpperSpinValueChanged(int value)
×
196
{
197
    m_inputSource->setRange(uchar(m_lowerSpin->value()), uchar(value));
×
198
}
×
199

200
void InputSelectionWidget::updateInputSource()
3✔
201
{
202
    QString uniName;
6✔
203
    QString chName;
6✔
204

205
    if (!m_inputSource || m_doc->inputOutputMap()->inputSourceNames(m_inputSource, uniName, chName) == false)
3✔
206
    {
207
        uniName = KInputNone;
3✔
208
        chName = KInputNone;
3✔
209
        m_lowerSpin->setEnabled(false);
3✔
210
        m_upperSpin->setEnabled(false);
3✔
211
        m_customFbButton->setChecked(false);
3✔
212
        m_feedbackGroup->setVisible(false);
3✔
213
    }
214
    else
215
    {
216
        m_lowerSpin->blockSignals(true);
×
217
        m_upperSpin->blockSignals(true);
×
218

219
        uchar min = 0, max = UCHAR_MAX;
×
220

221
        InputPatch *ip = m_doc->inputOutputMap()->inputPatch(m_inputSource->universe());
×
222
        if (ip != NULL && ip->profile() != NULL)
×
223
        {
224
            QLCInputChannel *ich = ip->profile()->channel(m_inputSource->channel());
×
225
            if (ich != NULL && ich->type() == QLCInputChannel::Button)
×
226
            {
227
                min = ich->lowerValue();
×
228
                max = ich->upperValue();
×
229
            }
230
        }
231
        m_lowerSpin->setValue((m_inputSource->lowerValue() != 0) ? m_inputSource->lowerValue() : min);
×
232
        m_upperSpin->setValue((m_inputSource->upperValue() != UCHAR_MAX) ? m_inputSource->upperValue() : max);
×
233
        if (m_lowerSpin->value() != 0 || m_upperSpin->value() != UCHAR_MAX)
×
234
        {
235
            m_customFbButton->setChecked(true);
×
236
        }
237
        else
238
        {
239
            m_customFbButton->setChecked(false);
×
240
            m_feedbackGroup->setVisible(false);
×
241
        }
242
        m_lowerSpin->blockSignals(false);
×
243
        m_upperSpin->blockSignals(false);
×
244
        m_lowerSpin->setEnabled(true);
×
245
        m_upperSpin->setEnabled(true);
×
246
    }
247

248
    m_inputUniverseEdit->setText(uniName);
3✔
249
    m_inputChannelEdit->setText(chName);
3✔
250
}
3✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc