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

mcallegari / qlcplus / 13633248611

03 Mar 2025 02:31PM UTC coverage: 31.871% (+0.4%) from 31.5%
13633248611

push

github

web-flow
actions: add chrpath to profile

14689 of 46089 relevant lines covered (31.87%)

26426.11 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

407
void SimpleDesk::setAbsoluteChannelValue(uint address, uchar value)
×
408
{
409
    if (address >= ((uint)m_doc->inputOutputMap()->universesCount() * 512))
×
410
        return;
411

412
    m_engine->setValue(address, value);
×
413
}
414

415
void SimpleDesk::resetChannel(quint32 address)
×
416
{
417
    m_engine->resetChannel(address);
×
418

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

421
    if (m_viewModeButton->isChecked() == false)
×
422
    {
423
        if (address < start || address >= start + m_channelsPerPage)
×
424
            return;
425

426
        Fixture *fxi = m_doc->fixture(m_doc->fixtureForAddress(address));
×
427
        ConsoleChannel *cc = m_universeSliders.value(address - start, NULL);
×
428
        if (cc == NULL)
×
429
            return;
430

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

449
        FixtureConsole *fc = m_consoleList.value(fxi->id(), NULL);
×
450
        if (fc == NULL)
×
451
            return;
452

453
        quint32 ch = address - fxi->universeAddress();
×
454

455
        if (fxi->id() % 2 == 0)
×
456
            fc->setChannelStylesheet(ch, ssOdd);
×
457
        else
458
            fc->setChannelStylesheet(ch, ssEven);
×
459
    }
460
}
461

462
void SimpleDesk::resetUniverse()
×
463
{
464
    // force a engine reset
465
    m_engine->resetUniverse(m_currentUniverse);
×
466
    // simulate a user click on the reset button
467
    // to avoid messing up with multithread calls
468
    m_universeResetButton->click();
×
469
}
×
470

471
void SimpleDesk::resetUniverse(int index)
×
472
{
473
    m_universesCombo->setCurrentIndex(index);
×
474
    resetUniverse();
×
475
}
×
476

477
/****************************************************************************
478
 * Universe controls
479
 ****************************************************************************/
480

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

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

522
void SimpleDesk::initUniversePager()
×
523
{
524
    //qDebug() << Q_FUNC_INFO;
525
    m_universePageSpin->setRange(1, int((512 + m_channelsPerPage - 1) / m_channelsPerPage));
×
526
    m_universePageSpin->setValue(1);
×
527
    slotUniversePageChanged(1);
×
528

529
    connect(m_viewModeButton, SIGNAL(clicked(bool)), this, SLOT(slotViewModeClicked(bool)));
×
530
    connect(m_universePageUpButton, SIGNAL(clicked()), this, SLOT(slotUniversePageUpClicked()));
×
531
    connect(m_universePageDownButton, SIGNAL(clicked()), this, SLOT(slotUniversePageDownClicked()));
×
532
    connect(m_universePageSpin, SIGNAL(valueChanged(int)), this, SLOT(slotUniversePageChanged(int)));
×
533
    connect(m_universeResetButton, SIGNAL(clicked()), this, SLOT(slotUniverseResetClicked()));
×
534
}
×
535

536
void SimpleDesk::resetUniverseSliders()
×
537
{
538
    //qDebug() << Q_FUNC_INFO;
539
    foreach (ConsoleChannel *channel, m_universeSliders)
×
540
    {
541
        if (channel != NULL)
×
542
            channel->setValue(0);
×
543
    }
544
}
×
545

546
void SimpleDesk::initSliderView(bool fullMode)
×
547
{
548
    m_consoleList.clear();
×
549

550
    if (fullMode == true)
×
551
    {
552
        scrollArea = new QScrollArea();
×
553
        scrollArea->setWidgetResizable(true);
×
554

555
        QFrame* grpBox = new QFrame(scrollArea);
×
556
        grpBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
×
557
        QHBoxLayout* fixturesLayout = new QHBoxLayout(grpBox);
×
558
        grpBox->setLayout(fixturesLayout);
×
559
        fixturesLayout->setSpacing(2);
×
560
        fixturesLayout->setContentsMargins(2, 2, 2, 2);
×
561

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

601
        m_universeGroup->layout()->addWidget(scrollArea);
×
602
    }
603
    else
604
    {
605
        int page = m_universesPage.at(m_universesCombo->currentIndex());
×
606
        slotUniversePageChanged(page);
×
607
    }
608
}
×
609

