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

mcallegari / qlcplus / 14499310713

16 Apr 2025 05:57PM UTC coverage: 31.873% (+0.02%) from 31.853%
14499310713

push

github

mcallegari
Restore VC properties default page and update changelog

14691 of 46092 relevant lines covered (31.87%)

26441.99 hits per line

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

99.3
/ui/src/virtualconsole/vcproperties.cpp
1
/*
2
  Q Light Controller Plus
3
  vcproperties.cpp
4

5
  Copyright (c) Heikki Junnila
6
                Massimo Callegari
7

8
  Licensed under the Apache License, Version 2.0 (the "License");
9
  you may not use this file except in compliance with the License.
10
  You may obtain a copy of the License at
11

12
      http://www.apache.org/licenses/LICENSE-2.0.txt
13

14
  Unless required by applicable law or agreed to in writing, software
15
  distributed under the License is distributed on an "AS IS" BASIS,
16
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
  See the License for the specific language governing permissions and
18
  limitations under the License.
19
*/
20

21
#include <QXmlStreamReader>
22
#include <QXmlStreamWriter>
23
#include <QWidget>
24
#include <QDebug>
25

26
#include "inputoutputmap.h"
27
#include "vcproperties.h"
28
#include "qlcchannel.h"
29

30
/*****************************************************************************
31
 * Properties Initialization
32
 *****************************************************************************/
33

34
VCProperties::VCProperties()
83✔
35
    : m_size(QSize(1920, 1080))
36
    , m_gmVisible(true)
83✔
37
    , m_gmChannelMode(GrandMaster::Intensity)
83✔
38
    , m_gmValueMode(GrandMaster::Reduce)
83✔
39
    , m_gmSliderMode(GrandMaster::Normal)
83✔
40
    , m_gmInputUniverse(InputOutputMap::invalidUniverse())
83✔
41
    , m_gmInputChannel(QLCChannel::invalid())
83✔
42
{
43
}
83✔
44

45
VCProperties::VCProperties(const VCProperties& properties)
308✔
46
    : m_size(properties.m_size)
308✔
47
    , m_gmVisible(properties.m_gmVisible)
308✔
48
    , m_gmChannelMode(properties.m_gmChannelMode)
308✔
49
    , m_gmValueMode(properties.m_gmValueMode)
308✔
50
    , m_gmSliderMode(properties.m_gmSliderMode)
308✔
51
    , m_gmInputUniverse(properties.m_gmInputUniverse)
308✔
52
    , m_gmInputChannel(properties.m_gmInputChannel)
308✔
53
{
54
}
308✔
55

56
VCProperties::~VCProperties()
391✔
57
{
58
}
391✔
59

60
VCProperties &VCProperties::operator=(const VCProperties &props)
4✔
61
{
62
    if (this != &props)
4✔
63
    {
64
        m_size = props.m_size;
4✔
65
        m_gmVisible = props.m_gmVisible;
4✔
66
        m_gmChannelMode = props.m_gmChannelMode;
4✔
67
        m_gmValueMode = props.m_gmValueMode;
4✔
68
        m_gmSliderMode = props.m_gmSliderMode;
4✔
69
        m_gmInputUniverse = props.m_gmInputUniverse;
4✔
70
        m_gmInputChannel = props.m_gmInputChannel;
4✔
71
    }
72

73
    return *this;
4✔
74
}
75

76
/*****************************************************************************
77
 * Size
78
 *****************************************************************************/
79

80
void VCProperties::setSize(const QSize& size)
3✔
81
{
82
    m_size = size;
3✔
83
}
3✔
84

85
QSize VCProperties::size() const
81✔
86
{
87
    return m_size;
81✔
88
}
89

90
/*****************************************************************************
91
 * Grand Master
92
 *****************************************************************************/
93

94
void VCProperties::setGrandMasterVisible(bool visible)
77✔
95
{
96
    m_gmVisible = visible;
77✔
97
}
77✔
98

99
bool VCProperties::grandMasterVisible() const
77✔
100
{
101
    return m_gmVisible;
77✔
102
}
103

104
void VCProperties::setGrandMasterChannelMode(GrandMaster::ChannelMode mode)
79✔
105
{
106
    m_gmChannelMode = mode;
79✔
107
}
79✔
108

109
GrandMaster::ChannelMode VCProperties::grandMasterChannelMode() const
3✔
110
{
111
    return m_gmChannelMode;
3✔
112
}
113

