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

mcallegari / qlcplus / 7252848206

18 Dec 2023 07:26PM UTC coverage: 32.067% (+0.001%) from 32.066%
7252848206

push

github

mcallegari
Code style review #1427

199 of 628 new or added lines in 101 files covered. (31.69%)

8 existing lines in 2 files now uncovered.

15169 of 47304 relevant lines covered (32.07%)

23733.74 hits per line

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

0.0
/ui/src/inputprofileeditor.cpp
1
/*
2
  Q Light Controller
3
  inputprofileeditor.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 <QTreeWidgetItem>
21
#include <QTextBrowser>
22
#include <QTreeWidget>
23
#include <QToolButton>
24
#include <QMessageBox>
25
#include <QTabWidget>
26
#include <QSettings>
27
#include <QCheckBox>
28
#include <QDialog>
29
#include <QTimer>
30
#include <QDebug>
31
#include <QFile>
32
#include <QList>
33
#include <QDir>
34

35
#include "qlcinputprofile.h"
36
#include "qlcchannel.h"
37

38
#include "inputchanneleditor.h"
39
#include "inputprofileeditor.h"
40
#include "inputoutputmap.h"
41
#include "apputil.h"
42

43
#define SETTINGS_GEOMETRY "inputprofileeditor/geometry"
44

45
#define KColumnNumber 0
46
#define KColumnName   1
47
#define KColumnType   2
48
#define KColumnValues 3
49

50
/****************************************************************************
51
 * Initialization
52
 ****************************************************************************/
53

54
InputProfileEditor::InputProfileEditor(QWidget* parent, QLCInputProfile* profile,
×
55
                                       InputOutputMap *ioMap)
×
56
    : QDialog(parent)
57
    , m_ioMap(ioMap)
58
    , m_wizardActive(false)
59
    , m_latestItem(NULL)
×
60
{
61
    Q_ASSERT(ioMap != NULL);
×
62

63
    setupUi(this);
×
64

65
    m_midiGroupSettings->setVisible(false);
×
66
    connect(m_typeCombo, SIGNAL(currentIndexChanged(int)),
×
67
            this, SLOT(slotTypeComboChanged(int)));
68

69
    /* Connect the buttons to slots */
70
    connect(m_addButton, SIGNAL(clicked()),
×
71
            this, SLOT(slotAddClicked()));
72
    connect(m_removeButton, SIGNAL(clicked()),
×
73
            this, SLOT(slotRemoveClicked()));
74
    connect(m_editButton, SIGNAL(clicked()),
×
75
            this, SLOT(slotEditClicked()));
76
    connect(m_wizardButton, SIGNAL(clicked(bool)),
×
77
            this, SLOT(slotWizardClicked(bool)));
78
    connect(m_tree, SIGNAL(itemClicked(QTreeWidgetItem*,int)),
×
79
            this, SLOT(slotItemClicked(QTreeWidgetItem*,int)));
80
    connect(m_tree, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)),
×
81
            this, SLOT(slotEditClicked()));
82
    connect(m_movementCombo, SIGNAL(currentIndexChanged(int)),
×
83
            this, SLOT(slotMovementComboChanged(int)));
84
    connect(m_sensitivitySpin, SIGNAL(valueChanged(int)),
×
85
            this, SLOT(slotSensitivitySpinChanged(int)));
86
    connect(m_extraPressCheck, SIGNAL(toggled(bool)),
×
87
            this, SLOT(slotExtraPressChecked(bool)));
88
    connect(m_lowerSpin, SIGNAL(valueChanged(int)),
×
89
            this, SLOT(slotLowerValueSpinChanged(int)));
90
    connect(m_upperSpin, SIGNAL(valueChanged(int)),
×
91
            this, SLOT(slotUpperValueSpinChanged(int)));
92

93
    /* Listen to input data */
94
    connect(m_ioMap, SIGNAL(inputValueChanged(quint32, quint32, uchar, const QString&)),
×
95
            this, SLOT(slotInputValueChanged(quint32, quint32, uchar, const QString&)));
96

97
    if (profile == NULL)
×
98
    {
99
        m_profile = new QLCInputProfile();
×
100
    }
101
    else
102
    {
103
        m_profile = profile->createCopy();
×
104
        if ((QFile::permissions(m_profile->path()) &
×
105
                QFile::WriteUser) == 0)
×
106
        {
107
            QMessageBox::warning(this, tr("File not writable"),
×
108
                                 tr("You do not have permission to write to "
×
109
                                    "the file %1. You might not be able to "
110
                                    "save your modifications to the profile.")
111
                                 .arg(QDir::toNativeSeparators(
×
112
                                          m_profile->path())));
×
113
        }
114
    }
