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

mcallegari / qlcplus / 16450929051

22 Jul 2025 05:09PM UTC coverage: 34.174% (-0.1%) from 34.286%
16450929051

Pull #1782

github

web-flow
Merge f80a306ab into 8a22b7b84
Pull Request #1782: Feature: Control RGB Matrix script properties with VC Knobs in animation widget

7 of 189 new or added lines in 6 files covered. (3.7%)

9 existing lines in 4 files now uncovered.

17704 of 51806 relevant lines covered (34.17%)

19373.32 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
#include <QMap>
24

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

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

44
    setupUi(this);
×
45

46
    m_lastAssignedID = 0;
×
47

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

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

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

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

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

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

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

NEW
88
    m_controlsTree->setSelectionMode(QAbstractItemView::ExtendedSelection);
×
NEW
89
    m_controlsTree->setEditTriggers(QAbstractItemView::NoEditTriggers);
×
NEW
90
    QStringList labels;
×
NEW
91
    labels << tr("Type") << tr("Value") << tr("Soft Patch");
×
NEW
92
    m_controlsTree->setHeaderLabels(labels);
×
93

94
    updateTree();
×
95
    slotColorComboActivated();
×
96

97
    connect(m_controlsTree, SIGNAL(itemClicked(QTreeWidgetItem*,int)),
×
98
            this, SLOT(slotTreeSelectionChanged()));
NEW
99
    connect(m_controlsTree, SIGNAL(itemChanged(QTreeWidgetItem*,int)),
×
100
            this, SLOT(slotTreeItemChanged(QTreeWidgetItem*,int)));
NEW
101
    connect(m_controlsTree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
×
102
            this, SLOT(slotTreeItemDoubleClicked(QTreeWidgetItem*,int)));
103

104
    connect(m_colorsCombo, SIGNAL(activated(int)),
×
105
            this, SLOT(slotColorComboActivated()));
106
    connect(m_addColorButton, SIGNAL(clicked()),
×
107
            this, SLOT(slotAddColorClicked()));
108
    connect(m_addColorKnobsButton, SIGNAL(clicked()),
×
109
            this, SLOT(slotAddColorKnobsClicked()));
110
    connect(m_addColorResetButton, SIGNAL(clicked()),
×
111
            this, SLOT(slotAddColorResetClicked()));
112

113
    connect(m_addPresetButton, SIGNAL(clicked()),
×
114
            this, SLOT(slotAddAnimationClicked()));
115
    connect(m_addTextButton, SIGNAL(clicked()),
×
116
            this, SLOT(slotAddTextClicked()));
117

118
    connect(m_removeButton, SIGNAL(clicked()),
×
119
            this, SLOT(slotRemoveClicked()));
120

121
    m_presetInputWidget = new InputSelectionWidget(m_doc, this);
×
122
    m_presetInputWidget->setCustomFeedbackVisibility(true);
×
123
    m_presetInputWidget->setWidgetPage(m_matrix->page());
×
124
    m_presetInputWidget->show();
×
125
    m_presetInputLayout->addWidget(m_presetInputWidget);
×
126

127
    connect(m_presetInputWidget, SIGNAL(inputValueChanged(quint32,quint32)),
×
128
            this, SLOT(slotInputValueChanged(quint32,quint32)));
129
    connect(m_presetInputWidget, SIGNAL(keySequenceChanged(QKeySequence)),
×
130
            this, SLOT(slotKeySequenceChanged(QKeySequence)));
131
}
×
132

133
VCMatrixProperties::~VCMatrixProperties()
×
134
{
135
    foreach (VCMatrixControl* control, m_controls)
×
136
        delete control;
×
137

138
    delete m_presetInputWidget;
×
139
}
×
140

141
/*********************************************************************
142
 * RGB Matrix attachment
143
 *********************************************************************/
144

145
void VCMatrixProperties::slotAttachFunction()
×
146
{
147
    FunctionSelection fs(this, m_doc);
×
148
    fs.setMultiSelection(false);
×
149
    fs.setFilter(Function::RGBMatrixType);
×
150
    fs.disableFilters(Function::SceneType | Function::ChaserType | Function::EFXType |
×
151
                      Function::ShowType | Function::ScriptType | Function::CollectionType |
152
                      Function::AudioType | Function::VideoType);
153

154
    if (fs.exec() == QDialog::Accepted && fs.selection().size() > 0)
×
155
        slotSetFunction(fs.selection().first());
×
156
}
×
157