610
void SimpleDesk::initChannelGroupsView()
×
611
{
612
    if (m_chGroupsArea != NULL)
×
613
    {
614
        delete m_chGroupsArea;
×
615
        m_chGroupsArea = NULL;
×
616
    }
617

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

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

650
void SimpleDesk::slotViewModeClicked(bool toggle)
×
651
{
652
    if (toggle == true)
×
653
    {
654
        QList<quint32> fxRemoveList;
655

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

692
void SimpleDesk::slotUniversePageUpClicked()
×
693
{
694
    qDebug() << Q_FUNC_INFO;
695
    m_universePageSpin->setValue(m_universePageSpin->value() + 1);
×
696
}
×
697

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

704
void SimpleDesk::slotUniversePageChanged(int page)
×
705
{
706
    qDebug() << Q_FUNC_INFO;
707
    QList<quint32> fxAddList, fxRemoveList;
708
    quint32 start = (page - 1) * m_channelsPerPage;
×
709

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

713
    /* Set the new page for this universe */
714
    m_universesPage.replace(m_currentUniverse, page);
×
715

716
    //qDebug() << "[slotUniversePageChanged] start: " << start << ", absoluteAddr: " << absoluteAddr;
717

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

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

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

799
        m_universeGroup->layout()->addWidget(slider);
×
800
        m_universeSliders[i] = slider;
×
801
    }
802
}
×
803

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

817
        while (it.hasNext() == true)
×
818
        {
819
            it.next();
×
820
            FixtureConsole *fc = it.value();
×
821
            Q_ASSERT(fc != NULL);
822
            fc->resetChannelsStylesheet();
×
823
        }
824
    }
825
}
×
826

