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

mcallegari / qlcplus / 19144422256

06 Nov 2025 05:33PM UTC coverage: 34.256% (-0.1%) from 34.358%
19144422256

push

github

mcallegari
Back to 5.1.0 debug

17718 of 51723 relevant lines covered (34.26%)

19528.23 hits per line

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

0.0
/ui/src/addrgbpanel.cpp
1
/*
2
  Q Light Controller Plus
3
  addrgbpanel.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 <QPushButton>
21
#include <QDebug>
22
#include <QSettings>
23

24
#include <math.h>
25

26
#include "addrgbpanel.h"
27
#include "doc.h"
28

29
#define SETTINGS_GEOMETRY "addrgbpanel/geometry"
30

31
AddRGBPanel::AddRGBPanel(QWidget *parent, const Doc *doc)
×
32
    : QDialog(parent)
33
    , m_doc(doc)
×
34
{
35
    setupUi(this);
×
36

37
    /* Fill universe combo with available universes */
38
    m_uniCombo->addItems(m_doc->inputOutputMap()->universeNames());
×
39

40
    m_compCombo->addItem("RGB");
×
41
    m_compCombo->addItem("BGR");
×
42
    m_compCombo->addItem("BRG");
×
43
    m_compCombo->addItem("GBR");
×
44
    m_compCombo->addItem("GRB");
×
45
    m_compCombo->addItem("RBG");
×
46
    m_compCombo->addItem("RGBW");
×
47

48
    checkAddressAvailability();
×
49

50
    QSettings settings;
×
51
    QVariant geometrySettings = settings.value(SETTINGS_GEOMETRY);
×
52
    if (geometrySettings.isValid() == true)
×
53
        restoreGeometry(geometrySettings.toByteArray());
×
54

55
    connect(m_uniCombo, SIGNAL(currentIndexChanged(int)),
×
56
            this, SLOT(slotUniverseChanged()));
57
    connect(m_compCombo, SIGNAL(currentIndexChanged(int)),
×
58
            this, SLOT(slotComponentsChanged()));
59
#if (QT_VERSION < QT_VERSION_CHECK(6, 7, 0))
60
    connect(m_16bitCheck, SIGNAL(stateChanged(int)),
61
            this, SLOT(slotComponentsChanged()));
62
#else
63
    connect(m_16bitCheck, SIGNAL(checkStateChanged(Qt::CheckState)),
×
64
            this, SLOT(slotComponentsChanged()));
65
#endif
66
    connect(m_addressSpin, SIGNAL(valueChanged(int)),
×
67
            this, SLOT(slotAddressChanged()));
68
    connect(m_columnSpin, SIGNAL(valueChanged(int)),
×
69
            this, SLOT(slotSizeChanged(int)));
70
    connect(m_rowSpin, SIGNAL(valueChanged(int)),
×
71
            this, SLOT(slotSizeChanged(int)));
72
}
×
73

74
AddRGBPanel::~AddRGBPanel()
×
75
{
76
    QSettings settings;
×
77
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
×
78
}
×
79
bool AddRGBPanel::checkAddressAvailability()
×
80
{
81
    int uniAddr = m_doc->inputOutputMap()->getUniverseID(m_uniCombo->currentIndex());
×
82
    int startAddress = ((m_addressSpin->value() - 1) & 0x01FF) | (uniAddr << 9);
×
83
    int channels = m_columnSpin->value() * m_rowSpin->value() * 3;
×
84
    QPushButton *okBtn = buttonBox->button(QDialogButtonBox::Ok);
×
85

86
    qDebug() << "Check availability for address: " << startAddress;
×
87

88
    for (int i = 0; i < channels; i++)
×
89
    {
90
        quint32 fid = m_doc->fixtureForAddress(startAddress + i);
×
91
        if (fid != Fixture::invalidId())
×
92
        {
93
            m_addrErrorLabel->show();
×
94
            okBtn->setEnabled(false);
×
95
            return false;
×
96
        }
97
    }
98
    m_addrErrorLabel->hide();
×
99
    okBtn->setEnabled(true);
×
100
    return true;
×
101
}
102

103
void AddRGBPanel::slotUniverseChanged()
×
104
{
105
    checkAddressAvailability();
×
106
}
×
107

