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

mcallegari / qlcplus / 8440834527

26 Mar 2024 06:08PM UTC coverage: 31.709% (-0.4%) from 32.081%
8440834527

Pull #1422

github

web-flow
Merge 34f746340 into 7e2ec9324
Pull Request #1422: RgbScript make stage colors available to scripts

50 of 898 new or added lines in 11 files covered. (5.57%)

9 existing lines in 4 files now uncovered.

15408 of 48592 relevant lines covered (31.71%)

22631.0 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);
×
NEW
72
    if (visibilityMask & VCMatrix::ShowColor1Button) m_mtxColor1ButtonCheck->setChecked(true);
×
NEW
73
    if (visibilityMask & VCMatrix::ShowColor2Button) m_mtxColor2ButtonCheck->setChecked(true);
×
NEW
74
    if (visibilityMask & VCMatrix::ShowColor3Button) m_mtxColor3ButtonCheck->setChecked(true);
×
NEW
75
    if (visibilityMask & VCMatrix::ShowColor4Button) m_mtxColor4ButtonCheck->setChecked(true);
×
NEW
76
    if (visibilityMask & VCMatrix::ShowColor5Button) m_mtxColor5ButtonCheck->setChecked(true);
×
UNCOV
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

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

NEW
94
    connect(m_addMtxColor1Button, SIGNAL(clicked()),
×
95
            this, SLOT(slotAddMtxColor1Clicked()));
NEW
96
    connect(m_addMtxColor1KnobsButton, SIGNAL(clicked()),
×
97
            this, SLOT(slotAddMtxColor1KnobsClicked()));
NEW
98
    connect(m_addMtxColor2Button, SIGNAL(clicked()),
×
99
            this, SLOT(slotAddMtxColor2Clicked()));
NEW
100
    connect(m_addMtxColor2KnobsButton, SIGNAL(clicked()),
×
101
            this, SLOT(slotAddMtxColor2KnobsClicked()));
NEW
102
    connect(m_addMtxColor2ResetButton, SIGNAL(clicked()),
×
103
            this, SLOT(slotAddMtxColor2ResetClicked()));
NEW
104
    connect(m_addMtxColor3Button, SIGNAL(clicked()),
×
105
            this, SLOT(slotAddMtxColor3Clicked()));
NEW
106
    connect(m_addMtxColor3KnobsButton, SIGNAL(clicked()),
×
107
            this, SLOT(slotAddMtxColor3KnobsClicked()));
NEW
108
    connect(m_addMtxColor3ResetButton, SIGNAL(clicked()),
×
109
            this, SLOT(slotAddMtxColor3ResetClicked()));
NEW
110
    connect(m_addMtxColor4Button, SIGNAL(clicked()),
×
111
            this, SLOT(slotAddMtxColor4Clicked()));
NEW
112
    connect(m_addMtxColor4KnobsButton, SIGNAL(clicked()),
×
113
            this, SLOT(slotAddMtxColor4KnobsClicked()));
NEW
114
    connect(m_addMtxColor4ResetButton, SIGNAL(clicked()),
×
115
            this, SLOT(slotAddMtxColor4ResetClicked()));
NEW
116
    connect(m_addMtxColor5Button, SIGNAL(clicked()),
×
117
            this, SLOT(slotAddMtxColor5Clicked()));
NEW
118
    connect(m_addMtxColor5KnobsButton, SIGNAL(clicked()),
×
119
            this, SLOT(slotAddMtxColor5KnobsClicked()));
NEW
120
    connect(m_addMtxColor5ResetButton, SIGNAL(clicked()),
×
121
            this, SLOT(slotAddMtxColor5ResetClicked()));
UNCOV
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);
×
131
    m_presetInputWidget->setCustomFeedbackVisibility(true);
×
132
    m_presetInputWidget->setWidgetPage(m_matrix->page());
×
133
    m_presetInputWidget->show();
×
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

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

147
    delete m_presetInputWidget;
×
148
}
×
149

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

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

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

167
void VCMatrixProperties::slotSetFunction(quint32 fid)
×
168
{
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
    {
178
        m_functionEdit->setText(func->name());
×
179
        if (m_nameEdit->text().simplified().contains(QString::number(m_matrix->id())))
×
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
    {
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
{
204
    m_sliderInputSource = QSharedPointer<QLCInputSource>(new QLCInputSource(universe, (m_matrix->page() << 16) | channel));
×
205
    updateSliderInputSource();
×
206
}
×
207

208
void VCMatrixProperties::slotChooseSliderInputClicked()
×
209
{
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()));
×
214
        updateSliderInputSource();
×
215
    }
216
}
×
217