115

116
    QList<QLCInputProfile::Type> types = QLCInputProfile::types();
×
117
    for (int i = 0; i < types.size(); ++i)
×
118
    {
119
        const QLCInputProfile::Type type = types.at(i);
×
120
        m_typeCombo->addItem(QLCInputProfile::typeToString(type), type);
×
121
        if (m_profile->type() == type)
×
122
        {
123
            m_typeCombo->setCurrentIndex(i);
×
124
            if (type == QLCInputProfile::MIDI)
×
125
            {
126
                m_midiGroupSettings->setVisible(true);
×
127
                m_noteOffCheck->setChecked(m_profile->midiSendNoteOff());
×
128
            }
129
        }
130
    }
131

132
    /* Profile manufacturer & model */
133
    m_manufacturerEdit->setText(m_profile->manufacturer());
×
134
    m_modelEdit->setText(m_profile->model());
×
135

136
    m_behaviourBox->hide();
×
137
    m_feedbackGroup->hide();
×
138
    /* Fill up the tree with profile's channels */
139
    fillTree();
×
140

141
    /* Timer that clears the input data icon after a while */
142
    m_timer = new QTimer(this);
×
143
    m_timer->setSingleShot(true);
×
144
    connect(m_timer, SIGNAL(timeout()), this, SLOT(slotTimerTimeout()));
×
145

146
    QSettings settings;
×
147
    QVariant var = settings.value(SETTINGS_GEOMETRY);
×
148
    if (var.isValid() == true)
×
149
        restoreGeometry(var.toByteArray());
×
150
    AppUtil::ensureWidgetIsVisible(this);
×
151
}
×
152

153
InputProfileEditor::~InputProfileEditor()
×
154
{
155
    QSettings settings;
×
156
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
×
157

158
    delete m_profile;
×
159
}
×
160

161
void InputProfileEditor::fillTree()
×
162
{
163
    m_tree->clear();
×
164

165
    QMapIterator <quint32,QLCInputChannel*> it(m_profile->channels());
×
166
    while (it.hasNext() == true)
×
167
    {
168
        it.next();
×
169
        updateChannelItem(new QTreeWidgetItem(m_tree), it.value());
×
170
    }
171
    m_tree->header()->resizeSections(QHeaderView::ResizeToContents);
×
172
}
×
173

174
void InputProfileEditor::updateChannelItem(QTreeWidgetItem* item,
×
175
                                           QLCInputChannel* ch)
176
{
177
    quint32 num;
178

179
    Q_ASSERT(item != NULL);
×
180
    Q_ASSERT(ch != NULL);
×
181

182
    num = m_profile->channelNumber(ch);
×
183
    item->setText(KColumnNumber, QString("%1").arg(num + 1, 4, 10, QChar('0')));
×
184
    item->setText(KColumnName, ch->name());
×
185
    item->setText(KColumnType, QLCInputChannel::typeToString(ch->type()));
×
186
    item->setIcon(KColumnType, ch->icon());
×
187
}
×
188

189
void InputProfileEditor::setOptionsVisibility(QLCInputChannel::Type type)
×
190
{
191
    bool showBox = true;
×
192
    bool showMovement = false;
×
193
    bool showSensitivity = false;
×
194
    bool showButtonOpts = false;
×
195

196
    if (type == QLCInputChannel::Slider || type == QLCInputChannel::Knob)
×
197
    {
198
        showMovement = true;
×
199
        showSensitivity = true;
×
200
        m_sensitivitySpin->setRange(10, 100);
×
201
    }
202
    else if (type == QLCInputChannel::Encoder)
×
203
    {
204
        showSensitivity = true;
×
205
        m_sensitivitySpin->setRange(1, 20);
×
206
    }
207
    else if (type == QLCInputChannel::Button)
×
208
    {
209
        showButtonOpts = true;
×
210
    }
211
    else
212
        showBox = false;
×
213

214
    m_movementLabel->setVisible(showMovement);
×
215
    m_movementCombo->setVisible(showMovement);
×
216
    m_sensitivityLabel->setVisible(showSensitivity);
×
217
    m_sensitivitySpin->setVisible(showSensitivity);
×
218
    m_extraPressCheck->setVisible(showButtonOpts);
×
219
    m_feedbackGroup->setVisible(showButtonOpts);
×
220
    m_behaviourBox->setVisible(showBox);
×
221
}
×
222

