• 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/consolechannel.cpp
1
/*
2
  Q Light Controller
3
  consolechannel.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 <QContextMenuEvent>
21
#include <QIntValidator>
22
#include <QWidgetAction>
23
#include <QVBoxLayout>
24
#include <QToolButton>
25
#include <QSpinBox>
26
#include <QDebug>
27
#include <QLabel>
28
#include <QMenu>
29
#include <QList>
30

31
#include "qlcchannel.h"
32
#include "qlccapability.h"
33

34
#include "doc.h"
35
#include "fixture.h"
36
#include "apputil.h"
37
#include "consolechannel.h"
38

39
/*****************************************************************************
40
 * Initialization
41
 *****************************************************************************/
42

43
ConsoleChannel::ConsoleChannel(QWidget* parent, Doc* doc, quint32 fixture, quint32 channel, bool isCheckable)
×
44
    : QGroupBox(parent)
45
    , m_doc(doc)
46
    , m_fixture(fixture)
47
    , m_chIndex(channel)
48
    , m_group(Fixture::invalidId())
×
49
    , m_presetButton(NULL)
50
    , m_cngWidget(NULL)
51
    , m_spin(NULL)
52
    , m_slider(NULL)
53
    , m_label(NULL)
54
    , m_resetButton(NULL)
55
    , m_showResetButton(false)
56
    , m_menu(NULL)
57
    , m_selected(false)
×
58
{
59
    Q_ASSERT(doc != NULL);
×
60
    Q_ASSERT(channel != QLCChannel::invalid());
×
61

62
    if (isCheckable == true)
×
63
        setCheckable(true);
×
64
    setFocusPolicy(Qt::NoFocus);
×
65
    init();
×
66
}
×
67

68
ConsoleChannel::~ConsoleChannel()
×
69
{
70
}
×
71

