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

mcallegari / qlcplus / 12610312303

04 Jan 2025 12:09PM UTC coverage: 31.65% (-0.01%) from 31.664%
12610312303

Pull #1659

github

mcallegari
ui: fix some more cross universe cases
Pull Request #1659: RGBPanel: implement cross universe and 16bit profiles

99 of 214 new or added lines in 10 files covered. (46.26%)

234 existing lines in 6 files now uncovered.

14141 of 44679 relevant lines covered (31.65%)

26856.33 hits per line

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

0.0
/ui/src/virtualconsole/vcmatrixproperties.cpp
1
/*
2
  Q Light Controller Plus
3
  vcmatrixproperties.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 <QColorDialog>
21
#include <QInputDialog>
22
#include <QTreeWidget>
23

24
#include "vcmatrixpresetselection.h"
25
#include "inputselectionwidget.h"
26
#include "vcmatrixproperties.h"
27
#include "selectinputchannel.h"
28
#include "functionselection.h"
29
#include "inputpatch.h"
30
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
31
 #include "rgbscript.h"
32
#else
33
 #include "rgbscriptv4.h"
34
#endif
35

36
VCMatrixProperties::VCMatrixProperties(VCMatrix* matrix, Doc* doc)
×
37
    : QDialog(matrix)
38
    , m_doc(doc)
×
39
{
40
    Q_ASSERT(matrix != NULL);
41
    Q_ASSERT(doc != NULL);
42

43
    setupUi(this);
×
44

45
    m_lastAssignedID = 0;
×
46

47
    /* Matrix text and function */
48
    m_matrix = matrix;
×
49
    m_nameEdit->setText(m_matrix->caption());
×
50
    slotSetFunction(m_matrix->function());
×
51

52
    if (m_matrix->instantChanges())
×
53
        m_instantCheck->setChecked(true);
×
54

55
    /* Matrix connections */
56
    connect(m_attachFunction, SIGNAL(clicked()), this, SLOT(slotAttachFunction()));
×
57
    connect(m_detachFunction, SIGNAL(clicked()), this, SLOT(slotSetFunction()));
×
58

59
    /* Slider external input */
60
    m_sliderInputSource = m_matrix->inputSource();
×
61
    updateSliderInputSource();
×
62

63
    connect(m_autoDetectInputButton, SIGNAL(toggled(bool)),
×
64
            this, SLOT(slotAutoDetectSliderInputToggled(bool)));
65
    connect(m_chooseInputButton, SIGNAL(clicked()),
×
66
            this, SLOT(slotChooseSliderInputClicked()));
67

68
    /* Visibility */
69
    quint32 visibilityMask = m_matrix->visibilityMask();
×
70
    if (visibilityMask & VCMatrix::ShowSlider) m_sliderCheck->setChecked(true);
×
71
    if (visibilityMask & VCMatrix::ShowLabel) m_labelCheck->setChecked(true);
×
72
    if (visibilityMask & VCMatrix::ShowColor1Button) m_mtxColor1ButtonCheck->setChecked(true);
×
73
    if (visibilityMask & VCMatrix::ShowColor2Button) m_mtxColor2ButtonCheck->setChecked(true);
×
74
    if (visibilityMask & VCMatrix::ShowColor3Button) m_mtxColor3ButtonCheck->setChecked(true);
×
75
    if (visibilityMask & VCMatrix::ShowColor4Button) m_mtxColor4ButtonCheck->setChecked(true);
×
76
    if (visibilityMask & VCMatrix::ShowColor5Button) m_mtxColor5ButtonCheck->setChecked(true);
×
77
    if (visibilityMask & VCMatrix::ShowPresetCombo) m_presetComboCheck->setChecked(true);
×
78

79
    /* Custom controls */
80
    foreach (const VCMatrixControl *control, m_matrix->customControls())
×
81
    {
82
        m_controls.append(new VCMatrixControl(*control));
×
83
        if (control->m_id > m_lastAssignedID)
×
84
            m_lastAssignedID = control->m_id;
×
85
    }
86

87
    m_controlsTree->setSelectionMode(QAbstractItemView::SingleSelection);
