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

mcallegari / qlcplus / 21225345472

21 Jan 2026 08:53PM UTC coverage: 34.161% (-0.001%) from 34.162%
21225345472

push

github

web-flow
Merge pull request #1936 from mcallegari/v5web

Version 5 web interface implementation

0 of 2 new or added lines in 1 file covered. (0.0%)

1 existing line in 1 file now uncovered.

17718 of 51866 relevant lines covered (34.16%)

19813.92 hits per line

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

0.0
/ui/src/simpledesk.cpp
1
/*
2
  Q Light Controller Plus
3
  simpledesk.cpp
4

5
  Copyright (c) Heikki Junnila
6
                Massimo Callegari
7

8
  Licensed under the Apache License, Version 2.0 (the "License");
9
  you may not use this file except in compliance with the License.
10
  You may obtain a copy of the License at
11

12
      http://www.apache.org/licenses/LICENSE-2.0.txt
13

14
  Unless required by applicable law or agreed to in writing, software
15
  distributed under the License is distributed on an "AS IS" BASIS,
16
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
  See the License for the specific language governing permissions and
18
  limitations under the License.
19
*/
20

21
#include <QXmlStreamReader>
22
#include <QXmlStreamWriter>
23
#include <QInputDialog>
24
#include <QToolButton>
25
#include <QHeaderView>
26
#include <QPushButton>
27
#include <QScrollArea>
28
#include <QSettings>
29
#include <QSplitter>
30
#include <QGroupBox>
31
#include <QTreeView>
32
#include <QComboBox>
33
#include <QSpinBox>
34
#include <QLayout>
35
#include <QLabel>
36
#include <QFrame>
37
#include <QDebug>
38

39
#include "grandmasterslider.h"
40
#include "simpledeskengine.h"
41
#include "speeddialwidget.h"
42
#include "fixtureconsole.h"
43
#include "playbackslider.h"
44
#include "consolechannel.h"
45
#include "cuestackmodel.h"
46
#include "groupsconsole.h"
47
#include "simpledesk.h"
48
#include "cuestack.h"
49
#include "apputil.h"
50
#include "cue.h"
51
#include "doc.h"
52

53
#define PROP_ADDRESS    "address"
54
#define PROP_PLAYBACK   "playback"
55

56
#define SETTINGS_SPLITTER       "simpledesk/splitter"
57
#define SETTINGS_PAGE_CHANNELS  "simpledesk/channelsperpage"
58
#define SETTINGS_PAGE_PLAYBACKS "simpledesk/playbacksperpage"
59
#define SETTINGS_CHANNEL_NAMES  "simpledesk/showchannelnames"
60
#define DEFAULT_PAGE_CHANNELS   32
61
#define DEFAULT_PAGE_PLAYBACKS  15
62

63
SimpleDesk* SimpleDesk::s_instance = NULL;
64

65
QString ssEven =  "QGroupBox { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #C3D1C9, stop: 1 #AFBBB4); "
66
                 " border: 1px solid gray; border-radius: 4px; }";
67
QString ssOdd = "QGroupBox { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D6D5E0, stop: 1 #A7A6AF); "
68
                 " border: 1px solid gray; border-radius: 4px; }";
69
QString ssNone = "QGroupBox { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #D6D2D0, stop: 1 #AFACAB); "
70
                 " border: 1px solid gray; border-radius: 4px; }";
71
QString ssOverride = "QGroupBox { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #FF2D2D, stop: 1 #FF5050); "
72
                     " border: 1px solid gray; border-radius: 4px; }";
73

74
/*****************************************************************************
75
 * Initialization
76
 *****************************************************************************/
77

78
SimpleDesk::SimpleDesk(QWidget* parent, Doc* doc)
×
79
    : QWidget(parent)
80
    , m_engine(new SimpleDeskEngine(doc))
×
81
    , m_doc(doc)
×
82
    , m_docChanged(false)
×
83
    , m_chGroupsArea(NULL)
×
84
    , m_currentUniverse(0)
×
85
    , m_channelsPerPage(DEFAULT_PAGE_CHANNELS)
×
86
    , m_selectedPlayback(UINT_MAX)
×
87
    , m_playbacksPerPage(DEFAULT_PAGE_PLAYBACKS)
×
88
    , m_speedDials(NULL)
×
89
{
90
    Q_ASSERT(s_instance == NULL);
×
91
    s_instance = this;
×
92

93
    Q_ASSERT(doc != NULL);
×
94

95
    QSettings settings;
×
96
    QVariant var = settings.value(SETTINGS_PAGE_CHANNELS);
×
97
    if (var.isValid() == true && var.toUInt() > 0)
×
98
    {
99
        qDebug() << "[SimpleDesk] Using custom channels per page setting";
×
100
        m_channelsPerPage = var.toUInt();
×
101
    }
102

103
    var = settings.value(SETTINGS_PAGE_PLAYBACKS);
×
104
    if (var.isValid() == true && var.toUInt() > 0)
×
105
        m_playbacksPerPage = var.toUInt();
×
106

107
    // default all the universes pages to 1
108
    for (quint32 i = 0; i < m_doc->inputOutputMap()->universesCount(); i++)
×
109
        m_universesPage.append(1);
×
110

111
    QString userStyle = AppUtil::getStyleSheet("SIMPLE_DESK_NONE");
×
112
    if (!userStyle.isEmpty())
×
113
        ssNone = userStyle;
×
114

115
    userStyle = AppUtil::getStyleSheet("SIMPLE_DESK_ODD");
×
116
    if (!userStyle.isEmpty())
×
117
        ssOdd = userStyle;
×
118

119
    userStyle = AppUtil::getStyleSheet("SIMPLE_DESK_EVEN");
×
120
    if (!userStyle.isEmpty())
×
121
        ssEven = userStyle;
×
122

123
    userStyle = AppUtil::getStyleSheet("SIMPLE_DESK_OVERRIDE");
×
124
    if (!userStyle.isEmpty())
×
125
        ssOverride = userStyle;
×
126

127
    initEngine();
×
128
    initView();
×
129
    initUniverseSliders();
×
130
    initUniversePager();
×
131
    initPlaybackSliders();
×
132
    initCueStack();
×
133

134
    slotSelectPlayback(0);
×
135

136
    connect(m_doc, SIGNAL(fixtureAdded(quint32)),
×
137
            this, SLOT(slotDocChanged()));
138
    connect(m_doc, SIGNAL(fixtureRemoved(quint32)),
×
139
            this, SLOT(slotDocChanged()));
140
    connect(m_doc, SIGNAL(fixtureChanged(quint32)),
×
141
            this, SLOT(slotDocChanged()));
142
    connect(m_doc, SIGNAL(channelsGroupAdded(quint32)),
×
143
            this, SLOT(slotDocChanged()));
144
    connect(m_doc, SIGNAL(channelsGroupRemoved(quint32)),
×
145
            this, SLOT(slotDocChanged()));
146

147
    connect(m_doc->inputOutputMap(), SIGNAL(universeAdded(quint32)),
×
148
            this, SLOT(slotDocChanged()));
149
    connect(m_doc->inputOutputMap(), SIGNAL(universeRemoved(quint32)),
×
150
            this, SLOT(slotDocChanged()));
151

152
    connect(m_doc->inputOutputMap(), SIGNAL(universeWritten(quint32, const QByteArray&)),
×
153
            this, SLOT(slotUniverseWritten(quint32, const QByteArray&)));
154
}
×
155

156
SimpleDesk::~SimpleDesk()
×
157
{
158
    QSettings settings;
×
159
    settings.setValue(SETTINGS_SPLITTER, m_splitter->saveState());
×
160

161
    Q_ASSERT(m_engine != NULL);
×
162
    delete m_engine;
×
163
    m_engine = NULL;
×
164

165
    s_instance = NULL;
×
166
}
×
167

168
SimpleDesk* SimpleDesk::instance()
×
169
{
170
    return s_instance;
×
171
}
172

173
void SimpleDesk::clearContents()
×
174
{
175
    //qDebug() << Q_FUNC_INFO;
176
    CueStackModel* model = qobject_cast<CueStackModel*> (m_cueStackView->model());
×
177
    Q_ASSERT(model != NULL);
×
178
    model->setCueStack(NULL);
×
179

180
    resetUniverseSliders();
×
181
    resetPlaybackSliders();
×
182
    m_engine->clearContents();
×
183
    slotSelectPlayback(0);
×
184
}
×
185

186
void SimpleDesk::initEngine()
×
187
{
188
    //qDebug() << Q_FUNC_INFO;
189
    connect(m_engine, SIGNAL(cueStackStarted(uint)), this, SLOT(slotCueStackStarted(uint)));
×
190
    connect(m_engine, SIGNAL(cueStackStopped(uint)), this, SLOT(slotCueStackStopped(uint)));
×
191
}
×
192

193
void SimpleDesk::initView()
×
194
{
195
    //qDebug() << Q_FUNC_INFO;
196

197
    new QVBoxLayout(this);
×
198
    layout()->setContentsMargins(0, 0, 0, 0);
×
199
    m_splitter = new QSplitter(this);
×
200
    layout()->addWidget(m_splitter);
×
201

202
    initTopSide();
×
203
    initBottomSide();
×
204

205
    QSettings settings;
×
206
    m_splitter->restoreState(settings.value(SETTINGS_SPLITTER).toByteArray());
×
207
    m_splitter->setOrientation(Qt::Vertical);
×
208
}
×
209