223
void InputProfileEditor::slotTypeComboChanged(int)
×
224
{
225
    if (currentProfileType() == QLCInputProfile::MIDI)
×
226
        m_midiGroupSettings->setVisible(true);
×
227
    else
228
        m_midiGroupSettings->setVisible(false);
×
229
}
×
230

231
/****************************************************************************
232
 * OK & Cancel
233
 ****************************************************************************/
234

235
void InputProfileEditor::reject()
×
236
{
237
    /* Don't allow closing the dialog in any way when the wizard is on */
238
    if (m_buttonBox->isEnabled() == false)
×
239
        return;
×
240

241
    QDialog::reject();
×
242
}
243

244
void InputProfileEditor::accept()
×
245
{
246
    /* Don't allow closing the dialog in any way when the wizard is on */
247
    if (m_buttonBox->isEnabled() == false)
×
248
        return;
×
249

250
    m_profile->setManufacturer(m_manufacturerEdit->text());
×
251
    m_profile->setModel(m_modelEdit->text());
×
252
    m_profile->setType(currentProfileType());
×
253

254
    if (currentProfileType() == QLCInputProfile::MIDI)
×
255
        m_profile->setMidiSendNoteOff(m_noteOffCheck->isChecked());
×
256

257
    /* Check that we have at least the bare necessities to save the profile */
258
    if (m_profile->manufacturer().isEmpty() == true ||
×
259
            m_profile->model().isEmpty() == true)
×
260
    {
261
        QMessageBox::warning(this, tr("Missing information"),
×
262
                             tr("Manufacturer and/or model name is missing."));
×
263
    }
264
    else
265
    {
266
        QDialog::accept();
×
267
    }
268
}
269

270
/****************************************************************************
271
 * Editing
272
 ****************************************************************************/
273

274
QList<QLCInputChannel *> InputProfileEditor::selectedChannels()
×
275
{
276
    QList<QLCInputChannel *> channels;
×
277

278
    QListIterator <QTreeWidgetItem*>it(m_tree->selectedItems());
×
279
    while (it.hasNext() == true)
×
280
    {
281
        QTreeWidgetItem *item = it.next();
×
282
        Q_ASSERT(item != NULL);
×
283

284
        quint32 chnum = item->text(KColumnNumber).toUInt() - 1;
×
285
        QLCInputChannel *channel = m_profile->channel(chnum);
×
286
        Q_ASSERT(channel != NULL);
×
287

288
        channels.append(channel);
×
289
    }
290
    return channels;
×
291
}
292

293
void InputProfileEditor::slotAddClicked()
×
294
{
295
    QLCInputChannel* channel = new QLCInputChannel();
×
296
    InputChannelEditor ice(this, m_profile, channel, currentProfileType());
×
297
add:
×
298
    if (ice.exec() == QDialog::Accepted)
×
299
    {
300
        channel->setType(ice.type());
×
301
        channel->setName(ice.name());
×
302

303
        if (m_profile->channel(ice.channel()) == NULL)
×
304
        {
305
            m_profile->insertChannel(ice.channel(), channel);
×
306
            updateChannelItem(new QTreeWidgetItem(m_tree), channel);
×
307
        }
308
        else
309
        {
310
            QMessageBox::warning(this,
×
311
                                 tr("Channel already exists"),
×
312
                                 tr("Channel %1 already exists")
×
313
                                 .arg(ice.channel() + 1));
×
314
            goto add;
×
315
        }
316
    }
317
    else
318
    {
319
        delete channel;
×
320
    }
321
}
×
322

323
void InputProfileEditor::slotRemoveClicked()
×
324
{
325
    QList <QTreeWidgetItem*> selected;
×
326
    QTreeWidgetItem* next = NULL;
×
327

328
    /* Ask for confirmation if we're deleting more than one channel */
329
    selected = m_tree->selectedItems();
×
330
    if (selected.count() > 1)
×
331
    {
332
        int r;
333
        r = QMessageBox::question(this, tr("Delete channels"),
×
334
                                  tr("Delete all %1 selected channels?")
×
335
                                  .arg(selected.count()),
×
336
                                  QMessageBox::Yes | QMessageBox::No);
337
        if (r == QMessageBox::No)
×
338
            return;
×
339
    }
340

341
    /* Remove all selected channels */
342
    QMutableListIterator <QTreeWidgetItem*> it(selected);
×
343
    while (it.hasNext() == true)
×
344
    {
345
        QTreeWidgetItem *item = it.next();
×
346
        Q_ASSERT(item != NULL);
×
347

348
        /* Remove & Delete the channel object */
349
        quint32 chnum = item->text(KColumnNumber).toUInt() - 1;
×
350
        m_profile->removeChannel(chnum);
×
351

352
        /* Choose the closest item below or above the removed items
353
           as the one that is selected after the removal */
354
        next = m_tree->itemBelow(item);
×
355
        if (next == NULL)
×
356
            next = m_tree->itemAbove(item);
×
357

358
        delete item;
×
359
    }
360

361
    m_tree->setCurrentItem(next);
×
362
}
363

