• 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/virtualconsole/vcpropertieseditor.cpp
1
/*
2
  Q Light Controller
3
  vcpropertieseditor.cpp
4

5
  Copyright (c) Heikki Junnila
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 <QRadioButton>
21
#include <QSettings>
22
#include <QCheckBox>
23
#include <QSpinBox>
24
#include <QAction>
25

26
#include "vcpropertieseditor.h"
27
#include "selectinputchannel.h"
28
#include "inputoutputmap.h"
29
#include "qlcinputsource.h"
30
#include "vcproperties.h"
31
#include "inputpatch.h"
32
#include "function.h"
33

34
#define SETTINGS_GEOMETRY "vcpropertieseditor/geometry"
35

36
/*****************************************************************************
37
 * Initialization
38
 *****************************************************************************/
39

40
VCPropertiesEditor::VCPropertiesEditor(QWidget* parent, const VCProperties& properties,
×
41
                                       InputOutputMap *ioMap)
×
42
    : QDialog(parent)
43
    , m_ioMap(ioMap)
×
44
{
45
    Q_ASSERT(ioMap != NULL);
×
46

47
    setupUi(this);
×
48

49
    QAction* action = new QAction(this);
×
50
    action->setShortcut(QKeySequence(QKeySequence::Close));
×
51
    connect(action, SIGNAL(triggered(bool)), this, SLOT(reject()));
×
52
    addAction(action);
×
53

54
    m_properties = properties;
×
55

56
    /* General page */
57
    m_sizeXSpin->setValue(properties.size().width());
×
58
    m_sizeYSpin->setValue(properties.size().height());
×
59

60
    /* Widgets page */
61
    QSettings settings;
×
62
    // ********************* BUTTON ****************************
63
    QVariant var = settings.value(SETTINGS_BUTTON_SIZE);
×
64
    if (var.isValid() == true)
×
65
    {
66
        QSize size = var.toSize();
×
67
        m_buttonWspin->setValue(size.width());
×
68
        m_buttonHspin->setValue(size.height());
×
69
    }
70
    else
71
    {
72
        m_buttonWspin->setValue(50);
×
73
        m_buttonHspin->setValue(50);
×
74
    }
75
    // ********************* BUTTON STATUS *********************
76
    var = settings.value(SETTINGS_BUTTON_STATUSLED);
×
77
    if (var.isValid() == true && var.toBool() == true)
×
78
            m_buttonStatusLEDRadio->setChecked(true);
×
79
    // ********************* SLIDER ****************************
80
    var = settings.value(SETTINGS_SLIDER_SIZE);
×
81
    if (var.isValid() == true)
×
82
    {
83
        QSize size = var.toSize();
×
84
        m_sliderWspin->setValue(size.width());
×
85
        m_sliderHspin->setValue(size.height());
×
86
    }
87
    else
88
    {
89
        m_sliderWspin->setValue(60);
×
90
        m_sliderHspin->setValue(200);
×
91
    }
92
    // ********************* SPEED DIAL ************************
93
    var = settings.value(SETTINGS_SPEEDDIAL_SIZE);
×
94
    if (var.isValid() == true)
×
95
    {
96
        QSize size = var.toSize();
×
97
        m_speedWspin->setValue(size.width());
×
98
        m_speedHspin->setValue(size.height());
×
99
    }
100
    else
101
    {
102
        m_speedWspin->setValue(200);
×
103
        m_speedHspin->setValue(175);
×
104
    }
105
    // ********************* SPEED DIAL VALUE ******************
106
    var = settings.value(SETTINGS_SPEEDDIAL_VALUE);
×
107
    if (var.isValid() == true)
×
108
        m_speedValueEdit->setText(Function::speedToString(var.toUInt()));
×
109
    else
110
        m_speedValueEdit->setText(Function::speedToString(0));
×
111

112
    connect(m_speedValueEdit, SIGNAL(editingFinished()),
×
113
            this, SLOT(slotSpeedDialConfirmed()));
114

115
    // ********************* XY PAD ****************************
116
    var = settings.value(SETTINGS_XYPAD_SIZE);
×
117
    if (var.isValid() == true)
×
118
    {
119
        QSize size = var.toSize();
×
120
        m_xypadWspin->setValue(size.width());
×
121
        m_xypadHspin->setValue(size.height());
×
122
    }
123
    else
124
    {
125
        m_xypadWspin->setValue(230);
×
126
        m_xypadHspin->setValue(230);
×
127
    }
128
    // ********************* CUE LIST **************************
129
    var = settings.value(SETTINGS_CUELIST_SIZE);
×
130
    if (var.isValid() == true)
×
131
    {
132
        QSize size = var.toSize();
×
133
        m_cuelistWspin->setValue(size.width());
×
134
        m_cuelistHspin->setValue(size.height());
×
135
    }
136
    else
137
    {
138
        m_cuelistWspin->setValue(300);
×
139
        m_cuelistHspin->setValue(220);
×
140
    }
141
    // ************************ FRAME **************************
142
    var = settings.value(SETTINGS_FRAME_SIZE);
×
143
    if (var.isValid() == true)
×
144
    {
145
        QSize size = var.toSize();
×
146
        m_frameWspin->setValue(size.width());
×
147
        m_frameHspin->setValue(size.height());
×
148
    }
149
    else
150
    {
151
        m_frameWspin->setValue(200);
×
152
        m_frameHspin->setValue(200);
×
153
    }
154
    // ********************* SOLO FRAME ************************
155
    var = settings.value(SETTINGS_SOLOFRAME_SIZE);
×
156
    if (var.isValid() == true)
×
157
    {
158
        QSize size = var.toSize();
×
159
        m_soloWspin->setValue(size.width());
×
160
        m_soloHspin->setValue(size.height());
×
161
    }
162
    else
163
    {
164
        m_soloWspin->setValue(200);
×
165
        m_soloHspin->setValue(200);
×
166
    }
167
    // ***************** AUDIO TRIGGERS ************************
168
    var = settings.value(SETTINGS_AUDIOTRIGGERS_SIZE);
×
169
    if (var.isValid() == true)
×
170
    {
171
        QSize size = var.toSize();
×
172
        m_audioWspin->setValue(size.width());
×
173
        m_audioHspin->setValue(size.height());
×
174
    }
175
    else
176
    {
177
        m_audioWspin->setValue(200);
×
178
        m_audioHspin->setValue(200);
×
179
    }
180
    // ***************** RGB MATRIX ************************
181
    var = settings.value(SETTINGS_RGBMATRIX_SIZE);
×
182
    if (var.isValid() == true)
×
183
    {
184
        QSize size = var.toSize();
×
185
        m_matrixWspin->setValue(size.width());
×
186
        m_matrixHspin->setValue(size.height());
×
187
    }
188
    else
189
    {
190
        m_matrixWspin->setValue(160);
×
191
        m_matrixHspin->setValue(120);
×
192
    }
193

NEW
194
    QVariant geometrySettings = settings.value(SETTINGS_GEOMETRY);
×
NEW
195
    if (geometrySettings.isValid() == true)
×
NEW
196
        restoreGeometry(geometrySettings.toByteArray());
×
197

198
    /* Grand Master page */
199
    switch (properties.grandMasterChannelMode())
×
200
    {
201
    default:
×
202
    case GrandMaster::Intensity:
203
        m_gmIntensityRadio->setChecked(true);
×
204
        break;
×
205
    case GrandMaster::AllChannels:
×
206
        m_gmAllChannelsRadio->setChecked(true);
×
207
        break;
×
208
    }
209

210
    switch (properties.grandMasterValueMode())
×
211
    {
212
    default:
×
213
    case GrandMaster::Reduce:
214
        m_gmReduceRadio->setChecked(true);
×
215
        break;
×
216
    case GrandMaster::Limit:
×
217
        m_gmLimitRadio->setChecked(true);
×
218
        break;
×
219
    }
220

221
    switch (properties.grandMasterSlideMode())
×
222
    {
223
    default:
×
224
    case GrandMaster::Normal:
225
        m_gmSliderModeNormalRadio->setChecked(true);
×
226
        break;
×
227
    case GrandMaster::Inverted:
×
228
        m_gmSliderModeInvertedRadio->setChecked(true);
×
229
        break;
×
230
    }
231

232
    updateGrandMasterInputSource();
×
233
}
×
234