72
void ConsoleChannel::init()
×
73
{
74
    Fixture* fxi = m_doc->fixture(m_fixture);
×
75
    //Q_ASSERT(fxi != NULL);
76

77
    new QVBoxLayout(this);
×
78
    layout()->setSpacing(0);
×
79
    layout()->setContentsMargins(0, 2, 0, 2);
×
80

81
    if (fxi != NULL)
×
82
    {
83
        m_presetButton = new QToolButton(this);
×
84
        m_presetButton->setStyle(AppUtil::saneStyle());
×
85
        layout()->addWidget(m_presetButton);
×
86
        layout()->setAlignment(m_presetButton, Qt::AlignHCenter);
×
87
        m_presetButton->setIconSize(QSize(32, 32));
×
88
        m_presetButton->setMinimumSize(QSize(32, 32));
×
89
        m_presetButton->setMaximumSize(QSize(32, 32));
×
90
        m_presetButton->setFocusPolicy(Qt::NoFocus);
×
91

92
        /* Create a menu only if channel has sophisticated contents */
93
        if (fxi->fixtureDef() != NULL && fxi->fixtureMode() != NULL)
×
94
            initMenu();
×
95
        else
96
            m_presetButton->setStyleSheet("QToolButton { border-image: url(:/intensity.png) 0 0 0 0 stretch stretch; }");
×
97
    }
98

99
    /* Value edit */
100
    m_spin = new QSpinBox(this);
×
101
    m_spin->setRange(0, UCHAR_MAX);
×
102
    m_spin->setValue(0);
×
103
    m_spin->setMinimumWidth(25);
×
104
    m_spin->setMaximumWidth(40);
×
105
    m_spin->setButtonSymbols(QAbstractSpinBox::NoButtons);
×
106
    m_spin->setStyle(AppUtil::saneStyle());
×
107
    layout()->addWidget(m_spin);
×
108
    m_spin->setAlignment(Qt::AlignCenter);
×
109
    m_spin->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
×
110
    layout()->setAlignment(m_spin, Qt::AlignHCenter);
×
111

112
    /* Value slider */
113
    m_slider = new ClickAndGoSlider(this);
×
114
    m_slider->setInvertedAppearance(false);
×
115
    m_slider->setRange(0, UCHAR_MAX);
×
116
    m_slider->setPageStep(1);
×
117
    m_slider->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
×
118
    m_slider->setFocusPolicy(Qt::NoFocus);
×
119
    connect(m_slider, SIGNAL(controlClicked()),
×
120
            this, SLOT(slotControlClicked()));
121

122
    QString style = "QSlider::groove:vertical { background: transparent; width: 32px; } "
123

124
                    "QSlider::handle:vertical { "
125
                    "background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #ddd, stop:0.45 #888, stop:0.50 #000, stop:0.55 #888, stop:1 #999);"
126
                    "border: 1px solid #5c5c5c;"
127
                    "border-radius: 4px; margin: 0 -1px; height: 20px; }"
128

129
                    "QSlider::handle:vertical:hover {"
130
                    "background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #eee, stop:0.45 #999, stop:0.50 #ff0000, stop:0.55 #999, stop:1 #ccc);"
131
                    "border: 1px solid #000; }"
132

133
                    "QSlider::add-page:vertical { background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #78d, stop: 1 #97CDEC );"
134
                    "border: 1px solid #5288A7; margin: 0 13px; }"
135

136
                    "QSlider::sub-page:vertical { background: QLinearGradient( x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #888, stop: 1 #ddd );"
137
                    "border: 1px solid #8E8A86; margin: 0 13px; }"
138

139
                    "QSlider::handle:vertical:disabled { background: QLinearGradient(x1:0, y1:0, x2:0, y2:1, stop:0 #ddd, stop:0.45 #888, stop:0.50 #444, stop:0.55 #888, stop:1 #999);"
140
                    "border: 1px solid #666; }";
×
141

142
    QString userStyle = AppUtil::getStyleSheet("CONSOLE_CHANNEL_COMMON");
×
143
    if (!userStyle.isEmpty())
×
144
        style = userStyle;
×
145

146
    m_slider->setMinimumWidth(25);
×
147
    m_slider->setMaximumWidth(40);
×
148
    m_slider->setVisible(false);
×
149
    m_slider->setSliderStyleSheet(style);
×
150
    layout()->addWidget(m_slider);
×
151
    //layout()->setAlignment(m_slider, Qt::AlignHCenter);
152

153
    /* Channel number label */
154
    m_label = new QLabel(this);
×
155
    m_label->setMinimumWidth(25);
×
156
    m_label->setMaximumWidth(80);
×
157
    layout()->addWidget(m_label);
×
158
    m_label->setAlignment(Qt::AlignCenter);
×
159
    m_label->setText(QString::number(m_chIndex + 1));
×
160
    m_label->setFocusPolicy(Qt::NoFocus);
×
161
    m_label->setWordWrap(true);
×
162

163
    /* Set tooltip */
164
    if (fxi == NULL)
×
165
    {
166
        setToolTip(tr("Intensity"));
×
167
    }
168
    else
169
    {
170
        const QLCChannel *ch = fxi->channel(m_chIndex);
×
171
        Q_ASSERT(ch != NULL);
×
172
        setToolTip(QString("%1").arg(ch->name()));
×
173
        setValue(ch->defaultValue(), false);
×
174
        m_channel = ch;
×
175
    }
176

177
    connect(m_spin, SIGNAL(valueChanged(int)), this, SLOT(slotSpinChanged(int)));
×
178
    connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(slotSliderChanged(int)));
×
179
    connect(this, SIGNAL(toggled(bool)), this, SLOT(slotChecked(bool)));
×
180
}
×
181

182
void ConsoleChannel::showEvent(QShowEvent *)
×
183
{
184
    if (m_styleSheet.isEmpty() == false)
×
185
    {
186
        setChannelStyleSheet(m_styleSheet);
×
187
        m_slider->setVisible(true);
×
188
        m_styleSheet = "";
×
189
    }
190
}
×
191

192
/*****************************************************************************
193
 * Fixture & Channel
194
 *****************************************************************************/
195

196
quint32 ConsoleChannel::fixture() const
×
197
{
198
    return m_fixture;
×
199
}
200

201
quint32 ConsoleChannel::channelIndex() const
×
202
{
203
    return m_chIndex;
×
204
}
205

206
const QLCChannel *ConsoleChannel::channel()
×
207
{
208
    return m_channel;
×
209
}
210

211
/*************************************************************************
212
 * Group
213
 *************************************************************************/
214
void ConsoleChannel::setLabel(QString label)
×
215
{
216
    m_label->setText(label);
×
217
}
×
218

219
void ConsoleChannel::setChannelsGroup(quint32 grpid)
×
220
{
221
    m_group = grpid;
×
222
    ChannelsGroup *grp = m_doc->channelsGroup(grpid);
×
223
    connect(grp, SIGNAL(valueChanged(quint32,uchar)),
×
224
            this, SLOT(slotInputValueChanged(quint32,uchar)));
225
}
×
226