364
void InputProfileEditor::slotEditClicked()
×
365
{
366
    QLCInputChannel* channel;
367
    quint32 chnum;
368
    QTreeWidgetItem* item;
369

370
    if (m_tree->selectedItems().count() == 1)
×
371
    {
372
        /* Just one item selected. Edit that. */
373
        item = m_tree->currentItem();
×
374
        if (item == NULL)
×
375
            return;
×
376

377
        /* Find the channel object associated to the selected item */
378
        chnum = item->text(KColumnNumber).toUInt() - 1;
×
379
        channel = m_profile->channel(chnum);
×
380
        Q_ASSERT(channel != NULL);
×
381

382
        /* Edit the channel and update its item if necessary */
383
        InputChannelEditor ice(this, m_profile, channel, currentProfileType());
×
384
edit:
×
385
        if (ice.exec() == QDialog::Accepted)
×
386
        {
387
            QLCInputChannel* another;
388
            another = m_profile->channel(ice.channel());
×
389

390
            if (another == NULL || another == channel)
×
391
            {
392
                if (ice.channel() != QLCChannel::invalid())
×
393
                    m_profile->remapChannel(channel, ice.channel());
×
394
                if (ice.name().isEmpty() == false)
×
395
                    channel->setName(ice.name());
×
396
                if (ice.type() != QLCInputChannel::NoType)
×
397
                {
398
                    if (ice.type() != channel->type())
×
399
                        setOptionsVisibility(ice.type());
×
400
                    channel->setType(ice.type());
×
401
                    if (m_sensitivitySpin->isVisible())
×
402
                        m_sensitivitySpin->setValue(channel->movementSensitivity());
×
403
                }
404

405
                updateChannelItem(item, channel);
×
406
            }
407
            else
408
            {
409
                QMessageBox::warning(this,
×
410
                                     tr("Channel already exists"),
×
411
                                     tr("Channel %1 already exists")
×
412
                                     .arg(ice.channel() + 1));
×
413
                goto edit;
×
414
            }
415
        }
416
    }
417
    else if (m_tree->selectedItems().count() > 1)
×
418
    {
419
        /* Multiple channels selected. Apply changes to all of them */
420
        InputChannelEditor ice(this, NULL, NULL, QLCInputProfile::DMX);
×
421
        if (ice.exec() == QDialog::Accepted)
×
422
        {
423
            QListIterator <QTreeWidgetItem*>
424
            it(m_tree->selectedItems());
×
425
            while (it.hasNext() == true)
×
426
            {
427
                item = it.next();
×
428
                Q_ASSERT(item != NULL);
×
429

430
                chnum = item->text(KColumnNumber).toUInt() - 1;
×
431
                channel = m_profile->channel(chnum);
×
432
                Q_ASSERT(channel != NULL);
×
433

434
                /* Set only name and type and only if they
435
                   have been modified. */
436
                if (ice.name().isEmpty() == false)
×
437
                    channel->setName(ice.name());
×
438
                if (ice.type() != QLCInputChannel::NoType)
×
439
                    channel->setType(ice.type());
×
440

441
                updateChannelItem(item, channel);
×
442
            }
443
        }
444
    }
445
}
446

447
void InputProfileEditor::slotWizardClicked(bool checked)
×
448
{
449
    if (checked == true)
×
450
    {
451
        QMessageBox::information(this, tr("Channel wizard activated"),
×
452
                                 tr("You have enabled the input channel wizard. After "
×
453
                                    "clicking OK, wiggle your mapped input profile's "
454
                                    "controls. They should appear into the list. "
455
                                    "Click the wizard button again to stop channel "
456
                                    "auto-detection.\n\nNote that the wizard cannot "
457
                                    "tell the difference between a knob and a slider "
458
                                    "so you will have to do the change manually."));
459
        m_wizardActive = true;
×
460
    }
461
    else
462
    {
463
        m_wizardActive = false;
×
464
    }
465

466
    m_buttonBox->setEnabled(!checked);
×
467
    m_tab->setTabEnabled(0, !checked);
×
468
}
×
469