210
void SimpleDesk::initTopSide()
×
211
{
212
    QWidget* topSide = new QWidget(this);
×
213
    QVBoxLayout* lay = new QVBoxLayout(topSide);
×
214
    lay->setContentsMargins(1, 1, 1, 1);
×
215
    m_splitter->addWidget(topSide);
×
216

217
    QHBoxLayout* uniLay = new QHBoxLayout;
×
218
    uniLay->setContentsMargins(1, 1, 1, 1);
×
219

220
    m_viewModeButton = new QToolButton(this);
×
221
    m_viewModeButton->setIcon(QIcon(":/tabview.png"));
×
222
    m_viewModeButton->setIconSize(QSize(24, 24));
×
223
    m_viewModeButton->setMinimumSize(QSize(36, 36));
×
224
    m_viewModeButton->setMaximumSize(QSize(36, 36));
×
225
    m_viewModeButton->setToolTip(tr("View mode"));
×
226
    m_viewModeButton->setCheckable(true);
×
227
    uniLay->addWidget(m_viewModeButton);
×
228

229
    m_universePageDownButton = new QToolButton(this);
×
230
    m_universePageDownButton->setIcon(QIcon(":/back.png"));
×
231
    m_universePageDownButton->setIconSize(QSize(24, 24));
×
232
    m_universePageDownButton->setMinimumSize(QSize(36, 36));
×
233
    m_universePageDownButton->setMaximumSize(QSize(36, 36));
×
234
    m_universePageDownButton->setToolTip(tr("Previous page"));
×
235
    uniLay->addWidget(m_universePageDownButton);
×
236

237
    m_universePageSpin = new QSpinBox(this);
×
238
    m_universePageSpin->setMaximumSize(QSize(40, 34));
×
239
    m_universePageSpin->setButtonSymbols(QAbstractSpinBox::NoButtons);
×
240
    m_universePageSpin->setAlignment(Qt::AlignCenter);
×
241
    m_universePageSpin->setWrapping(true);
×
242
    m_universePageSpin->setToolTip(tr("Current page"));
×
243
    uniLay->addWidget(m_universePageSpin);
×
244

245
    m_universePageUpButton = new QToolButton(this);
×
246
    m_universePageUpButton->setIcon(QIcon(":/forward.png"));
×
247
    m_universePageUpButton->setIconSize(QSize(24, 24));
×
248
    m_universePageUpButton->setMinimumSize(QSize(36, 36));
×
249
    m_universePageUpButton->setMaximumSize(QSize(36, 36));
×
250
    m_universePageUpButton->setToolTip(tr("Next page"));
×
251
    uniLay->addWidget(m_universePageUpButton);
×
252

253
    m_universeResetButton = new QToolButton(this);
×
254
    m_universeResetButton->setIcon(QIcon(":/fileclose.png"));
×
255
    m_universeResetButton->setIconSize(QSize(24, 24));
×
256
    m_universeResetButton->setMinimumSize(QSize(36, 36));
×
257
    m_universeResetButton->setMaximumSize(QSize(36, 36));
×
258
    m_universeResetButton->setToolTip(tr("Reset universe"));
×
259
    uniLay->addWidget(m_universeResetButton);
×
260

261
    uniLay->addSpacing(50);
×
262

263
    QLabel *label = new QLabel(tr("Universe"));
×
264
    label->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
×
265
    uniLay->addWidget(label);
×
266

267
    m_universesCombo = new QComboBox(this);
×
268
    //m_universesCombo->setFixedWidth(200);
269
    m_universesCombo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
×
270
    uniLay->addWidget(m_universesCombo);
×
271
    lay->addLayout(uniLay);
×
272

273
    initUniversesCombo();
×
274
    connect(m_universesCombo, SIGNAL(currentIndexChanged(int)),
×
275
            this, SLOT(slotUniversesComboChanged(int)));
276

277
    m_universeGroup = new QFrame(this);
×
278
    //m_universeGroup->setTitle(tr("Universe"));
279
    QHBoxLayout *grpLay = new QHBoxLayout(m_universeGroup);
×
280
    //m_universeGroup->setFlat(true);
281
    grpLay->setContentsMargins(1, 1, 1, 1);
×
282
    grpLay->setSpacing(1);
×
283
    lay->addWidget(m_universeGroup);
×
284

285
    QVBoxLayout *vbox = new QVBoxLayout;
×
286
    m_grandMasterSlider = new GrandMasterSlider(this, m_doc->inputOutputMap());
×
287
    vbox->addWidget(m_grandMasterSlider);
×
288

289
    grpLay->addLayout(vbox);
×
290
}
×
291

292
void SimpleDesk::initBottomSide()
×
293
{
294
    m_tabs = new QTabWidget(this);
×
295
    m_splitter->addWidget(m_tabs);
×
296

297
    QWidget* cueStackWidget = new QWidget(this);
×
298
    QHBoxLayout* lay = new QHBoxLayout(cueStackWidget);
×
299
    lay->setContentsMargins(1, 1, 1, 1);
×
300
    m_tabs->addTab(cueStackWidget, tr("Cue Stack"));
×
301

302
    m_playbackGroup = new QGroupBox(this);
×
303
    m_playbackGroup->setTitle(tr("Playback"));
×
304
    QHBoxLayout *grpLay = new QHBoxLayout(m_playbackGroup);
×
305
    grpLay->setContentsMargins(0, 6, 0, 0);
×
306
    grpLay->setSpacing(1);
×
307
    lay->addWidget(m_playbackGroup);
×
308

309
    m_cueStackGroup = new QGroupBox(this);
×
310
    m_cueStackGroup->setTitle(tr("Cue Stack"));
×
311
    QVBoxLayout *grpLay2 = new QVBoxLayout(m_cueStackGroup);
×
312
    grpLay2->setContentsMargins(0, 6, 0, 0);
×
313
    lay->addWidget(m_cueStackGroup);
×
314

315
    QHBoxLayout* hbox = new QHBoxLayout;
×
316
    hbox->setContentsMargins(0, 0, 0, 0);
×
317
    m_previousCueButton = new QToolButton(this);
×
318
    m_previousCueButton->setIcon(QIcon(":/back.png"));
×
319
    m_previousCueButton->setIconSize(QSize(32, 32));
×
320
    m_previousCueButton->setToolTip(tr("Previous cue"));
×
321
    hbox->addWidget(m_previousCueButton);
×
322

323
    m_stopCueStackButton = new QToolButton(this);
×
324
    m_stopCueStackButton->setIcon(QIcon(":/player_stop.png"));
×
325
    m_stopCueStackButton->setIconSize(QSize(32, 32));
×
326
    m_stopCueStackButton->setToolTip(tr("Stop cue stack"));
×
327
    hbox->addWidget(m_stopCueStackButton);
×
328

329
    m_nextCueButton = new QToolButton(this);
×
330
    m_nextCueButton->setIcon(QIcon(":/forward.png"));
×
331
    m_nextCueButton->setIconSize(QSize(32, 32));
×
332
    m_nextCueButton->setToolTip(tr("Next cue"));
×
333
    hbox->addWidget(m_nextCueButton);
×
334

335
    hbox->addStretch();
×
336

337
    m_cloneCueStackButton = new QToolButton(this);
×
338
    m_cloneCueStackButton->setIcon(QIcon(":/editcopy.png"));
×
339
    m_cloneCueStackButton->setIconSize(QSize(32, 32));
×
340
    m_cloneCueStackButton->setToolTip(tr("Clone cue stack"));
×
341
    hbox->addWidget(m_cloneCueStackButton);
×
342

343
    m_editCueStackButton = new QToolButton(this);
×
344
    m_editCueStackButton->setIcon(QIcon(":/edit.png"));
×
345
    m_editCueStackButton->setIconSize(QSize(32, 32));
×
346
    m_editCueStackButton->setToolTip(tr("Edit cue stack"));
×
347
    m_editCueStackButton->setCheckable(true);
×
348
    hbox->addWidget(m_editCueStackButton);
×
349

350
    m_recordCueButton = new QToolButton(this);
×
351
    m_recordCueButton->setIcon(QIcon(":/record.png"));
×
352
    m_recordCueButton->setIconSize(QSize(32, 32));
×
353
    m_recordCueButton->setToolTip(tr("Record cue"));
×
354
    hbox->addWidget(m_recordCueButton);
×
355

356
    grpLay2->addLayout(hbox);
×
357

358
    m_cueStackView = new QTreeView(this);
×
359
    m_cueStackView->setAllColumnsShowFocus(true);
×
360
    m_cueStackView->setSelectionMode(QAbstractItemView::ExtendedSelection);
×
361
    m_cueStackView->setDragEnabled(true);
×
362
    m_cueStackView->setDragDropMode(QAbstractItemView::InternalMove);
×
363
    m_cueStackGroup->layout()->addWidget(m_cueStackView);
×
364

365
    initChannelGroupsView();
×
366
}
×
367

368
void SimpleDesk::slotDocChanged()
×
369
{
370
    m_docChanged = true;
×
371
}
×
372

373
int SimpleDesk::getSlidersNumber()
×
374
{
375
    return m_channelsPerPage;
×
376
}
377

378
int SimpleDesk::getCurrentUniverseIndex()
×
379
{
380
    return m_currentUniverse;
×
381
}
382

383
int SimpleDesk::getCurrentPage()
×
384
{
385
    return m_universePageSpin->value();
×
386
}
387

388
uchar SimpleDesk::getAbsoluteChannelValue(uint address)
×
389
{
390
    if (m_engine->hasChannel(address))
×
391
    {
392
        return m_engine->value(address);
×
393
    }
394
    else
395
    {
396
        QList<Universe*> ua = m_doc->inputOutputMap()->claimUniverses();
×
397
        int uni = address >> 9;
×
398
        uint channel = address & 0x01FF;
×
399
        if (uni >= ua.count())
×
400
            return 0;
×
401
        uchar value = ua.at(uni)->preGMValue(channel);
×
402
        m_doc->inputOutputMap()->releaseUniverses(false);
×
403
        return value;
×
404
    }
×
405
}
406