227
void ConsoleChannel::slotInputValueChanged(quint32 channel, uchar value)
×
228
{
229
    Q_UNUSED(channel)
230
    setValue(value);
×
231
}
×
232

233
/*****************************************************************************
234
 * Value
235
 *****************************************************************************/
236

237
void ConsoleChannel::setValue(uchar value, bool apply)
×
238
{
239
    if (m_slider->value() == value &&
×
240
        m_spin->value() == value)
×
241
            return;
×
242

243
    if (apply == false)
×
244
    {
245
        m_spin->blockSignals(true);
×
246
        m_slider->blockSignals(true);
×
247
    }
248

249
    m_slider->setValue(int(value));
×
250
    m_spin->setValue(int(value));
×
251

252
    if (apply == false)
×
253
    {
254
        m_spin->blockSignals(false);
×
255
        m_slider->blockSignals(false);
×
256
    }
257
}
258

259
uchar ConsoleChannel::value() const
×
260
{
261
    return uchar(m_slider->value());
×
262
}
263

264
void ConsoleChannel::slotSpinChanged(int value)
×
265
{
266
    if (value != m_slider->value())
×
267
        m_slider->setValue(value);
×
268

269
    if (m_group == Fixture::invalidId())
×
270
        emit valueChanged(m_fixture, m_chIndex, value);
×
271
    else
272
        emit groupValueChanged(m_group, value);
×
273
}
×
274

275
void ConsoleChannel::slotSliderChanged(int value)
×
276
{
277
    if (value != m_spin->value())
×
278
        m_spin->setValue(value);
×
279
}
×
280
void ConsoleChannel::slotChecked(bool state)
×
281
{
282
    emit checked(m_fixture, m_chIndex, state);
×
283

284
    // Emit the current value also when turning the channel back on
285
    if (state == true)
×
286
        emit valueChanged(m_fixture, m_chIndex, m_slider->value());
×
287
}
×
288

289
/*************************************************************************
290
 * Look & Feel
291
 *************************************************************************/
292

293
void ConsoleChannel::setChannelStyleSheet(const QString &styleSheet)
×
294
{
NEW
295
    if (isVisible())
×
296
        QGroupBox::setStyleSheet(styleSheet);
×
297
    else
298
        m_styleSheet = styleSheet;
×
299
}
×
300

301
void ConsoleChannel::showResetButton(bool show)
×
302
{
303
    if (show == true)
×
304
    {
305
        if (m_resetButton == NULL)
×
306
        {
307
            m_resetButton = new QToolButton(this);
×
308
            m_resetButton->setStyle(AppUtil::saneStyle());
×
309
            layout()->addWidget(m_resetButton);
×
310
            layout()->setAlignment(m_resetButton, Qt::AlignHCenter);
×
311
            m_resetButton->setIconSize(QSize(32, 32));
×
312
            m_resetButton->setMinimumSize(QSize(32, 32));
×
313
            m_resetButton->setMaximumSize(QSize(32, 32));
×
314
            m_resetButton->setFocusPolicy(Qt::NoFocus);
×
315
            m_resetButton->setIcon(QIcon(":/fileclose.png"));
×
316
            m_resetButton->setToolTip(tr("Reset this channel"));
×
317
        }
318
        connect(m_resetButton, SIGNAL(clicked(bool)),
×
319
                this, SLOT(slotResetButtonClicked()));
320
    }
321
    else
322
    {
323
        if (m_resetButton != NULL)
×
324
        {
325
            layout()->removeWidget(m_resetButton);
×
326
            delete m_resetButton;
×
327
            m_resetButton = NULL;
×
328
        }
329
    }
330
}
×
331

332
bool ConsoleChannel::hasResetButton()
×
333
{
334
    return m_resetButton != NULL ? true : false;
×
335
}
336

337
void ConsoleChannel::slotResetButtonClicked()
×
338
{
339
    emit resetRequest(m_fixture, m_chIndex);
×
340
}
×
341

342
/*****************************************************************************
343
 * Menu
344
 *****************************************************************************/
345

346
void ConsoleChannel::initMenu()
×
347
{
348
    Fixture* fxi = m_doc->fixture(fixture());
×
349
    Q_ASSERT(fxi != NULL);
×
350

351
    const QLCChannel* ch = fxi->channel(m_chIndex);
×
352
    Q_ASSERT(ch != NULL);
×
353

354
    // Get rid of a possible previous menu
355
    if (m_menu != NULL)
×
356
    {
357
        delete m_menu;
×
358
        m_menu = NULL;
×
359
    }
360

361
    // Create a popup menu and set the channel name as its title
362
    m_menu = new QMenu(this);
×
363
    m_presetButton->setMenu(m_menu);
×
364
    m_presetButton->setPopupMode(QToolButton::InstantPopup);
×
365

366
    QString btnIconStr = ch->getIconNameFromGroup(ch->group());
×
367
    if (btnIconStr.startsWith(":"))
×
368
        m_presetButton->setStyleSheet("QToolButton { border-image: url(" + btnIconStr + ") 0 0 0 0 stretch stretch; }");
×
369
    else
370
    {
371
        m_presetButton->setStyleSheet("QToolButton { background: " + btnIconStr + "; }");
×
372
        setIntensityButton(ch);
×
373
    }
374

375
    switch(ch->group())
×
376
    {
377
    case QLCChannel::Colour:
×
378
        m_cngWidget = new ClickAndGoWidget();
×
379
        m_cngWidget->setType(ClickAndGoWidget::Preset, ch);
×
380
        break;
×
381
    case QLCChannel::Effect:
×
382
        m_cngWidget = new ClickAndGoWidget();
×
383
        m_cngWidget->setType(ClickAndGoWidget::Preset, ch);
×
384
        break;
×
385
    case QLCChannel::Gobo:
×
386
        m_cngWidget = new ClickAndGoWidget();
×
387
        m_cngWidget->setType(ClickAndGoWidget::Preset, ch);
×
388
        break;
×
389
    default:
×
390
        break;
×
391
    }
392

393
    if (m_cngWidget != NULL)
×
394
    {
395
        QWidgetAction* action = new QWidgetAction(this);
×
396
        action->setDefaultWidget(m_cngWidget);
×
397
        m_menu->addAction(action);
×
398
        connect(m_cngWidget, SIGNAL(levelChanged(uchar)),
×
399
                this, SLOT(slotClickAndGoLevelChanged(uchar)));
400
        connect(m_cngWidget, SIGNAL(levelAndPresetChanged(uchar,QImage)),
×
401
                this, SLOT(slotClickAndGoLevelAndPresetChanged(uchar, QImage)));
402
    }
403
    else
404
    {
405
        QAction* action = m_menu->addAction(m_presetButton->icon(), ch->name());
×
406
        m_menu->setTitle(ch->name());
×
407
        action->setEnabled(false);
×
408
        m_menu->addSeparator();
×
409

410
        // Initialize the preset menu only for intelligent fixtures
411
        initCapabilityMenu(ch);
×
412
    }
413
}
×
414