158
void VCMatrixProperties::slotSetFunction(quint32 fid)
×
159
{
160
    m_function = fid;
×
161
    Function* func = m_doc->function(m_function);
×
162

163
    if (func == NULL)
×
164
    {
165
        m_functionEdit->setText(tr("No function"));
×
166
    }
167
    else
168
    {
169
        m_functionEdit->setText(func->name());
×
170
        if (m_nameEdit->text().simplified().contains(QString::number(m_matrix->id())))
×
171
            m_nameEdit->setText(func->name());
×
172
    }
173
}
×
174

175
/*********************************************************************
176
 * Slider External input
177
 *********************************************************************/
178

179
void VCMatrixProperties::slotAutoDetectSliderInputToggled(bool checked)
×
180
{
181
    if (checked == true)
×
182
    {
183
        connect(m_doc->inputOutputMap(), SIGNAL(inputValueChanged(quint32,quint32,uchar)),
×
184
                this, SLOT(slotSliderInputValueChanged(quint32,quint32)));
185
    }
186
    else
187
    {
188
        disconnect(m_doc->inputOutputMap(), SIGNAL(inputValueChanged(quint32,quint32,uchar)),
×
189
                   this, SLOT(slotSliderInputValueChanged(quint32,quint32)));
190
    }
191
}
×
192

193
void VCMatrixProperties::slotSliderInputValueChanged(quint32 universe, quint32 channel)
×
194
{
195
    m_sliderInputSource = QSharedPointer<QLCInputSource>(new QLCInputSource(universe, (m_matrix->page() << 16) | channel));
×
196
    updateSliderInputSource();
×
197
}
×
198

199
void VCMatrixProperties::slotChooseSliderInputClicked()
×
200
{
201
    SelectInputChannel sic(this, m_doc->inputOutputMap());
×
202
    if (sic.exec() == QDialog::Accepted)
×
203
    {
204
        m_sliderInputSource = QSharedPointer<QLCInputSource>(new QLCInputSource(sic.universe(), sic.channel()));
×
205
        updateSliderInputSource();
×
206
    }
207
}
×
208

209
void VCMatrixProperties::updateSliderInputSource()
×
210
{
211
    QString uniName;
×
212
    QString chName;
×
213

214
    if (m_doc->inputOutputMap()->inputSourceNames(m_sliderInputSource, uniName, chName) == false)
×
215
    {
216
        uniName = KInputNone;
×
217
        chName = KInputNone;
×
218
    }
219

220
    m_inputUniverseEdit->setText(uniName);
×
221
    m_inputChannelEdit->setText(chName);
×
222
}
×
223

224
/*********************************************************************
225
 * Custom controls
226
 *********************************************************************/
227

228
void VCMatrixProperties::updateTree()
×
229
{
230
    m_controlsTree->blockSignals(true);
×
231
    m_controlsTree->clear();
×
232
    foreach (VCMatrixControl *control, m_controls)
×
233
    {
234
        QTreeWidgetItem *item = new QTreeWidgetItem(m_controlsTree);
×
235
        item->setData(0, Qt::UserRole, control->m_id);
×
236

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

NEW
352
        if (control->m_inputSource.isNull() == false && control->m_inputSource->isValid())
×
353
        {
NEW
354
            item->setText(KColumnSoftPatch, QString("%1.%2").arg(control->m_inputSource->universe() + 1).arg(control->m_inputSource->channel() + 1));
×
355
        }
NEW
356
        item->setFlags(item->flags() | Qt::ItemIsEditable);
×
357
    }
×
358
    m_controlsTree->resizeColumnToContents(0);
×
359
    m_controlsTree->blockSignals(false);
×
360
}
×
361

362
VCMatrixControl *VCMatrixProperties::getSelectedControl()
×
363
{
364
    if (m_controlsTree->selectedItems().isEmpty())
×
365
        return NULL;
×
366

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

378
    Q_ASSERT(false);
×
379
    return NULL;
380
}
381

382
QList<QColor> VCMatrixProperties::rgbColorList()
×
383
{
384
    QList<QColor> colors;
×
385
    colors.append(QColor(Qt::red));
×
386
    colors.append(QColor(Qt::green));
×
387
    colors.append(QColor(Qt::blue));
×
388
    return colors;
×
389
}
×
390

391
void VCMatrixProperties::addControl(VCMatrixControl *control)
×
392
{
393
    m_controls.append(control);
×
394
}
×
395

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

408
void VCMatrixProperties::slotAddColorClicked()
×
409
{
410
    QColor col = QColorDialog::getColor();
×
411
    if (col.isValid() == true)
×
412
    {
413
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
414
        newControl->m_type = VCMatrixControl::ControlType(int(VCMatrixControl::Color1) + m_colorsCombo->currentIndex());
×
415
        newControl->m_color = col;
×
416
        addControl(newControl);
×
417
        updateTree();
×
418
    }
419
}
×
420

421
void VCMatrixProperties::slotAddColorKnobsClicked()
×
422
{
423
    foreach (QColor col, VCMatrixProperties::rgbColorList())
×
424
    {
425
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
426
        newControl->m_type = VCMatrixControl::ControlType(int(VCMatrixControl::Color1Knob) + m_colorsCombo->currentIndex());
×
427
        newControl->m_color = col;
×
428
        addControl(newControl);
×
429
    }
×
430
    updateTree();
×
431
}
×
432

433
void VCMatrixProperties::slotAddColorResetClicked()
×
434
{
435
    VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
436
    newControl->m_type = VCMatrixControl::ControlType(int(VCMatrixControl::Color1Reset) + m_colorsCombo->currentIndex());
×
437
    addControl(newControl);
×
438
    updateTree();
×
439
}
×
440

441
void VCMatrixProperties::slotAddAnimationClicked()
×
442
{
443
    VCMatrixPresetSelection ps(m_doc, this);
×
444

445
    if (ps.exec() == QDialog::Accepted)
×
446
    {
NEW
447
        QMap<QString, bool> dynProps = ps.dynamicProperties();
×
NEW
448
        if (dynProps.isEmpty())
×
449
        {
NEW
450
            VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
NEW
451
            newControl->m_type = VCMatrixControl::Animation;
×
NEW
452
            newControl->m_resource = ps.selectedPreset();
×
NEW
453
            newControl->m_properties = ps.customizedProperties();
×
NEW
454
            newControl->m_dynamicProperties = ps.dynamicProperties();
×
NEW
455
            addControl(newControl);
×
456
        }
457
        else
458
        {
NEW
459
            QMapIterator<QString, bool> it(dynProps);
×
NEW
460
            while (it.hasNext())
×
461
            {
NEW
462
                it.next();
×
NEW
463
                if (it.value() == true)
×
464
                {
NEW
465
                    VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
NEW
466
                    newControl->m_type = VCMatrixControl::AnimationKnob;
×
NEW
467
                    newControl->m_resource = it.key();
×
NEW
468
                    addControl(newControl);
×
469
                }
470
            }
NEW
471
        }
×
UNCOV
472
        updateTree();
×
UNCOV
473
    }
×
474
}
×
475

476
void VCMatrixProperties::slotAddTextClicked()
×
477
{
478
    bool ok;
479
    QString text = QInputDialog::getText(this, tr("Enter a text"),
×
480
                                      tr("Text"), QLineEdit::Normal,
×
481
                                      "Q Light Controller+", &ok);
×
482
    if (ok && !text.isEmpty())
×
483
    {
484
        VCMatrixControl *newControl = new VCMatrixControl(++m_lastAssignedID);
×
485
        newControl->m_type = VCMatrixControl::Text;
×
486
        newControl->m_resource = text;
×
487
        addControl(newControl);
×
488
        updateTree();
×
489
    }
490
}
×
491