×
88

89
    updateTree();
×
90

UNCOV
91
    connect(m_controlsTree, SIGNAL(itemClicked(QTreeWidgetItem*,int)),
×
92
            this, SLOT(slotTreeSelectionChanged()));
93

UNCOV
94
    connect(m_addMtxColor1Button, SIGNAL(clicked()),
×
95
            this, SLOT(slotAddMtxColor1Clicked()));
UNCOV
96
    connect(m_addMtxColor1KnobsButton, SIGNAL(clicked()),
×
97
            this, SLOT(slotAddMtxColor1KnobsClicked()));
UNCOV
98
    connect(m_addMtxColor2Button, SIGNAL(clicked()),
×
99
            this, SLOT(slotAddMtxColor2Clicked()));
UNCOV
100
    connect(m_addMtxColor2KnobsButton, SIGNAL(clicked()),
×
101
            this, SLOT(slotAddMtxColor2KnobsClicked()));
UNCOV
102
    connect(m_addMtxColor2ResetButton, SIGNAL(clicked()),
×
103
            this, SLOT(slotAddMtxColor2ResetClicked()));
104
    connect(m_addMtxColor3Button, SIGNAL(clicked()),
×
105
            this, SLOT(slotAddMtxColor3Clicked()));
106
    connect(m_addMtxColor3KnobsButton, SIGNAL(clicked()),
×
107
            this, SLOT(slotAddMtxColor3KnobsClicked()));
UNCOV
108
    connect(m_addMtxColor3ResetButton, SIGNAL(clicked()),
×
109
            this, SLOT(slotAddMtxColor3ResetClicked()));
UNCOV
110
    connect(m_addMtxColor4Button, SIGNAL(clicked()),
×
111
            this, SLOT(slotAddMtxColor4Clicked()));
112
    connect(m_addMtxColor4KnobsButton, SIGNAL(clicked()),
×
113
            this, SLOT(slotAddMtxColor4KnobsClicked()));
114
    connect(m_addMtxColor4ResetButton, SIGNAL(clicked()),
×
115
            this, SLOT(slotAddMtxColor4ResetClicked()));
116
    connect(m_addMtxColor5Button, SIGNAL(clicked()),
×
117
            this, SLOT(slotAddMtxColor5Clicked()));
118
    connect(m_addMtxColor5KnobsButton, SIGNAL(clicked()),
×
119
            this, SLOT(slotAddMtxColor5KnobsClicked()));
120
    connect(m_addMtxColor5ResetButton, SIGNAL(clicked()),
×
121
            this, SLOT(slotAddMtxColor5ResetClicked()));
122
    connect(m_addPresetButton, SIGNAL(clicked()),
×
123
            this, SLOT(slotAddAnimationClicked()));
124
    connect(m_addTextButton, SIGNAL(clicked()),
×
125
            this, SLOT(slotAddTextClicked()));
126

127
    connect(m_removeButton, SIGNAL(clicked()),
×
128
            this, SLOT(slotRemoveClicked()));
129

130
    m_presetInputWidget = new InputSelectionWidget(m_doc, this);
×
UNCOV
131
    m_presetInputWidget->setCustomFeedbackVisibility(true);
×
UNCOV
132
    m_presetInputWidget->setWidgetPage(m_matrix->page());
×
UNCOV
133
    m_presetInputWidget->show();
×
UNCOV
134
    m_presetInputLayout->addWidget(m_presetInputWidget);
×
135

136
    connect(m_presetInputWidget, SIGNAL(inputValueChanged(quint32,quint32)),
×
137
            this, SLOT(slotInputValueChanged(quint32,quint32)));
138
    connect(m_presetInputWidget, SIGNAL(keySequenceChanged(QKeySequence)),
×
139
            this, SLOT(slotKeySequenceChanged(QKeySequence)));
140
}
×
141

UNCOV
142
VCMatrixProperties::~VCMatrixProperties()
×
143
{
UNCOV
144
    foreach (VCMatrixControl* control, m_controls)
×
145
        delete control;
×
146

147
    delete m_presetInputWidget;
×
UNCOV
148
}
×
149