235
VCPropertiesEditor::~VCPropertiesEditor()
×
236
{
NEW
237
    QSettings settings;
×
NEW
238
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
×
UNCOV
239
}
×
240

241
VCProperties VCPropertiesEditor::properties() const
×
242
{
243
    return m_properties;
×
244
}
245

246
QSize VCPropertiesEditor::buttonSize()
×
247
{
248
    return QSize(m_buttonWspin->value(), m_buttonHspin->value());
×
249
}
250

251
bool VCPropertiesEditor::buttonStatusLED()
×
252
{
253
    if (m_buttonStatusLEDRadio->isChecked())
×
254
        return true;
×
255
    else
256
        return false;
×
257
}
258

259
QSize VCPropertiesEditor::sliderSize()
×
260
{
261
    return QSize(m_sliderWspin->value(), m_sliderHspin->value());
×
262
}
263

264
QSize VCPropertiesEditor::speedDialSize()
×
265
{
266
    return QSize(m_speedWspin->value(), m_speedHspin->value());
×
267
}
268

269
uint VCPropertiesEditor::speedDialValue()
×
270
{
271
    return Function::stringToSpeed(m_speedValueEdit->text());
×
272
}
273

274
QSize VCPropertiesEditor::xypadSize()
×
275
{
276
    return QSize(m_xypadWspin->value(), m_xypadHspin->value());
×
277
}
278

279
QSize VCPropertiesEditor::cuelistSize()
×
280
{
281
    return QSize(m_cuelistWspin->value(), m_cuelistHspin->value());
×
282
}
283