492
void VCMatrixProperties::slotRemoveClicked()
×
493
{
494
    if (m_controlsTree->selectedItems().isEmpty())
×
495
        return;
×
496
    QTreeWidgetItem *selItem = m_controlsTree->selectedItems().first();
×
497
    quint8 ctlID = selItem->data(0, Qt::UserRole).toUInt();
×
498

499
    {
500
        // For R/G/B Knobs:
501
        // Remove the two others
502
        VCMatrixControl *control = getSelectedControl();
×
503
        if (control != NULL)
×
504
        {
505
            if (control->m_type == VCMatrixControl::Color1Knob
×
506
                    || control->m_type == VCMatrixControl::Color2Knob
×
507
                    || control->m_type == VCMatrixControl::Color3Knob
×
508
                    || control->m_type == VCMatrixControl::Color4Knob
×
509
                    || control->m_type == VCMatrixControl::Color5Knob)
×
510
            {
511
                if (control->m_color == Qt::red)
×
512
                {
513
                    removeControl(ctlID + 1);
×
514
                    removeControl(ctlID + 2);
×
515
                }
516
                else if (control->m_color == Qt::green)
×
517
                {
518
                    removeControl(ctlID - 1);
×
519
                    removeControl(ctlID + 1);
×
520
                }
521
                else if (control->m_color == Qt::blue)
×
522
                {
523
                    removeControl(ctlID - 2);
×
524
                    removeControl(ctlID - 1);
×
525
                }
526
                else
527
                {
528
                    Q_ASSERT(false);
×
529
                }
530
            }
531
        }
532
    }
533

534
    removeControl(ctlID);
×
535
    updateTree();
×
536
}
537

538
void VCMatrixProperties::slotInputValueChanged(quint32 universe, quint32 channel)
×
539
{
540
    Q_UNUSED(universe);
541
    Q_UNUSED(channel);
542

543
    VCMatrixControl *preset = getSelectedControl();
×
544

545
    if (preset != NULL) {
×
546
        preset->m_inputSource = m_presetInputWidget->inputSource();
×
547
    }
548
}
×
549

550
void VCMatrixProperties::slotKeySequenceChanged(QKeySequence key)
×
551
{
552
    VCMatrixControl *preset = getSelectedControl();
×
553

554
    if (preset != NULL)
×
555
        preset->m_keySequence = key;
×
556
}
×
557

558

559
void VCMatrixProperties::slotTreeSelectionChanged()
×
560
{
561
    VCMatrixControl *control = getSelectedControl();
×
562

563
    if (control != NULL)
×
564
    {
565
        m_presetInputWidget->setInputSource(control->m_inputSource);
×
566
        m_presetInputWidget->setKeySequence(control->m_keySequence.toString(QKeySequence::NativeText));
×
567
        if (control->widgetType() == VCMatrixControl::Button)
×
568
        {
569
            m_presetInputWidget->setCustomFeedbackVisibility(true);
×
570
            m_presetInputWidget->setKeyInputVisibility(true);
×
571
        }
572
        else
573
        {
574
            m_presetInputWidget->setCustomFeedbackVisibility(false);
×
575
            m_presetInputWidget->setKeyInputVisibility(false);
×
576
        }
577
    }
578
}
×
579

NEW
580
void VCMatrixProperties::slotTreeItemDoubleClicked(QTreeWidgetItem *item, int column)
×
581
{
NEW
582
    if (column == KColumnSoftPatch)
×
NEW
583
        m_controlsTree->editItem(item, column);
×
NEW
584
}
×
585