150
/*********************************************************************
151
 * RGB Matrix attachment
152
 *********************************************************************/
153

154
void VCMatrixProperties::slotAttachFunction()
×
155
{
156
    FunctionSelection fs(this, m_doc);
×
UNCOV
157
    fs.setMultiSelection(false);
×
UNCOV
158
    fs.setFilter(Function::RGBMatrixType);
×
UNCOV
159
    fs.disableFilters(Function::SceneType | Function::ChaserType | Function::EFXType |
×
160
                      Function::ShowType | Function::ScriptType | Function::CollectionType |
161
                      Function::AudioType | Function::VideoType);
162

UNCOV
163
    if (fs.exec() == QDialog::Accepted && fs.selection().size() > 0)
×
164
        slotSetFunction(fs.selection().first());
×
UNCOV
165
}
×
166

UNCOV
167
void VCMatrixProperties::slotSetFunction(quint32 fid)
×
168
{
UNCOV
169
    m_function = fid;
×
170
    Function* func = m_doc->function(m_function);
×
171

172
    if (func == NULL)
×
173
    {
174
        m_functionEdit->setText(tr("No function"));
×
175
    }
176
    else
177
    {
UNCOV
178
        m_functionEdit->setText(func->name());
×
179
        if (m_nameEdit->text().simplified().contains(QString::number(m_matrix->id())))
×
UNCOV
180
            m_nameEdit->setText(func->name());
×
181
    }
182
}
×
183

184
/*********************************************************************
185
 * Slider External input
186
 *********************************************************************/
187

188
void VCMatrixProperties::slotAutoDetectSliderInputToggled(bool checked)
×
189
{
190
    if (checked == true)
×
191
    {
192
        connect(m_doc->inputOutputMap(), SIGNAL(inputValueChanged(quint32,quint32,uchar)),
×
193
                this, SLOT(slotSliderInputValueChanged(quint32,quint32)));
194
    }
195
    else
196
    {
UNCOV
197
        disconnect(m_doc->inputOutputMap(), SIGNAL(inputValueChanged(quint32,quint32,uchar)),
×
198
                   this, SLOT(slotSliderInputValueChanged(quint32,quint32)));
199
    }
200
}
×
201

202
void VCMatrixProperties::slotSliderInputValueChanged(quint32 universe, quint32 channel)
×
203
{
UNCOV
204
    m_sliderInputSource = QSharedPointer<QLCInputSource>(new QLCInputSource(universe, (m_matrix->page() << 16) | channel));
×
205
    updateSliderInputSource();
×
UNCOV
206
}
×
207

208
void VCMatrixProperties::slotChooseSliderInputClicked()
×
209
{
UNCOV
210
    SelectInputChannel sic(this, m_doc->inputOutputMap());
×
211
    if (sic.exec() == QDialog::Accepted)
×
212
    {
213
        m_sliderInputSource = QSharedPointer<QLCInputSource>(new QLCInputSource(sic.universe(), sic.channel()));
×
UNCOV
214
        updateSliderInputSource();
×
215
    }
UNCOV
216
}
×
217

UNCOV
218
void VCMatrixProperties::updateSliderInputSource()
×
219
{
UNCOV
220
    QString uniName;
×
221
    QString chName;
×
222

223
    if (m_doc->inputOutputMap()->inputSourceNames(m_sliderInputSource, uniName, chName) == false)
×
224
    {
225
        uniName = KInputNone;
×
226
        chName = KInputNone;
×
227
    }
228

UNCOV
229
    m_inputUniverseEdit->setText(uniName);
×
230
    m_inputChannelEdit->setText(chName);
×
231
}
×
232

233
/*********************************************************************
234
 * Custom controls
235
 *********************************************************************/
236