218
void VCMatrixProperties::updateSliderInputSource()
×
219
{
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

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
    {
243
        QTreeWidgetItem *item = new QTreeWidgetItem(m_controlsTree);
×
244
        item->setData(0, Qt::UserRole, control->m_id);
×
245

246
        switch(control->m_type)
×
247
        {
NEW
248
            case VCMatrixControl::Color1:
×
249
                item->setIcon(0, QIcon(":/color.png"));
×
NEW
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;
×
NEW
254
            case VCMatrixControl::Color1Knob:
×
255
                item->setIcon(0, QIcon(":/knob.png"));
×
NEW
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;
×
NEW
260
            case VCMatrixControl::Color2:
×
261
                item->setIcon(0, QIcon(":/color.png"));
×
NEW
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;
×
NEW
266
            case VCMatrixControl::Color2Knob:
×
267
                item->setIcon(0, QIcon(":/knob.png"));
×
NEW
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;
×
NEW
272
            case VCMatrixControl::Color2Reset:
×
273
                item->setIcon(0, QIcon(":/fileclose.png"));
×
NEW
274
                item->setText(0, tr("Color 2 Reset"));
×
NEW
275
            break;
×
NEW
276
            case VCMatrixControl::Color3:
×
NEW
277
                item->setIcon(0, QIcon(":/color.png"));
×
NEW
278
                item->setText(0, tr("Color 3"));
×
NEW
279
                item->setText(1, control->m_color.name());
×
NEW
280
                item->setBackground(1, QBrush(control->m_color));
×
NEW
281
            break;
×
NEW
282
            case VCMatrixControl::Color3Knob:
×
NEW
283
                item->setIcon(0, QIcon(":/knob.png"));
×
NEW
284
                item->setText(0, tr("Color 3 Knob"));
×
NEW
285
                item->setText(1, control->m_color.name());
×
NEW
286
                item->setBackground(1, QBrush(control->m_color));
×
NEW
287
            break;
×
NEW
288
            case VCMatrixControl::Color3Reset:
×
NEW
289
                item->setIcon(0, QIcon(":/fileclose.png"));
×
NEW
290
                item->setText(0, tr("Color 3 Reset"));
×
NEW
291
            break;
×
NEW
292
            case VCMatrixControl::Color4:
×
NEW
293
                item->setIcon(0, QIcon(":/color.png"));
×
NEW
294
                item->setText(0, tr("Color 4"));
×
NEW
295
                item->setText(1, control->m_color.name());
×
NEW
296
                item->setBackground(1, QBrush(control->m_color));
×
NEW
297
            break;
×
NEW
298
            case VCMatrixControl::Color4Knob:
×
NEW
299
                item->setIcon(0, QIcon(":/knob.png"));
×
NEW
300
                item->setText(0, tr("Color 4 Knob"));
×
NEW
301
                item->setText(1, control->m_color.name());
×
NEW
302
                item->setBackground(1, QBrush(control->m_color));
×
NEW
303
            break;
×
NEW
304
            case VCMatrixControl::Color4Reset:
×
NEW
305
                item->setIcon(0, QIcon(":/fileclose.png"));
×
NEW
306
                item->setText(0, tr("Color 4 Reset"));
×
NEW
307
            break;
×
NEW
308
            case VCMatrixControl::Color5:
×
NEW
309
                item->setIcon(0, QIcon(":/color.png"));
×
NEW
310
                item->setText(0, tr("Color 5"));
×
NEW
311
                item->setText(1, control->m_color.name());
×
NEW
312
                item->setBackground(1, QBrush(control->m_color));
×
NEW
313
            break;
×
NEW
314
            case VCMatrixControl::Color5Knob:
×
NEW
315
                item->setIcon(0, QIcon(":/knob.png"));
×
NEW
316
                item->setText(0, tr("Color 5 Knob"));
×
NEW
317
                item->setText(1, control->m_color.name());
×
NEW
318
                item->setBackground(1, QBrush(control->m_color));
×
NEW
319
            break;
×
NEW
320
            case VCMatrixControl::Color5Reset:
×
NEW
321
                item->setIcon(0, QIcon(":/fileclose.png"));
×
NEW
322
                item->setText(0, tr("Color 5 Reset"));
×
323
            break;
×
324
            case VCMatrixControl::Animation:
×
325
            {
326
                item->setIcon(0, QIcon(":/script.png"));
×
327
                item->setText(0, tr("Animation"));
×
328
                QString presetName = control->m_resource;
×
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();
×
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"));
×
349
                item->setText(0, tr("Text"));
×
350
                item->setText(1, control->m_resource);
×
351
            break;
×
352
        }
353
    }
354
    m_controlsTree->resizeColumnToContents(0);
×
355
    m_controlsTree->blockSignals(false);
×
356
}
×
357

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

363
    QTreeWidgetItem * item = m_controlsTree->selectedItems().first();
×
364
    if (item != NULL)
×
365
    {
366
        quint8 ctlID = item->data(0, Qt::UserRole).toUInt();
×
367
        foreach (VCMatrixControl *control, m_controls)
×
368
        {
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;
×
381
    colors.append(QColor(Qt::red));
×
382
    colors.append(QColor(Qt::green));
×
383
    colors.append(QColor(Qt::blue));
×
384
    return colors;
×
385
}
386

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

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
        {
398
            m_controls.removeAt(i);
×
399
            return;
×
400
        }
401
    }
402
}
403

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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();
×
571
        addControl(newControl);
×
572
        updateTree();
×
573
    }
574
}
×
575

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

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

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

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

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

643
    VCMatrixControl *preset = getSelectedControl();
×
644

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

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

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

658

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

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

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

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

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

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

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

© 2025 Coveralls, Inc