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

mcallegari / qlcplus / 6683238402

29 Oct 2023 12:10PM UTC coverage: 28.07%. Remained the same
6683238402

push

github

mcallegari
engine: fix build

15385 of 54809 relevant lines covered (28.07%)

20267.63 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
    m_slider->setMinimumWidth(25);
×
123
    m_slider->setMaximumWidth(40);
×
124
    m_slider->setVisible(false);
×
125
    m_slider->setSliderStyleSheet(
×
126
        "QSlider::groove:vertical { background: transparent; width: 32px; } "
127

128
        "QSlider::handle:vertical { "
129
        "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);"
130
        "border: 1px solid #5c5c5c;"
131
        "border-radius: 4px; margin: 0 -1px; height: 20px; }"
132

133
        "QSlider::handle:vertical:hover {"
134
        "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);"
135
        "border: 1px solid #000; }"
136

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

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

143
        "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);"
144
        "border: 1px solid #666; }"
145
        );
146
    layout()->addWidget(m_slider);
×
147
    //layout()->setAlignment(m_slider, Qt::AlignHCenter);
148

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

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

173
    connect(m_spin, SIGNAL(valueChanged(int)), this, SLOT(slotSpinChanged(int)));
×
174
    connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(slotSliderChanged(int)));
×
175
    connect(this, SIGNAL(toggled(bool)), this, SLOT(slotChecked(bool)));
×
176
}
×
177

178
void ConsoleChannel::showEvent(QShowEvent *)
×
179
{
180
    if (m_styleSheet.isEmpty() == false)
×
181
    {
182
        setChannelStyleSheet(m_styleSheet);
×
183
        m_slider->setVisible(true);
×
184
        m_styleSheet = "";
×
185
    }
186
}
×
187

188
/*****************************************************************************
189
 * Fixture & Channel
190
 *****************************************************************************/
191

192
quint32 ConsoleChannel::fixture() const
×
193
{
194
    return m_fixture;
×
195
}
196

197
quint32 ConsoleChannel::channelIndex() const
×
198
{
199
    return m_chIndex;
×
200
}
201

202
const QLCChannel *ConsoleChannel::channel()
×
203
{
204
    return m_channel;
×
205
}
206

207
/*************************************************************************
208
 * Group
209
 *************************************************************************/
210
void ConsoleChannel::setLabel(QString label)
×
211
{
212
    m_label->setText(label);
×
213
}
×
214

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

223
void ConsoleChannel::slotInputValueChanged(quint32 channel, uchar value)
×
224
{
225
    Q_UNUSED(channel)
226
    setValue(value);
×
227
}
×
228

229
/*****************************************************************************
230
 * Value
231
 *****************************************************************************/
232

233
void ConsoleChannel::setValue(uchar value, bool apply)
×
234
{
235
    if (m_slider->value() == value &&
×
236
        m_spin->value() == value)
×
237
            return;
×
238

239
    if (apply == false)
×
240
    {
241
        m_spin->blockSignals(true);
×
242
        m_slider->blockSignals(true);
×
243
    }
244

245
    m_slider->setValue(int(value));
×
246
    m_spin->setValue(int(value));
×
247

248
    if (apply == false)
×
249
    {
250
        m_spin->blockSignals(false);
×
251
        m_slider->blockSignals(false);
×
252
    }
253
}
254

255
uchar ConsoleChannel::value() const
×
256
{
257
    return uchar(m_slider->value());
×
258
}
259

260
void ConsoleChannel::slotSpinChanged(int value)
×
261
{
262
    if (value != m_slider->value())
×
263
        m_slider->setValue(value);
×
264

265
    if (m_group == Fixture::invalidId())
×
266
        emit valueChanged(m_fixture, m_chIndex, value);
×
267
    else
268
        emit groupValueChanged(m_group, value);
×
269
}
×
270

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

280
    // Emit the current value also when turning the channel back on
281
    if (state == true)
×
282
        emit valueChanged(m_fixture, m_chIndex, m_slider->value());
×
283
}
×
284

285
/*************************************************************************
286
 * Look & Feel
287
 *************************************************************************/
288

289
void ConsoleChannel::setChannelStyleSheet(const QString &styleSheet)
×
290
{
291
    if(isVisible())
×
292
        QGroupBox::setStyleSheet(styleSheet);
×
293
    else
294
        m_styleSheet = styleSheet;
×
295
}
×
296

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

328
bool ConsoleChannel::hasResetButton()
×
329
{
330
    return m_resetButton != NULL ? true : false;
×
331
}
332

333
void ConsoleChannel::slotResetButtonClicked()
×
334
{
335
    emit resetRequest(m_fixture, m_chIndex);
×
336
}
×
337