470
void InputProfileEditor::slotItemClicked(QTreeWidgetItem *item, int col)
×
471
{
472
    Q_UNUSED(col)
473

474
    quint32 chNum = item->text(KColumnNumber).toUInt() - 1;
×
475
    QLCInputChannel *ich = m_profile->channel(chNum);
×
476
    if (ich != NULL)
×
477
    {
478
        setOptionsVisibility(ich->type());
×
479

480
        if (ich->type() == QLCInputChannel::Slider || ich->type() == QLCInputChannel::Knob)
×
481
        {
482
            if (ich->movementType() == QLCInputChannel::Absolute)
×
483
            {
484
                m_movementCombo->setCurrentIndex(0);
×
485
                m_sensitivitySpin->setEnabled(false);
×
486
            }
487
            else
488
            {
489
                m_movementCombo->setCurrentIndex(1);
×
490
                m_sensitivitySpin->setValue(ich->movementSensitivity());
×
491
                m_sensitivitySpin->setEnabled(true);
×
492
            }
493
        }
494
        else if (ich->type() == QLCInputChannel::Encoder)
×
495
        {
496
            m_sensitivitySpin->setValue(ich->movementSensitivity());
×
497
            m_sensitivitySpin->setEnabled(true);
×
498
        }
499
        else if (ich->type() == QLCInputChannel::Button)
×
500
        {
501
            m_extraPressCheck->setChecked(ich->sendExtraPress());
×
502
            m_lowerSpin->blockSignals(true);
×
503
            m_upperSpin->blockSignals(true);
×
504
            m_lowerSpin->setValue(ich->lowerValue());
×
505
            m_upperSpin->setValue(ich->upperValue());
×
506
            m_lowerSpin->blockSignals(false);
×
507
            m_upperSpin->blockSignals(false);
×
508
        }
509
    }
510
    else
511
        setOptionsVisibility(QLCInputChannel::NoType);
×
512
}
×
513

514
void InputProfileEditor::slotMovementComboChanged(int index)
×
515
{
516
    if (index == 1)
×
517
        m_sensitivitySpin->setEnabled(true);
×
518
    else
519
        m_sensitivitySpin->setEnabled(false);
×
520

NEW
521
    foreach (QLCInputChannel *channel, selectedChannels())
×
522
    {
523
        if (channel->type() == QLCInputChannel::Slider ||
×
524
            channel->type() == QLCInputChannel::Knob)
×
525
        {
526
            if (index == 1)
×
527
                channel->setMovementType(QLCInputChannel::Relative);
×
528
            else
529
                channel->setMovementType(QLCInputChannel::Absolute);
×
530
        }
531
    }
532
}
×
533

534
void InputProfileEditor::slotSensitivitySpinChanged(int value)
×
535
{
NEW
536
    foreach (QLCInputChannel *channel, selectedChannels())
×
537
    {
538
        if ((channel->type() == QLCInputChannel::Slider ||
×
539
             channel->type() == QLCInputChannel::Knob) &&
×
540
            channel->movementType() == QLCInputChannel::Relative)
×
541
                channel->setMovementSensitivity(value);
×
542
        else if (channel->type() == QLCInputChannel::Encoder)
×
543
            channel->setMovementSensitivity(value);
×
544
    }
545
}
×
546

547
void InputProfileEditor::slotExtraPressChecked(bool checked)
×
548
{
NEW
549
    foreach (QLCInputChannel *channel, selectedChannels())
×
550
    {
NEW
551
        if (channel->type() == QLCInputChannel::Button)
×
552
            channel->setSendExtraPress(checked);
×
553
    }
554
}
×
555

556
void InputProfileEditor::slotLowerValueSpinChanged(int value)
×
557
{
NEW
558
    foreach (QLCInputChannel *channel, selectedChannels())
×
559
    {
560
        if (channel->type() == QLCInputChannel::Button)
×
561
            channel->setRange(uchar(value), uchar(m_upperSpin->value()));
×
562
    }
563
}
×
564