237
void VCMatrixProperties::updateTree()
×
238
{
239
    m_controlsTree->blockSignals(true);
×
240
    m_controlsTree->clear();
×
241
    foreach (VCMatrixControl *control, m_controls)
×
242
    {
UNCOV
243
        QTreeWidgetItem *item = new QTreeWidgetItem(m_controlsTree);
×
244
        item->setData(0, Qt::UserRole, control->m_id);
×
245

246
        switch(control->m_type)
×
247
        {
248
            case VCMatrixControl::Color1:
×
249
                item->setIcon(0, QIcon(":/color.png"));
×
250
                item->setText(0, tr("Color 1"));
×
251
                item->setText(1, control->m_color.name());
×
252
                item->setBackground(1, QBrush(control->m_color));
×
253
            break;
×
254
            case VCMatrixControl::Color1Knob:
×
255
                item->setIcon(0, QIcon(":/knob.png"));
×
256
                item->setText(0, tr("Color 1 Knob"));
×
257
                item->setText(1, control->m_color.name());
×
258
                item->setBackground(1, QBrush(control->m_color));
×
259
            break;
×
260
            case VCMatrixControl::Color2:
×
261
                item->setIcon(0, QIcon(":/color.png"));
×
262
                item->setText(0, tr("Color 2"));
×
263
                item->setText(1, control->m_color.name());
×
264
                item->setBackground(1, QBrush(control->m_color));
×
265
            break;
×
266
            case VCMatrixControl::Color2Knob:
×
267
                item->setIcon(0, QIcon(":/knob.png"));
×
268
                item->setText(0, tr("Color 2 Knob"));
×
269
                item->setText(1, control->m_color.name());
×
270
                item->setBackground(1, QBrush(control->m_color));
×
271
            break;
×
272
            case VCMatrixControl::Color2Reset:
×
273
                item->setIcon(0, QIcon(":/fileclose.png"));
×
274
                item->setText(0, tr("Color 2 Reset"));
×
275
            break;
×
276
            case VCMatrixControl::Color3:
×
277
                item->setIcon(0, QIcon(":/color.png"));
×
278
                item->setText(0, tr("Color 3"));
×
279
                item->setText(1, control->m_color.name());
×
280
                item->setBackground(1, QBrush(control->m_color));
×
281
            break;
×
282
            case VCMatrixControl::Color3Knob:
×
283
                item->setIcon(0, QIcon(":/knob.png"));
×
284
                item->setText(0, tr("Color 3 Knob"));
×
285
                item->setText(1, control->m_color.name());
×
286
                item->setBackground(1, QBrush(control->m_color));
×
287
            break;
×
288
            case VCMatrixControl::Color3Reset:
×
289
                item->setIcon(0, QIcon(":/fileclose.png"));
×
290
                item->setText(0, tr("Color 3 Reset"));
×
291
            break;
×
292
            case VCMatrixControl::Color4:
×
293
                item->setIcon(0, QIcon(":/color.png"));
×
294
                item->setText(0, tr("Color 4"));
×
295
                item->setText(1, control->m_color.name());
×
296
                item->setBackground(1, QBrush(control->m_color));
×
297
            break;
×
298
            case VCMatrixControl::Color4Knob:
×
299
                item->setIcon(0, QIcon(":/knob.png"));
×
300
                item->setText(0, tr("Color 4 Knob"));
×
301
                item->setText(1, control->m_color.name());
×
302
                item->setBackground(1, QBrush(control->m_color));
×
303
            break;
×
304
            case VCMatrixControl::Color4Reset:
×
305
                item->setIcon(0, QIcon(":/fileclose.png"));
×
306
                item->setText(0, tr("Color 4 Reset"));
×
307
            break;
×
308
            case VCMatrixControl::Color5:
×
UNCOV
309
                item->setIcon(0, QIcon(":/color.png"));
×
310
                item->setText(0, tr("Color 5"));
×
311
                item->setText(1, control->m_color.name());
×
312
                item->setBackground(1, QBrush(control->m_color));
×
313
            break;
×
UNCOV
314
            case VCMatrixControl::Color5Knob:
×
315
                item->setIcon(0, QIcon(":/knob.png"));
×
316
                item->setText(0, tr("Color 5 Knob"));
×
317
                item->setText(1, control->m_color.name());
×
UNCOV
318
                item->setBackground(1, QBrush(control->m_color));
×
UNCOV
319
            break;
×
UNCOV
320
            case VCMatrixControl::Color5Reset:
×
321
                item->setIcon(0, QIcon(":/fileclose.png"));
×
322
                item->setText(0, tr("Color 5 Reset"));
×
UNCOV
323
            break;
×
324
            case VCMatrixControl::Animation:
×
325
            {
326
                item->setIcon(0, QIcon(":/script.png"));
×
UNCOV
327
                item->setText(0, tr("Animation"));
×
328
                QString presetName = control->m_resource;
×
UNCOV
329
                if (!control->m_properties.isEmpty())
×
330
                {
331
                    presetName += " (";
×
332
                    QHashIterator<QString, QString> it(control->m_properties);
×
333
                    while (it.hasNext())
×
334
                    {
335
                        it.next();
336
                        presetName += it.value();
UNCOV
337
                        if (it.hasNext())
×
338
                            presetName += ",";
×
339
                    }
340
                    presetName += ")";
×
341
                }
342
                item->setText(1, presetName);
×
343
            }
344
            break;
×
345
            case VCMatrixControl::Image:
346
            break;
347
            case VCMatrixControl::Text:
×
348
                item->setIcon(0, QIcon(":/fonts.png"));
×
UNCOV
349
                item->setText(0, tr("Text"));
×
350
                item->setText(1, control->m_resource);
×
351
            break;
352
        }
353
    }
UNCOV
354
    m_controlsTree->resizeColumnToContents(0);
×
UNCOV
355
    m_controlsTree->blockSignals(false);
×
UNCOV
356
}
×
357