284
QSize VCPropertiesEditor::frameSize()
×
285
{
286
    return QSize(m_frameWspin->value(), m_frameHspin->value());
×
287
}
288

289
QSize VCPropertiesEditor::soloFrameSize()
×
290
{
291
    return QSize(m_soloWspin->value(), m_soloHspin->value());
×
292
}
293

294
QSize VCPropertiesEditor::audioTriggersSize()
×
295
{
296
    return QSize(m_audioWspin->value(), m_audioHspin->value());
×
297
}
298

299
QSize VCPropertiesEditor::rgbMatrixSize()
×
300
{
301
    return QSize(m_matrixWspin->value(), m_matrixHspin->value());
×
302
}
303

304
/*****************************************************************************
305
 * Layout page
306
 *****************************************************************************/
307

308
void VCPropertiesEditor::slotSizeXChanged(int value)
×
309
{
310
    QSize sz(m_properties.size());
×
311
    sz.setWidth(value);
×
312
    m_properties.setSize(sz);
×
313
}
×
314

315
void VCPropertiesEditor::slotSizeYChanged(int value)
×
316
{
317
    QSize sz(m_properties.size());
×
318
    sz.setHeight(value);
×
319
    m_properties.setSize(sz);
×
320
}
×
321

322
void VCPropertiesEditor::slotSpeedDialConfirmed()
×
323
{
324
    if (m_speedValueEdit->text().contains(".") == false)
×
325
    {
326
        m_speedValueEdit->setText(Function::speedToString(m_speedValueEdit->text().toUInt()));
×
327
    }
328
}
×
329

330

331

332
/*****************************************************************************
333
 * Grand Master page
334
 *****************************************************************************/
335

336
void VCPropertiesEditor::slotGrandMasterIntensityToggled(bool checked)
×
337
{
338
    if (checked == true)
×
339
        m_properties.setGrandMasterChannelMode(GrandMaster::Intensity);
×
340
    else
341
        m_properties.setGrandMasterChannelMode(GrandMaster::AllChannels);
×
342
}
×
343

344
void VCPropertiesEditor::slotGrandMasterReduceToggled(bool checked)
×
345
{
346
    if (checked == true)
×
347
        m_properties.setGrandMasterValueMode(GrandMaster::Reduce);
×
348
    else
349
        m_properties.setGrandMasterValueMode(GrandMaster::Limit);
×
350
}
×
351

352
void VCPropertiesEditor::slotGrandMasterSliderNormalToggled(bool checked)
×
353
{
354
    if (checked == true)
×
355
        m_properties.setGrandMasterSliderMode(GrandMaster::Normal);
×
356
    else
357
        m_properties.setGrandMasterSliderMode(GrandMaster::Inverted);
×
358
}
×
359

360
void VCPropertiesEditor::slotAutoDetectGrandMasterInputToggled(bool checked)
×
361
{
362
    if (checked == true)
×
363
    {
364
        connect(m_ioMap, SIGNAL(inputValueChanged(quint32,quint32,uchar)),
×
365
                this, SLOT(slotGrandMasterInputValueChanged(quint32,quint32)));
366
    }
367
    else
368
    {
369
        disconnect(m_ioMap, SIGNAL(inputValueChanged(quint32,quint32,uchar)),
×
370
                   this, SLOT(slotGrandMasterInputValueChanged(quint32,quint32)));
371
    }
372
}
×
373

374
void VCPropertiesEditor::slotGrandMasterInputValueChanged(quint32 universe,
×
375
                                                          quint32 channel)
376
{
377
    m_properties.setGrandMasterInputSource(universe, channel);
×
378
    updateGrandMasterInputSource();
×
379
}
×
380

381
void VCPropertiesEditor::slotChooseGrandMasterInputClicked()
×
382
{
383
    SelectInputChannel sic(this, m_ioMap);
×
384
    if (sic.exec() == QDialog::Accepted)
×
385
    {
386
        m_properties.setGrandMasterInputSource(sic.universe(), sic.channel());
×
387
        updateGrandMasterInputSource();
×
388
    }
389
}
×
390

391
void VCPropertiesEditor::updateGrandMasterInputSource()
×
392
{
393
    QString uniName;
×
394
    QString chName;
×
395

396
    if (m_ioMap->inputSourceNames(
×
397
                QSharedPointer<QLCInputSource>(
×
398
                    new QLCInputSource(
399
                        m_properties.grandMasterInputUniverse(),
×
400
                        m_properties.grandMasterInputChannel())),
×
401
                uniName, chName) == true)
×
402
    {
403
        /* Display the gathered information */
404
        m_gmInputUniverseEdit->setText(uniName);
×
405
        m_gmInputChannelEdit->setText(chName);
×
406
    }
407
    else
408
    {
409
        m_gmInputUniverseEdit->setText(KInputNone);
×
410
        m_gmInputChannelEdit->setText(KInputNone);
×
411
    }
412
}
×
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

© 2025 Coveralls, Inc