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

mcallegari / qlcplus / 7252848206

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

push

github

mcallegari
Code style review #1427

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

8 existing lines in 2 files now uncovered.

15169 of 47304 relevant lines covered (32.07%)

23733.74 hits per line

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

0.0
/ui/src/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
        return m_engine->value(address);
×
392
    else
393
    {
394
        QList<Universe*> ua = m_doc->inputOutputMap()->claimUniverses();
×
395
        int uni = address >> 9;
×
396
        uint channel = address & 0x01FF;
×
397
        if (uni >= ua.count())
×
398
            return 0;
×
399
        uchar value = ua.at(uni)->preGMValue(channel);
×
400
        m_doc->inputOutputMap()->releaseUniverses(false);
×
401
        return value;
×
402
    }
403
}
404

405
void SimpleDesk::setAbsoluteChannelValue(uint address, uchar value)
×
406
{
407
    m_engine->setValue(address, value);
×
408
}
×
409

410
void SimpleDesk::resetChannel(quint32 address)
×
411
{
412
    m_engine->resetChannel(address);
×
413
}
×
414

415
void SimpleDesk::resetUniverse()
×
416
{
417
    // force a engine reset
418
    m_engine->resetUniverse(m_currentUniverse);
×
419
    // simulate a user click on the reset button
420
    // to avoid messing up with multithread calls
421
    m_universeResetButton->click();
×
422
}
×
423

424
/****************************************************************************
425
 * Universe controls
426
 ****************************************************************************/
427

428
void SimpleDesk::initUniversesCombo()
×
429
{
430
    disconnect(m_universesCombo, SIGNAL(currentIndexChanged(int)),
×
431
            this, SLOT(slotUniversesComboChanged(int)));
432
    int currIdx = m_universesCombo->currentIndex();
×
433
    m_universesCombo->clear();
×
434
    m_universesCombo->addItems(m_doc->inputOutputMap()->universeNames());
×
435
    if (currIdx != -1)
×
436
        m_universesCombo->setCurrentIndex(currIdx);
×
437
    while (m_universesPage.length() < m_universesCombo->count())
×
438
        m_universesPage.append(1);
×
439
    connect(m_universesCombo, SIGNAL(currentIndexChanged(int)),
×
440
            this, SLOT(slotUniversesComboChanged(int)));
441
}
×
442

443
void SimpleDesk::initUniverseSliders()
×
444
{
445
    //qDebug() << Q_FUNC_INFO;
446
    quint32 start = m_universesPage.at(m_currentUniverse) * m_channelsPerPage;
×
447
    for (quint32 i = 0; i < m_channelsPerPage; i++)
×
448
    {
449
        ConsoleChannel* slider = NULL;
×
450
        Fixture* fxi = m_doc->fixture(m_doc->fixtureForAddress(start + i));
×
451
        if (fxi == NULL)
×
452
            slider = new ConsoleChannel(this, m_doc, Fixture::invalidId(), i, false);
×
453
        else
454
        {
455
            uint ch = (start + i) - fxi->universeAddress();
×
456
            slider = new ConsoleChannel(this, m_doc, fxi->id(), ch, false);
×
457
            slider->setValue(uchar(fxi->channelValueAt(ch)));
×
458
        }
459
        slider->showResetButton(true);
×
460
        m_universeGroup->layout()->addWidget(slider);
×
461
        m_universeSliders << slider;
×
462
        connect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
463
                this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
464
        connect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
465
                this, SLOT(slotChannelResetClicked(quint32,quint32)));
466
    }
467
}
×
468

469
void SimpleDesk::initUniversePager()
×
470
{
471
    //qDebug() << Q_FUNC_INFO;
472
    m_universePageSpin->setRange(1, int((512 + m_channelsPerPage - 1) / m_channelsPerPage));
×
473
    m_universePageSpin->setValue(1);
×
474
    slotUniversePageChanged(1);
×
475

476
    connect(m_viewModeButton, SIGNAL(clicked(bool)), this, SLOT(slotViewModeClicked(bool)));
×
477
    connect(m_universePageUpButton, SIGNAL(clicked()), this, SLOT(slotUniversePageUpClicked()));
×
478
    connect(m_universePageDownButton, SIGNAL(clicked()), this, SLOT(slotUniversePageDownClicked()));
×
479
    connect(m_universePageSpin, SIGNAL(valueChanged(int)), this, SLOT(slotUniversePageChanged(int)));
×
480
    connect(m_universeResetButton, SIGNAL(clicked()), this, SLOT(slotUniverseResetClicked()));
×
481
}
×
482

483
void SimpleDesk::resetUniverseSliders()
×
484
{
485
    //qDebug() << Q_FUNC_INFO;
486
    foreach (ConsoleChannel *channel, m_universeSliders)
×
487
    {
488
        if (channel != NULL)
×
489
            channel->setValue(0);
×
490
    }
491
}
×
492