UNCOV
358
VCMatrixControl *VCMatrixProperties::getSelectedControl()
×
359
{
UNCOV
360
    if (m_controlsTree->selectedItems().isEmpty())
×
361
        return NULL;
362

UNCOV
363
    QTreeWidgetItem * item = m_controlsTree->selectedItems().first();
×
UNCOV
364
    if (item != NULL)
×
365
    {
366
        quint8 ctlID = item->data(0, Qt::UserRole).toUInt();
×
367
        foreach (VCMatrixControl *control, m_controls)
×
368
        {
UNCOV
369
            if (control->m_id == ctlID)
×
370
                return control;
371
        }
372
    }
373

374
    Q_ASSERT(false);
375
    return NULL;
376
}
377

378
QList<QColor> VCMatrixProperties::rgbColorList()
×
379
{
380
    QList<QColor> colors;
UNCOV
381
    colors.append(QColor(Qt::red));
×
382
    colors.append(QColor(Qt::green));
×
383
    colors.append(QColor(Qt::blue));
×
UNCOV
384
    return colors;
×
385
}
386

UNCOV
387
void VCMatrixProperties::addControl(VCMatrixControl *control)
×
388
{
UNCOV
389
    m_controls.append(control);
×
390
}
×
391

UNCOV
392
void VCMatrixProperties::removeControl(quint8 id)
×
393
{
394
    for (int i = 0; i < m_controls.count(); i++)
×
395
    {
396
        if (m_controls.at(i)->m_id == id)
×
397
        {
UNCOV
398
            m_controls.removeAt(i);
×
399
            return;
×
400
        }
401
    }
402
}
403

UNCOV
404
void VCMatrixProperties::slotAddMtxColor1Clicked()
×
405
{
406
    QColor col = QColorDialog::getColor();
×
407
    if (col.isValid() == true)
×
408
    {
UNCOV
409
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
410
        newControl->m_type = VCMatrixControl::Color1;
×
411
        newControl->m_color = col;
×
UNCOV
412
        addControl(newControl);
×
413
        updateTree();
×
414
    }
415
}
×
416

417
void VCMatrixProperties::slotAddMtxColor1KnobsClicked()
×
418
{
419
    foreach (QColor col, VCMatrixProperties::rgbColorList())
×
420
    {
421
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
UNCOV
422
        newControl->m_type = VCMatrixControl::Color1Knob;
×
423
        newControl->m_color = col;
×
UNCOV
424
        addControl(newControl);
×
425
    }
UNCOV
426
    updateTree();
×
427
}
×
428