565
void InputProfileEditor::slotUpperValueSpinChanged(int value)
×
566
{
NEW
567
    foreach (QLCInputChannel *channel, selectedChannels())
×
568
    {
569
        if (channel->type() == QLCInputChannel::Button)
×
570
            channel->setRange(uchar(m_lowerSpin->value()), uchar(value));
×
571
    }
572
}
×
573

574
void InputProfileEditor::slotInputValueChanged(quint32 universe,
×
575
                                               quint32 channel,
576
                                               uchar value,
577
                                               const QString& key)
578
{
579
    QTreeWidgetItem* latestItem = NULL;
×
580

581
    Q_UNUSED(universe);
582

583
    /* Get a list of items that represent the given channel. Basically
584
       the list should always contain just one item. */
585
    QList <QTreeWidgetItem*> list;
×
586
    if (channel == UINT_MAX && key.isEmpty() == false)
×
587
        list = m_tree->findItems(key, Qt::MatchExactly, KColumnName);
×
588
    else
589
        list = m_tree->findItems(QString("%1").arg(channel + 1, 4, 10, QChar('0')), Qt::MatchExactly,
×
590
                             KColumnNumber);
×
591
    if (list.size() != 0)
×
592
        latestItem = list.first();
×
593

594
    if (list.size() == 0 && m_wizardActive == true)
×
595
    {
596
        /* No channel items found. Create a new channel to the
597
           profile and display it also in the tree widget */
598
        QLCInputChannel* ch = new QLCInputChannel();
×
NEW
599
        if (key.isEmpty())
×
600
            ch->setName(tr("Button %1").arg(channel + 1));
×
601
        else
602
            ch->setName(key);
×
603
        ch->setType(QLCInputChannel::Button);
×
604
        m_profile->insertChannel(channel, ch);
×
605

606
        latestItem = new QTreeWidgetItem(m_tree);
×
607
        updateChannelItem(latestItem, ch);
×
608
    }
609
    else if (m_wizardActive == true)
×
610
    {
611
        /* Existing channel & item found. Modify their contents. */
612
        latestItem = list.first();
×
613
        QVariant var = latestItem->data(KColumnValues, Qt::UserRole);
×
614
        QStringList values(var.toStringList());
×
615

616
        if (values.size() > 3)
×
617
        {
618
            /* No need to collect any more values, since this channel has
619
               been judged to be a slider when count == 3 (see below). */
620
        }
621
        else if (values.contains(QString("%1").arg(value)) == false)
×
622
        {
623
            values << QString("%1").arg(value);
×
624
            values.sort();
×
625
            latestItem->setData(KColumnValues, Qt::UserRole, values);
×
626
        }
627

628
        /* Change the channel type only the one time when its value
629
           count goes over 2. I.e. when a channel can have more than
630
           two distinct values, it can no longer be a button. */
631
        if (values.size() == 3)
×
632
        {
633
            QLCInputChannel* ch = m_profile->channel(channel);
×
634
            Q_ASSERT(ch != NULL);
×
635

636
            if (ch->type() == QLCInputChannel::Button)
×
637
            {
638
                ch->setType(QLCInputChannel::Slider);
×
NEW
639
                if (key.isEmpty())
×
640
                    ch->setName(tr("Slider %1").arg(channel + 1));
×
641
                else
642
                    ch->setName(key);
×
643
                updateChannelItem(latestItem, ch);
×
644
            }
645
        }
646
    }
647

648
    if (latestItem != NULL)
×
649
    {
650
        if (m_latestItem != NULL)
×
651
            m_latestItem->setIcon(KColumnNumber, QIcon());
×
652
        m_latestItem = latestItem;
×
653
        m_latestItem->setIcon(KColumnNumber, QIcon(":/input.png"));
×
654
        m_tree->scrollToItem(m_latestItem);
×
655
        m_timer->start(250);
×
656
    }
657
}
×
658

659
void InputProfileEditor::slotTimerTimeout()
×
660
{
661
    if (m_latestItem != NULL)
×
662
        m_latestItem->setIcon(KColumnNumber, QIcon());
×
663
    m_latestItem = NULL;
×
664
}
×
665

666
/****************************************************************************
667
 * Profile
668
 ****************************************************************************/
669

670
QLCInputProfile* InputProfileEditor::profile()
×
671
{
672
    return m_profile;
×
673
}
674

675
QLCInputProfile::Type InputProfileEditor::currentProfileType() const
×
676
{
677
    return static_cast<QLCInputProfile::Type>(m_typeCombo->itemData(m_typeCombo->currentIndex()).toInt());
×
678
}
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