493
void SimpleDesk::initSliderView(bool fullMode)
×
494
{
495
    m_consoleList.clear();
×
496

497
    if (fullMode == true)
×
498
    {
499
        scrollArea = new QScrollArea();
×
500
        scrollArea->setWidgetResizable(true);
×
501

502
        QFrame* grpBox = new QFrame(scrollArea);
×
503
        grpBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
×
504
        QHBoxLayout* fixturesLayout = new QHBoxLayout(grpBox);
×
505
        grpBox->setLayout(fixturesLayout);
×
506
        fixturesLayout->setSpacing(2);
×
507
        fixturesLayout->setContentsMargins(2, 2, 2, 2);
×
508

509
        int c = 0;
×
NEW
510
        foreach (Fixture *fixture, m_doc->fixtures())
×
511
        {
512
            if (fixture->universe() != (quint32)m_universesCombo->currentIndex())
×
513
                continue;
×
514
            FixtureConsole* console = NULL;
×
515
            if (c%2 == 0)
×
516
                console = new FixtureConsole(scrollArea, m_doc, FixtureConsole::GroupOdd, false);
×
517
            else
518
                console = new FixtureConsole(scrollArea, m_doc, FixtureConsole::GroupEven, false);
×
519
            console->setFixture(fixture->id());
×
520
            console->enableResetButton(true);
×
521
            quint32 absoluteAddr = fixture->universeAddress();
×
522
            QByteArray fxValues = fixture->channelValues();
×
523
            for (quint32 i = 0; i < fixture->channels(); i++)
×
524
            {
525
                if (m_engine->hasChannel(absoluteAddr + i))
×
526
                {
527
                    SceneValue scv(fixture->id(), i, m_engine->value(absoluteAddr + i));
×
528
                    console->setSceneValue(scv);
×
529
                    console->setChannelStylesheet(i, ssOverride);
×
530
                }
531
                else
532
                {
533
                    SceneValue scv(fixture->id(), i, (uchar)fxValues.at(i));
×
534
                    console->setSceneValue(scv);
×
535
                }
536
            }
537
            fixturesLayout->addWidget(console);
×
538
            connect(console, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
539
                    this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
540
            connect(console, SIGNAL(resetRequest(quint32,quint32)),
×
541
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
542
            c++;
×
543
            m_consoleList[fixture->id()] = console;
×
544
        }
545
        fixturesLayout->addStretch(1);
×
546
        scrollArea->setWidget(grpBox);
×
547

548
        m_universeGroup->layout()->addWidget(scrollArea);
×
549
    }
550
    else
551
    {
552
        int page = m_universesPage.at(m_universesCombo->currentIndex());
×
553
        slotUniversePageChanged(page);
×
554
    }
555
}
×
556

557
void SimpleDesk::initChannelGroupsView()
×
558
{
559
    if (m_chGroupsArea != NULL)
×
560
    {
561
        delete m_chGroupsArea;
×
562
        m_chGroupsArea = NULL;
×
563
    }
564

565
    if (m_doc->channelsGroups().count() > 0)
×
566
    {
567
        m_chGroupsArea = new QScrollArea();
×
568
        QList<quint32> chGrpIDs;
×
NEW
569
        foreach (ChannelsGroup *grp, m_doc->channelsGroups())
×
570
            chGrpIDs.append(grp->id());
×
571
        GroupsConsole* console = new GroupsConsole(m_chGroupsArea, m_doc, chGrpIDs, QList<uchar>());
×
572
        m_chGroupsArea->setWidget(console);
×
573
        m_chGroupsArea->setWidgetResizable(true);
×
574
        m_tabs->addTab(m_chGroupsArea, tr("Channel groups"));
×
575
        connect(console, SIGNAL(groupValueChanged(quint32,uchar)),
×
576
                this, SLOT(slotGroupValueChanged(quint32,uchar)));
577
    }
578
}
×
579

580
void SimpleDesk::slotUniversesComboChanged(int index)
×
581
{
582
    m_currentUniverse = index;
×
583
    if (m_viewModeButton->isChecked() == true)
×
584
    {
585
        m_universeGroup->layout()->removeWidget(scrollArea);
×
586
        delete scrollArea;
×
587
        initSliderView(true);
×
588
    }
589
    else
590
    {
591
        int page = m_universesPage.at(index);
×
592
        slotUniversePageChanged(m_universesPage.at(index));
×
593
        m_universePageSpin->setValue(page);
×
594
    }
595
}
×
596

597
void SimpleDesk::slotViewModeClicked(bool toggle)
×
598
{
599
    if (toggle == true)
×
600
    {
601
        QList<quint32> fxRemoveList;
×
602

603
        for (quint32 i = 0; i < m_channelsPerPage; i++)
×
604
        {
605
            ConsoleChannel* slider = m_universeSliders[i];
×
606
            if (slider != NULL)
×
607
            {
608
                m_universeGroup->layout()->removeWidget(slider);
×
609
                disconnect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
610
                       this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
611
                disconnect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
612
                        this, SLOT(slotChannelResetClicked(quint32,quint32)));
613
                if (fxRemoveList.contains(slider->fixture()) == false)
×
614
                {
615
                    Fixture *currFx = m_doc->fixture(slider->fixture());
×
616
                    if (currFx != NULL)
×
617
                    {
618
                        disconnect(currFx, SIGNAL(aliasChanged()), this, SLOT(slotAliasChanged()));
×
619
                        fxRemoveList.append(slider->fixture());
×
620
                    }
621
                }
622
                delete slider;
×
623
                m_universeSliders[i] = NULL;
×
624
            }
625
        }
626
        initSliderView(true);
×
627
    }
628
    else
629
    {
630
        m_universeGroup->layout()->removeWidget(scrollArea);
×
631
        delete scrollArea;
×
632
        initSliderView(false);
×
633
    }
634
    m_universePageUpButton->setEnabled(!toggle);
×
635
    m_universePageDownButton->setEnabled(!toggle);
×
636
    m_universePageSpin->setEnabled(!toggle);
×
637
}
×
638

639
void SimpleDesk::slotUniversePageUpClicked()
×
640
{
641
    qDebug() << Q_FUNC_INFO;
×
642
    m_universePageSpin->setValue(m_universePageSpin->value() + 1);
×
643
}
×
644

645
void SimpleDesk::slotUniversePageDownClicked()
×
646
{
647
    qDebug() << Q_FUNC_INFO;
×
648
    m_universePageSpin->setValue(m_universePageSpin->value() - 1);
×
649
}
×
650

651
void SimpleDesk::slotUniversePageChanged(int page)
×
652
{
653
    qDebug() << Q_FUNC_INFO;
×
654
    QList<quint32> fxAddList, fxRemoveList;
×
655
    quint32 start = (page - 1) * m_channelsPerPage;
×
656

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

660
    /* Set the new page for this universe */
661
    m_universesPage.replace(m_currentUniverse, page);
×
662

663
    //qDebug() << "[slotUniversePageChanged] start: " << start << ", absoluteAddr: " << absoluteAddr;
664

665
    for (quint32 i = 0; i < m_channelsPerPage; i++)
×
666
    {
667
        ConsoleChannel *slider = m_universeSliders[i];
×
668
        if (slider != NULL)
×
669
        {
670
            m_universeGroup->layout()->removeWidget(slider);
×
671
            disconnect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
672
                   this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
673
            disconnect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
674
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
675

676
            if (fxRemoveList.contains(slider->fixture()) == false)
×
677
            {
678
                Fixture *currFx = m_doc->fixture(slider->fixture());
×
679
                if (currFx != NULL)
×
680
                {
681
                    disconnect(currFx, SIGNAL(aliasChanged()), this, SLOT(slotAliasChanged()));
×
682
                    fxRemoveList.append(slider->fixture());
×
683
                }
684
            }
685
            delete slider;
×
686
            m_universeSliders[i] = NULL;
×
687
        }
688
        Fixture *fx = m_doc->fixture(m_doc->fixtureForAddress(absoluteAddr + i));
×
689
        if (fx == NULL)
×
690
        {
691
            slider = new ConsoleChannel(this, m_doc, Fixture::invalidId(), start + i, false);
×
692
            slider->setVisible(false);
×
693
            if (m_engine->hasChannel((m_currentUniverse << 9) + (start + i)))
×
694
                slider->setChannelStyleSheet(ssOverride);
×
695
            else
696
                slider->setChannelStyleSheet(ssNone);
×
697
        }
698
        else
699
        {
700
            uint ch = (absoluteAddr + i) - fx->universeAddress();
×
701
            slider = new ConsoleChannel(this, m_doc, fx->id(), ch, false);
×
702
            slider->setVisible(false);
×
703
            if (m_engine->hasChannel(absoluteAddr + i))
×
704
            {
705
                slider->setChannelStyleSheet(ssOverride);
×
706
            }
707
            else
708
            {
709
                if (fx->id() % 2 == 0)
×
710
                    slider->setChannelStyleSheet(ssOdd);
×
711
                else
712
                    slider->setChannelStyleSheet(ssEven);
×
713
                slider->setValue(uchar(fx->channelValueAt(ch)));
×
714
            }
715
            if (fxAddList.contains(fx->id()) == false)
×
716
            {
717
                connect(fx, SIGNAL(aliasChanged()), this, SLOT(slotAliasChanged()));
×
718
                fxAddList.append(fx->id());
×
719
            }
720
        }
721
        slider->showResetButton(true);
×
722
        slider->setVisible(true);
×
723

724
        if ((start + i) < 512)
×
725
        {
726
            slider->setEnabled(true);
×
727
            slider->setProperty(PROP_ADDRESS, absoluteAddr + i);
×
728
            slider->setLabel(QString::number(start + i + 1));
×
729
            //qDebug() << "Set slider value[" << (absoluteAddr + i) << "] = " << m_engine->value(absoluteAddr + i);
730
            if (m_engine->hasChannel(absoluteAddr + i))
×
731
                slider->setValue(m_engine->value(absoluteAddr + i), false);
×
732
            connect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
733
                    this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
734
            connect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
735
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
736
        }
737
        else
738
        {
739
            slider->setEnabled(false);
×
740
            slider->setProperty(PROP_ADDRESS, QVariant());
×
741
            slider->setValue(0);
×
742
            slider->setLabel("---");
×
743
            slider->setPalette(this->palette());
×
744
        }
745

746
        m_universeGroup->layout()->addWidget(slider);
×
747
        m_universeSliders[i] = slider;
×
748
    }
749
}
×
750

751
void SimpleDesk::slotUniverseResetClicked()
×
752
{
753
    qDebug() << Q_FUNC_INFO;
×
754
    m_engine->resetUniverse(m_currentUniverse);
×
755
    m_universePageSpin->setValue(1);
×
756
    if (m_viewModeButton->isChecked() == false)
×
757
        slotUniversePageChanged(1);
×
758
    else
759
    {
760
        QHashIterator <quint32,FixtureConsole*> it(m_consoleList);
×
761

762
        while (it.hasNext() == true)
×
763
        {
764
            it.next();
×
765
            FixtureConsole *fc = it.value();
×
766
            Q_ASSERT(fc != NULL);
×
767
            fc->resetChannelsStylesheet();
×
768
        }
769
    }
770
}
×
771

772
void SimpleDesk::slotChannelResetClicked(quint32 fxID, quint32 channel)
×
773
{
774
    if (fxID != Fixture::invalidId())
×
775
    {
776
        Fixture *fixture = m_doc->fixture(fxID);
×
777
        if (fixture == NULL)
×
778
            return;
×
779

780
        quint32 absAddr = fixture->universeAddress() + channel;
×
781
        m_engine->resetChannel(absAddr);
×
782

783
        if (m_viewModeButton->isChecked() == true)
×
784
        {
785
            Fixture *fixture = m_doc->fixture(fxID);
×
786
            if (fixture == NULL)
×
787
                return;
×
788

789
            if (m_consoleList.contains(fxID))
×
790
            {
791
                FixtureConsole *fc = m_consoleList[fxID];
×
792
                if (fc != NULL)
×
793
                {
794
                    if (fixture->id() % 2 == 0)
×
795
                        fc->setChannelStylesheet(channel, ssOdd);
×
796
                    else
797
                        fc->setChannelStylesheet(channel, ssEven);
×
798
                }
799
            }
800
        }
801
        else
802
        {
803
            ConsoleChannel *slider = qobject_cast<ConsoleChannel *>(sender());
×
804
            if (fixture->id() % 2 == 0)
×
805
                slider->setChannelStyleSheet(ssOdd);
×
806
            else
807
                slider->setChannelStyleSheet(ssEven);
×
808
        }
809
    }
810
    else
811
    {
812
        ConsoleChannel *slider = qobject_cast<ConsoleChannel *>(sender());
×
813
        m_engine->resetChannel(channel);
×
814
        slider->setChannelStyleSheet(ssNone);
×
815
    }
816
}
817

818
void SimpleDesk::slotAliasChanged()
×
819
{
820
    Fixture *fxi = qobject_cast<Fixture *>(sender());
×
821
    int i = 0;
×
822

823
    foreach (ConsoleChannel *cc, m_universeSliders)
×
824
    {
825
        quint32 chIndex = cc->channelIndex();
×
826

827
        if (cc->fixture() == fxi->id() && cc->channel() != fxi->channel(chIndex))
×
828
        {
829
            disconnect(cc, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
830
                       this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
831
            disconnect(cc, SIGNAL(resetRequest(quint32,quint32)),
×
832
                       this, SLOT(slotChannelResetClicked(quint32,quint32)));
833

834
            ConsoleChannel *newCC = new ConsoleChannel(this, m_doc, fxi->id(), chIndex, false);
×
835
            newCC->setVisible(false);
×
836

837
            if (m_engine->hasChannel(fxi->universeAddress() + chIndex))
×
838
            {
839
                newCC->setChannelStyleSheet(ssOverride);
×
840
            }
841
            else
842
            {
843
                if (fxi->id() % 2 == 0)
×
844
                    newCC->setChannelStyleSheet(ssOdd);
×
845
                else
846
                    newCC->setChannelStyleSheet(ssEven);
×
847
            }
848

849
            newCC->setValue(cc->value());
×
850
            newCC->showResetButton(true);
×
851
            newCC->setProperty(PROP_ADDRESS, fxi->universeAddress() + chIndex);
×
852
            newCC->setVisible(true);
×
853

854
            connect(newCC, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
855
                    this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
856
            connect(newCC, SIGNAL(resetRequest(quint32,quint32)),
×
857
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
858

859
            QLayoutItem *item = m_universeGroup->layout()->replaceWidget(cc, newCC);
×
860
            delete item;
×
861
            delete cc;
×
862
            m_universeSliders.replace(i, newCC);
×
863
        }
864
        i++;
×
865
    }
866
}
×
867

868
void SimpleDesk::slotUniverseSliderValueChanged(quint32 fid, quint32 chan, uchar value)
×
869
{
870
    QVariant var(sender()->property(PROP_ADDRESS));
×
871
    if (var.isValid()) // Not true with disabled sliders
×
872
    {
873
        quint32 chanAbsAddr = var.toUInt();
×
874
        if (m_viewModeButton->isChecked() == false &&
×
875
            m_engine->hasChannel(chanAbsAddr) == false)
×
876
        {
877
            quint32 chanAddr = (chanAbsAddr & 0x01FF) - ((m_universePageSpin->value() - 1) * m_channelsPerPage);
×
878
            if (chanAddr < (quint32)m_universeSliders.count())
×
879
            {
880
                ConsoleChannel *chan = m_universeSliders.at(chanAddr);
×
881
                chan->setChannelStyleSheet(ssOverride);
×
882
            }
883
        }
884
        m_engine->setValue(chanAbsAddr, value);
×
885

886
        if (m_editCueStackButton->isChecked() == true)
×
887
            replaceCurrentCue();
×
888
    }
889
    else // calculate the absolute address from the given parameters
890
    {
891
        Fixture *fixture = m_doc->fixture(fid);
×
892
        if (fixture == NULL)
×
893
            return;
×
894

895
        quint32 chanAbsAddr = fixture->universeAddress() + chan;
×
896
        if (m_viewModeButton->isChecked() == true &&
×
897
            m_engine->hasChannel(chanAbsAddr) == false)
×
898
        {
899
            if (m_consoleList.contains(fid))
×
900
            {
901
                FixtureConsole *fc = m_consoleList[fid];
×
902
                if (fc != NULL)
×
903
                    fc->setChannelStylesheet(chan, ssOverride);
×
904
            }
905
        }
906
        m_engine->setValue(chanAbsAddr, value);
×
907

908
        if (m_editCueStackButton->isChecked() == true)
×
909
            replaceCurrentCue();
×
910
    }
911
}
912

913
void SimpleDesk::slotUniverseWritten(quint32 idx, const QByteArray& universeData)
×
914
{
915
    // If Simple Desk is not visible, don't even waste CPU
916
    if (isVisible() == false)
×
917
        return;
×
918

919
    if (idx != (quint32)m_currentUniverse)
×
920
        return;
×
921

922
    //qDebug() << "SIMPLE DESK UNIVERSE WRITTEN" << idx;
923

924
    if (m_viewModeButton->isChecked() == false)
×
925
    {
926
        quint32 start = (m_universePageSpin->value() - 1) * m_channelsPerPage;
×
927

928
        // update current page sliders
929
        for (quint32 i = start; i < start + (quint32)m_channelsPerPage; i++)
×
930
        {
931
            if (i >= (quint32)universeData.length())
×
932
                break;
×
933

934
            quint32 absAddr = i + (idx << 9);
×
935
            ConsoleChannel *cc = m_universeSliders[i - start];
×
936
            if (cc == NULL)
×
937
                continue;
×
938

939
            if (m_engine->hasChannel(absAddr) == true)
×
940
            {
941
                if (cc->value() != m_engine->value(absAddr))
×
942
                {
943
                    cc->blockSignals(true);
×
944
                    cc->setValue(m_engine->value(absAddr), false);
×
945
                    cc->setChannelStyleSheet(ssOverride);
×
946
                    cc->blockSignals(false);
×
947
                }
948
                continue;
×
949
            }
950

951
            cc->blockSignals(true);
×
952
            cc->setValue(universeData.at(i), false);
×
953
            cc->blockSignals(false);
×
954
        }
955
    }
956
    else
957
    {
NEW
958
        foreach (FixtureConsole *fc, m_consoleList.values())
×
959
        {
960
            if (fc == NULL)
×
961
                continue;
×
962

963
            quint32 fxi = fc->fixture();
×
964
            Fixture *fixture = m_doc->fixture(fxi);
×
965
            if (fixture != NULL)
×
966
            {
967
                quint32 startAddr = fixture->address();
×
968
                for (quint32 c = 0; c < fixture->channels(); c++)
×
969
                {
970
                    if (startAddr + c >= (quint32)universeData.length())
×
971
                        break;
×
972

973
                    if (m_engine->hasChannel((startAddr + c) + (idx << 9)) == true)
×
974
                        continue;
×
975

976
                    fc->blockSignals(true);
×
977
                    fc->setValue(c, universeData.at(startAddr + c), false);
×
978
                    fc->blockSignals(false);
×
979
                }
980
            }
981
        }
982
    }
983
}
984

985
void SimpleDesk::slotUpdateUniverseSliders()
×
986
{
987
    //qDebug() << Q_FUNC_INFO;
988
    if (m_viewModeButton->isChecked() == true)
×
989
    {
990
        m_universeGroup->layout()->removeWidget(scrollArea);
×
991
        delete scrollArea;
×
992
        initSliderView(true);
×
993
    }
994
    else
995
    {
996
        slotUniversePageChanged(m_universePageSpin->value());
×
997
    }
998
}
×
999

1000
/****************************************************************************
1001
 * Playback Sliders
1002
 ****************************************************************************/
1003

1004
void SimpleDesk::initPlaybackSliders()
×
1005
{
1006
    //qDebug() << Q_FUNC_INFO;
1007
    for (uint i = 0; i < m_playbacksPerPage; i++)
×
1008
    {
1009
        PlaybackSlider* slider = new PlaybackSlider(m_playbackGroup);
×
1010
        m_playbackGroup->layout()->addWidget(slider);
×
1011
        slider->setLabel(QString::number(i + 1));
×
1012
        slider->setProperty(PROP_PLAYBACK, uint(i));
×
1013
        m_playbackSliders << slider;
×
1014
        connect(slider, SIGNAL(selected()), this, SLOT(slotPlaybackSelected()));
×
1015
        connect(slider, SIGNAL(started()), this, SLOT(slotPlaybackStarted()));
×
1016
        connect(slider, SIGNAL(stopped()), this, SLOT(slotPlaybackStopped()));
×
1017
        connect(slider, SIGNAL(flashing(bool)), this, SLOT(slotPlaybackFlashing(bool)));
×
1018
        connect(slider, SIGNAL(valueChanged(uchar)), this, SLOT(slotPlaybackValueChanged(uchar)));
×
1019
    }
1020
}
×
1021

1022
void SimpleDesk::resetPlaybackSliders()
×
1023
{
1024
    //qDebug() << Q_FUNC_INFO;
1025
    QListIterator <PlaybackSlider*> it(m_playbackSliders);
×
1026
    while (it.hasNext() == true)
×
1027
        it.next()->setValue(0);
×
1028
}
×
1029

1030
void SimpleDesk::slotPlaybackSelected()
×
1031
{
1032
    //qDebug() << Q_FUNC_INFO;
1033
    Q_ASSERT(sender() != NULL);
×
1034
    uint pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1035
    if (m_selectedPlayback == pb)
×
1036
        return;
×
1037

1038
    slotSelectPlayback(pb);
×
1039
}
1040

1041
void SimpleDesk::slotSelectPlayback(uint pb)
×
1042
{
1043
    //qDebug() << Q_FUNC_INFO;
1044

1045
    if (m_selectedPlayback != UINT_MAX)
×
1046
        m_playbackSliders[m_selectedPlayback]->setSelected(false);
×
1047

1048
    if (pb != UINT_MAX)
×
1049
        m_playbackSliders[pb]->setSelected(true);
×
1050
    m_selectedPlayback = pb;
×
1051

1052
    CueStack* cueStack = m_engine->cueStack(pb);
×
1053
    Q_ASSERT(cueStack != NULL);
×
1054

1055
    CueStackModel* model = qobject_cast<CueStackModel*> (m_cueStackView->model());
×
1056
    Q_ASSERT(model != NULL);
×
1057
    model->setCueStack(cueStack);
×
1058

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

1061
    updateCueStackButtons();
×
1062
}
×
1063

1064
void SimpleDesk::slotPlaybackStarted()
×
1065
{
1066
    //qDebug() << Q_FUNC_INFO;
1067
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1068
    CueStack* cueStack = m_engine->cueStack(pb);
×
1069
    Q_ASSERT(cueStack != NULL);
×
1070

1071
    if (!cueStack->isRunning())
×
1072
        cueStack->nextCue();
×
1073
}
×
1074

1075
void SimpleDesk::slotPlaybackStopped()
×
1076
{
1077
    //qDebug() << Q_FUNC_INFO;
1078
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1079
    CueStack* cueStack = m_engine->cueStack(pb);
×
1080
    Q_ASSERT(cueStack != NULL);
×
1081

1082
    if (cueStack->isRunning())
×
1083
        cueStack->stop();
×
1084
}
×
1085

1086
void SimpleDesk::slotPlaybackFlashing(bool enabled)
×
1087
{
1088
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1089
    CueStack* cueStack = m_engine->cueStack(pb);
×
1090
    Q_ASSERT(cueStack != NULL);
×
1091

1092
    cueStack->setFlashing(enabled);
×
1093
}
×
1094

1095
void SimpleDesk::slotPlaybackValueChanged(uchar value)
×
1096
{
1097
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1098
    CueStack* cueStack = m_engine->cueStack(pb);
×
1099
    Q_ASSERT(cueStack != NULL);
×
1100

1101
    cueStack->adjustIntensity(qreal(value) / qreal(UCHAR_MAX));
×
1102
}
×
1103

1104
void SimpleDesk::slotGroupValueChanged(quint32 groupID, uchar value)
×
1105
{
1106
    ChannelsGroup *group = m_doc->channelsGroup(groupID);
×
1107
    if (group == NULL)
×
1108
        return;
×
1109
    quint32 start = (m_universePageSpin->value() - 1) * m_channelsPerPage;
×
1110

1111
    foreach (SceneValue scv, group->getChannels())
×
1112
    {
1113
        Fixture *fixture = m_doc->fixture(scv.fxi);
×
1114
        if (fixture == NULL)
×
1115
            continue;
×
1116
        quint32 absAddr = fixture->universeAddress() + scv.channel;
×
1117

1118
        // Update sliders on screen
1119
        if (m_viewModeButton->isChecked() == false)
×
1120
        {
1121
            if (fixture->universe() == (quint32)m_currentUniverse &&
×
1122
                absAddr >= start &&
×
1123
                absAddr < start + m_channelsPerPage)
×
1124
            {
1125
                ConsoleChannel *cc = m_universeSliders[absAddr - start];
×
1126
                if (cc != NULL)
×
1127
                {
1128
                    cc->blockSignals(true);
×
1129
                    cc->setValue(value, false);
×
1130
                    cc->blockSignals(false);
×
1131
                }
1132
            }
1133
        }
1134
        else
1135
        {
1136
            if (m_consoleList.contains(fixture->id()))
×
1137
            {
1138
                FixtureConsole *fc = m_consoleList[fixture->id()];
×
NEW
1139
                if (fc != NULL)
×
1140
                {
1141
                    fc->blockSignals(true);
×
1142
                    if (m_engine->hasChannel(absAddr) == false)
×
1143
                        fc->setChannelStylesheet(scv.channel, ssOverride);
×
1144
                    fc->setValue(scv.channel, value, false);
×
1145
                    fc->blockSignals(false);
×
1146
                }
1147
            }
1148
        }
1149

1150
        m_engine->setValue(absAddr, value);
×
1151
    }
1152
}
1153

1154
/****************************************************************************
1155
 * Cue Stack controls
1156
 ****************************************************************************/
1157

1158
void SimpleDesk::initCueStack()
×
1159
{
1160
    //qDebug() << Q_FUNC_INFO;
1161
    CueStackModel* model = new CueStackModel(this);
×
1162
    m_cueStackView->setModel(model);
×
1163

1164
    connect(m_previousCueButton, SIGNAL(clicked()), this, SLOT(slotPreviousCueClicked()));
×
1165
    connect(m_nextCueButton, SIGNAL(clicked()), this, SLOT(slotNextCueClicked()));
×
1166
    connect(m_stopCueStackButton, SIGNAL(clicked()), this, SLOT(slotStopCueStackClicked()));
×
1167
    connect(m_cloneCueStackButton, SIGNAL(clicked()), this, SLOT(slotCloneCueStackClicked()));
×
1168
    connect(m_editCueStackButton, SIGNAL(toggled(bool)), this, SLOT(slotEditCueStackClicked(bool)));
×
1169
    connect(m_recordCueButton, SIGNAL(clicked()), this, SLOT(slotRecordCueClicked()));
×
1170

1171
    connect(m_cueStackView->selectionModel(),
×
1172
            SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),
1173
            this, SLOT(slotCueStackSelectionChanged()));
1174
}
×
1175

1176
void SimpleDesk::updateCueStackButtons()
×
1177
{
1178
    //qDebug() << Q_FUNC_INFO;
1179
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1180
    if (cueStack == NULL)
×
1181
        return;
×
1182

1183
    m_stopCueStackButton->setEnabled(cueStack->isRunning());
×
1184
    m_nextCueButton->setEnabled(cueStack->cues().size() > 0);
×
1185
    m_previousCueButton->setEnabled(cueStack->cues().size() > 0);
×
1186
}
1187

1188
void SimpleDesk::replaceCurrentCue()
×
1189
{
1190
    qDebug() << Q_FUNC_INFO;
×
1191
    Q_ASSERT(m_selectedPlayback < uint(m_playbackSliders.size()));
×
1192

1193
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1194
    Q_ASSERT(cueStack != NULL);
×
1195

1196
    QItemSelectionModel* selectionModel = m_cueStackView->selectionModel();
×
1197
    if (selectionModel->hasSelection() == true)
×
1198
    {
1199
        // Replace current cue values
1200
        QModelIndex index = m_cueStackView->currentIndex();
×
1201
        QString name = cueStack->cues().at(index.row()).name();
×
1202
        Cue cue = m_engine->cue();
×
1203
        cue.setName(name);
×
1204
        cueStack->replaceCue(index.row(), cue);
×
1205
    }
1206
}
×
1207

1208
void SimpleDesk::createSpeedDials()
×
1209
{
1210
    if (m_speedDials != NULL)
×
1211
        return;
×
1212

1213
    m_speedDials = new SpeedDialWidget(this);
×
1214
    m_speedDials->setAttribute(Qt::WA_DeleteOnClose);
×
1215
    connect(m_speedDials, SIGNAL(fadeInChanged(int)),
×
1216
            this, SLOT(slotFadeInDialChanged(int)));
1217
    connect(m_speedDials, SIGNAL(fadeOutChanged(int)),
×
1218
            this, SLOT(slotFadeOutDialChanged(int)));
1219
    connect(m_speedDials, SIGNAL(holdChanged(int)),
×
1220
            this, SLOT(slotHoldDialChanged(int)));
1221
    connect(m_speedDials, SIGNAL(destroyed(QObject*)),
×
1222
            this, SLOT(slotDialDestroyed(QObject*)));
1223
    connect(m_speedDials, SIGNAL(optionalTextEdited(const QString&)),
×
1224
            this, SLOT(slotCueNameEdited(const QString&)));
1225
    m_speedDials->raise();
×
1226
    m_speedDials->show();
×
1227
}
1228

1229
void SimpleDesk::updateSpeedDials()
×
1230
{
1231
    qDebug() << Q_FUNC_INFO;
×
1232

1233
    if (m_speedDials == NULL)
×
1234
        return;
×
1235

1236
    Q_ASSERT(m_cueStackView != NULL);
×
1237
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1238
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1239

1240
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1241
    Q_ASSERT(cueStack != NULL);
×
1242

1243
    if (selected.size() == 0)
×
1244
    {
1245
        m_speedDials->setEnabled(false);
×
1246

1247
        m_speedDials->setWindowTitle(tr("No selection"));
×
1248
        m_speedDials->setFadeInSpeed(0);
×
1249
        m_speedDials->setFadeOutSpeed(0);
×
1250
        m_speedDials->setDuration(0);
×
1251

1252
        m_speedDials->setOptionalTextTitle(QString());
×
1253
        m_speedDials->setOptionalText(QString());
×
1254
    }
1255
    else if (selected.size() == 1)
×
1256
    {
1257
        m_speedDials->setEnabled(true);
×
1258

1259
        QModelIndex index = selected.first();
×
1260
        Q_ASSERT(index.row() >= 0 && index.row() < cueStack->cues().size());
×
1261
        Cue cue = cueStack->cues()[index.row()];
×
1262
        m_speedDials->setWindowTitle(cue.name());
×
1263
        m_speedDials->setFadeInSpeed(cue.fadeInSpeed());
×
1264
        m_speedDials->setFadeOutSpeed(cue.fadeOutSpeed());
×
1265
        if ((int)cue.duration() < 0)
×
1266
            m_speedDials->setDuration(cue.duration());
×
1267
        else
1268
            m_speedDials->setDuration(cue.duration() - cue.fadeInSpeed() - cue.fadeOutSpeed());
×
1269

1270
        m_speedDials->setOptionalTextTitle(tr("Cue name"));
×
1271
        m_speedDials->setOptionalText(cue.name());
×
1272
    }
1273
    else
1274
    {
1275
        m_speedDials->setEnabled(true);
×
1276

1277
        m_speedDials->setWindowTitle(tr("Multiple Cues"));
×
1278
        m_speedDials->setFadeInSpeed(0);
×
1279
        m_speedDials->setFadeOutSpeed(0);
×
1280
        m_speedDials->setDuration(0);
×
1281

1282
        m_speedDials->setOptionalTextTitle(QString());
×
1283
        m_speedDials->setOptionalText(QString());
×
1284
    }
1285
}
1286

1287
CueStack* SimpleDesk::currentCueStack() const
×
1288
{
1289
    Q_ASSERT(m_engine != NULL);
×
1290
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1291
    Q_ASSERT(cueStack != NULL);
×
1292
    return cueStack;
×
1293
}
1294

1295
int SimpleDesk::currentCueIndex() const
×
1296
{
1297
    Q_ASSERT(m_cueStackView != NULL);
×
1298
    return m_cueStackView->currentIndex().row();
×
1299
}
1300

1301
void SimpleDesk::slotCueStackStarted(uint stack)
×
1302
{
1303
    qDebug() << Q_FUNC_INFO;
×
1304
    if (stack != m_selectedPlayback)
×
1305
        return;
×
1306

1307
    PlaybackSlider* slider = m_playbackSliders[m_selectedPlayback];
×
1308
    Q_ASSERT(slider != NULL);
×
1309
    if (slider->value() == 0)
×
1310
        slider->setValue(UCHAR_MAX);
×
1311
    updateCueStackButtons();
×
1312
}
1313

1314
void SimpleDesk::slotCueStackStopped(uint stack)
×
1315
{
1316
    qDebug() << Q_FUNC_INFO;
×
1317
    if (stack != m_selectedPlayback)
×
1318
        return;
×
1319

1320
    PlaybackSlider* slider = m_playbackSliders[m_selectedPlayback];
×
1321
    Q_ASSERT(slider != NULL);
×
1322
    if (slider->value() != 0)
×
1323
        slider->setValue(0);
×
1324
    updateCueStackButtons();
×
1325
}
1326

1327
void SimpleDesk::slotCueStackSelectionChanged()
×
1328
{
1329
    qDebug() << Q_FUNC_INFO;
×
1330

1331
    Q_ASSERT(m_cueStackView != NULL);
×
1332
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1333
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1334

1335
    updateCueStackButtons();
×
1336

1337
    // Destroy the existing delete icon
1338
    if (m_cueDeleteIconIndex.isValid() == true)
×
1339
        m_cueStackView->setIndexWidget(m_cueDeleteIconIndex, NULL);
×
1340
    m_cueDeleteIconIndex = QModelIndex();
×
1341

1342
    if (m_editCueStackButton->isChecked() == true)
×
1343
    {
1344
        CueStack* cueStack = currentCueStack();
×
1345
        if (selected.size() == 0)
×
1346
        {
1347
            resetUniverseSliders();
×
1348
            m_universeGroup->setEnabled(false);
×
1349
        }
1350
        else if (selected.size() == 1)
×
1351
        {
1352
            m_universeGroup->setEnabled(true);
×
1353
            QModelIndex index = selected.first();
×
1354
            if (index.row() >= 0 && index.row() < cueStack->cues().size())
×
1355
            {
1356
                Cue cue = cueStack->cues()[index.row()];
×
1357
                m_engine->setCue(cue);
×
1358
                slotUniversePageChanged(m_universePageSpin->value());
×
1359
            }
1360
        }
1361
        else
1362
        {
1363
            m_universeGroup->setEnabled(false);
×
1364
            resetUniverseSliders();
×
1365
        }
1366

1367
        // Put a delete button on the first selected item
1368
        if (selected.size() > 0)
×
1369
        {
1370
            QModelIndex index = selected.first();
×
1371
            if (index.row() >= 0 && index.row() < cueStack->cues().size())
×
1372
            {
1373
                QPushButton* btn = new QPushButton(m_cueStackView);
×
1374
                btn->setToolTip(tr("Delete cue"));
×
1375
                btn->setFlat(true);
×
1376
                btn->setFixedSize(m_cueStackView->sizeHintForIndex(index));
×
1377
                btn->setIcon(QIcon(":/delete.png"));
×
1378
                m_cueStackView->setIndexWidget(index, btn);
×
1379
                m_cueDeleteIconIndex = index;
×
1380
                connect(btn, SIGNAL(clicked()), this, SLOT(slotDeleteCueClicked()));
×
1381
            }
1382
        }
1383
    }
1384
    else
1385
    {
1386
        m_universeGroup->setEnabled(true);
×
1387
    }
1388

1389
    updateSpeedDials();
×
1390
}
×
1391

1392
void SimpleDesk::slotPreviousCueClicked()
×
1393
{
1394
    qDebug() << Q_FUNC_INFO;
×
1395
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1396
    Q_ASSERT(cueStack != NULL);
×
1397
    cueStack->previousCue();
×
1398
}
×
1399

1400
void SimpleDesk::slotNextCueClicked()
×
1401
{
1402
    qDebug() << Q_FUNC_INFO;
×
1403
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1404
    Q_ASSERT(cueStack != NULL);
×
1405
    cueStack->nextCue();
×
1406
}
×
1407

1408
void SimpleDesk::slotStopCueStackClicked()
×
1409
{
1410
    qDebug() << Q_FUNC_INFO;
×
1411
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1412
    Q_ASSERT(cueStack != NULL);
×
1413
    cueStack->stop();
×
1414
}
×
1415

1416
void SimpleDesk::slotCloneCueStackClicked()
×
1417
{
1418
    qDebug() << Q_FUNC_INFO;
×
1419

1420
    QStringList items;
×
1421
    for (uint i = 0; i < m_playbacksPerPage; i++)
×
1422
    {
1423
        if (i != m_selectedPlayback)
×
1424
            items << QString::number(i + 1);
×
1425
    }
1426

1427
    bool ok = false;
×
1428
    QString text = QInputDialog::getItem(this, tr("Clone Cue Stack"), tr("Clone To Playback#"),
×
1429
                                         items, 0, false, &ok);
×
1430
    if (ok == false)
×
1431
        return;
×
1432

1433
    uint pb = text.toUInt() - 1;
×
1434
    CueStack* cs = m_engine->cueStack(m_selectedPlayback);
×
1435
    CueStack* clone = m_engine->cueStack(pb);
×
1436
    Q_ASSERT(cs != NULL);
×
1437
    Q_ASSERT(clone != NULL);
×
1438

1439
    while (clone->cues().size() > 0)
×
1440
        clone->removeCue(0);
×
1441

1442
    QListIterator <Cue> it(cs->cues());
×
1443
    while (it.hasNext() == true)
×
1444
        clone->appendCue(it.next());
×
1445

1446
    slotSelectPlayback(pb);
×
1447
}
1448

1449
void SimpleDesk::slotDialDestroyed(QObject *)
×
1450
{
1451
    if (m_speedDials != NULL)
×
1452
        m_speedDials->deleteLater();
×
1453
    m_speedDials = NULL;
×
1454
    m_editCueStackButton->setChecked(false);
×
1455
}
×
1456

1457
void SimpleDesk::slotEditCueStackClicked(bool state)
×
1458
{
1459
    qDebug() << Q_FUNC_INFO;
×
1460

1461
    slotCueStackSelectionChanged();
×
1462

1463
    if (state == true)
×
1464
    {
1465
        createSpeedDials();
×
1466
        updateSpeedDials();
×
1467
    }
1468
    else
1469
    {
1470
        resetUniverseSliders();
×
1471
        if (m_speedDials != NULL)
×
1472
            m_speedDials->deleteLater();
×
1473
        m_speedDials = NULL;
×
1474
    }
1475
}
×
1476

1477
void SimpleDesk::slotRecordCueClicked()
×
1478
{
1479
    qDebug() << Q_FUNC_INFO;
×
1480
    Q_ASSERT(m_selectedPlayback < uint(m_playbackSliders.size()));
×
1481

1482
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1483
    Q_ASSERT(cueStack != NULL);
×
1484

1485
    QItemSelectionModel* selModel = m_cueStackView->selectionModel();
×
1486
    Q_ASSERT(selModel != NULL);
×
1487
    int index = 0;
×
1488
    if (selModel->hasSelection() == true)
×
1489
        index = selModel->currentIndex().row() + 1;
×
1490
    else
1491
        index = cueStack->cues().size();
×
1492

1493
    Cue cue = m_engine->cue();
×
1494
    cue.setName(tr("Cue %1").arg(cueStack->cues().size() + 1));
×
1495
    cueStack->insertCue(index, cue);
×
1496

1497
    // Select the newly-created Cue, all columns from 0 to last
1498
    const QAbstractItemModel* itemModel = selModel->model();
×
1499
    Q_ASSERT(itemModel != NULL);
×
1500
    int firstCol = 0;
×
1501
    int lastCol = itemModel->columnCount() - 1;
×
1502
    QItemSelection sel(itemModel->index(index, firstCol), itemModel->index(index, lastCol));
×
1503
    selModel->select(sel, QItemSelectionModel::ClearAndSelect);
×
1504
    selModel->setCurrentIndex(itemModel->index(index, firstCol), QItemSelectionModel::Current);
×
1505

1506
    updateCueStackButtons();
×
1507
}
×
1508

1509
void SimpleDesk::slotDeleteCueClicked()
×
1510
{
1511
    Q_ASSERT(m_cueStackView != NULL);
×
1512
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1513
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1514
    QModelIndex current = m_cueStackView->selectionModel()->currentIndex();
×
1515
    CueStack* cueStack = currentCueStack();
×
1516
    Q_ASSERT(cueStack != NULL);
×
1517
    QList <int> indexes;
×
1518
    foreach (QModelIndex index, selected)
×
1519
        indexes << index.row();
×
1520
    cueStack->removeCues(indexes);
×
1521

1522
    // Select an item ~at the current index
1523
    QAbstractItemModel* model = m_cueStackView->model();
×
1524
    if (model->hasIndex(current.row(), 0) == true)
×
1525
    {
1526
        m_cueStackView->setCurrentIndex(current);
×
1527
    }
1528
    else if (model->rowCount() != 0)
×
1529
    {
1530
        QModelIndex index = model->index(model->rowCount() - 1, 0);
×
1531
        m_cueStackView->setCurrentIndex(index);
×
1532
    }
1533
}
×
1534

1535
void SimpleDesk::slotFadeInDialChanged(int ms)
×
1536
{
1537
    Q_ASSERT(m_cueStackView != NULL);
×
1538
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1539
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1540
    CueStack* cueStack = currentCueStack();
×
1541
    foreach (QModelIndex index, selected)
×
1542
        cueStack->setFadeInSpeed(ms, index.row());
×
1543
}
×
1544

1545
void SimpleDesk::slotFadeOutDialChanged(int ms)
×
1546
{
1547
    Q_ASSERT(m_cueStackView != NULL);
×
1548
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1549
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1550
    CueStack* cueStack = currentCueStack();
×
1551
    foreach (QModelIndex index, selected)
×
1552
        cueStack->setFadeOutSpeed(ms, index.row());
×
1553
}
×
1554

1555
void SimpleDesk::slotHoldDialChanged(int ms)
×
1556
{
1557
    Q_ASSERT(m_cueStackView != NULL);
×
1558
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1559
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1560
    CueStack* cueStack = currentCueStack();
×
1561
    foreach (QModelIndex index, selected)
×
1562
    {
1563
        if (ms < 0)
×
1564
            cueStack->setDuration(ms, index.row());
×
1565
        else
1566
            cueStack->setDuration(cueStack->fadeInSpeed() + ms + cueStack->fadeOutSpeed(), index.row());
×
1567
    }
1568
}
×
1569

1570
void SimpleDesk::slotCueNameEdited(const QString& name)
×
1571
{
1572
    Q_ASSERT(m_cueStackView != NULL);
×
1573
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
×
1574
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1575
    CueStack* cueStack = currentCueStack();
×
1576
    if (selected.size() == 1)
×
1577
        cueStack->setName(name, selected.first().row());
×
1578
}
×
1579

1580
void SimpleDesk::showEvent(QShowEvent* ev)
×
1581
{
1582
    if (m_docChanged == true)
×
1583
    {
1584
        if (m_editCueStackButton->isChecked() == true)
×
1585
            slotEditCueStackClicked(true);
×
1586
        initUniversesCombo();
×
1587
        initChannelGroupsView();
×
1588
        m_docChanged = false;
×
1589
    }
1590
    slotUpdateUniverseSliders();
×
1591
    QWidget::showEvent(ev);
×
1592
}
×
1593

1594
void SimpleDesk::hideEvent(QHideEvent* ev)
×
1595
{
1596
    if (m_speedDials != NULL)
×
1597
        m_speedDials->deleteLater();
×
1598
    m_speedDials = NULL;
×
1599
    QWidget::hideEvent(ev);
×
1600
}
×
1601

1602
void SimpleDesk::resizeEvent(QResizeEvent *ev)
×
1603
{
1604
    QWidget::resizeEvent(ev);
×
1605

1606
    QSettings settings;
×
1607
    QVariant var = settings.value(SETTINGS_PAGE_CHANNELS);
×
1608
    QSize newSize = ev->size();
×
1609
    //qDebug() << "Resize event. Frame size:" << newSize;
1610

1611
    // this block makes sense only in a fixed layout
1612
    if (m_viewModeButton->isChecked() == false)
×
1613
    {
1614
        // if channels per page are not forced by the user,
1615
        // perform an autodetection
1616
        if (var.isValid() == false || var.toUInt() == 0)
×
1617
        {
1618
            uint currChannels = m_channelsPerPage;
×
1619
            // 42 is the answer to life, the universe and everything...
1620
            // but also the width of a console channel slider :)
1621
            m_channelsPerPage = (newSize.width() - m_grandMasterSlider->width()) / 42;
×
1622
            //qDebug() << "Old channels per page:" << currChannels << ", new value:" << m_channelsPerPage;
1623
            if (m_channelsPerPage != currChannels)
×
1624
            {
1625
                int slidersDiff = (int)currChannels - (int)m_channelsPerPage;
×
1626
                if (slidersDiff < 0)
×
1627
                {
1628
                    for (int a = 0; a < -slidersDiff; a++)
×
1629
                        m_universeSliders.append(NULL);
×
1630
                }
1631
                else if (slidersDiff > 0)
×
1632
                {
1633
                    for (int r = 0; r < slidersDiff; r++)
×
1634
                    {
1635
                        ConsoleChannel* slider = m_universeSliders.takeLast();
×
1636
                        if (slider != NULL)
×
1637
                        {
1638
                            m_universeGroup->layout()->removeWidget(slider);
×
1639
                            disconnect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
1640
                                   this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
1641
                            disconnect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
1642
                                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
1643
                            delete slider;
×
1644
                        }
1645
                    }
1646
                }
1647
                m_universePageSpin->setRange(1, int((512 + m_channelsPerPage - 1) / m_channelsPerPage));
×
1648
                if (this->isVisible() == true)
×
1649
                    slotUniversePageChanged(m_universePageSpin->value());
×
1650
            }
1651
        }
1652
    }
1653

1654
    // check if the value has been forced by the user
1655
    var = settings.value(SETTINGS_PAGE_PLAYBACKS);
×
1656
    if (var.isValid() == true && var.toUInt() > 0)
×
1657
        return;
×
1658

1659
    uint currPlayback = m_playbacksPerPage;
×
1660
    // always have playback sliders to fill half of the window
1661
    m_playbacksPerPage = (newSize.width() / 2) / 42;
×
1662

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

1665
    if (currPlayback != m_playbacksPerPage)
×
1666
    {
1667
        int pbDiff = (int)currPlayback - (int)m_playbacksPerPage;
×
1668
        if (pbDiff < 0)
×
1669
        {
1670
            for (int a = 0; a < -pbDiff; a++)
×
1671
            {
1672
                PlaybackSlider* slider = new PlaybackSlider(m_playbackGroup);
×
1673
                m_playbackGroup->layout()->addWidget(slider);
×
1674
                slider->setLabel(QString::number(m_playbackSliders.count() + 1));
×
1675
                slider->setProperty(PROP_PLAYBACK, uint(m_playbackSliders.count()));
×
1676
                m_playbackSliders << slider;
×
1677
                connect(slider, SIGNAL(selected()), this, SLOT(slotPlaybackSelected()));
×
1678
                connect(slider, SIGNAL(started()), this, SLOT(slotPlaybackStarted()));
×
1679
                connect(slider, SIGNAL(stopped()), this, SLOT(slotPlaybackStopped()));
×
1680
                connect(slider, SIGNAL(flashing(bool)), this, SLOT(slotPlaybackFlashing(bool)));
×
1681
                connect(slider, SIGNAL(valueChanged(uchar)), this, SLOT(slotPlaybackValueChanged(uchar)));
×
1682
            }
1683
        }
1684
        else if (pbDiff > 0)
×
1685
        {
1686
            for (int r = 0; r < pbDiff; r++)
×
1687
            {
1688
                PlaybackSlider* slider = m_playbackSliders.takeLast();
×
1689
                if (slider == NULL)
×
1690
                    continue;
×
1691
                disconnect(slider, SIGNAL(selected()), this, SLOT(slotPlaybackSelected()));
×
1692
                disconnect(slider, SIGNAL(started()), this, SLOT(slotPlaybackStarted()));
×
1693
                disconnect(slider, SIGNAL(stopped()), this, SLOT(slotPlaybackStopped()));
×
1694
                disconnect(slider, SIGNAL(flashing(bool)), this, SLOT(slotPlaybackFlashing(bool)));
×
1695
                disconnect(slider, SIGNAL(valueChanged(uchar)), this, SLOT(slotPlaybackValueChanged(uchar)));
×
1696
                m_playbackGroup->layout()->removeWidget(slider);
×
1697
                delete slider;
×
1698
            }
1699
        }
1700
    }
1701

1702
}
1703

1704
/****************************************************************************
1705
 * Load & Save
1706
 ****************************************************************************/
1707

1708
bool SimpleDesk::loadXML(QXmlStreamReader &root)
×
1709
{
1710
    Q_ASSERT(m_engine != NULL);
×
1711

1712
    clearContents();
×
1713

1714
    if (root.name() != KXMLQLCSimpleDesk)
×
1715
    {
1716
        qWarning() << Q_FUNC_INFO << "Simple Desk node not found";
×
1717
        return false;
×
1718
    }
1719

1720
    while (root.readNextStartElement())
×
1721
    {
1722
        if (root.name() == KXMLQLCSimpleDeskEngine)
×
1723
        {
1724
            m_engine->loadXML(root);
×
1725
        }
1726
        else
1727
        {
1728
            qWarning() << Q_FUNC_INFO << "Unrecognized Simple Desk node:" << root.name();
×
1729
            root.skipCurrentElement();
×
1730
        }
1731
    }
1732

1733
    slotSelectPlayback(0);
×
1734

1735
    return true;
×
1736
}
1737

1738
bool SimpleDesk::saveXML(QXmlStreamWriter *doc) const
×
1739
{
1740
    Q_ASSERT(doc != NULL);
×
1741
    Q_ASSERT(m_engine != NULL);
×
1742

1743
    doc->writeStartElement(KXMLQLCSimpleDesk);
×
1744

1745
    if (m_engine->saveXML(doc) == false)
×
1746
        return false;
×
1747

1748
    doc->writeEndElement();
×
1749

1750
    return true;
×
1751
}
1752

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