114
void VCProperties::setGrandMasterValueMode(GrandMaster::ValueMode mode)
79✔
115
{
116
    m_gmValueMode = mode;
79✔
117
}
79✔
118

119
GrandMaster::ValueMode VCProperties::grandMasterValueMode() const
3✔
120
{
121
    return m_gmValueMode;
3✔
122
}
123

124
void VCProperties::setGrandMasterSliderMode(GrandMaster::SliderMode mode)
77✔
125
{
126
    m_gmSliderMode = mode;
77✔
127
}
77✔
128

129
GrandMaster::SliderMode VCProperties::grandMasterSliderMode() const
76✔
130
{
131
    return m_gmSliderMode;
76✔
132
}
133

134
void VCProperties::setGrandMasterInputSource(quint32 universe, quint32 channel)
78✔
135
{
136
    m_gmInputUniverse = universe;
78✔
137
    m_gmInputChannel = channel;
78✔
138
}
78✔
139

140
quint32 VCProperties::grandMasterInputUniverse() const
154✔
141
{
142
    return m_gmInputUniverse;
154✔
143
}
144

145
quint32 VCProperties::grandMasterInputChannel() const
154✔
146
{
147
    return m_gmInputChannel;
154✔
148
}
149

150
/*****************************************************************************
151
 * Load & Save
152
 *****************************************************************************/
153

154
bool VCProperties::loadXML(QXmlStreamReader &root)
4✔
155
{
156
    if (root.name() != KXMLQLCVCProperties)
8✔
157
    {
158
        qWarning() << Q_FUNC_INFO << "Virtual console properties node not found";
1✔
159
        return false;
1✔
160
    }
161

162
    QString str;
163
    while (root.readNextStartElement())
11✔
164
    {
165
        if (root.name() == KXMLQLCVCPropertiesSize)
16✔
166
        {
167
            QSize sz;
3✔
168

169
            /* Width */
170
            str = root.attributes().value(KXMLQLCVCPropertiesSizeWidth).toString();
3✔
171
            if (str.isEmpty() == false)
3✔
172
                sz.setWidth(str.toInt());
3✔
173

174
            /* Height */
175
            str = root.attributes().value(KXMLQLCVCPropertiesSizeHeight).toString();
3✔
176
            if (str.isEmpty() == false)
3✔
177
                sz.setHeight(str.toInt());
3✔
178

179
            /* Set size if both are valid */
180
            if (sz.isValid() == true)
181
                setSize(sz);
3✔
182
            root.skipCurrentElement();
3✔
183
        }
184
        else if (root.name() == KXMLQLCVCPropertiesGrandMaster)
10✔
185
        {
186
            QXmlStreamAttributes attrs = root.attributes();
3✔
187

188
            if (attrs.hasAttribute(KXMLQLCVCPropertiesGrandMasterVisible))
3✔
189
            {
190
                    setGrandMasterVisible(attrs.value(KXMLQLCVCPropertiesGrandMasterVisible).toString() == "1");
1✔
191
            }
192

193
            str = attrs.value(KXMLQLCVCPropertiesGrandMasterChannelMode).toString();
3✔
194
            setGrandMasterChannelMode(GrandMaster::stringToChannelMode(str));
3✔
195

196
            str = attrs.value(KXMLQLCVCPropertiesGrandMasterValueMode).toString();
3✔
197
            setGrandMasterValueMode(GrandMaster::stringToValueMode(str));
3✔
198

199
            if (attrs.hasAttribute(KXMLQLCVCPropertiesGrandMasterSliderMode))
3✔
200
            {
201
                str = attrs.value(KXMLQLCVCPropertiesGrandMasterSliderMode).toString();
1✔
202
                setGrandMasterSliderMode(GrandMaster::stringToSliderMode(str));
1✔
203
            }
204

205
            QXmlStreamReader::TokenType tType = root.readNext();
3✔
206
            if (tType == QXmlStreamReader::Characters)
3✔
207
                tType = root.readNext();
×
208

209
            // check if there is a Input tag defined
210
            if (tType == QXmlStreamReader::StartElement)
3✔
211
            {
212
                if (root.name() == KXMLQLCVCPropertiesInput)
4✔
213
                {
214
                    quint32 universe = InputOutputMap::invalidUniverse();
2✔
215
                    quint32 channel = QLCChannel::invalid();
2✔
216
                    /* External input */
217
                    if (loadXMLInput(root, &universe, &channel) == true)
2✔
218
                        setGrandMasterInputSource(universe, channel);
2✔
219
                }
220
                root.skipCurrentElement();
2✔
221
            }
222
        }
223
        else
224
        {
225
            qWarning() << Q_FUNC_INFO << "Unknown virtual console property tag:"
4✔
226
                       << root.name().toString();
2✔
227
            root.skipCurrentElement();
2✔
228
        }
229
    }
230

231
    return true;
232
}
3✔
233