827
void SimpleDesk::slotChannelResetClicked(quint32 fxID, quint32 channel)
×
828
{
829
    if (fxID != Fixture::invalidId())
×
830
    {
831
        Fixture *fixture = m_doc->fixture(fxID);
×
832
        if (fixture == NULL)
×
833
            return;
834

835
        quint32 absAddr = fixture->universeAddress() + channel;
×
836
        m_engine->resetChannel(absAddr);
×
837

838
        if (m_viewModeButton->isChecked() == true)
×
839
        {
840
            Fixture *fixture = m_doc->fixture(fxID);
×
841
            if (fixture == NULL)
×
842
                return;
843

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

873
void SimpleDesk::slotAliasChanged()
×
874
{
875
    Fixture *fxi = qobject_cast<Fixture *>(sender());
×
876
    int i = 0;
877

878
    foreach (ConsoleChannel *cc, m_universeSliders)
×
879
    {
880
        quint32 chIndex = cc->channelIndex();
×
881

882
        if (cc->fixture() == fxi->id() && cc->channel() != fxi->channel(chIndex))
×
883
        {
884
            disconnect(cc, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
885
                       this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
886
            disconnect(cc, SIGNAL(resetRequest(quint32,quint32)),
×
887
                       this, SLOT(slotChannelResetClicked(quint32,quint32)));
888

889
            ConsoleChannel *newCC = new ConsoleChannel(this, m_doc, fxi->id(), chIndex, false);
×
890
            newCC->setVisible(false);
×
891

892
            if (m_engine->hasChannel(fxi->universeAddress() + chIndex))
×
893
            {
894
                newCC->setChannelStyleSheet(ssOverride);
×
895
            }
896
            else
897
            {
898
                if (fxi->id() % 2 == 0)
×
899
                    newCC->setChannelStyleSheet(ssOdd);
×
900
                else
901
                    newCC->setChannelStyleSheet(ssEven);
×
902
            }
903

904
            newCC->setValue(cc->value());
×
905
            newCC->showResetButton(true);
×
906
            newCC->setProperty(PROP_ADDRESS, fxi->universeAddress() + chIndex);
×
907
            newCC->setVisible(true);
×
908

909
            connect(newCC, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
910
                    this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
911
            connect(newCC, SIGNAL(resetRequest(quint32,quint32)),
×
912
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
913

914
            QLayoutItem *item = m_universeGroup->layout()->replaceWidget(cc, newCC);
×
915
            delete item;
×
916
            delete cc;
×
917
            m_universeSliders.replace(i, newCC);
×
918
        }
919
        i++;
×
920
    }
921
}
×
922

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

941
        if (m_editCueStackButton->isChecked() == true)
×
942
            replaceCurrentCue();
×
943
    }
944
    else // calculate the absolute address from the given parameters
945
    {
946
        Fixture *fixture = m_doc->fixture(fid);
×
947
        if (fixture == NULL)
×
948
            return;
949

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

963
        if (m_editCueStackButton->isChecked() == true)
×
964
            replaceCurrentCue();
×
965
    }
966
}
×
967

968
void SimpleDesk::slotUniverseWritten(quint32 idx, const QByteArray& universeData)
×
969
{
970
    // If Simple Desk is not visible, don't even waste CPU
971
    if (isVisible() == false)
×
972
        return;
973

974
    if (idx != (quint32)m_currentUniverse)
×
975
        return;
976

977
    //qDebug() << "SIMPLE DESK UNIVERSE WRITTEN" << idx;
978

979
    if (m_viewModeButton->isChecked() == false)
×
980
    {
981
        quint32 start = (m_universePageSpin->value() - 1) * m_channelsPerPage;
×
982

983
        // update current page sliders
984
        for (quint32 i = start; i < start + (quint32)m_channelsPerPage; i++)
×
985
        {
986
            if (i >= (quint32)universeData.length())
×
987
                break;
988

989
            quint32 absAddr = i + (idx << 9);
×
990
            ConsoleChannel *cc = m_universeSliders[i - start];
×
991
            if (cc == NULL)
×
992
                continue;
×
993

994
            if (m_engine->hasChannel(absAddr) == true)
×
995
            {
996
                if (cc->value() != m_engine->value(absAddr))
×
997
                {
998
                    cc->blockSignals(true);
×
999
                    cc->setValue(m_engine->value(absAddr), false);
×
1000
                    cc->setChannelStyleSheet(ssOverride);
×
1001
                    cc->blockSignals(false);
×
1002
                }
1003
                continue;
×
1004
            }
1005

1006
            cc->blockSignals(true);
×
1007
            cc->setValue(universeData.at(i), false);
×
1008
            cc->blockSignals(false);
×
1009
        }
1010
    }
1011
    else
1012
    {
1013
        foreach (FixtureConsole *fc, m_consoleList.values())
×
1014
        {
1015
            if (fc == NULL)
×
1016
                continue;
×
1017

1018
            quint32 fxi = fc->fixture();
×
1019
            Fixture *fixture = m_doc->fixture(fxi);
×
1020
            if (fixture != NULL)
×
1021
            {
1022
                quint32 startAddr = fixture->address();
×
1023
                for (quint32 c = 0; c < fixture->channels(); c++)
×
1024
                {
1025
                    if (startAddr + c >= (quint32)universeData.length())
×
1026
                        break;
1027

1028
                    if (m_engine->hasChannel((startAddr + c) + (idx << 9)) == true)
×
1029
                    {
1030
                        fc->setValue(c, universeData.at(startAddr + c), false);
×
1031
                        fc->setChannelStylesheet(c, ssOverride);
×
1032
                        continue;
×
1033
                    }
1034

1035
                    fc->blockSignals(true);
×
1036
                    fc->setValue(c, universeData.at(startAddr + c), false);
×
1037
                    fc->blockSignals(false);
×
1038
                }
1039
            }
1040
        }
1041
    }
1042
}
1043

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

1059
/****************************************************************************
1060
 * Playback Sliders
1061
 ****************************************************************************/
1062

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

1081
void SimpleDesk::resetPlaybackSliders()
×
1082
{
1083
    //qDebug() << Q_FUNC_INFO;
1084
    QListIterator <PlaybackSlider*> it(m_playbackSliders);
×
1085
    while (it.hasNext() == true)
×
1086
        it.next()->setValue(0);
×
1087
}
×
1088

1089
void SimpleDesk::slotPlaybackSelected()
×
1090
{
1091
    //qDebug() << Q_FUNC_INFO;
1092
    Q_ASSERT(sender() != NULL);
1093
    uint pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1094
    if (m_selectedPlayback == pb)
×
1095
        return;
1096

1097
    slotSelectPlayback(pb);
×
1098
}
1099

1100
void SimpleDesk::slotSelectPlayback(uint pb)
×
1101
{
1102
    //qDebug() << Q_FUNC_INFO;
1103

1104
    if (m_selectedPlayback != UINT_MAX)
×
1105
        m_playbackSliders[m_selectedPlayback]->setSelected(false);
×
1106

1107
    if (pb != UINT_MAX)
×
1108
        m_playbackSliders[pb]->setSelected(true);
×
1109
    m_selectedPlayback = pb;
×
1110

1111
    CueStack* cueStack = m_engine->cueStack(pb);
×
1112
    Q_ASSERT(cueStack != NULL);
1113

1114
    CueStackModel* model = qobject_cast<CueStackModel*> (m_cueStackView->model());
×
1115
    Q_ASSERT(model != NULL);
1116
    model->setCueStack(cueStack);
×
1117

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

1120
    updateCueStackButtons();
×
1121
}
×
1122

1123
void SimpleDesk::slotPlaybackStarted()
×
1124
{
1125
    //qDebug() << Q_FUNC_INFO;
1126
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1127
    CueStack* cueStack = m_engine->cueStack(pb);
×
1128
    Q_ASSERT(cueStack != NULL);
1129

1130
    if (!cueStack->isRunning())
×
1131
        cueStack->nextCue();
×
1132
}
×
1133

1134
void SimpleDesk::slotPlaybackStopped()
×
1135
{
1136
    //qDebug() << Q_FUNC_INFO;
1137
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1138
    CueStack* cueStack = m_engine->cueStack(pb);
×
1139
    Q_ASSERT(cueStack != NULL);
1140

1141
    if (cueStack->isRunning())
×
1142
        cueStack->stop();
×
1143
}
×
1144

1145
void SimpleDesk::slotPlaybackFlashing(bool enabled)
×
1146
{
1147
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1148
    CueStack* cueStack = m_engine->cueStack(pb);
×
1149
    Q_ASSERT(cueStack != NULL);
1150

1151
    cueStack->setFlashing(enabled);
×
1152
}
×
1153

1154
void SimpleDesk::slotPlaybackValueChanged(uchar value)
×
1155
{
1156
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1157
    CueStack* cueStack = m_engine->cueStack(pb);
×
1158
    Q_ASSERT(cueStack != NULL);
1159

1160
    cueStack->adjustIntensity(qreal(value) / qreal(UCHAR_MAX));
×
1161
}
×
1162

1163
void SimpleDesk::slotGroupValueChanged(quint32 groupID, uchar value)
×
1164
{
1165
    ChannelsGroup *group = m_doc->channelsGroup(groupID);
×
1166
    if (group == NULL)
×
1167
        return;
1168
    quint32 start = (m_universePageSpin->value() - 1) * m_channelsPerPage;
×
1169

1170
    foreach (SceneValue scv, group->getChannels())
×
1171
    {
1172
        Fixture *fixture = m_doc->fixture(scv.fxi);
×
1173
        if (fixture == NULL)
×
1174
            continue;
1175
        quint32 absAddr = fixture->universeAddress() + scv.channel;
×
1176

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

1209
        m_engine->setValue(absAddr, value);
×
1210
    }
×
1211
}
1212

1213
/****************************************************************************
1214
 * Cue Stack controls
1215
 ****************************************************************************/
1216

1217
void SimpleDesk::initCueStack()
×
1218
{
1219
    //qDebug() << Q_FUNC_INFO;
1220
    CueStackModel* model = new CueStackModel(this);
×
1221
    m_cueStackView->setModel(model);
×
1222

1223
    connect(m_previousCueButton, SIGNAL(clicked()), this, SLOT(slotPreviousCueClicked()));
×
1224
    connect(m_nextCueButton, SIGNAL(clicked()), this, SLOT(slotNextCueClicked()));
×
1225
    connect(m_stopCueStackButton, SIGNAL(clicked()), this, SLOT(slotStopCueStackClicked()));
×
1226
    connect(m_cloneCueStackButton, SIGNAL(clicked()), this, SLOT(slotCloneCueStackClicked()));
×
1227
    connect(m_editCueStackButton, SIGNAL(toggled(bool)), this, SLOT(slotEditCueStackClicked(bool)));
×
1228
    connect(m_recordCueButton, SIGNAL(clicked()), this, SLOT(slotRecordCueClicked()));
×
1229

1230
    connect(m_cueStackView->selectionModel(),
×
1231
            SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),
1232
            this, SLOT(slotCueStackSelectionChanged()));
1233
}
×
1234

1235
void SimpleDesk::updateCueStackButtons()
×
1236
{
1237
    //qDebug() << Q_FUNC_INFO;
1238
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1239
    if (cueStack == NULL)
×
1240
        return;
1241

1242
    m_stopCueStackButton->setEnabled(cueStack->isRunning());
×
1243
    m_nextCueButton->setEnabled(cueStack->cues().size() > 0);
×
1244
    m_previousCueButton->setEnabled(cueStack->cues().size() > 0);
×
1245
}
1246

1247
void SimpleDesk::replaceCurrentCue()
×
1248
{
1249
    qDebug() << Q_FUNC_INFO;
1250
    Q_ASSERT(m_selectedPlayback < uint(m_playbackSliders.size()));
1251

1252
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1253
    Q_ASSERT(cueStack != NULL);
1254

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

1267
void SimpleDesk::createSpeedDials()
×
1268
{
1269
    if (m_speedDials != NULL)
×
1270
        return;
1271

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

1288
void SimpleDesk::updateSpeedDials()
×
1289
{
1290
    qDebug() << Q_FUNC_INFO;
1291

1292
    if (m_speedDials == NULL)
×
1293
        return;
×
1294

1295
    Q_ASSERT(m_cueStackView != NULL);
1296
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1297
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1298

1299
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1300
    Q_ASSERT(cueStack != NULL);
1301

1302
    if (selected.size() == 0)
×
1303
    {
1304
        m_speedDials->setEnabled(false);
×
1305

1306
        m_speedDials->setWindowTitle(tr("No selection"));
×
1307
        m_speedDials->setFadeInSpeed(0);
×
1308
        m_speedDials->setFadeOutSpeed(0);
×
1309
        m_speedDials->setDuration(0);
×
1310

1311
        m_speedDials->setOptionalTextTitle(QString());
×
1312
        m_speedDials->setOptionalText(QString());
×
1313
    }
1314
    else if (selected.size() == 1)
×
1315
    {
1316
        m_speedDials->setEnabled(true);
×
1317

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

1329
        m_speedDials->setOptionalTextTitle(tr("Cue name"));
×
1330
        m_speedDials->setOptionalText(cue.name());
×
1331
    }
×
1332
    else
1333
    {
1334
        m_speedDials->setEnabled(true);
×
1335

1336
        m_speedDials->setWindowTitle(tr("Multiple Cues"));
×
1337
        m_speedDials->setFadeInSpeed(0);
×
1338
        m_speedDials->setFadeOutSpeed(0);
×
1339
        m_speedDials->setDuration(0);
×
1340

1341
        m_speedDials->setOptionalTextTitle(QString());
×
1342
        m_speedDials->setOptionalText(QString());
×
1343
    }
1344
}
×
1345

1346
CueStack* SimpleDesk::currentCueStack() const
×
1347
{
1348
    Q_ASSERT(m_engine != NULL);
1349
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1350
    Q_ASSERT(cueStack != NULL);
1351
    return cueStack;
×
1352
}
1353

1354
int SimpleDesk::currentCueIndex() const
×
1355
{
1356
    Q_ASSERT(m_cueStackView != NULL);
1357
    return m_cueStackView->currentIndex().row();
×
1358
}
1359

1360
void SimpleDesk::slotCueStackStarted(uint stack)
×
1361
{
1362
    qDebug() << Q_FUNC_INFO;
1363
    if (stack != m_selectedPlayback)
×
1364
        return;
1365

1366
    PlaybackSlider* slider = m_playbackSliders[m_selectedPlayback];
×
1367
    Q_ASSERT(slider != NULL);
1368
    if (slider->value() == 0)
×
1369
        slider->setValue(UCHAR_MAX);
×
1370
    updateCueStackButtons();
×
1371
}
1372

1373
void SimpleDesk::slotCueStackStopped(uint stack)
×
1374
{
1375
    qDebug() << Q_FUNC_INFO;
1376
    if (stack != m_selectedPlayback)
×
1377
        return;
1378

1379
    PlaybackSlider* slider = m_playbackSliders[m_selectedPlayback];
×
1380
    Q_ASSERT(slider != NULL);
1381
    if (slider->value() != 0)
×
1382
        slider->setValue(0);
×
1383
    updateCueStackButtons();
×
1384
}
1385

1386
void SimpleDesk::slotCueStackSelectionChanged()
×
1387
{
1388
    qDebug() << Q_FUNC_INFO;
1389

1390
    Q_ASSERT(m_cueStackView != NULL);
1391
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1392
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1393

1394
    updateCueStackButtons();
×
1395

1396
    // Destroy the existing delete icon
1397
    if (m_cueDeleteIconIndex.isValid() == true)
1398
        m_cueStackView->setIndexWidget(m_cueDeleteIconIndex, NULL);
×
1399
    m_cueDeleteIconIndex = QModelIndex();
×
1400

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

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

1448
    updateSpeedDials();
×
1449
}
×
1450

1451
void SimpleDesk::slotPreviousCueClicked()
×
1452
{
1453
    qDebug() << Q_FUNC_INFO;
1454
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1455
    Q_ASSERT(cueStack != NULL);
1456
    cueStack->previousCue();
×
1457
}
×
1458

1459
void SimpleDesk::slotNextCueClicked()
×
1460
{
1461
    qDebug() << Q_FUNC_INFO;
1462
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1463
    Q_ASSERT(cueStack != NULL);
1464
    cueStack->nextCue();
×
1465
}
×
1466

1467
void SimpleDesk::slotStopCueStackClicked()
×
1468
{
1469
    qDebug() << Q_FUNC_INFO;
1470
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1471
    Q_ASSERT(cueStack != NULL);
1472
    cueStack->stop();
×
1473
}
×
1474

1475
void SimpleDesk::slotCloneCueStackClicked()
×
1476
{
1477
    qDebug() << Q_FUNC_INFO;
1478

1479
    QStringList items;
1480
    for (uint i = 0; i < m_playbacksPerPage; i++)
×
1481
    {
1482
        if (i != m_selectedPlayback)
×
1483
            items << QString::number(i + 1);
×
1484
    }
1485

1486
    bool ok = false;
×
1487
    QString text = QInputDialog::getItem(this, tr("Clone Cue Stack"), tr("Clone To Playback#"),
×
1488
                                         items, 0, false, &ok);
×
1489
    if (ok == false)
×
1490
        return;
1491

1492
    uint pb = text.toUInt() - 1;
×
1493
    CueStack* cs = m_engine->cueStack(m_selectedPlayback);
×
1494
    CueStack* clone = m_engine->cueStack(pb);
×
1495
    Q_ASSERT(cs != NULL);
1496
    Q_ASSERT(clone != NULL);
1497

1498
    while (clone->cues().size() > 0)
×
1499
        clone->removeCue(0);
×
1500

1501
    QListIterator <Cue> it(cs->cues());
×
1502
    while (it.hasNext() == true)
×
1503
        clone->appendCue(it.next());
×
1504

1505
    slotSelectPlayback(pb);
×
1506
}
×
1507

1508
void SimpleDesk::slotDialDestroyed(QObject *)
×
1509
{
1510
    if (m_speedDials != NULL)
×
1511
        m_speedDials->deleteLater();
×
1512
    m_speedDials = NULL;
×
1513
    m_editCueStackButton->setChecked(false);
×
1514
}
×
1515

1516
void SimpleDesk::slotEditCueStackClicked(bool state)
×
1517
{
1518
    qDebug() << Q_FUNC_INFO;
1519

1520
    slotCueStackSelectionChanged();
×
1521

1522
    if (state == true)
×
1523
    {
1524
        createSpeedDials();
×
1525
        updateSpeedDials();
×
1526
    }
1527
    else
1528
    {
1529
        resetUniverseSliders();
×
1530
        if (m_speedDials != NULL)
×
1531
            m_speedDials->deleteLater();
×
1532
        m_speedDials = NULL;
×
1533
    }
1534
}
×
1535

1536
void SimpleDesk::slotRecordCueClicked()
×
1537
{
1538
    qDebug() << Q_FUNC_INFO;
1539
    Q_ASSERT(m_selectedPlayback < uint(m_playbackSliders.size()));
1540

1541
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1542
    Q_ASSERT(cueStack != NULL);
1543

1544
    QItemSelectionModel* selModel = m_cueStackView->selectionModel();
×
1545
    Q_ASSERT(selModel != NULL);
1546
    int index = 0;
1547
    if (selModel->hasSelection() == true)
×
1548
        index = selModel->currentIndex().row() + 1;
×
1549
    else
1550
        index = cueStack->cues().size();
×
1551

1552
    Cue cue = m_engine->cue();
×
1553
    cue.setName(tr("Cue %1").arg(cueStack->cues().size() + 1));
×
1554
    cueStack->insertCue(index, cue);
×
1555

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

1565
    updateCueStackButtons();
×
1566
}
×
1567

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

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

1594
void SimpleDesk::slotFadeInDialChanged(int ms)
×
1595
{
1596
    Q_ASSERT(m_cueStackView != NULL);
1597
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1598
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1599
    CueStack* cueStack = currentCueStack();
×
1600
    foreach (QModelIndex index, selected)
×
1601
        cueStack->setFadeInSpeed(ms, index.row());
×
1602
}
×
1603

1604
void SimpleDesk::slotFadeOutDialChanged(int ms)
×
1605
{
1606
    Q_ASSERT(m_cueStackView != NULL);
1607
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1608
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1609
    CueStack* cueStack = currentCueStack();
×
1610
    foreach (QModelIndex index, selected)
×
1611
        cueStack->setFadeOutSpeed(ms, index.row());
×
1612
}
×
1613

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

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

1639
void SimpleDesk::showEvent(QShowEvent* ev)
×
1640
{
1641
    if (m_docChanged == true)
×
1642
    {
1643
        if (m_editCueStackButton->isChecked() == true)
×
1644
            slotEditCueStackClicked(true);
×
1645
        initUniversesCombo();
×
1646
        initChannelGroupsView();
×
1647
        m_docChanged = false;
×
1648
    }
1649
    slotUpdateUniverseSliders();
×
1650
    QWidget::showEvent(ev);
×
1651
}
×
1652

1653
void SimpleDesk::hideEvent(QHideEvent* ev)
×
1654
{
1655
    if (m_speedDials != NULL)
×
1656
        m_speedDials->deleteLater();
×
1657
    m_speedDials = NULL;
×
1658
    QWidget::hideEvent(ev);
×
1659
}
×
1660

1661
void SimpleDesk::resizeEvent(QResizeEvent *ev)
×
1662
{
1663
    QWidget::resizeEvent(ev);
×
1664

1665
    QSettings settings;
×
1666
    QVariant var = settings.value(SETTINGS_PAGE_CHANNELS);
×
1667
    QSize newSize = ev->size();
×
1668
    //qDebug() << "Resize event. Frame size:" << newSize;
1669

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

1713
    // check if the value has been forced by the user
1714
    var = settings.value(SETTINGS_PAGE_PLAYBACKS);
×
1715
    if (var.isValid() == true && var.toUInt() > 0)
×
1716
        return;
1717

1718
    uint currPlayback = m_playbacksPerPage;
×
1719
    // always have playback sliders to fill half of the window
1720
    m_playbacksPerPage = (newSize.width() / 2) / 42;
×
1721

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

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

1761
}
×
1762

1763
/****************************************************************************
1764
 * Load & Save
1765
 ****************************************************************************/
1766

1767
bool SimpleDesk::loadXML(QXmlStreamReader &root)
×
1768
{
1769
    Q_ASSERT(m_engine != NULL);
1770

1771
    clearContents();
×
1772

1773
    if (root.name() != KXMLQLCSimpleDesk)
×
1774
    {
1775
        qWarning() << Q_FUNC_INFO << "Simple Desk node not found";
×
1776
        return false;
×
1777
    }
1778

1779
    while (root.readNextStartElement())
×
1780
    {
1781
        if (root.name() == KXMLQLCSimpleDeskEngine)
×
1782
        {
1783
            m_engine->loadXML(root);
×
1784
        }
1785
        else
1786
        {
1787
            qWarning() << Q_FUNC_INFO << "Unrecognized Simple Desk node:" << root.name();
×
1788
            root.skipCurrentElement();
×
1789
        }
1790
    }
1791

1792
    slotSelectPlayback(0);
×
1793

1794
    return true;
×
1795
}
1796

1797
bool SimpleDesk::saveXML(QXmlStreamWriter *doc) const
×
1798
{
1799
    Q_ASSERT(doc != NULL);
1800
    Q_ASSERT(m_engine != NULL);
1801

1802
    doc->writeStartElement(KXMLQLCSimpleDesk);
×
1803

1804
    if (m_engine->saveXML(doc) == false)
×
1805
        return false;
1806

1807
    doc->writeEndElement();
×
1808

1809
    return true;
×
1810
}
1811

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc