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

mcallegari / qlcplus / 8961243534

05 May 2024 09:23PM UTC coverage: 32.068% (+4.0%) from 28.094%
8961243534

push

github

mcallegari
Merge branch 'master' into qmltoqt6

902 of 2557 new or added lines in 140 files covered. (35.28%)

166 existing lines in 76 files now uncovered.

15395 of 48008 relevant lines covered (32.07%)

22949.67 hits per line

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

NEW
129
CustomFeedbackDialog::~CustomFeedbackDialog()
×
130
{
NEW
131
}
×
132

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

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

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

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

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

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

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

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

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

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

© 2025 Coveralls, Inc