234
bool VCProperties::saveXML(QXmlStreamWriter *doc) const
1✔
235
{
236
    Q_ASSERT(doc != NULL);
237

238
    /* Properties entry */
239
    doc->writeStartElement(KXMLQLCVCProperties);
1✔
240

241
    /* Size */
242
    doc->writeStartElement(KXMLQLCVCPropertiesSize);
1✔
243
    doc->writeAttribute(KXMLQLCVCPropertiesSizeWidth, QString::number(size().width()));
1✔
244
    doc->writeAttribute(KXMLQLCVCPropertiesSizeHeight, QString::number(size().height()));
1✔
245
    doc->writeEndElement();
1✔
246

247
    /***********************
248
     * Grand Master slider *
249
     ***********************/
250
    doc->writeStartElement(KXMLQLCVCPropertiesGrandMaster);
1✔
251

252
    /* Visible */
253
    doc->writeAttribute(KXMLQLCVCPropertiesGrandMasterVisible, QString::number(grandMasterVisible()));
1✔
254

255
    /* Channel mode */
256
    doc->writeAttribute(KXMLQLCVCPropertiesGrandMasterChannelMode,
1✔
257
                     GrandMaster::channelModeToString(m_gmChannelMode));
2✔
258

259
    /* Value mode */
260
    doc->writeAttribute(KXMLQLCVCPropertiesGrandMasterValueMode,
1✔
261
                     GrandMaster::valueModeToString(m_gmValueMode));
2✔
262

263
    /* Slider mode */
264
    doc->writeAttribute(KXMLQLCVCPropertiesGrandMasterSliderMode,
1✔
265
                     GrandMaster::sliderModeToString(m_gmSliderMode));
2✔
266

267
    /* Grand Master external input */
268
    if (m_gmInputUniverse != InputOutputMap::invalidUniverse() &&
2✔
269
        m_gmInputChannel != QLCChannel::invalid())
1✔
270
    {
271
        doc->writeStartElement(KXMLQLCVCPropertiesInput);
1✔
272
        doc->writeAttribute(KXMLQLCVCPropertiesInputUniverse,
1✔
273
                            QString("%1").arg(m_gmInputUniverse));
2✔
274
        doc->writeAttribute(KXMLQLCVCPropertiesInputChannel,
1✔
275
                            QString("%1").arg(m_gmInputChannel));
2✔
276
        doc->writeEndElement();
1✔
277
    }
278
    /* End the <GrandMaster> tag */
279
    doc->writeEndElement();
1✔
280

281
    /* End the <Properties> tag */
282
    doc->writeEndElement();
1✔
283

284
    return true;
1✔
285
}
286

287
bool VCProperties::loadXMLInput(QXmlStreamReader &root, quint32* universe, quint32* channel)
5✔
288
{
289
    /* External input */
290
    if (root.name() != KXMLQLCVCPropertiesInput)
10✔
291
        return false;
292

293
    QXmlStreamAttributes attrs = root.attributes();
4✔
294

295
    /* Universe */
296
    QString str = attrs.value(KXMLQLCVCPropertiesInputUniverse).toString();
4✔
297
    if (str.isEmpty() == false)
4✔
298
        *universe = str.toUInt();
3✔
299
    else
300
        *universe = InputOutputMap::invalidUniverse();
1✔
301

302
    /* Channel */
303
    str = attrs.value(KXMLQLCVCPropertiesInputChannel).toString();
4✔
304
    if (str.isEmpty() == false)
4✔
305
        *channel = str.toUInt();
3✔
306
    else
307
        *channel = QLCChannel::invalid();
1✔
308

309
    root.skipCurrentElement();
4✔
310

311
    /* Verdict */
312
    if (*universe != InputOutputMap::invalidUniverse() &&
7✔
313
        *channel != QLCChannel::invalid())
3✔
314
    {
315
        return true;
316
    }
317
    else
318
    {
319
        return false;
1✔
320
    }
321
}
4✔
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