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

mcallegari / qlcplus / 14775166357

01 May 2025 12:13PM UTC coverage: 31.867% (-0.004%) from 31.871%
14775166357

Pull #1746

github

web-flow
Merge 34ee87582 into e7ad6716b
Pull Request #1746: Update m_columnSpin when m_compCombo or m_16bitCheck change

0 of 8 new or added lines in 1 file covered. (0.0%)

25 existing lines in 2 files now uncovered.

14686 of 46085 relevant lines covered (31.87%)

26489.83 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 <QSettings>
22
#include <QDebug>
23
#include <cmath>
24

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

28
#define SETTINGS_GEOMETRY "addrgbpanel/geometry"
29

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

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

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

47
    checkAddressAvailability();
×
48

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

54
    connect(m_uniCombo, SIGNAL(currentIndexChanged(int)),
×
55
            this, SLOT(slotUniverseChanged()));
56
    connect(m_compCombo, SIGNAL(currentIndexChanged(int)),
×
57
            this, SLOT(slotComponentsChanged()));
NEW
58
    connect(m_16bitCheck, SIGNAL(stateChanged(int)),
×
59
            this, SLOT(slotComponentsChanged()));
UNCOV
60
    connect(m_addressSpin, SIGNAL(valueChanged(int)),
×
61
            this, SLOT(slotAddressChanged()));
62
    connect(m_columnSpin, SIGNAL(valueChanged(int)),
×
63
            this, SLOT(slotSizeChanged(int)));
64
    connect(m_rowSpin, SIGNAL(valueChanged(int)),
×
65
            this, SLOT(slotSizeChanged(int)));
66
}
×
67

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

80
    qDebug() << "Check availability for address: " << startAddress;
81

82
    for (int i = 0; i < channels; i++)
×
83
    {
84
        quint32 fid = m_doc->fixtureForAddress(startAddress + i);
×
85
        if (fid != Fixture::invalidId())
×
86
        {
87
            m_addrErrorLabel->show();
×
88
            okBtn->setEnabled(false);
×
89
            return false;
×
90
        }
91
    }
92
    m_addrErrorLabel->hide();
×
93
    okBtn->setEnabled(true);
×
94
    return true;
95
}
96

97
void AddRGBPanel::slotUniverseChanged()
×
98
{
99
    checkAddressAvailability();
×
100
}
×
101

NEW
102
void AddRGBPanel::slotComponentsChanged()
×
103
{
104
    int dmxChannelsPerPixel = 3;
NEW
105
    if (m_compCombo->currentIndex() == 6) // RGBW
×
106
        dmxChannelsPerPixel = 4;
107

NEW
108
    if (m_16bitCheck->isChecked())
×
NEW
109
        dmxChannelsPerPixel *= 2;
×
110

NEW
111
    m_columnSpin->setMaximum(floor(UNIVERSE_SIZE / dmxChannelsPerPixel));
×
112

NEW
113
    if (m_columnSpin->value() > m_columnSpin->maximum())
×
NEW
114
        m_columnSpin->setValue(m_columnSpin->maximum());
×
UNCOV
115
}
×
116

117
void AddRGBPanel::slotAddressChanged()
×
118
{
119
    checkAddressAvailability();
×
120
}
×
121

122
QString AddRGBPanel::name()
×
123
{
124
    return m_nameEdit->text();
×
125
}
126

127
int AddRGBPanel::universeIndex()
×
128
{
129
    return m_uniCombo->currentIndex();
×
130
}
131

132
int AddRGBPanel::address()
×
133
{
134
    return m_addressSpin->value() - 1;
×
135
}
136

137
int AddRGBPanel::columns()
×
138
{
139
    return m_columnSpin->value();
×
140
}
141

142
int AddRGBPanel::rows()
×
143
{
144
    return m_rowSpin->value();
×
145
}
146

147
quint32 AddRGBPanel::physicalWidth()
×
148
{
149
    return m_phyWidthSpin->value();
×
150
}
151

152
quint32 AddRGBPanel::physicalHeight()
×
153
{
154
    return m_phyHeightSpin->value();
×
155
}
156

157
AddRGBPanel::Orientation AddRGBPanel::orientation()
×
158
{
159
    if (m_oriTopLeftRadio->isChecked())
×
160
        return TopLeft;
161
    else if (m_oriTopRightRadio->isChecked())
×
162
        return TopRight;
163
    else if (m_oriBottomLeftRadio->isChecked())
×
164
        return BottomLeft;
165
    else if (m_oriBottomRightRadio->isChecked())
×
166
        return BottomRight;
×
167

168
    return None;
169
}
170

171
AddRGBPanel::Type AddRGBPanel::type()
×
172
{
173
    if (m_snakeRadio->isChecked())
×
174
        return Snake;
175
    else if (m_zigzagRadio->isChecked())
×
176
        return ZigZag;
×
177

178
    return Unknown;
179
}
180

181
AddRGBPanel::Direction AddRGBPanel::direction()
×
182
{
183
        if (m_verticalRadio->isChecked())
×
184
                return Vertical;
185
        else if (m_horizontalRadio->isChecked())
×
186
                return Horizontal;
×
187

188
        return Undefined;
189
}
190

191
Fixture::Components AddRGBPanel::components()
×
192
{
193
    if (m_compCombo->currentIndex() == 1)
×
194
        return Fixture::BGR;
195
    else if (m_compCombo->currentIndex() == 2)
×
196
        return Fixture::BRG;
197
    else if (m_compCombo->currentIndex() == 3)
×
198
        return Fixture::GBR;
199
    else if (m_compCombo->currentIndex() == 4)
×
200
        return Fixture::GRB;
201
    else if (m_compCombo->currentIndex() == 5)
×
202
        return Fixture::RBG;
203
    else if (m_compCombo->currentIndex() == 6)
×
204
        return Fixture::RGBW;
×
205

206
    return Fixture::RGB;
207
}
208

209
bool AddRGBPanel::is16Bit()
×
210
{
211
    return m_16bitCheck->isChecked();
×
212
}
213

214
bool AddRGBPanel::crossUniverse()
×
215
{
216
    return m_crossUniverseCheck->isChecked();
×
217
}
218

219
void AddRGBPanel::slotSizeChanged(int)
×
220
{
221
    checkAddressAvailability();
×
222
    m_totalLabel->setText(QString::number(m_columnSpin->value() * m_rowSpin->value()));
×
223
}
×
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