415
void ConsoleChannel::setIntensityButton(const QLCChannel* channel)
×
416
{
417
    QFont fnt = m_presetButton->font();
×
418
    fnt.setBold(true);
×
419
    m_presetButton->setFont(fnt);
×
420

421
    if (channel->colour() == QLCChannel::Red)
×
422
    {
423
        m_presetButton->setText("R"); // Don't localize
×
424
        m_cngWidget = new ClickAndGoWidget();
×
425
        m_cngWidget->setType(ClickAndGoWidget::Red);
×
426
    }
427
    else if (channel->colour() == QLCChannel::Green)
×
428
    {
429
        m_presetButton->setText("G"); // Don't localize
×
430
        m_cngWidget = new ClickAndGoWidget();
×
431
        m_cngWidget->setType(ClickAndGoWidget::Green);
×
432
    }
433
    else if (channel->colour() == QLCChannel::Blue)
×
434
    {
435
        QPalette pal = m_presetButton->palette();
×
436
        pal.setColor(QPalette::ButtonText, Qt::white); // Improve contrast
×
437
        m_presetButton->setPalette(pal);
×
438
        m_presetButton->setText("B"); // Don't localize
×
439
        m_cngWidget = new ClickAndGoWidget();
×
440
        m_cngWidget->setType(ClickAndGoWidget::Blue);
×
441
    }
442
    else if (channel->colour() == QLCChannel::Cyan)
×
443
    {
444
        m_presetButton->setText("C"); // Don't localize
×
445
        m_cngWidget = new ClickAndGoWidget();
×
446
        m_cngWidget->setType(ClickAndGoWidget::Cyan);
×
447
    }
448
    else if (channel->colour() == QLCChannel::Magenta)
×
449
    {
450
        m_presetButton->setText("M"); // Don't localize
×
451
        m_cngWidget = new ClickAndGoWidget();
×
452
        m_cngWidget->setType(ClickAndGoWidget::Magenta);
×
453
    }
454
    else if (channel->colour() == QLCChannel::Yellow)
×
455
    {
456
        m_presetButton->setText("Y"); // Don't localize
×
457
        m_cngWidget = new ClickAndGoWidget();
×
458
        m_cngWidget->setType(ClickAndGoWidget::Yellow);
×
459
    }
460
    else if (channel->colour() == QLCChannel::Amber)
×
461
    {
462
        m_presetButton->setText("A"); // Don't localize
×
463
        m_cngWidget = new ClickAndGoWidget();
×
464
        m_cngWidget->setType(ClickAndGoWidget::Amber);
×
465
    }
466
    else if (channel->colour() == QLCChannel::White)
×
467
    {
468
        m_presetButton->setText("W"); // Don't localize
×
469
        m_cngWidget = new ClickAndGoWidget();
×
470
        m_cngWidget->setType(ClickAndGoWidget::White);
×
471
    }
472
    else if (channel->colour() == QLCChannel::UV)
×
473
    {
474
        m_presetButton->setText("UV"); // Don't localize
×
475
        m_cngWidget = new ClickAndGoWidget();
×
476
        m_cngWidget->setType(ClickAndGoWidget::UV);
×
477
    }
478
    else if (channel->colour() == QLCChannel::Lime)
×
479
    {
480
        m_presetButton->setText("L");
×
481
        m_cngWidget = new ClickAndGoWidget();
×
482
        m_cngWidget->setType(ClickAndGoWidget::Lime);
×
483
    }
484
    else if (channel->colour() == QLCChannel::Indigo)
×
485
    {
486
        m_presetButton->setText("I");
×
487
        m_cngWidget = new ClickAndGoWidget();
×
488
        m_cngWidget->setType(ClickAndGoWidget::Indigo);
×
489
    }
490
    else
491
    {
492
        // None of the primary colours matched and since this is an
493
        // intensity channel, it must be controlling a plain dimmer OSLT.
494
        m_presetButton->setStyleSheet("QToolButton { border-image: url(:/intensity.png) 0 0 0 0 stretch stretch; }");
×
495
    }
496
}
×
497

498
void ConsoleChannel::initCapabilityMenu(const QLCChannel* ch)
×
499
{
500
    QLCCapability* cap;
501
    QMenu* valueMenu;
502
    QAction* action;
503
    QString s;
×
504
    QString t;
×
505

506
    QListIterator <QLCCapability*> it(ch->capabilities());
×
507
    while (it.hasNext() == true)
×
508
    {
509
        cap = it.next();
×
510

511
        // Set the value range and name as the menu item's name
512
        s = QString("%1: %2 - %3").arg(cap->name())
×
513
            .arg(cap->min()).arg(cap->max());
×
514

515
        if (cap->max() - cap->min() > 0)
×
516
        {
517
            // Create submenu for ranges of more than one value
518
            valueMenu = new QMenu(m_menu);
×
519
            valueMenu->setTitle(s);
×
520

521
            /* Add a color icon */
522
            if (ch->group() == QLCChannel::Colour)
×
523
                valueMenu->setIcon(colorIcon(cap->name()));
×
524

525
            for (int i = cap->min(); i <= cap->max(); i++)
×
526
            {
527
                action = valueMenu->addAction(t.asprintf("%.3d", i));
×
528
                action->setData(i);
×
529
            }
530

531
            m_menu->addMenu(valueMenu);
×
532
        }
533
        else
534
        {
535
            // Just one value in this range, put that into the menu
536
            action = m_menu->addAction(s);
×
537
            action->setData(cap->min());
×
538

539
            /* Add a color icon */
540
            if (ch->group() == QLCChannel::Colour)
×
541
                action->setIcon(colorIcon(cap->name()));
×
542
        }
543
    }
544

545
    // Connect menu item activation signal to this
546
    connect(m_menu, SIGNAL(triggered(QAction*)),
×
547
            this, SLOT(slotContextMenuTriggered(QAction*)));
548

549
    // Set the menu also as the preset button's popup menu
550
    m_presetButton->setMenu(m_menu);
×
551
}
×
552