429
void VCMatrixProperties::slotAddMtxColor2Clicked()
×
430
{
431
    QColor col = QColorDialog::getColor();
×
432
    if (col.isValid() == true)
×
433
    {
434
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
UNCOV
435
        newControl->m_type = VCMatrixControl::Color2;
×
436
        newControl->m_color = col;
×
UNCOV
437
        addControl(newControl);
×
UNCOV
438
        updateTree();
×
439
    }
440
}
×
441

442
void VCMatrixProperties::slotAddMtxColor2KnobsClicked()
×
443
{
444
    foreach (QColor col, VCMatrixProperties::rgbColorList())
×
445
    {
446
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
447
        newControl->m_type = VCMatrixControl::Color2Knob;
×
448
        newControl->m_color = col;
×
UNCOV
449
        addControl(newControl);
×
450
    }
UNCOV
451
    updateTree();
×
452
}
×
453

454
void VCMatrixProperties::slotAddMtxColor2ResetClicked()
×
455
{
456
    VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
457
    newControl->m_type = VCMatrixControl::Color2Reset;
×
UNCOV
458
    addControl(newControl);
×
UNCOV
459
    updateTree();
×
UNCOV
460
}
×
461

462
void VCMatrixProperties::slotAddMtxColor3Clicked()
×
463
{
UNCOV
464
    QColor col = QColorDialog::getColor();
×
465
    if (col.isValid() == true)
×
466
    {
UNCOV
467
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
UNCOV
468
        newControl->m_type = VCMatrixControl::Color3;
×
469
        newControl->m_color = col;
×
UNCOV
470
        addControl(newControl);
×
471
        updateTree();
×
472
    }
473
}
×
474

UNCOV
475
void VCMatrixProperties::slotAddMtxColor3KnobsClicked()
×
476
{
UNCOV
477
    foreach (QColor col, VCMatrixProperties::rgbColorList())
×
478
    {
479
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
UNCOV
480
        newControl->m_type = VCMatrixControl::Color3Knob;
×
481
        newControl->m_color = col;
×
UNCOV
482
        addControl(newControl);
×
483
    }
484
    updateTree();
×
UNCOV
485
}
×
486

UNCOV
487
void VCMatrixProperties::slotAddMtxColor3ResetClicked()
×
488
{
UNCOV
489
    VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
UNCOV
490
    newControl->m_type = VCMatrixControl::Color3Reset;
×
UNCOV
491
    addControl(newControl);
×
UNCOV
492
    updateTree();
×
UNCOV
493
}
×
494

495
void VCMatrixProperties::slotAddMtxColor4Clicked()
×
496
{
UNCOV
497
    QColor col = QColorDialog::getColor();
×
498
    if (col.isValid() == true)
×
499
    {
UNCOV
500
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
UNCOV
501
        newControl->m_type = VCMatrixControl::Color4;
×
UNCOV
502
        newControl->m_color = col;
×
503
        addControl(newControl);
×
UNCOV
504
        updateTree();
×
505
    }
506
}
×
507

508
void VCMatrixProperties::slotAddMtxColor4KnobsClicked()
×
509
{
510
    foreach (QColor col, VCMatrixProperties::rgbColorList())
×
511
    {
512
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
UNCOV
513
        newControl->m_type = VCMatrixControl::Color4Knob;
×
514
        newControl->m_color = col;
×
515
        addControl(newControl);
×
516
    }
UNCOV
517
    updateTree();
×
UNCOV
518
}
×
519

UNCOV
520
void VCMatrixProperties::slotAddMtxColor4ResetClicked()
×
521
{
UNCOV
522
    VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
523
    newControl->m_type = VCMatrixControl::Color4Reset;
×
UNCOV
524
    addControl(newControl);
×
525
    updateTree();
×
526
}
×
527

UNCOV
528
void VCMatrixProperties::slotAddMtxColor5Clicked()
×
529
{
530
    QColor col = QColorDialog::getColor();
×
UNCOV
531
    if (col.isValid() == true)
×
532
    {
UNCOV
533
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
534
        newControl->m_type = VCMatrixControl::Color5;
×
535
        newControl->m_color = col;
×
UNCOV
536
        addControl(newControl);
×
UNCOV
537
        updateTree();
×
538
    }
UNCOV
539
}
×
540

