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

mcallegari / qlcplus / 8103290030

29 Feb 2024 10:11PM UTC coverage: 32.036% (+0.05%) from 31.988%
8103290030

push

github

mcallegari
qmlui: fix to build with latest changes

15332 of 47859 relevant lines covered (32.04%)

23585.55 hits per line

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

0.0
/ui/src/customfeedbacksdialog.cpp
1
/*
2
  Q Light Controller Plus
3
  customfeedbacksdialog.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 "customfeedbacksdialog.h"
21
#include "qlcinputchannel.h"
22
#include "qlcinputsource.h"
23
#include "doc.h"
24

25
CustomFeedbacksDialog::CustomFeedbacksDialog(Doc *doc, const QSharedPointer<QLCInputSource> &source, QWidget *parent)
×
26
    : QDialog(parent)
27
    , m_doc(doc)
28
    , m_profile(NULL)
29
    , m_inputSource(source)
30
    , m_selectedFeedback(None)
×
31
{
32
    setupUi(this);
×
33

34
    bool enableControls = source.isNull() ? false : true;
×
35

36
    if (enableControls)
×
37
    {
38
        m_lowerSpin->setValue(m_inputSource->feedbackValue(QLCInputFeedback::LowerValue));
×
39
        m_upperSpin->setValue(m_inputSource->feedbackValue(QLCInputFeedback::UpperValue));
×
40
        m_monitorSpin->setValue(m_inputSource->feedbackValue(QLCInputFeedback::MonitorValue));
×
41
    }
42

43
    m_lowerSpin->setEnabled(enableControls);
×
44
    m_upperSpin->setEnabled(enableControls);
×
45

46
    m_monitorLabel->setVisible(false);
×
47
    m_monitorSpin->setVisible(false);
×
48
    m_monitorChannelCombo->setVisible(false);
×
49
    m_profileColorsTree->setVisible(false);
×
50
    m_midiChannelGroup->hide();
×
51

52
    if (enableControls)
×
53
    {
54
        InputPatch *ip = m_doc->inputOutputMap()->inputPatch(m_inputSource->universe());
×
55
        if (ip != NULL && ip->profile() != NULL)
×
56
        {
57
            m_profile = ip->profile();
×
58
            if (m_profile->hasColorTable())
×
59
            {
60
                m_lowerColor->setVisible(true);
×
61
                m_upperColor->setVisible(true);
×
62

63
                QMapIterator <uchar, QPair<QString, QColor>> it(m_profile->colorTable());
×
64
                while (it.hasNext() == true)
×
65
                {
66
                    it.next();
×
67
                    QPair<QString, QColor> lc = it.value();
×
68
                    QTreeWidgetItem *item = new QTreeWidgetItem(m_profileColorsTree);
×
69
                    item->setText(0, QString::number(it.key()));
×
70
                    item->setText(1, lc.first);
×
71

72
                    QLabel *colLabel = new QLabel();
×
73
                    colLabel->setStyleSheet(QString("background-color: %1").arg(lc.second.name()));
×
74

75
                    if (it.key() == m_inputSource->feedbackValue(QLCInputFeedback::LowerValue))
×
76
                        m_lowerColor->setStyleSheet(QString("background-color: %1").arg(lc.second.name()));
×
77

78
                    if (it.key() == m_inputSource->feedbackValue(QLCInputFeedback::UpperValue))
×
79
                        m_upperColor->setStyleSheet(QString("background-color: %1").arg(lc.second.name()));
×
80

81
                    if (it.key() == m_inputSource->feedbackValue(QLCInputFeedback::MonitorValue))
×
82
                        m_monitorColor->setStyleSheet(QString("background-color: %1").arg(lc.second.name()));
×
83

84
                    m_profileColorsTree->setItemWidget(item, 2, colLabel);
×
85
                }
86
            }
87
            if (m_profile->type() == QLCInputProfile::MIDI && m_profile->hasMidiChannelTable())
×
88
            {
89
                m_midiChannelGroup->show();
×
90
                m_lowerChannelCombo->addItem(tr("From plugin settings"));
×
91
                m_upperChannelCombo->addItem(tr("From plugin settings"));
×
92
                m_monitorChannelCombo->addItem(tr("From plugin settings"));
×
93

94
                QMapIterator <uchar, QString> it(m_profile->midiChannelTable());
×
95
                while (it.hasNext() == true)
×
96
                {
97
                    it.next();
×
98
                    m_lowerChannelCombo->addItem(it.value());
×
99
                    m_upperChannelCombo->addItem(it.value());
×
100
                    m_monitorChannelCombo->addItem(it.value());
×
101
                }
102

103
                QVariant extraParams = m_inputSource->feedbackExtraParams(QLCInputFeedback::LowerValue);
×
104
                if (extraParams.isValid())
×
105
                    m_lowerChannelCombo->setCurrentIndex(extraParams.toInt() + 1);
×
106

107
                extraParams = m_inputSource->feedbackExtraParams(QLCInputFeedback::UpperValue);
×
108
                if (extraParams.isValid())
×
109
                    m_upperChannelCombo->setCurrentIndex(extraParams.toInt() + 1);
×
110

111
                extraParams = m_inputSource->feedbackExtraParams(QLCInputFeedback::MonitorValue);
×
112
                if (extraParams.isValid())
×
113
                    m_monitorChannelCombo->setCurrentIndex(extraParams.toInt() + 1);
×
114
            }
115
        }
116
    }
117

118
    // connect signals
119
    connect(m_lowerColor, SIGNAL(clicked()),
×
120
            this, SLOT(slotLowerColorButtonClicked()));
121
    connect(m_upperColor, SIGNAL(clicked()),
×
122
            this, SLOT(slotUpperColorButtonClicked()));
123
    connect(m_monitorColor, SIGNAL(clicked()),
×
124
            this, SLOT(slotMonitorColorButtonClicked()));
125
    connect(m_profileColorsTree, SIGNAL(itemClicked(QTreeWidgetItem *, int)),
×
126
            this, SLOT(slotColorSelected(QTreeWidgetItem *)));
127
}
×
128

129
CustomFeedbacksDialog::~CustomFeedbacksDialog()
×
130
{
131
}
×
132

133
void CustomFeedbacksDialog::setMonitoringVisibility(bool visible)
×
134
{
135
    m_monitorLabel->setVisible(visible);
×
136
    m_monitorSpin->setVisible(visible);
×
137
    m_monitorChannelCombo->setVisible(visible);
×
138
}
×
139

140
void CustomFeedbacksDialog::accept()
×
141
{
142
    if (m_inputSource.isNull())
×
143
        return;
×
144

145
    m_inputSource->setFeedbackValue(QLCInputFeedback::LowerValue, m_lowerSpin->value());
×
146
    m_inputSource->setFeedbackValue(QLCInputFeedback::UpperValue, m_upperSpin->value());
×
147
    if (m_monitorSpin->isVisible())
×
148
        m_inputSource->setFeedbackValue(QLCInputFeedback::MonitorValue, m_monitorSpin->value());
×
149

150
    if (m_midiChannelGroup->isVisible())
×
151
    {
152
        m_inputSource->setFeedbackExtraParams(QLCInputFeedback::LowerValue, m_lowerChannelCombo->currentIndex() - 1);
×
153
        m_inputSource->setFeedbackExtraParams(QLCInputFeedback::UpperValue, m_upperChannelCombo->currentIndex() - 1);
×
154
        if (m_monitorSpin->isVisible())
×
155
            m_inputSource->setFeedbackExtraParams(QLCInputFeedback::MonitorValue, m_monitorChannelCombo->currentIndex() - 1);
×
156
    }
157

158
    QDialog::accept();
×
159
}
160

161
void CustomFeedbacksDialog::slotLowerColorButtonClicked()
×
162
{
163
    m_selectedFeedback = LowerValue;
×
164
    m_profileColorsTree->setVisible(true);
×
165
}
×
166

167
void CustomFeedbacksDialog::slotUpperColorButtonClicked()
×
168
{
169
    m_selectedFeedback = UpperValue;
×
170
    m_profileColorsTree->setVisible(true);
×
171
}
×
172

173
void CustomFeedbacksDialog::slotMonitorColorButtonClicked()
×
174
{
175
    m_selectedFeedback = MonitoringValue;
×
176
    m_profileColorsTree->setVisible(true);
×
177
}
×
178

179
void CustomFeedbacksDialog::slotColorSelected(QTreeWidgetItem *item)
×
180
{
181
    QLabel *label = qobject_cast<QLabel *>(m_profileColorsTree->itemWidget(item, 2));
×
182

183
    if (m_selectedFeedback == LowerValue)
×
184
    {
185
        m_lowerSpin->setValue(item->text(0).toInt());
×
186
        m_lowerColor->setStyleSheet(label->styleSheet());
×
187
    }
188
    else if (m_selectedFeedback == UpperValue)
×
189
    {
190
        m_upperSpin->setValue(item->text(0).toInt());
×
191
        m_upperColor->setStyleSheet(label->styleSheet());
×
192
    }
193
    else if (m_selectedFeedback == MonitoringValue)
×
194
    {
195
        m_monitorSpin->setValue(item->text(0).toInt());
×
196
        m_monitorColor->setStyleSheet(label->styleSheet());
×
197
    }
198
    m_profileColorsTree->setVisible(false);
×
199
    m_selectedFeedback = None;
×
200
}
×
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