NEW
586
void VCMatrixProperties::slotTreeItemChanged(QTreeWidgetItem *item, int column)
×
587
{
NEW
588
    if (item == NULL || column != KColumnSoftPatch)
×
NEW
589
        return;
×
590

NEW
591
    QList<QTreeWidgetItem*> selection = m_controlsTree->selectedItems();
×
NEW
592
    QString patch = item->text(KColumnSoftPatch);
×
NEW
593
    QStringList list = patch.split(".");
×
594

NEW
595
    if (list.length() != 2)
×
NEW
596
        return;
×
597

NEW
598
    quint32 universe = list.at(0).toUInt();
×
NEW
599
    quint32 channel = list.at(1).toUInt();
×
600

NEW
601
    if (selection.count() > 1)
×
602
    {
NEW
603
        m_controlsTree->blockSignals(true);
×
NEW
604
        for (int i = 0; i < selection.count(); ++i)
×
605
        {
NEW
606
            QTreeWidgetItem *selItem = selection.at(i);
×
NEW
607
            quint8 ctlID = selItem->data(0, Qt::UserRole).toUInt();
×
NEW
608
            foreach (VCMatrixControl *control, m_controls)
×
609
            {
NEW
610
                if (control->m_id == ctlID)
×
611
                {
NEW
612
                    if (universe > 0 && channel > 0)
×
613
                    {
NEW
614
                        control->m_inputSource = QSharedPointer<QLCInputSource>(new QLCInputSource(universe - 1, (channel + i) - 1));
×
NEW
615
                        selItem->setText(KColumnSoftPatch, QString("%1.%2").arg(universe).arg(channel + i));
×
616
                    }
617
                    else
618
                    {
NEW
619
                        control->m_inputSource.clear();
×
NEW
620
                        selItem->setText(KColumnSoftPatch, "");
×
621
                    }
NEW
622
                    break;
×
623
                }
NEW
624
            }
×
625
        }
NEW
626
        m_controlsTree->blockSignals(false);
×
627
    }
628
    else
629
    {
NEW
630
        VCMatrixControl *control = getSelectedControl();
×
NEW
631
        if (control == NULL)
×
NEW
632
            return;
×
633

NEW
634
        if (patch.isEmpty())
×
635
        {
NEW
636
            control->m_inputSource.clear();
×
637
        }
638
        else
639
        {
NEW
640
            if (universe > 0 && channel > 0)
×
NEW
641
                control->m_inputSource = QSharedPointer<QLCInputSource>(new QLCInputSource(universe - 1, channel - 1));
×
642
            else
NEW
643
                control->m_inputSource.clear();
×
644
        }
645
    }
NEW
646
}
×
647

UNCOV
648
void VCMatrixProperties::slotColorComboActivated()
×
649
{
650
    if (m_colorsCombo->currentIndex() == 0)
×
651
        m_addColorResetButton->setEnabled(false);
×
652
    else
653
        m_addColorResetButton->setEnabled(true);
×
654
}
×
655

656
void VCMatrixProperties::accept()
×
657
{
658
    m_matrix->setCaption(m_nameEdit->text());
×
659
    m_matrix->setFunction(m_function);
×
660
    if (m_instantCheck->isChecked())
×
661
        m_matrix->setInstantChanges(true);
×
662
    else
663
        m_matrix->setInstantChanges(false);
×
664

665
    /* External input */
666
    m_matrix->setInputSource(m_sliderInputSource);
×
667

668
    /* Visibility */
669
    quint32 visibilityMask = 0;
×
670
    if (m_sliderCheck->isChecked()) visibilityMask |= VCMatrix::ShowSlider;
×
671
    if (m_labelCheck->isChecked()) visibilityMask |= VCMatrix::ShowLabel;
×
672
    if (m_mtxColor1ButtonCheck->isChecked()) visibilityMask |= VCMatrix::ShowColor1Button;
×
673
    if (m_mtxColor2ButtonCheck->isChecked()) visibilityMask |= VCMatrix::ShowColor2Button;
×
674
    if (m_mtxColor3ButtonCheck->isChecked()) visibilityMask |= VCMatrix::ShowColor3Button;
×
675
    if (m_mtxColor4ButtonCheck->isChecked()) visibilityMask |= VCMatrix::ShowColor4Button;
×
676
    if (m_mtxColor5ButtonCheck->isChecked()) visibilityMask |= VCMatrix::ShowColor5Button;
×
677
    if (m_presetComboCheck->isChecked()) visibilityMask |= VCMatrix::ShowPresetCombo;
×
678
    m_matrix->setVisibilityMask(visibilityMask);
×
679

680
    /* Controls */
681
    m_matrix->resetCustomControls();
×
682
    for (int i = 0; i < m_controls.count(); i++)
×
683
        m_matrix->addCustomControl(*m_controls.at(i));
×
684

685
    /* Close dialog */
686
    QDialog::accept();
×
687
}
×
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