UNCOV
541
void VCMatrixProperties::slotAddMtxColor5KnobsClicked()
×
542
{
543
    foreach (QColor col, VCMatrixProperties::rgbColorList())
×
544
    {
545
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
546
        newControl->m_type = VCMatrixControl::Color5Knob;
×
UNCOV
547
        newControl->m_color = col;
×
548
        addControl(newControl);
×
549
    }
550
    updateTree();
×
551
}
×
552

553
void VCMatrixProperties::slotAddMtxColor5ResetClicked()
×
554
{
555
    VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
UNCOV
556
    newControl->m_type = VCMatrixControl::Color5Reset;
×
UNCOV
557
    addControl(newControl);
×
558
    updateTree();
×
UNCOV
559
}
×
560

UNCOV
561
void VCMatrixProperties::slotAddAnimationClicked()
×
562
{
563
    VCMatrixPresetSelection ps(m_doc, this);
×
564

565
    if (ps.exec() == QDialog::Accepted)
×
566
    {
567
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
568
        newControl->m_type = VCMatrixControl::Animation;
×
569
        newControl->m_resource = ps.selectedPreset();
×
570
        newControl->m_properties = ps.customizedProperties();
×
UNCOV
571
        addControl(newControl);
×
UNCOV
572
        updateTree();
×
573
    }
574
}
×
575

UNCOV
576
void VCMatrixProperties::slotAddTextClicked()
×
577
{
578
    bool ok;
579
    QString text = QInputDialog::getText(this, tr("Enter a text"),
×
UNCOV
580
                                      tr("Text"), QLineEdit::Normal,
×
UNCOV
581
                                      "Q Light Controller+", &ok);
×
UNCOV
582
    if (ok && !text.isEmpty())
×
583
    {
UNCOV
584
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
UNCOV
585
        newControl->m_type = VCMatrixControl::Text;
×
UNCOV
586
        newControl->m_resource = text;
×
UNCOV
587
        addControl(newControl);
×
UNCOV
588
        updateTree();
×
589
    }
UNCOV
590
}
×
591

UNCOV
592
void VCMatrixProperties::slotRemoveClicked()
×
593
{
UNCOV
594
    if (m_controlsTree->selectedItems().isEmpty())
×
595
        return;
UNCOV
596
    QTreeWidgetItem *selItem = m_controlsTree->selectedItems().first();
×
UNCOV
597
    quint8 ctlID = selItem->data(0, Qt::UserRole).toUInt();
×
598

599
    {
600
        // For R/G/B Knobs:
601
        // Remove the two others
UNCOV
602
        VCMatrixControl *control = getSelectedControl();
×
UNCOV
603
        if (control != NULL)
×
604
        {
UNCOV
605
            if (control->m_type == VCMatrixControl::Color1Knob
×
UNCOV
606
                    || control->m_type == VCMatrixControl::Color2Knob
×
UNCOV
607
                    || control->m_type == VCMatrixControl::Color3Knob
×
UNCOV
608
                    || control->m_type == VCMatrixControl::Color4Knob
×
UNCOV
609
                    || control->m_type == VCMatrixControl::Color5Knob)
×
610
            {
UNCOV
611
                if (control->m_color == Qt::red)
×
612
                {
UNCOV
613
                    removeControl(ctlID + 1);
×
UNCOV
614
                    removeControl(ctlID + 2);
×
615
                }
UNCOV
616
                else if (control->m_color == Qt::green)
×
617
                {
UNCOV
618
                    removeControl(ctlID - 1);
×
UNCOV
619
                    removeControl(ctlID + 1);
×
620
                }
UNCOV
621
                else if (control->m_color == Qt::blue)
×
622
                {
UNCOV
623
                    removeControl(ctlID - 2);
×
UNCOV
624
                    removeControl(ctlID - 1);
×
625
                }
626
                else
627
                {
628
                    Q_ASSERT(false);
629
                }
630
            }
631
        }
632
    }
633

UNCOV
634
    removeControl(ctlID);
×
UNCOV
635
    updateTree();
×
636
}
637