553
QIcon ConsoleChannel::colorIcon(const QString& name)
×
554
{
555
    /* Return immediately with a rainbow icon -- if appropriate */
556
    if (name.toLower().contains("rainbow") ||
×
557
            name.toLower().contains("cw") == true)
×
558
    {
559
        return QIcon(":/rainbow.png");
×
560
    }
561
    else if (name.toLower().contains("cto") == true)
×
562
    {
563
        QColor color(255, 201, 0);
×
564
        QPixmap pm(32, 32);
×
565
        pm.fill(color);
×
566
        return QIcon(pm);
×
567
    }
568
    else if (name.toLower().contains("ctb") == true)
×
569
    {
570
        QColor color(0, 128, 190);
×
571
        QPixmap pm(32, 32);
×
572
        pm.fill(color);
×
573
        return QIcon(pm);
×
574
    }
575
    else if (name.toLower().contains("uv") == true)
×
576
    {
577
        QColor color(37, 0, 136);
×
578
        QPixmap pm(32, 32);
×
579
        pm.fill(color);
×
580
        return QIcon(pm);
×
581
    }
582

583
#ifdef Q_WS_X11
584
    QColor::setAllowX11ColorNames(true);
585
#endif
586
    QStringList colorList(QColor::colorNames());
×
587
    QString colname;
×
588
    QColor color;
×
589
    int index;
590

591
    colname = name.toLower().remove(QRegularExpression("[0-9]")).remove(' ');
×
592
    index = colorList.indexOf(colname);
×
593
    if (index != -1)
×
594
    {
595
        color.setNamedColor(colname);
×
596
    }
597
    else
598
    {
599
        QString re("(");
×
600
        QListIterator <QString> it(name.toLower().split(" "));
×
601
        while (it.hasNext() == true)
×
602
        {
603
            re += it.next();
×
604
            if (it.hasNext() == true)
×
605
                re += "|";
×
606
        }
607
        re += ")";
×
608

609
        QRegularExpression regex(re, QRegularExpression::CaseInsensitiveOption);
×
610
        index = colorList.indexOf(regex);
×
611
        if (index != -1)
×
612
            color.setNamedColor(colorList.at(index));
×
613
    }
614

615
    if (color.isValid() == true)
×
616
    {
617
        QPixmap pm(32, 32);
×
618
        pm.fill(color);
×
619
        return QIcon(pm);
×
620
    }
621
    else
622
    {
623
        return QIcon();
×
624
    }
625
}
626

627
void ConsoleChannel::contextMenuEvent(QContextMenuEvent* e)
×
628
{
629
    // Show the preset menu only of it has been created.
630
    // Generic dimmer fixtures don't have capabilities and so
631
    // they will not have these menus either.
632
    if (m_menu != NULL)
×
633
    {
634
        m_menu->exec(e->globalPos());
×
635
        e->accept();
×
636
    }
637
}
×
638

639
void ConsoleChannel::slotContextMenuTriggered(QAction* action)
×
640
{
641
    Q_ASSERT(action != NULL);
×
642

643
    // The menuitem's data contains a valid DMX value
644
    setValue(action->data().toInt());
×
645
}
×
646

647
void ConsoleChannel::slotClickAndGoLevelChanged(uchar level)
×
648
{
649
    setValue(level);
×
650
}
×
651

652
void ConsoleChannel::slotClickAndGoLevelAndPresetChanged(uchar level, QImage img)
×
653
{
654
    Q_UNUSED(img)
655
    setValue(level);
×
656
}
×
657

658
/*************************************************************************
659
 * Selection
660
 *************************************************************************/
661

662
bool ConsoleChannel::isSelected()
×
663
{
664
    return m_selected;
×
665
}
666

667
void ConsoleChannel::slotControlClicked()
×
668
{
669
    qDebug() << "CONTROL modifier + click";
×
670
    if (m_selected == false)
×
671
    {
672
        m_originalStyle = styleSheet();
×
673
        int topMargin = isCheckable()?16:1;
×
674

675
        QString common = "QGroupBox::title {top:-15px; left: 12px; subcontrol-origin: border; background-color: transparent; } "
676
                         "QGroupBox::indicator { width: 18px; height: 18px; } "
677
                         "QGroupBox::indicator:checked { image: url(:/checkbox_full.png) } "
678
                         "QGroupBox::indicator:unchecked { image: url(:/checkbox_empty.png) }";
×
679
        QString ssSelected = QString("QGroupBox { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D9D730, stop: 1 #AFAD27); "
×
680
                                 "border: 1px solid gray; border-radius: 4px; margin-top: %1px; margin-right: 1px; } " +
681
                                 (isCheckable()?common:"")).arg(topMargin);
×
682
        setChannelStyleSheet(ssSelected);
×
683
        m_selected = true;
×
684
    }
685
    else
686
    {
687
        setChannelStyleSheet(m_originalStyle);
×
688
        m_selected = false;
×
689
    }
690
}
×
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