NEW
407
bool SimpleDesk::isChannelOverridden(uint address)
×
408
{
NEW
409
    return m_engine->hasChannel(address);
×
410
}
411

UNCOV
412
void SimpleDesk::setAbsoluteChannelValue(uint address, uchar value)
×
413
{
414
    if (address >= ((uint)m_doc->inputOutputMap()->universesCount() * 512))
×
415
        return;
×
416

417
    m_engine->setValue(address, value);
×
418
}
419

420
void SimpleDesk::resetChannel(quint32 address)
×
421
{
422
    m_engine->resetChannel(address);
×
423

424
    quint32 start = (m_currentUniverse * 512) + (m_universePageSpin->value() - 1) * m_channelsPerPage;
×
425

426
    if (m_viewModeButton->isChecked() == false)
×
427
    {
428
        if (address < start || address >= start + m_channelsPerPage)
×
429
            return;
×
430

431
        Fixture *fxi = m_doc->fixture(m_doc->fixtureForAddress(address));
×
432
        ConsoleChannel *cc = m_universeSliders.value(address - start, NULL);
×
433
        if (cc == NULL)
×
434
            return;
×
435

436
        if (fxi == NULL)
×
437
        {
438
            cc->setChannelStyleSheet(ssNone);
×
439
        }
440
        else
441
        {
442
            if (fxi->id() % 2)
×
443
                cc->setChannelStyleSheet(ssEven);
×
444
            else
445
                cc->setChannelStyleSheet(ssOdd);
×
446
        }
447
    }
448
    else
449
    {
450
        Fixture *fxi = m_doc->fixture(m_doc->fixtureForAddress(address));
×
451
        if (fxi == NULL)
×
452
            return;
×
453

454
        FixtureConsole *fc = m_consoleList.value(fxi->id(), NULL);
×
455
        if (fc == NULL)
×
456
            return;
×
457

458
        quint32 ch = address - fxi->universeAddress();
×
459

460
        if (fxi->id() % 2 == 0)
×
461
            fc->setChannelStylesheet(ch, ssOdd);
×
462
        else
463
            fc->setChannelStylesheet(ch, ssEven);
×
464
    }
465
}
466

467
void SimpleDesk::resetUniverse()
×
468
{
469
    // force a engine reset
470
    m_engine->resetUniverse(m_currentUniverse);
×
471
    // simulate a user click on the reset button
472
    // to avoid messing up with multithread calls
473
    m_universeResetButton->click();
×
474
}
×
475

476
void SimpleDesk::resetUniverse(int index)
×
477
{
478
    m_universesCombo->setCurrentIndex(index);
×
479
    resetUniverse();
×
480
}
×
481

482
/****************************************************************************
483
 * Universe controls
484
 ****************************************************************************/
485

486
void SimpleDesk::initUniversesCombo()
×
487
{
488
    disconnect(m_universesCombo, SIGNAL(currentIndexChanged(int)),
×
489
            this, SLOT(slotUniversesComboChanged(int)));
490
    int currIdx = m_universesCombo->currentIndex();
×
491
    m_universesCombo->clear();
×
492
    m_universesCombo->addItems(m_doc->inputOutputMap()->universeNames());
×
493
    if (currIdx != -1)
×
494
        m_universesCombo->setCurrentIndex(currIdx);
×
495
    while (m_universesPage.length() < m_universesCombo->count())
×
496
        m_universesPage.append(1);
×
497
    connect(m_universesCombo, SIGNAL(currentIndexChanged(int)),
×
498
            this, SLOT(slotUniversesComboChanged(int)));
499
}
×
500

501
void SimpleDesk::initUniverseSliders()
×
502
{
503
    //qDebug() << Q_FUNC_INFO;
504
    quint32 start = m_universesPage.at(m_currentUniverse) * m_channelsPerPage;
×
505
    for (quint32 i = 0; i < m_channelsPerPage; i++)
×
506
    {
507
        ConsoleChannel* slider = NULL;
×
508
        Fixture* fxi = m_doc->fixture(m_doc->fixtureForAddress(start + i));
×
509
        if (fxi == NULL)
×
510
            slider = new ConsoleChannel(this, m_doc, Fixture::invalidId(), i, false);
×
511
        else
512
        {
513
            uint ch = (start + i) - fxi->universeAddress();
×
514
            slider = new ConsoleChannel(this, m_doc, fxi->id(), ch, false);
×
515
            slider->setValue(uchar(fxi->channelValueAt(ch)));
×
516
        }
517
        slider->showResetButton(true);
×
518
        m_universeGroup->layout()->addWidget(slider);
×
519
        m_universeSliders << slider;
×
520
        connect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
521
                this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
522
        connect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
523
                this, SLOT(slotChannelResetClicked(quint32,quint32)));
524
    }
525
}
×
526

527
void SimpleDesk::initUniversePager()
×
528
{
529
    //qDebug() << Q_FUNC_INFO;
530
    m_universePageSpin->setRange(1, int((512 + m_channelsPerPage - 1) / m_channelsPerPage));
×
531
    m_universePageSpin->setValue(1);
×
532
    slotUniversePageChanged(1);
×
533

534
    connect(m_viewModeButton, SIGNAL(clicked(bool)), this, SLOT(slotViewModeClicked(bool)));
×
535
    connect(m_universePageUpButton, SIGNAL(clicked()), this, SLOT(slotUniversePageUpClicked()));
×
536
    connect(m_universePageDownButton, SIGNAL(clicked()), this, SLOT(slotUniversePageDownClicked()));
×
537
    connect(m_universePageSpin, SIGNAL(valueChanged(int)), this, SLOT(slotUniversePageChanged(int)));
×
538
    connect(m_universeResetButton, SIGNAL(clicked()), this, SLOT(slotUniverseResetClicked()));
×
539
}
×
540

541
void SimpleDesk::resetUniverseSliders()
×
542
{
543
    //qDebug() << Q_FUNC_INFO;
544
    foreach (ConsoleChannel *channel, m_universeSliders)
×
545
    {
546
        if (channel != NULL)
×
547
            channel->setValue(0);
×
548
    }
×
549
}
×
550