UNCOV
638
void VCMatrixProperties::slotInputValueChanged(quint32 universe, quint32 channel)
×
639
{
640
    Q_UNUSED(universe);
641
    Q_UNUSED(channel);
642

UNCOV
643
    VCMatrixControl *preset = getSelectedControl();
×
644

UNCOV
645
    if (preset != NULL) {
×
UNCOV
646
        preset->m_inputSource = m_presetInputWidget->inputSource();
×
647
    }
UNCOV
648
}
×
649

UNCOV
650
void VCMatrixProperties::slotKeySequenceChanged(QKeySequence key)
×
651
{
UNCOV
652
    VCMatrixControl *preset = getSelectedControl();
×
653

UNCOV
654
    if (preset != NULL)
×
UNCOV
655
        preset->m_keySequence = key;
×
UNCOV
656
}
×
657

658

UNCOV
659
void VCMatrixProperties::slotTreeSelectionChanged()
×
660
{
UNCOV
661
    VCMatrixControl *control = getSelectedControl();
×
662

UNCOV
663
    if (control != NULL)
×
664
    {
UNCOV
665
        m_presetInputWidget->setInputSource(control->m_inputSource);
×
UNCOV
666
        m_presetInputWidget->setKeySequence(control->m_keySequence.toString(QKeySequence::NativeText));
×
UNCOV
667
        if (control->widgetType() == VCMatrixControl::Button)
×
668
        {
UNCOV
669
            m_presetInputWidget->setCustomFeedbackVisibility(true);
×
UNCOV
670
            m_presetInputWidget->setKeyInputVisibility(true);
×
671
        }
672
        else
673
        {
UNCOV
674
            m_presetInputWidget->setCustomFeedbackVisibility(false);
×
UNCOV
675
            m_presetInputWidget->setKeyInputVisibility(false);
×
676
        }
677
    }
UNCOV
678
}
×
679

UNCOV
680
void VCMatrixProperties::accept()
×
681
{
UNCOV
682
    m_matrix->setCaption(m_nameEdit->text());
×
UNCOV
683
    m_matrix->setFunction(m_function);
×
UNCOV
684
    if (m_instantCheck->isChecked())
×
UNCOV
685
        m_matrix->setInstantChanges(true);
×
686
    else
UNCOV
687
        m_matrix->setInstantChanges(false);
×
688

689
    /* External input */
UNCOV
690
    m_matrix->setInputSource(m_sliderInputSource);
×
691

692
    /* Visibility */
693
    quint32 visibilityMask = 0;
UNCOV
694
    if (m_sliderCheck->isChecked()) visibilityMask |= VCMatrix::ShowSlider;
×
UNCOV
695
    if (m_labelCheck->isChecked()) visibilityMask |= VCMatrix::ShowLabel;
×
UNCOV
696
    if (m_mtxColor1ButtonCheck->isChecked()) visibilityMask |= VCMatrix::ShowColor1Button;
×
UNCOV
697
    if (m_mtxColor2ButtonCheck->isChecked()) visibilityMask |= VCMatrix::ShowColor2Button;
×
UNCOV
698
    if (m_mtxColor3ButtonCheck->isChecked()) visibilityMask |= VCMatrix::ShowColor3Button;
×
UNCOV
699
    if (m_mtxColor4ButtonCheck->isChecked()) visibilityMask |= VCMatrix::ShowColor4Button;
×
UNCOV
700
    if (m_mtxColor5ButtonCheck->isChecked()) visibilityMask |= VCMatrix::ShowColor5Button;
×
UNCOV
701
    if (m_presetComboCheck->isChecked()) visibilityMask |= VCMatrix::ShowPresetCombo;
×
UNCOV
702
    m_matrix->setVisibilityMask(visibilityMask);
×
703

704
    /* Controls */
UNCOV
705
    m_matrix->resetCustomControls();
×
UNCOV
706
    for (int i = 0; i < m_controls.count(); i++)
×
UNCOV
707
        m_matrix->addCustomControl(*m_controls.at(i));
×
708

709
    /* Close dialog */
UNCOV
710
    QDialog::accept();
×
UNCOV
711
}
×
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