338
/*****************************************************************************
339
 * Menu
340
 *****************************************************************************/
341

342
void ConsoleChannel::initMenu()
×
343
{
344
    Fixture* fxi = m_doc->fixture(fixture());
×
345
    Q_ASSERT(fxi != NULL);
×
346

347
    const QLCChannel* ch = fxi->channel(m_chIndex);
×
348
    Q_ASSERT(ch != NULL);
×
349

350
    // Get rid of a possible previous menu
351
    if (m_menu != NULL)
×
352
    {
353
        delete m_menu;
×
354
        m_menu = NULL;
×
355
    }
356

357
    // Create a popup menu and set the channel name as its title
358
    m_menu = new QMenu(this);
×
359
    m_presetButton->setMenu(m_menu);
×
360
    m_presetButton->setPopupMode(QToolButton::InstantPopup);
×
361

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

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

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

406
        // Initialize the preset menu only for intelligent fixtures
407
        initCapabilityMenu(ch);
×
408
    }
409
}
×
410

411
void ConsoleChannel::setIntensityButton(const QLCChannel* channel)
×
412
{
413
    QFont fnt = m_presetButton->font();
×
414
    fnt.setBold(true);
×
415
    m_presetButton->setFont(fnt);
×
416

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

494
void ConsoleChannel::initCapabilityMenu(const QLCChannel* ch)
×
495
{
496
    QLCCapability* cap;
497
    QMenu* valueMenu;
498
    QAction* action;
499
    QString s;
×
500
    QString t;
×
501

502
    QListIterator <QLCCapability*> it(ch->capabilities());
×
503
    while (it.hasNext() == true)
×
504
    {
505
        cap = it.next();
×
506

507
        // Set the value range and name as the menu item's name
508
        s = QString("%1: %2 - %3").arg(cap->name())
×
509
            .arg(cap->min()).arg(cap->max());
×
510

511
        if (cap->max() - cap->min() > 0)
×
512
        {
513
            // Create submenu for ranges of more than one value
514
            valueMenu = new QMenu(m_menu);
×
515
            valueMenu->setTitle(s);
×
516

517
            /* Add a color icon */
518
            if (ch->group() == QLCChannel::Colour)
×
519
                valueMenu->setIcon(colorIcon(cap->name()));
×
520

521
            for (int i = cap->min(); i <= cap->max(); i++)
×
522
            {
523
                action = valueMenu->addAction(t.asprintf("%.3d", i));
×
524
                action->setData(i);
×
525
            }
526

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

535
            /* Add a color icon */
536
            if (ch->group() == QLCChannel::Colour)
×
537
                action->setIcon(colorIcon(cap->name()));
×
538
        }
539
    }
540

541
    // Connect menu item activation signal to this
542
    connect(m_menu, SIGNAL(triggered(QAction*)),
×
543
            this, SLOT(slotContextMenuTriggered(QAction*)));
544

545
    // Set the menu also as the preset button's popup menu
546
    m_presetButton->setMenu(m_menu);
×
547
}
×
548

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

579
#ifdef Q_WS_X11
580
    QColor::setAllowX11ColorNames(true);
581
#endif
582
    QStringList colorList(QColor::colorNames());
×
583
    QString colname;
×
584
    QColor color;
×
585
    int index;
586

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

605
        QRegularExpression regex(re, QRegularExpression::CaseInsensitiveOption);
×
606
        index = colorList.indexOf(regex);
×
607
        if (index != -1)
×
608
            color.setNamedColor(colorList.at(index));
×
609
    }
610

611
    if (color.isValid() == true)
×
612
    {
613
        QPixmap pm(32, 32);
×
614
        pm.fill(color);
×
615
        return QIcon(pm);
×
616
    }
617
    else
618
    {
619
        return QIcon();
×
620
    }
621
}
622

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

635
void ConsoleChannel::slotContextMenuTriggered(QAction* action)
×
636
{
637
    Q_ASSERT(action != NULL);
×
638

639
    // The menuitem's data contains a valid DMX value
640
    setValue(action->data().toInt());
×
641
}
×
642

643
void ConsoleChannel::slotClickAndGoLevelChanged(uchar level)
×
644
{
645
    setValue(level);
×
646
}
×
647

648
void ConsoleChannel::slotClickAndGoLevelAndPresetChanged(uchar level, QImage img)
×
649
{
650
    Q_UNUSED(img)
651
    setValue(level);
×
652
}
×
653

654
/*************************************************************************
655
 * Selection
656
 *************************************************************************/
657

658
bool ConsoleChannel::isSelected()
×
659
{
660
    return m_selected;
×
661
}
662

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

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