108
void AddRGBPanel::slotComponentsChanged()
×
109
{
110
    int dmxChannelsPerPixel = 3;
×
111
    if (m_compCombo->currentIndex() == 6) // RGBW
×
112
        dmxChannelsPerPixel = 4;
×
113

114
    if (m_16bitCheck->isChecked())
×
115
        dmxChannelsPerPixel *= 2;
×
116

117
    m_columnSpin->setMaximum(floor(UNIVERSE_SIZE / dmxChannelsPerPixel));
×
118

119
    if (m_columnSpin->value() > m_columnSpin->maximum())
×
120
        m_columnSpin->setValue(m_columnSpin->maximum());
×
121
}
×
122

123
void AddRGBPanel::slotAddressChanged()
×
124
{
125
    checkAddressAvailability();
×
126
}
×
127

128
QString AddRGBPanel::name()
×
129
{
130
    return m_nameEdit->text();
×
131
}
132

133
int AddRGBPanel::universeIndex()
×
134
{
135
    return m_uniCombo->currentIndex();
×
136
}
137

138
int AddRGBPanel::address()
×
139
{
140
    return m_addressSpin->value() - 1;
×
141
}
142

143
int AddRGBPanel::columns()
×
144
{
145
    return m_columnSpin->value();
×
146
}
147

148
int AddRGBPanel::rows()
×
149
{
150
    return m_rowSpin->value();
×
151
}
152

153
quint32 AddRGBPanel::physicalWidth()
×
154
{
155
    return m_phyWidthSpin->value();
×
156
}
157

158
quint32 AddRGBPanel::physicalHeight()
×
159
{
160
    return m_phyHeightSpin->value();
×
161
}
162

163
AddRGBPanel::Orientation AddRGBPanel::orientation()
×
164
{
165
    if (m_oriTopLeftRadio->isChecked())
×
166
        return TopLeft;
×
167
    else if (m_oriTopRightRadio->isChecked())
×
168
        return TopRight;
×
169
    else if (m_oriBottomLeftRadio->isChecked())
×
170
        return BottomLeft;
×
171
    else if (m_oriBottomRightRadio->isChecked())
×
172
        return BottomRight;
×
173

174
    return None;
×
175
}
176

177
AddRGBPanel::Type AddRGBPanel::type()
×
178
{
179
    if (m_snakeRadio->isChecked())
×
180
        return Snake;
×
181
    else if (m_zigzagRadio->isChecked())
×
182
        return ZigZag;
×
183

184
    return Unknown;
×
185
}
186

187
AddRGBPanel::Direction AddRGBPanel::direction()
×
188
{
189
        if (m_verticalRadio->isChecked())
×
190
                return Vertical;
×
191
        else if (m_horizontalRadio->isChecked())
×
192
                return Horizontal;
×
193

194
        return Undefined;
×
195
}
196

197
Fixture::Components AddRGBPanel::components()
×
198
{
199
    if (m_compCombo->currentIndex() == 1)
×
200
        return Fixture::BGR;
×
201
    else if (m_compCombo->currentIndex() == 2)
×
202
        return Fixture::BRG;
×
203
    else if (m_compCombo->currentIndex() == 3)
×
204
        return Fixture::GBR;
×
205
    else if (m_compCombo->currentIndex() == 4)
×
206
        return Fixture::GRB;
×
207
    else if (m_compCombo->currentIndex() == 5)
×
208
        return Fixture::RBG;
×
209
    else if (m_compCombo->currentIndex() == 6)
×
210
        return Fixture::RGBW;
×
211

212
    return Fixture::RGB;
×
213
}
214

215
bool AddRGBPanel::is16Bit()
×
216
{
217
    return m_16bitCheck->isChecked();
×
218
}
219

220
bool AddRGBPanel::crossUniverse()
×
221
{
222
    return m_crossUniverseCheck->isChecked();
×
223
}
224

225
void AddRGBPanel::slotSizeChanged(int)
×
226
{
227
    checkAddressAvailability();
×
228
    m_totalLabel->setText(QString::number(m_columnSpin->value() * m_rowSpin->value()));
×
229
}
×
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