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

mcallegari / qlcplus / 14755738104

30 Apr 2025 01:27PM UTC coverage: 31.868% (-0.003%) from 31.871%
14755738104

Pull #1746

github

web-flow
Merge ee4308137 into 02101a8ec
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%)

2 existing lines in 1 file now uncovered.

14686 of 46084 relevant lines covered (31.87%)

26490.4 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()));
NEW
59
    connect(m_16bitCheck, SIGNAL(stateChanged(int)),
×
60
            this, SLOT(slotComponentsChanged()));
UNCOV
61
    connect(m_addressSpin, SIGNAL(valueChanged(int)),
×
62
            this, SLOT(slotAddressChanged()));
63
    connect(m_columnSpin, SIGNAL(valueChanged(int)),
×
64
            this, SLOT(slotSizeChanged(int)));
65
    connect(m_rowSpin, SIGNAL(valueChanged(int)),
×
66
            this, SLOT(slotSizeChanged(int)));
67
}
×
68

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

169
    return None;
170
}
171

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

179
    return Unknown;
180
}
181

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

189
        return Undefined;
190
}
191

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

207
    return Fixture::RGB;
208
}
209

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

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

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