• 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/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 "addrgbpanel.h"
25
#include "ui_addrgbpanel.h"
26
#include "doc.h"
27

28
#define SETTINGS_GEOMETRY "addrgbpanel/geometry"
29

UNCOV
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

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

UNCOV
54
    connect(m_uniCombo, SIGNAL(currentIndexChanged(int)),
×
55
            this, SLOT(slotUniverseChanged()));
56
    connect(m_addressSpin, SIGNAL(valueChanged(int)),
×
57
            this, SLOT(slotAddressChanged()));
58
    connect(m_columnSpin, SIGNAL(valueChanged(int)),
×
59
            this, SLOT(slotSizeChanged(int)));
60
    connect(m_rowSpin, SIGNAL(valueChanged(int)),
×
61
            this, SLOT(slotSizeChanged(int)));
62
}
×
63

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

76
    qDebug() << "Check availability for address: " << startAddress;
×
77

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

93
void AddRGBPanel::slotUniverseChanged()
×
94
{
95
    checkAddressAvailability();
×
96
}
×
97

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

103
QString AddRGBPanel::name()
×
104
{
105
    return m_nameEdit->text();
×
106
}
107

108
int AddRGBPanel::universeIndex()
×
109
{
110
    return m_uniCombo->currentIndex();
×
111
}
112

113
int AddRGBPanel::address()
×
114
{
115
    return m_addressSpin->value() - 1;
×
116
}
117

118
int AddRGBPanel::columns()
×
119
{
120
    return m_columnSpin->value();
×
121
}
122

123
int AddRGBPanel::rows()
×
124
{
125
    return m_rowSpin->value();
×
126
}
127

128
quint32 AddRGBPanel::physicalWidth()
×
129
{
130
    return m_phyWidthSpin->value();
×
131
}
132

133
quint32 AddRGBPanel::physicalHeight()
×
134
{
135
    return m_phyHeightSpin->value();
×
136
}
137

138
AddRGBPanel::Orientation AddRGBPanel::orientation()
×
139
{
140
    if (m_oriTopLeftRadio->isChecked())
×
141
        return TopLeft;
×
142
    else if (m_oriTopRightRadio->isChecked())
×
143
        return TopRight;
×
144
    else if (m_oriBottomLeftRadio->isChecked())
×
145
        return BottomLeft;
×
146
    else if (m_oriBottomRightRadio->isChecked())
×
147
        return BottomRight;
×
148

149
    return None;
×
150
}
151

152
AddRGBPanel::Type AddRGBPanel::type()
×
153
{
154
    if (m_snakeRadio->isChecked())
×
155
        return Snake;
×
156
    else if (m_zigzagRadio->isChecked())
×
157
        return ZigZag;
×
158

159
    return Unknown;
×
160
}
161

162
AddRGBPanel::Direction AddRGBPanel::direction()
×
163
{
164
        if (m_verticalRadio->isChecked())
×
165
                return Vertical;
×
166
        else if (m_horizontalRadio->isChecked())
×
167
                return Horizontal;
×
168

169
        return Undefined;
×
170
}
171

172
Fixture::Components AddRGBPanel::components()
×
173
{
174
    if (m_compCombo->currentIndex() == 1)
×
175
        return Fixture::BGR;
×
176
    else if (m_compCombo->currentIndex() == 2)
×
177
        return Fixture::BRG;
×
178
    else if (m_compCombo->currentIndex() == 3)
×
179
        return Fixture::GBR;
×
180
    else if (m_compCombo->currentIndex() == 4)
×
181
        return Fixture::GRB;
×
182
    else if (m_compCombo->currentIndex() == 5)
×
183
        return Fixture::RBG;
×
184
    else if (m_compCombo->currentIndex() == 6)
×
185
        return Fixture::RGBW;
×
186

187
    return Fixture::RGB;
×
188
}
189

190
void AddRGBPanel::slotSizeChanged(int)
×
191
{
192
    checkAddressAvailability();
×
193
    m_totalLabel->setText(QString::number(m_columnSpin->value() * m_rowSpin->value()));
×
194
}
×
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