551
void SimpleDesk::initSliderView(bool fullMode)
×
552
{
553
    m_consoleList.clear();
×
554

555
    if (fullMode == true)
×
556
    {
557
        scrollArea = new QScrollArea();
×
558
        scrollArea->setWidgetResizable(true);
×
559

560
        QFrame* grpBox = new QFrame(scrollArea);
×
561
        grpBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
×
562
        QHBoxLayout* fixturesLayout = new QHBoxLayout(grpBox);
×
563
        grpBox->setLayout(fixturesLayout);
×
564
        fixturesLayout->setSpacing(2);
×
565
        fixturesLayout->setContentsMargins(2, 2, 2, 2);
×
566

567
        int c = 0;
×
568
        foreach (Fixture *fixture, m_doc->fixtures())
×
569
        {
570
            if (fixture->universe() != (quint32)m_universesCombo->currentIndex())
×
571
                continue;
×
572
            FixtureConsole* console = NULL;
×
573
            if (c%2 == 0)
×
574
                console = new FixtureConsole(scrollArea, m_doc, FixtureConsole::GroupOdd, false);
×
575
            else
576
                console = new FixtureConsole(scrollArea, m_doc, FixtureConsole::GroupEven, false);
×
577
            console->setFixture(fixture->id());
×
578
            console->enableResetButton(true);
×
579
            quint32 absoluteAddr = fixture->universeAddress();
×
580
            QByteArray fxValues = fixture->channelValues();
×
581
            for (quint32 i = 0; i < fixture->channels(); i++)
×
582
            {
583
                if (m_engine->hasChannel(absoluteAddr + i))
×
584
                {
585
                    SceneValue scv(fixture->id(), i, m_engine->value(absoluteAddr + i));
×
586
                    console->setSceneValue(scv);
×
587
                    console->setChannelStylesheet(i, ssOverride);
×
588
                }
×
589
                else
590
                {
591
                    SceneValue scv(fixture->id(), i, (uchar)fxValues.at(i));
×
592
                    console->setSceneValue(scv);
×
593
                }
×
594
            }
595
            fixturesLayout->addWidget(console);
×
596
            connect(console, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
597
                    this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
598
            connect(console, SIGNAL(resetRequest(quint32,quint32)),
×
599
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
600
            c++;
×
601
            m_consoleList[fixture->id()] = console;
×
602
        }
×
603
        fixturesLayout->addStretch(1);
×
604
        scrollArea->setWidget(grpBox);
×
605

606
        m_universeGroup->layout()->addWidget(scrollArea);
×
607
    }
608
    else
609
    {
610
        int page = m_universesPage.at(m_universesCombo->currentIndex());
×
611
        slotUniversePageChanged(page);
×
612
    }
613
}
×
614

615
void SimpleDesk::initChannelGroupsView()
×
616
{
617
    if (m_chGroupsArea != NULL)
×
618
    {
619
        delete m_chGroupsArea;
×
620
        m_chGroupsArea = NULL;
×
621
    }
622

623
    if (m_doc->channelsGroups().count() > 0)
×
624
    {
625
        m_chGroupsArea = new QScrollArea();
×
626
        QList<quint32> chGrpIDs;
×
627
        foreach (ChannelsGroup *grp, m_doc->channelsGroups())
×
628
            chGrpIDs.append(grp->id());
×
629
        GroupsConsole* console = new GroupsConsole(m_chGroupsArea, m_doc, chGrpIDs, QList<uchar>());
×
630
        m_chGroupsArea->setWidget(console);
×
631
        m_chGroupsArea->setWidgetResizable(true);
×
632
        m_tabs->addTab(m_chGroupsArea, tr("Channel groups"));
×
633
        connect(console, SIGNAL(groupValueChanged(quint32,uchar)),
×
634
                this, SLOT(slotGroupValueChanged(quint32,uchar)));
635
    }
×
636
}
×
637

638
void SimpleDesk::slotUniversesComboChanged(int index)
×
639
{
640
    m_currentUniverse = index;
×
641
    if (m_viewModeButton->isChecked() == true)
×
642
    {
643
        m_universeGroup->layout()->removeWidget(scrollArea);
×
644
        delete scrollArea;
×
645
        initSliderView(true);
×
646
    }
647
    else
648
    {
649
        int page = m_universesPage.at(index);
×
650
        slotUniversePageChanged(m_universesPage.at(index));
×
651
        m_universePageSpin->setValue(page);
×
652
    }
653
}
×
654

655
void SimpleDesk::slotViewModeClicked(bool toggle)
×
656
{
657
    if (toggle == true)
×
658
    {
659
        QList<quint32> fxRemoveList;
×
660

661
        for (quint32 i = 0; i < m_channelsPerPage; i++)
×
662
        {
663
            ConsoleChannel* slider = m_universeSliders[i];
×
664
            if (slider != NULL)
×
665
            {
666
                m_universeGroup->layout()->removeWidget(slider);
×
667
                disconnect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
668
                       this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
669
                disconnect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
670
                        this, SLOT(slotChannelResetClicked(quint32,quint32)));
671
                if (fxRemoveList.contains(slider->fixture()) == false)
×
672
                {
673
                    Fixture *currFx = m_doc->fixture(slider->fixture());
×
674
                    if (currFx != NULL)
×
675
                    {
676
                        disconnect(currFx, SIGNAL(aliasChanged()), this, SLOT(slotAliasChanged()));
×
677
                        fxRemoveList.append(slider->fixture());
×
678
                    }
679
                }
680
                delete slider;
×
681
                m_universeSliders[i] = NULL;
×
682
            }
683
        }
684
        initSliderView(true);
×
685
    }
×
686
    else
687
    {
688
        m_universeGroup->layout()->removeWidget(scrollArea);
×
689
        delete scrollArea;
×
690
        initSliderView(false);
×
691
    }
692
    m_universePageUpButton->setEnabled(!toggle);
×
693
    m_universePageDownButton->setEnabled(!toggle);
×
694
    m_universePageSpin->setEnabled(!toggle);
×
695
}
×
696

697
void SimpleDesk::slotUniversePageUpClicked()
×
698
{
699
    qDebug() << Q_FUNC_INFO;
×
700
    m_universePageSpin->setValue(m_universePageSpin->value() + 1);
×
701
}
×
702

703
void SimpleDesk::slotUniversePageDownClicked()
×
704
{
705
    qDebug() << Q_FUNC_INFO;
×
706
    m_universePageSpin->setValue(m_universePageSpin->value() - 1);
×
707
}
×
708

709
void SimpleDesk::slotUniversePageChanged(int page)
×
710
{
711
    qDebug() << Q_FUNC_INFO;
×
712
    QList<quint32> fxAddList, fxRemoveList;
×
713
    quint32 start = (page - 1) * m_channelsPerPage;
×
714

715
    /* now, calculate the absolute address including current universe (0 - 2048) */
716
    quint32 absoluteAddr = start | (m_currentUniverse << 9);
×
717

718
    /* Set the new page for this universe */
719
    m_universesPage.replace(m_currentUniverse, page);
×
720

721
    //qDebug() << "[slotUniversePageChanged] start: " << start << ", absoluteAddr: " << absoluteAddr;
722

723
    for (quint32 i = 0; i < m_channelsPerPage; i++)
×
724
    {
725
        ConsoleChannel *slider = m_universeSliders[i];
×
726
        if (slider != NULL)
×
727
        {
728
            m_universeGroup->layout()->removeWidget(slider);
×
729
            disconnect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
730
                   this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
731
            disconnect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
732
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
733

734
            if (fxRemoveList.contains(slider->fixture()) == false)
×
735
            {
736
                Fixture *currFx = m_doc->fixture(slider->fixture());
×
737
                if (currFx != NULL)
×
738
                {
739
                    disconnect(currFx, SIGNAL(aliasChanged()), this, SLOT(slotAliasChanged()));
×
740
                    fxRemoveList.append(slider->fixture());
×
741
                }
742
            }
743
            delete slider;
×
744
            m_universeSliders[i] = NULL;
×
745
        }
746
        Fixture *fx = m_doc->fixture(m_doc->fixtureForAddress(absoluteAddr + i));
×
747
        if (fx == NULL)
×
748
        {
749
            slider = new ConsoleChannel(this, m_doc, Fixture::invalidId(), start + i, false);
×
750
            slider->setVisible(false);
×
751
            if (m_engine->hasChannel((m_currentUniverse << 9) + (start + i)))
×
752
                slider->setChannelStyleSheet(ssOverride);
×
753
            else
754
                slider->setChannelStyleSheet(ssNone);
×
755
        }
756
        else
757
        {
758
            uint ch = (absoluteAddr + i) - fx->universeAddress();
×
759
            slider = new ConsoleChannel(this, m_doc, fx->id(), ch, false);
×
760
            slider->setVisible(false);
×
761
            if (m_engine->hasChannel(absoluteAddr + i))
×
762
            {
763
                slider->setChannelStyleSheet(ssOverride);
×
764
            }
765
            else
766
            {
767
                if (fx->id() % 2 == 0)
×
768
                    slider->setChannelStyleSheet(ssOdd);
×
769
                else
770
                    slider->setChannelStyleSheet(ssEven);
×
771
                slider->setValue(uchar(fx->channelValueAt(ch)));
×
772
            }
773
            if (fxAddList.contains(fx->id()) == false)
×
774
            {
775
                connect(fx, SIGNAL(aliasChanged()), this, SLOT(slotAliasChanged()));
×
776
                fxAddList.append(fx->id());
×
777
            }
778
        }
779
        slider->showResetButton(true);
×
780
        slider->setVisible(true);
×
781

782
        if ((start + i) < 512)
×
783
        {
784
            slider->setEnabled(true);
×
785
            slider->setProperty(PROP_ADDRESS, absoluteAddr + i);
×
786
            slider->setLabel(QString::number(start + i + 1));
×
787
            //qDebug() << "Set slider value[" << (absoluteAddr + i) << "] = " << m_engine->value(absoluteAddr + i);
788
            if (m_engine->hasChannel(absoluteAddr + i))
×
789
                slider->setValue(m_engine->value(absoluteAddr + i), false);
×
790
            connect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
791
                    this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
792
            connect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
793
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
794
        }
795
        else
796
        {
797
            slider->setEnabled(false);
×
798
            slider->setProperty(PROP_ADDRESS, QVariant());
×
799
            slider->setValue(0);
×
800
            slider->setLabel("---");
×
801
            slider->setPalette(this->palette());
×
802
        }
803

804
        m_universeGroup->layout()->addWidget(slider);
×
805
        m_universeSliders[i] = slider;
×
806
    }
807
}
×
808

809
void SimpleDesk::slotUniverseResetClicked()
×
810
{
811
    qDebug() << Q_FUNC_INFO;
×
812
    m_engine->resetUniverse(m_currentUniverse);
×
813
    m_universePageSpin->setValue(1);
×
814
    if (m_viewModeButton->isChecked() == false)
×
815
    {
816
        slotUniversePageChanged(1);
×
817
    }
818
    else
819
    {
820
        QHashIterator <quint32,FixtureConsole*> it(m_consoleList);
×
821

822
        while (it.hasNext() == true)
×
823
        {
824
            it.next();
×
825
            FixtureConsole *fc = it.value();
×
826
            Q_ASSERT(fc != NULL);
×
827
            fc->resetChannelsStylesheet();
×
828
        }
829
    }
×
830
}
×
831

832
void SimpleDesk::slotChannelResetClicked(quint32 fxID, quint32 channel)
×
833
{
834
    if (fxID != Fixture::invalidId())
×
835
    {
836
        Fixture *fixture = m_doc->fixture(fxID);
×
837
        if (fixture == NULL)
×
838
            return;
×
839

840
        quint32 absAddr = fixture->universeAddress() + channel;
×
841
        m_engine->resetChannel(absAddr);
×
842

843
        if (m_viewModeButton->isChecked() == true)
×
844
        {
845
            Fixture *fixture = m_doc->fixture(fxID);
×
846
            if (fixture == NULL)
×
847
                return;
×
848

849
            if (m_consoleList.contains(fxID))
×
850
            {
851
                FixtureConsole *fc = m_consoleList[fxID];
×
852
                if (fc != NULL)
×
853
                {
854
                    if (fixture->id() % 2 == 0)
×
855
                        fc->setChannelStylesheet(channel, ssOdd);
×
856
                    else
857
                        fc->setChannelStylesheet(channel, ssEven);
×
858
                }
859
            }
860
        }
861
        else
862
        {
863
            ConsoleChannel *slider = qobject_cast<ConsoleChannel *>(sender());
×
864
            if (fixture->id() % 2 == 0)
×
865
                slider->setChannelStyleSheet(ssOdd);
×
866
            else
867
                slider->setChannelStyleSheet(ssEven);
×
868
        }
869
    }
870
    else
871
    {
872
        ConsoleChannel *slider = qobject_cast<ConsoleChannel *>(sender());
×
873
        m_engine->resetChannel(channel);
×
874
        slider->setChannelStyleSheet(ssNone);
×
875
    }
876
}
877

878
void SimpleDesk::slotAliasChanged()
×
879
{
880
    Fixture *fxi = qobject_cast<Fixture *>(sender());
×
881
    int i = 0;
×
882

883
    foreach (ConsoleChannel *cc, m_universeSliders)
×
884
    {
885
        quint32 chIndex = cc->channelIndex();
×
886

887
        if (cc->fixture() == fxi->id() && cc->channel() != fxi->channel(chIndex))
×
888
        {
889
            disconnect(cc, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
890
                       this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
891
            disconnect(cc, SIGNAL(resetRequest(quint32,quint32)),
×
892
                       this, SLOT(slotChannelResetClicked(quint32,quint32)));
893

894
            ConsoleChannel *newCC = new ConsoleChannel(this, m_doc, fxi->id(), chIndex, false);
×
895
            newCC->setVisible(false);
×
896

897
            if (m_engine->hasChannel(fxi->universeAddress() + chIndex))
×
898
            {
899
                newCC->setChannelStyleSheet(ssOverride);
×
900
            }
901
            else
902
            {
903
                if (fxi->id() % 2 == 0)
×
904
                    newCC->setChannelStyleSheet(ssOdd);
×
905
                else
906
                    newCC->setChannelStyleSheet(ssEven);
×
907
            }
908

909
            newCC->setValue(cc->value());
×
910
            newCC->showResetButton(true);
×
911
            newCC->setProperty(PROP_ADDRESS, fxi->universeAddress() + chIndex);
×
912
            newCC->setVisible(true);
×
913

914
            connect(newCC, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
915
                    this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
916
            connect(newCC, SIGNAL(resetRequest(quint32,quint32)),
×
917
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
918

919
            QLayoutItem *item = m_universeGroup->layout()->replaceWidget(cc, newCC);
×
920
            delete item;
×
921
            delete cc;
×
922
            m_universeSliders.replace(i, newCC);
×
923
        }
924
        i++;
×
925
    }
×
926
}
×
927

928
void SimpleDesk::slotUniverseSliderValueChanged(quint32 fid, quint32 chan, uchar value)
×
929
{
930
    QVariant var(sender()->property(PROP_ADDRESS));
×
931
    if (var.isValid()) // Not true with disabled sliders
×
932
    {
933
        quint32 chanAbsAddr = var.toUInt();
×
934
        if (m_viewModeButton->isChecked() == false &&
×
935
            m_engine->hasChannel(chanAbsAddr) == false)
×
936
        {
937
            quint32 chanAddr = (chanAbsAddr & 0x01FF) - ((m_universePageSpin->value() - 1) * m_channelsPerPage);
×
938
            if (chanAddr < (quint32)m_universeSliders.count())
×
939
            {
940
                ConsoleChannel *chan = m_universeSliders.at(chanAddr);
×
941
                chan->setChannelStyleSheet(ssOverride);
×
942
            }
943
        }
944
        m_engine->setValue(chanAbsAddr, value);
×
945

946
        if (m_editCueStackButton->isChecked() == true)
×
947
            replaceCurrentCue();
×
948
    }
949
    else // calculate the absolute address from the given parameters
950
    {
951
        Fixture *fixture = m_doc->fixture(fid);
×
952
        if (fixture == NULL)
×
953
            return;
×
954

955
        quint32 chanAbsAddr = fixture->universeAddress() + chan;
×
956
        if (m_viewModeButton->isChecked() == true &&
×
957
            m_engine->hasChannel(chanAbsAddr) == false)
×
958
        {
959
            if (m_consoleList.contains(fid))
×
960
            {
961
                FixtureConsole *fc = m_consoleList[fid];
×
962
                if (fc != NULL)
×
963
                    fc->setChannelStylesheet(chan, ssOverride);
×
964
            }
965
        }
966
        m_engine->setValue(chanAbsAddr, value);
×
967

968
        if (m_editCueStackButton->isChecked() == true)
×
969
            replaceCurrentCue();
×
970
    }
971
}
×
972

973
void SimpleDesk::slotUniverseWritten(quint32 idx, const QByteArray& universeData)
×
974
{
975
    // If Simple Desk is not visible, don't even waste CPU
976
    if (isVisible() == false)
×
977
        return;
×
978

979
    if (idx != (quint32)m_currentUniverse)
×
980
        return;
×
981

982
    //qDebug() << "SIMPLE DESK UNIVERSE WRITTEN" << idx;
983

984
    if (m_viewModeButton->isChecked() == false)
×
985
    {
986
        quint32 start = (m_universePageSpin->value() - 1) * m_channelsPerPage;
×
987

988
        // update current page sliders
989
        for (quint32 i = start; i < start + (quint32)m_channelsPerPage; i++)
×
990
        {
991
            if (i >= (quint32)universeData.length())
×
992
                break;
×
993

994
            quint32 absAddr = i + (idx << 9);
×
995
            ConsoleChannel *cc = m_universeSliders[i - start];
×
996
            if (cc == NULL)
×
997
                continue;
×
998

999
            if (m_engine->hasChannel(absAddr) == true)
×
1000
            {
1001
                if (cc->value() != m_engine->value(absAddr))
×
1002
                {
1003
                    cc->blockSignals(true);
×
1004
                    cc->setValue(m_engine->value(absAddr), false);
×
1005
                    cc->setChannelStyleSheet(ssOverride);
×
1006
                    cc->blockSignals(false);
×
1007
                }
1008
                continue;
×
1009
            }
1010

1011
            cc->blockSignals(true);
×
1012
            cc->setValue(universeData.at(i), false);
×
1013
            cc->blockSignals(false);
×
1014
        }
1015
    }
1016
    else
1017
    {
1018
        foreach (FixtureConsole *fc, m_consoleList)
×
1019
        {
1020
            if (fc == NULL)
×
1021
                continue;
×
1022

1023
            quint32 fxi = fc->fixture();
×
1024
            Fixture *fixture = m_doc->fixture(fxi);
×
1025
            if (fixture != NULL)
×
1026
            {
1027
                quint32 startAddr = fixture->address();
×
1028
                for (quint32 c = 0; c < fixture->channels(); c++)
×
1029
                {
1030
                    if (startAddr + c >= (quint32)universeData.length())
×
1031
                        break;
×
1032

1033
                    if (m_engine->hasChannel((startAddr + c) + (idx << 9)) == true)
×
1034
                    {
1035
                        fc->setValue(c, universeData.at(startAddr + c), false);
×
1036
                        fc->setChannelStylesheet(c, ssOverride);
×
1037
                        continue;
×
1038
                    }
1039

1040
                    fc->blockSignals(true);
×
1041
                    fc->setValue(c, universeData.at(startAddr + c), false);
×
1042
                    fc->blockSignals(false);
×
1043
                }
1044
            }
1045
        }
×
1046
    }
1047
}
1048

1049
void SimpleDesk::slotUpdateUniverseSliders()
×
1050
{
1051
    //qDebug() << Q_FUNC_INFO;
1052
    if (m_viewModeButton->isChecked() == true)
×
1053
    {
1054
        m_universeGroup->layout()->removeWidget(scrollArea);
×
1055
        delete scrollArea;
×
1056
        initSliderView(true);
×
1057
    }
1058
    else
1059
    {
1060
        slotUniversePageChanged(m_universePageSpin->value());
×
1061
    }
1062
}
×
1063

1064
/****************************************************************************
1065
 * Playback Sliders
1066
 ****************************************************************************/
1067

1068
void SimpleDesk::initPlaybackSliders()
×
1069
{
1070
    //qDebug() << Q_FUNC_INFO;
1071
    for (uint i = 0; i < m_playbacksPerPage; i++)
×
1072
    {
1073
        PlaybackSlider* slider = new PlaybackSlider(m_playbackGroup);
×
1074
        m_playbackGroup->layout()->addWidget(slider);
×
1075
        slider->setLabel(QString::number(i + 1));
×
1076
        slider->setProperty(PROP_PLAYBACK, uint(i));
×
1077
        m_playbackSliders << slider;
×
1078
        connect(slider, SIGNAL(selected()), this, SLOT(slotPlaybackSelected()));
×
1079
        connect(slider, SIGNAL(started()), this, SLOT(slotPlaybackStarted()));
×
1080
        connect(slider, SIGNAL(stopped()), this, SLOT(slotPlaybackStopped()));
×
1081
        connect(slider, SIGNAL(flashing(bool)), this, SLOT(slotPlaybackFlashing(bool)));
×
1082
        connect(slider, SIGNAL(valueChanged(uchar)), this, SLOT(slotPlaybackValueChanged(uchar)));
×
1083
    }
1084
}
×
1085

1086
void SimpleDesk::resetPlaybackSliders()
×
1087
{
1088
    //qDebug() << Q_FUNC_INFO;
1089
    QListIterator <PlaybackSlider*> it(m_playbackSliders);
×
1090
    while (it.hasNext() == true)
×
1091
        it.next()->setValue(0);
×
1092
}
×
1093

1094
void SimpleDesk::slotPlaybackSelected()
×
1095
{
1096
    //qDebug() << Q_FUNC_INFO;
1097
    Q_ASSERT(sender() != NULL);
×
1098
    uint pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1099
    if (m_selectedPlayback == pb)
×
1100
        return;
×
1101

1102
    slotSelectPlayback(pb);
×
1103
}
1104

1105
void SimpleDesk::slotSelectPlayback(uint pb)
×
1106
{
1107
    //qDebug() << Q_FUNC_INFO;
1108

1109
    if (m_selectedPlayback != UINT_MAX)
×
1110
        m_playbackSliders[m_selectedPlayback]->setSelected(false);
×
1111

1112
    if (pb != UINT_MAX)
×
1113
        m_playbackSliders[pb]->setSelected(true);
×
1114
    m_selectedPlayback = pb;
×
1115

1116
    CueStack* cueStack = m_engine->cueStack(pb);
×
1117
    Q_ASSERT(cueStack != NULL);
×
1118

1119
    CueStackModel* model = qobject_cast<CueStackModel*> (m_cueStackView->model());
×
1120
    Q_ASSERT(model != NULL);
×
1121
    model->setCueStack(cueStack);
×
1122

1123
    m_cueStackGroup->setTitle(tr("Cue Stack - Playback %1").arg(m_selectedPlayback + 1));
×
1124

1125
    updateCueStackButtons();
×
1126
}
×
1127

1128
void SimpleDesk::slotPlaybackStarted()
×
1129
{
1130
    //qDebug() << Q_FUNC_INFO;
1131
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1132
    CueStack* cueStack = m_engine->cueStack(pb);
×
1133
    Q_ASSERT(cueStack != NULL);
×
1134

1135
    if (!cueStack->isRunning())
×
1136
        cueStack->nextCue();
×
1137
}
×
1138

1139
void SimpleDesk::slotPlaybackStopped()
×
1140
{
1141
    //qDebug() << Q_FUNC_INFO;
1142
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1143
    CueStack* cueStack = m_engine->cueStack(pb);
×
1144
    Q_ASSERT(cueStack != NULL);
×
1145

1146
    if (cueStack->isRunning())
×
1147
        cueStack->stop();
×
1148
}
×
1149

1150
void SimpleDesk::slotPlaybackFlashing(bool enabled)
×
1151
{
1152
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1153
    CueStack* cueStack = m_engine->cueStack(pb);
×
1154
    Q_ASSERT(cueStack != NULL);
×
1155

1156
    cueStack->setFlashing(enabled);
×
1157
}
×
1158

1159
void SimpleDesk::slotPlaybackValueChanged(uchar value)
×
1160
{
1161
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1162
    CueStack* cueStack = m_engine->cueStack(pb);
×
1163
    Q_ASSERT(cueStack != NULL);
×
1164

1165
    cueStack->adjustIntensity(qreal(value) / qreal(UCHAR_MAX));
×
1166
}
×
1167

1168
void SimpleDesk::slotGroupValueChanged(quint32 groupID, uchar value)
×
1169
{
1170
    ChannelsGroup *group = m_doc->channelsGroup(groupID);
×
1171
    if (group == NULL)
×
1172
        return;
×
1173
    quint32 start = (m_universePageSpin->value() - 1) * m_channelsPerPage;
×
1174

1175
    foreach (SceneValue scv, group->getChannels())
×
1176
    {
1177
        Fixture *fixture = m_doc->fixture(scv.fxi);
×
1178
        if (fixture == NULL)
×
1179
            continue;
×
1180
        quint32 absAddr = fixture->universeAddress() + scv.channel;
×
1181

1182
        // Update sliders on screen
1183
        if (m_viewModeButton->isChecked() == false)
×
1184
        {
1185
            if (fixture->universe() == (quint32)m_currentUniverse &&
×
1186
                absAddr >= start &&
×
1187
                absAddr < start + m_channelsPerPage)
×
1188
            {
1189
                ConsoleChannel *cc = m_universeSliders[absAddr - start];
×
1190
                if (cc != NULL)
×
1191
                {
1192
                    cc->blockSignals(true);
×
1193
                    cc->setValue(value, false);
×
1194
                    cc->blockSignals(false);
×
1195
                }
1196
            }
1197
        }
1198
        else
1199
        {
1200
            if (m_consoleList.contains(fixture->id()))
×
1201
            {
1202
                FixtureConsole *fc = m_consoleList[fixture->id()];
×
1203
                if (fc != NULL)
×
1204
                {
1205
                    fc->blockSignals(true);
×
1206
                    if (m_engine->hasChannel(absAddr) == false)
×
1207
                        fc->setChannelStylesheet(scv.channel, ssOverride);
×
1208
                    fc->setValue(scv.channel, value, false);
×
1209
                    fc->blockSignals(false);
×
1210
                }
1211
            }
1212
        }
1213

1214
        m_engine->setValue(absAddr, value);
×
1215
    }
×
1216
}
1217

1218
/****************************************************************************
1219
 * Cue Stack controls
1220
 ****************************************************************************/
1221

1222
void SimpleDesk::initCueStack()
×
1223
{
1224
    //qDebug() << Q_FUNC_INFO;
1225
    CueStackModel* model = new CueStackModel(this);
×
1226
    m_cueStackView->setModel(model);
×
1227

1228
    connect(m_previousCueButton, SIGNAL(clicked()), this, SLOT(slotPreviousCueClicked()));
×
1229
    connect(m_nextCueButton, SIGNAL(clicked()), this, SLOT(slotNextCueClicked()));
×
1230
    connect(m_stopCueStackButton, SIGNAL(clicked()), this, SLOT(slotStopCueStackClicked()));
×
1231
    connect(m_cloneCueStackButton, SIGNAL(clicked()), this, SLOT(slotCloneCueStackClicked()));
×
1232
    connect(m_editCueStackButton, SIGNAL(toggled(bool)), this, SLOT(slotEditCueStackClicked(bool)));
×
1233
    connect(m_recordCueButton, SIGNAL(clicked()), this, SLOT(slotRecordCueClicked()));
×
1234

1235
    connect(m_cueStackView->selectionModel(),
×
1236
            SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),
1237
            this, SLOT(slotCueStackSelectionChanged()));
1238
}
×
1239

1240
void SimpleDesk::updateCueStackButtons()
×
1241
{
1242
    //qDebug() << Q_FUNC_INFO;
1243
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1244
    if (cueStack == NULL)
×
1245
        return;
×
1246

1247
    m_stopCueStackButton->setEnabled(cueStack->isRunning());
×
1248
    m_nextCueButton->setEnabled(cueStack->cues().size() > 0);
×
1249
    m_previousCueButton->setEnabled(cueStack->cues().size() > 0);
×
1250
}
1251

1252
void SimpleDesk::replaceCurrentCue()
×
1253
{
1254
    qDebug() << Q_FUNC_INFO;
×
1255
    Q_ASSERT(m_selectedPlayback < uint(m_playbackSliders.size()));
×
1256

1257
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1258
    Q_ASSERT(cueStack != NULL);
×
1259

1260
    QItemSelectionModel* selectionModel = m_cueStackView->selectionModel();
×
1261
    if (selectionModel->hasSelection() == true)
×
1262
    {
1263
        // Replace current cue values
1264
        QModelIndex index = m_cueStackView->currentIndex();
×
1265
        QString name = cueStack->cues().at(index.row()).name();
×
1266
        Cue cue = m_engine->cue();
×
1267
        cue.setName(name);
×
1268
        cueStack->replaceCue(index.row(), cue);
×
1269
    }
×
1270
}
×
1271

1272
void SimpleDesk::createSpeedDials()
×
1273
{
1274
    if (m_speedDials != NULL)
×
1275
        return;
×
1276

1277
    m_speedDials = new SpeedDialWidget(this);
×
1278
    m_speedDials->setAttribute(Qt::WA_DeleteOnClose);
×
1279
    connect(m_speedDials, SIGNAL(fadeInChanged(int)),
×
1280
            this, SLOT(slotFadeInDialChanged(int)));
1281
    connect(m_speedDials, SIGNAL(fadeOutChanged(int)),
×
1282
            this, SLOT(slotFadeOutDialChanged(int)));
1283
    connect(m_speedDials, SIGNAL(holdChanged(int)),
×
1284
            this, SLOT(slotHoldDialChanged(int)));
1285
    connect(m_speedDials, SIGNAL(destroyed(QObject*)),
×
1286
            this, SLOT(slotDialDestroyed(QObject*)));
1287
    connect(m_speedDials, SIGNAL(optionalTextEdited(const QString&)),
×
1288
            this, SLOT(slotCueNameEdited(const QString&)));
1289
    m_speedDials->raise();
×
1290
    m_speedDials->show();
×
1291
}
1292

1293
void SimpleDesk::updateSpeedDials()
×
1294
{
1295
    qDebug() << Q_FUNC_INFO;
×
1296

1297
    if (m_speedDials == NULL)
×
1298
        return;
×
1299

1300
    Q_ASSERT(m_cueStackView != NULL);
×
1301
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1302
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1303

1304
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1305
    Q_ASSERT(cueStack != NULL);
×
1306

1307
    if (selected.size() == 0)
×
1308
    {
1309
        m_speedDials->setEnabled(false);
×
1310

1311
        m_speedDials->setWindowTitle(tr("No selection"));
×
1312
        m_speedDials->setFadeInSpeed(0);
×
1313
        m_speedDials->setFadeOutSpeed(0);
×
1314
        m_speedDials->setDuration(0);
×
1315

1316
        m_speedDials->setOptionalTextTitle(QString());
×
1317
        m_speedDials->setOptionalText(QString());
×
1318
    }
1319
    else if (selected.size() == 1)
×
1320
    {
1321
        m_speedDials->setEnabled(true);
×
1322

1323
        QModelIndex index = selected.first();
×
1324
        Q_ASSERT(index.row() >= 0 && index.row() < cueStack->cues().size());
×
1325
        Cue cue = cueStack->cues()[index.row()];
×
1326
        m_speedDials->setWindowTitle(cue.name());
×
1327
        m_speedDials->setFadeInSpeed(cue.fadeInSpeed());
×
1328
        m_speedDials->setFadeOutSpeed(cue.fadeOutSpeed());
×
1329
        if ((int)cue.duration() < 0)
×
1330
            m_speedDials->setDuration(cue.duration());
×
1331
        else
1332
            m_speedDials->setDuration(cue.duration() - cue.fadeInSpeed() - cue.fadeOutSpeed());
×
1333

1334
        m_speedDials->setOptionalTextTitle(tr("Cue name"));
×
1335
        m_speedDials->setOptionalText(cue.name());
×
1336
    }
×
1337
    else
1338
    {
1339
        m_speedDials->setEnabled(true);
×
1340

1341
        m_speedDials->setWindowTitle(tr("Multiple Cues"));
×
1342
        m_speedDials->setFadeInSpeed(0);
×
1343
        m_speedDials->setFadeOutSpeed(0);
×
1344
        m_speedDials->setDuration(0);
×
1345

1346
        m_speedDials->setOptionalTextTitle(QString());
×
1347
        m_speedDials->setOptionalText(QString());
×
1348
    }
1349
}
×
1350

1351
CueStack* SimpleDesk::currentCueStack() const
×
1352
{
1353
    Q_ASSERT(m_engine != NULL);
×
1354
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1355
    Q_ASSERT(cueStack != NULL);
×
1356
    return cueStack;
×
1357
}
1358

1359
int SimpleDesk::currentCueIndex() const
×
1360
{
1361
    Q_ASSERT(m_cueStackView != NULL);
×
1362
    return m_cueStackView->currentIndex().row();
×
1363
}
1364

1365
void SimpleDesk::slotCueStackStarted(uint stack)
×
1366
{
1367
    qDebug() << Q_FUNC_INFO;
×
1368
    if (stack != m_selectedPlayback)
×
1369
        return;
×
1370

1371
    PlaybackSlider* slider = m_playbackSliders[m_selectedPlayback];
×
1372
    Q_ASSERT(slider != NULL);
×
1373
    if (slider->value() == 0)
×
1374
        slider->setValue(UCHAR_MAX);
×
1375
    updateCueStackButtons();
×
1376
}
1377

1378
void SimpleDesk::slotCueStackStopped(uint stack)
×
1379
{
1380
    qDebug() << Q_FUNC_INFO;
×
1381
    if (stack != m_selectedPlayback)
×
1382
        return;
×
1383

1384
    PlaybackSlider* slider = m_playbackSliders[m_selectedPlayback];
×
1385
    Q_ASSERT(slider != NULL);
×
1386
    if (slider->value() != 0)
×
1387
        slider->setValue(0);
×
1388
    updateCueStackButtons();
×
1389
}
1390

1391
void SimpleDesk::slotCueStackSelectionChanged()
×
1392
{
1393
    qDebug() << Q_FUNC_INFO;
×
1394

1395
    Q_ASSERT(m_cueStackView != NULL);
×
1396
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1397
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1398

1399
    updateCueStackButtons();
×
1400

1401
    // Destroy the existing delete icon
1402
    if (m_cueDeleteIconIndex.isValid() == true)
×
1403
        m_cueStackView->setIndexWidget(m_cueDeleteIconIndex, NULL);
×
1404
    m_cueDeleteIconIndex = QModelIndex();
×
1405

1406
    if (m_editCueStackButton->isChecked() == true)
×
1407
    {
1408
        CueStack* cueStack = currentCueStack();
×
1409
        if (selected.size() == 0)
×
1410
        {
1411
            resetUniverseSliders();
×
1412
            m_universeGroup->setEnabled(false);
×
1413
        }
1414
        else if (selected.size() == 1)
×
1415
        {
1416
            m_universeGroup->setEnabled(true);
×
1417
            QModelIndex index = selected.first();
×
1418
            if (index.row() >= 0 && index.row() < cueStack->cues().size())
×
1419
            {
1420
                Cue cue = cueStack->cues()[index.row()];
×
1421
                m_engine->setCue(cue);
×
1422
                slotUniversePageChanged(m_universePageSpin->value());
×
1423
            }
×
1424
        }
1425
        else
1426
        {
1427
            m_universeGroup->setEnabled(false);
×
1428
            resetUniverseSliders();
×
1429
        }
1430

1431
        // Put a delete button on the first selected item
1432
        if (selected.size() > 0)
×
1433
        {
1434
            QModelIndex index = selected.first();
×
1435
            if (index.row() >= 0 && index.row() < cueStack->cues().size())
×
1436
            {
1437
                QPushButton* btn = new QPushButton(m_cueStackView);
×
1438
                btn->setToolTip(tr("Delete cue"));
×
1439
                btn->setFlat(true);
×
1440
                btn->setFixedSize(m_cueStackView->sizeHintForIndex(index));
×
1441
                btn->setIcon(QIcon(":/delete.png"));
×
1442
                m_cueStackView->setIndexWidget(index, btn);
×
1443
                m_cueDeleteIconIndex = index;
×
1444
                connect(btn, SIGNAL(clicked()), this, SLOT(slotDeleteCueClicked()));
×
1445
            }
1446
        }
1447
    }
1448
    else
1449
    {
1450
        m_universeGroup->setEnabled(true);
×
1451
    }
1452

1453
    updateSpeedDials();
×
1454
}
×
1455

1456
void SimpleDesk::slotPreviousCueClicked()
×
1457
{
1458
    qDebug() << Q_FUNC_INFO;
×
1459
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1460
    Q_ASSERT(cueStack != NULL);
×
1461
    cueStack->previousCue();
×
1462
}
×
1463

1464
void SimpleDesk::slotNextCueClicked()
×
1465
{
1466
    qDebug() << Q_FUNC_INFO;
×
1467
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1468
    Q_ASSERT(cueStack != NULL);
×
1469
    cueStack->nextCue();
×
1470
}
×
1471

1472
void SimpleDesk::slotStopCueStackClicked()
×
1473
{
1474
    qDebug() << Q_FUNC_INFO;
×
1475
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1476
    Q_ASSERT(cueStack != NULL);
×
1477
    cueStack->stop();
×
1478
}
×
1479

1480
void SimpleDesk::slotCloneCueStackClicked()
×
1481
{
1482
    qDebug() << Q_FUNC_INFO;
×
1483

1484
    QStringList items;
×
1485
    for (uint i = 0; i < m_playbacksPerPage; i++)
×
1486
    {
1487
        if (i != m_selectedPlayback)
×
1488
            items << QString::number(i + 1);
×
1489
    }
1490

1491
    bool ok = false;
×
1492
    QString text = QInputDialog::getItem(this, tr("Clone Cue Stack"), tr("Clone To Playback#"),
×
1493
                                         items, 0, false, &ok);
×
1494
    if (ok == false)
×
1495
        return;
×
1496

1497
    uint pb = text.toUInt() - 1;
×
1498
    CueStack* cs = m_engine->cueStack(m_selectedPlayback);
×
1499
    CueStack* clone = m_engine->cueStack(pb);
×
1500
    Q_ASSERT(cs != NULL);
×
1501
    Q_ASSERT(clone != NULL);
×
1502

1503
    while (clone->cues().size() > 0)
×
1504
        clone->removeCue(0);
×
1505

1506
    QListIterator <Cue> it(cs->cues());
×
1507
    while (it.hasNext() == true)
×
1508
        clone->appendCue(it.next());
×
1509

1510
    slotSelectPlayback(pb);
×
1511
}
×
1512

1513
void SimpleDesk::slotDialDestroyed(QObject *)
×
1514
{
1515
    if (m_speedDials != NULL)
×
1516
        m_speedDials->deleteLater();
×
1517
    m_speedDials = NULL;
×
1518
    m_editCueStackButton->setChecked(false);
×
1519
}
×
1520

1521
void SimpleDesk::slotEditCueStackClicked(bool state)
×
1522
{
1523
    qDebug() << Q_FUNC_INFO;
×
1524

1525
    slotCueStackSelectionChanged();
×
1526

1527
    if (state == true)
×
1528
    {
1529
        createSpeedDials();
×
1530
        updateSpeedDials();
×
1531
    }
1532
    else
1533
    {
1534
        resetUniverseSliders();
×
1535
        if (m_speedDials != NULL)
×
1536
            m_speedDials->deleteLater();
×
1537
        m_speedDials = NULL;
×
1538
    }
1539
}
×
1540

1541
void SimpleDesk::slotRecordCueClicked()
×
1542
{
1543
    qDebug() << Q_FUNC_INFO;
×
1544
    Q_ASSERT(m_selectedPlayback < uint(m_playbackSliders.size()));
×
1545

1546
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1547
    Q_ASSERT(cueStack != NULL);
×
1548

1549
    QItemSelectionModel* selModel = m_cueStackView->selectionModel();
×
1550
    Q_ASSERT(selModel != NULL);
×
1551
    int index = 0;
×
1552
    if (selModel->hasSelection() == true)
×
1553
        index = selModel->currentIndex().row() + 1;
×
1554
    else
1555
        index = cueStack->cues().size();
×
1556

1557
    Cue cue = m_engine->cue();
×
1558
    cue.setName(tr("Cue %1").arg(cueStack->cues().size() + 1));
×
1559
    cueStack->insertCue(index, cue);
×
1560

1561
    // Select the newly-created Cue, all columns from 0 to last
1562
    const QAbstractItemModel* itemModel = selModel->model();
×
1563
    Q_ASSERT(itemModel != NULL);
×
1564
    int firstCol = 0;
×
1565
    int lastCol = itemModel->columnCount() - 1;
×
1566
    QItemSelection sel(itemModel->index(index, firstCol), itemModel->index(index, lastCol));
×
1567
    selModel->select(sel, QItemSelectionModel::ClearAndSelect);
×
1568
    selModel->setCurrentIndex(itemModel->index(index, firstCol), QItemSelectionModel::Current);
×
1569

1570
    updateCueStackButtons();
×
1571
}
×
1572

1573
void SimpleDesk::slotDeleteCueClicked()
×
1574
{
1575
    Q_ASSERT(m_cueStackView != NULL);
×
1576
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1577
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1578
    QModelIndex current = m_cueStackView->selectionModel()->currentIndex();
×
1579
    CueStack* cueStack = currentCueStack();
×
1580
    Q_ASSERT(cueStack != NULL);
×
1581
    QList <int> indexes;
×
1582
    foreach (QModelIndex index, selected)
×
1583
        indexes << index.row();
×
1584
    cueStack->removeCues(indexes);
×
1585

1586
    // Select an item ~at the current index
1587
    QAbstractItemModel* model = m_cueStackView->model();
×
1588
    if (model->hasIndex(current.row(), 0) == true)
×
1589
    {
1590
        m_cueStackView->setCurrentIndex(current);
×
1591
    }
1592
    else if (model->rowCount() != 0)
×
1593
    {
1594
        QModelIndex index = model->index(model->rowCount() - 1, 0);
×
1595
        m_cueStackView->setCurrentIndex(index);
×
1596
    }
1597
}
×
1598

1599
void SimpleDesk::slotFadeInDialChanged(int ms)
×
1600
{
1601
    Q_ASSERT(m_cueStackView != NULL);
×
1602
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1603
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1604
    CueStack* cueStack = currentCueStack();
×
1605
    foreach (QModelIndex index, selected)
×
1606
        cueStack->setFadeInSpeed(ms, index.row());
×
1607
}
×
1608

1609
void SimpleDesk::slotFadeOutDialChanged(int ms)
×
1610
{
1611
    Q_ASSERT(m_cueStackView != NULL);
×
1612
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1613
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1614
    CueStack* cueStack = currentCueStack();
×
1615
    foreach (QModelIndex index, selected)
×
1616
        cueStack->setFadeOutSpeed(ms, index.row());
×
1617
}
×
1618

1619
void SimpleDesk::slotHoldDialChanged(int ms)
×
1620
{
1621
    Q_ASSERT(m_cueStackView != NULL);
×
1622
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1623
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1624
    CueStack* cueStack = currentCueStack();
×
1625
    foreach (QModelIndex index, selected)
×
1626
    {
1627
        if (ms < 0)
×
1628
            cueStack->setDuration(ms, index.row());
×
1629
        else
1630
            cueStack->setDuration(cueStack->fadeInSpeed() + ms + cueStack->fadeOutSpeed(), index.row());
×
1631
    }
×
1632
}
×
1633

1634
void SimpleDesk::slotCueNameEdited(const QString& name)
×
1635
{
1636
    Q_ASSERT(m_cueStackView != NULL);
×
1637
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1638
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1639
    CueStack* cueStack = currentCueStack();
×
1640
    if (selected.size() == 1)
×
1641
        cueStack->setName(name, selected.first().row());
×
1642
}
×
1643

1644
void SimpleDesk::showEvent(QShowEvent* ev)
×
1645
{
1646
    if (m_docChanged == true)
×
1647
    {
1648
        if (m_editCueStackButton->isChecked() == true)
×
1649
            slotEditCueStackClicked(true);
×
1650
        initUniversesCombo();
×
1651
        initChannelGroupsView();
×
1652
        m_docChanged = false;
×
1653
    }
1654
    slotUpdateUniverseSliders();
×
1655
    QWidget::showEvent(ev);
×
1656
}
×
1657

1658
void SimpleDesk::hideEvent(QHideEvent* ev)
×
1659
{
1660
    if (m_speedDials != NULL)
×
1661
        m_speedDials->deleteLater();
×
1662
    m_speedDials = NULL;
×
1663
    QWidget::hideEvent(ev);
×
1664
}
×
1665

1666
void SimpleDesk::resizeEvent(QResizeEvent *ev)
×
1667
{
1668
    QWidget::resizeEvent(ev);
×
1669

1670
    QSettings settings;
×
1671
    QVariant var = settings.value(SETTINGS_PAGE_CHANNELS);
×
1672
    QSize newSize = ev->size();
×
1673
    //qDebug() << "Resize event. Frame size:" << newSize;
1674

1675
    // this block makes sense only in a fixed layout
1676
    if (m_viewModeButton->isChecked() == false)
×
1677
    {
1678
        // if channels per page are not forced by the user,
1679
        // perform an autodetection
1680
        if (var.isValid() == false || var.toUInt() == 0)
×
1681
        {
1682
            uint currChannels = m_channelsPerPage;
×
1683
            // 42 is the answer to life, the universe and everything...
1684
            // but also the width of a console channel slider :)
1685
            m_channelsPerPage = (newSize.width() - m_grandMasterSlider->width()) / 42;
×
1686
            //qDebug() << "Old channels per page:" << currChannels << ", new value:" << m_channelsPerPage;
1687
            if (m_channelsPerPage != currChannels)
×
1688
            {
1689
                int slidersDiff = (int)currChannels - (int)m_channelsPerPage;
×
1690
                if (slidersDiff < 0)
×
1691
                {
1692
                    for (int a = 0; a < -slidersDiff; a++)
×
1693
                        m_universeSliders.append(NULL);
×
1694
                }
1695
                else if (slidersDiff > 0)
×
1696
                {
1697
                    for (int r = 0; r < slidersDiff; r++)
×
1698
                    {
1699
                        ConsoleChannel* slider = m_universeSliders.takeLast();
×
1700
                        if (slider != NULL)
×
1701
                        {
1702
                            m_universeGroup->layout()->removeWidget(slider);
×
1703
                            disconnect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
1704
                                   this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
1705
                            disconnect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
1706
                                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
1707
                            delete slider;
×
1708
                        }
1709
                    }
1710
                }
1711
                m_universePageSpin->setRange(1, int((512 + m_channelsPerPage - 1) / m_channelsPerPage));
×
1712
                if (this->isVisible() == true)
×
1713
                    slotUniversePageChanged(m_universePageSpin->value());
×
1714
            }
1715
        }
1716
    }
1717

1718
    // check if the value has been forced by the user
1719
    var = settings.value(SETTINGS_PAGE_PLAYBACKS);
×
1720
    if (var.isValid() == true && var.toUInt() > 0)
×
1721
        return;
×
1722

1723
    uint currPlayback = m_playbacksPerPage;
×
1724
    // always have playback sliders to fill half of the window
1725
    m_playbacksPerPage = (newSize.width() / 2) / 42;
×
1726

1727
    //qDebug() << "Old playback per page:" << currPlayback << ", new value:" << m_playbacksPerPage;
1728

1729
    if (currPlayback != m_playbacksPerPage)
×
1730
    {
1731
        int pbDiff = (int)currPlayback - (int)m_playbacksPerPage;
×
1732
        if (pbDiff < 0)
×
1733
        {
1734
            for (int a = 0; a < -pbDiff; a++)
×
1735
            {
1736
                PlaybackSlider* slider = new PlaybackSlider(m_playbackGroup);
×
1737
                m_playbackGroup->layout()->addWidget(slider);
×
1738
                slider->setLabel(QString::number(m_playbackSliders.count() + 1));
×
1739
                slider->setProperty(PROP_PLAYBACK, uint(m_playbackSliders.count()));
×
1740
                m_playbackSliders << slider;
×
1741
                connect(slider, SIGNAL(selected()), this, SLOT(slotPlaybackSelected()));
×
1742
                connect(slider, SIGNAL(started()), this, SLOT(slotPlaybackStarted()));
×
1743
                connect(slider, SIGNAL(stopped()), this, SLOT(slotPlaybackStopped()));
×
1744
                connect(slider, SIGNAL(flashing(bool)), this, SLOT(slotPlaybackFlashing(bool)));
×
1745
                connect(slider, SIGNAL(valueChanged(uchar)), this, SLOT(slotPlaybackValueChanged(uchar)));
×
1746
            }
1747
        }
1748
        else if (pbDiff > 0)
×
1749
        {
1750
            for (int r = 0; r < pbDiff; r++)
×
1751
            {
1752
                PlaybackSlider* slider = m_playbackSliders.takeLast();
×
1753
                if (slider == NULL)
×
1754
                    continue;
×
1755
                disconnect(slider, SIGNAL(selected()), this, SLOT(slotPlaybackSelected()));
×
1756
                disconnect(slider, SIGNAL(started()), this, SLOT(slotPlaybackStarted()));
×
1757
                disconnect(slider, SIGNAL(stopped()), this, SLOT(slotPlaybackStopped()));
×
1758
                disconnect(slider, SIGNAL(flashing(bool)), this, SLOT(slotPlaybackFlashing(bool)));
×
1759
                disconnect(slider, SIGNAL(valueChanged(uchar)), this, SLOT(slotPlaybackValueChanged(uchar)));
×
1760
                m_playbackGroup->layout()->removeWidget(slider);
×
1761
                delete slider;
×
1762
            }
1763
        }
1764
    }
1765

1766
}
×
1767

1768
/****************************************************************************
1769
 * Load & Save
1770
 ****************************************************************************/
1771

1772
bool SimpleDesk::loadXML(QXmlStreamReader &root)
×
1773
{
1774
    Q_ASSERT(m_engine != NULL);
×
1775

1776
    clearContents();
×
1777

1778
    if (root.name() != KXMLQLCSimpleDesk)
×
1779
    {
1780
        qWarning() << Q_FUNC_INFO << "Simple Desk node not found";
×
1781
        return false;
×
1782
    }
1783

1784
    while (root.readNextStartElement())
×
1785
    {
1786
        if (root.name() == KXMLQLCSimpleDeskEngine)
×
1787
        {
1788
            m_engine->loadXML(root);
×
1789
        }
1790
        else
1791
        {
1792
            qWarning() << Q_FUNC_INFO << "Unrecognized Simple Desk node:" << root.name();
×
1793
            root.skipCurrentElement();
×
1794
        }
1795
    }
1796

1797
    slotSelectPlayback(0);
×
1798

1799
    return true;
×
1800
}
1801

1802
bool SimpleDesk::saveXML(QXmlStreamWriter *doc) const
×
1803
{
1804
    Q_ASSERT(doc != NULL);
×
1805
    Q_ASSERT(m_engine != NULL);
×
1806

1807
    doc->writeStartElement(KXMLQLCSimpleDesk);
×
1808

1809
    if (m_engine->saveXML(doc) == false)
×
1810
        return false;
×
1811

1812
    doc->writeEndElement();
×
1813

1814
    return true;
×
1815
}
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