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

mcallegari / qlcplus / 12535554772

29 Dec 2024 12:51PM UTC coverage: 31.956% (-0.007%) from 31.963%
12535554772

push

github

mcallegari
ui/simpledesk: improve the previous commit

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

1 existing line in 1 file now uncovered.

14045 of 43951 relevant lines covered (31.96%)

27314.35 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

NEW
414
    quint32 start = (m_universePageSpin->value() - 1) * m_channelsPerPage;
×
415

NEW
416
    if (m_viewModeButton->isChecked() == false &&
×
NEW
417
        address >= start && address < start + m_channelsPerPage)
×
418
    {
NEW
419
        Fixture *fxi = m_doc->fixture(m_doc->fixtureForAddress(address));
×
NEW
420
        ConsoleChannel *cc = m_universeSliders[address - start];
×
NEW
421
        if (fxi == NULL)
×
422
        {
NEW
423
            cc->setChannelStyleSheet(ssNone);
×
424
        }
425
        else
426
        {
NEW
427
            if (fxi->id() % 2)
×
NEW
428
                cc->setChannelStyleSheet(ssEven);
×
429
            else
NEW
430
                cc->setChannelStyleSheet(ssOdd);
×
431
        }
432
    }
UNCOV
433
}
×
434

435
void SimpleDesk::resetUniverse()
×
436
{
437
    // force a engine reset
438
    m_engine->resetUniverse(m_currentUniverse);
×
439
    // simulate a user click on the reset button
440
    // to avoid messing up with multithread calls
441
    m_universeResetButton->click();
×
442
}
×
443

444
void SimpleDesk::resetUniverse(int index)
×
445
{
446
    m_universesCombo->setCurrentIndex(index);
×
447
    resetUniverse();
×
448
}
×
449

450
/****************************************************************************
451
 * Universe controls
452
 ****************************************************************************/
453

454
void SimpleDesk::initUniversesCombo()
×
455
{
456
    disconnect(m_universesCombo, SIGNAL(currentIndexChanged(int)),
×
457
            this, SLOT(slotUniversesComboChanged(int)));
458
    int currIdx = m_universesCombo->currentIndex();
×
459
    m_universesCombo->clear();
×
460
    m_universesCombo->addItems(m_doc->inputOutputMap()->universeNames());
×
461
    if (currIdx != -1)
×
462
        m_universesCombo->setCurrentIndex(currIdx);
×
463
    while (m_universesPage.length() < m_universesCombo->count())
×
464
        m_universesPage.append(1);
×
465
    connect(m_universesCombo, SIGNAL(currentIndexChanged(int)),
×
466
            this, SLOT(slotUniversesComboChanged(int)));
467
}
×
468

469
void SimpleDesk::initUniverseSliders()
×
470
{
471
    //qDebug() << Q_FUNC_INFO;
472
    quint32 start = m_universesPage.at(m_currentUniverse) * m_channelsPerPage;
×
473
    for (quint32 i = 0; i < m_channelsPerPage; i++)
×
474
    {
475
        ConsoleChannel* slider = NULL;
×
476
        Fixture* fxi = m_doc->fixture(m_doc->fixtureForAddress(start + i));
×
477
        if (fxi == NULL)
×
478
            slider = new ConsoleChannel(this, m_doc, Fixture::invalidId(), i, false);
×
479
        else
480
        {
481
            uint ch = (start + i) - fxi->universeAddress();
×
482
            slider = new ConsoleChannel(this, m_doc, fxi->id(), ch, false);
×
483
            slider->setValue(uchar(fxi->channelValueAt(ch)));
×
484
        }
485
        slider->showResetButton(true);
×
486
        m_universeGroup->layout()->addWidget(slider);
×
487
        m_universeSliders << slider;
×
488
        connect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
489
                this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
490
        connect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
491
                this, SLOT(slotChannelResetClicked(quint32,quint32)));
492
    }
493
}
×
494

495
void SimpleDesk::initUniversePager()
×
496
{
497
    //qDebug() << Q_FUNC_INFO;
498
    m_universePageSpin->setRange(1, int((512 + m_channelsPerPage - 1) / m_channelsPerPage));
×
499
    m_universePageSpin->setValue(1);
×
500
    slotUniversePageChanged(1);
×
501

502
    connect(m_viewModeButton, SIGNAL(clicked(bool)), this, SLOT(slotViewModeClicked(bool)));
×
503
    connect(m_universePageUpButton, SIGNAL(clicked()), this, SLOT(slotUniversePageUpClicked()));
×
504
    connect(m_universePageDownButton, SIGNAL(clicked()), this, SLOT(slotUniversePageDownClicked()));
×
505
    connect(m_universePageSpin, SIGNAL(valueChanged(int)), this, SLOT(slotUniversePageChanged(int)));
×
506
    connect(m_universeResetButton, SIGNAL(clicked()), this, SLOT(slotUniverseResetClicked()));
×
507
}
×
508

509
void SimpleDesk::resetUniverseSliders()
×
510
{
511
    //qDebug() << Q_FUNC_INFO;
512
    foreach (ConsoleChannel *channel, m_universeSliders)
×
513
    {
514
        if (channel != NULL)
×
515
            channel->setValue(0);
×
516
    }
517
}
×
518

519
void SimpleDesk::initSliderView(bool fullMode)
×
520
{
521
    m_consoleList.clear();
×
522

523
    if (fullMode == true)
×
524
    {
525
        scrollArea = new QScrollArea();
×
526
        scrollArea->setWidgetResizable(true);
×
527

528
        QFrame* grpBox = new QFrame(scrollArea);
×
529
        grpBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
×
530
        QHBoxLayout* fixturesLayout = new QHBoxLayout(grpBox);
×
531
        grpBox->setLayout(fixturesLayout);
×
532
        fixturesLayout->setSpacing(2);
×
533
        fixturesLayout->setContentsMargins(2, 2, 2, 2);
×
534

535
        int c = 0;
536
        foreach (Fixture *fixture, m_doc->fixtures())
×
537
        {
538
            if (fixture->universe() != (quint32)m_universesCombo->currentIndex())
×
539
                continue;
×
540
            FixtureConsole* console = NULL;
541
            if (c%2 == 0)
×
542
                console = new FixtureConsole(scrollArea, m_doc, FixtureConsole::GroupOdd, false);
×
543
            else
544
                console = new FixtureConsole(scrollArea, m_doc, FixtureConsole::GroupEven, false);
×
545
            console->setFixture(fixture->id());
×
546
            console->enableResetButton(true);
×
547
            quint32 absoluteAddr = fixture->universeAddress();
×
548
            QByteArray fxValues = fixture->channelValues();
×
549
            for (quint32 i = 0; i < fixture->channels(); i++)
×
550
            {
551
                if (m_engine->hasChannel(absoluteAddr + i))
×
552
                {
553
                    SceneValue scv(fixture->id(), i, m_engine->value(absoluteAddr + i));
×
554
                    console->setSceneValue(scv);
×
555
                    console->setChannelStylesheet(i, ssOverride);
×
556
                }
557
                else
558
                {
559
                    SceneValue scv(fixture->id(), i, (uchar)fxValues.at(i));
×
560
                    console->setSceneValue(scv);
×
561
                }
562
            }
563
            fixturesLayout->addWidget(console);
×
564
            connect(console, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
565
                    this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
566
            connect(console, SIGNAL(resetRequest(quint32,quint32)),
×
567
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
568
            c++;
×
569
            m_consoleList[fixture->id()] = console;
×
570
        }
571
        fixturesLayout->addStretch(1);
×
572
        scrollArea->setWidget(grpBox);
×
573

574
        m_universeGroup->layout()->addWidget(scrollArea);
×
575
    }
576
    else
577
    {
578
        int page = m_universesPage.at(m_universesCombo->currentIndex());
×
579
        slotUniversePageChanged(page);
×
580
    }
581
}
×
582

583
void SimpleDesk::initChannelGroupsView()
×
584
{
585
    if (m_chGroupsArea != NULL)
×
586
    {
587
        delete m_chGroupsArea;
×
588
        m_chGroupsArea = NULL;
×
589
    }
590

591
    if (m_doc->channelsGroups().count() > 0)
×
592
    {
593
        m_chGroupsArea = new QScrollArea();
×
594
        QList<quint32> chGrpIDs;
×
595
        foreach (ChannelsGroup *grp, m_doc->channelsGroups())
×
596
            chGrpIDs.append(grp->id());
×
597
        GroupsConsole* console = new GroupsConsole(m_chGroupsArea, m_doc, chGrpIDs, QList<uchar>());
×
598
        m_chGroupsArea->setWidget(console);
×
599
        m_chGroupsArea->setWidgetResizable(true);
×
600
        m_tabs->addTab(m_chGroupsArea, tr("Channel groups"));
×
601
        connect(console, SIGNAL(groupValueChanged(quint32,uchar)),
×
602
                this, SLOT(slotGroupValueChanged(quint32,uchar)));
603
    }
604
}
×
605

606
void SimpleDesk::slotUniversesComboChanged(int index)
×
607
{
608
    m_currentUniverse = index;
×
609
    if (m_viewModeButton->isChecked() == true)
×
610
    {
611
        m_universeGroup->layout()->removeWidget(scrollArea);
×
612
        delete scrollArea;
×
613
        initSliderView(true);
×
614
    }
615
    else
616
    {
617
        int page = m_universesPage.at(index);
×
618
        slotUniversePageChanged(m_universesPage.at(index));
×
619
        m_universePageSpin->setValue(page);
×
620
    }
621
}
×
622

623
void SimpleDesk::slotViewModeClicked(bool toggle)
×
624
{
625
    if (toggle == true)
×
626
    {
627
        QList<quint32> fxRemoveList;
×
628

629
        for (quint32 i = 0; i < m_channelsPerPage; i++)
×
630
        {
631
            ConsoleChannel* slider = m_universeSliders[i];
×
632
            if (slider != NULL)
×
633
            {
634
                m_universeGroup->layout()->removeWidget(slider);
×
635
                disconnect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
636
                       this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
637
                disconnect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
638
                        this, SLOT(slotChannelResetClicked(quint32,quint32)));
639
                if (fxRemoveList.contains(slider->fixture()) == false)
×
640
                {
641
                    Fixture *currFx = m_doc->fixture(slider->fixture());
×
642
                    if (currFx != NULL)
×
643
                    {
644
                        disconnect(currFx, SIGNAL(aliasChanged()), this, SLOT(slotAliasChanged()));
×
645
                        fxRemoveList.append(slider->fixture());
×
646
                    }
647
                }
648
                delete slider;
×
649
                m_universeSliders[i] = NULL;
×
650
            }
651
        }
652
        initSliderView(true);
×
653
    }
654
    else
655
    {
656
        m_universeGroup->layout()->removeWidget(scrollArea);
×
657
        delete scrollArea;
×
658
        initSliderView(false);
×
659
    }
660
    m_universePageUpButton->setEnabled(!toggle);
×
661
    m_universePageDownButton->setEnabled(!toggle);
×
662
    m_universePageSpin->setEnabled(!toggle);
×
663
}
×
664

665
void SimpleDesk::slotUniversePageUpClicked()
×
666
{
667
    qDebug() << Q_FUNC_INFO;
668
    m_universePageSpin->setValue(m_universePageSpin->value() + 1);
×
669
}
×
670

671
void SimpleDesk::slotUniversePageDownClicked()
×
672
{
673
    qDebug() << Q_FUNC_INFO;
674
    m_universePageSpin->setValue(m_universePageSpin->value() - 1);
×
675
}
×
676

677
void SimpleDesk::slotUniversePageChanged(int page)
×
678
{
679
    qDebug() << Q_FUNC_INFO;
680
    QList<quint32> fxAddList, fxRemoveList;
×
681
    quint32 start = (page - 1) * m_channelsPerPage;
×
682

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

686
    /* Set the new page for this universe */
687
    m_universesPage.replace(m_currentUniverse, page);
×
688

689
    //qDebug() << "[slotUniversePageChanged] start: " << start << ", absoluteAddr: " << absoluteAddr;
690

691
    for (quint32 i = 0; i < m_channelsPerPage; i++)
×
692
    {
693
        ConsoleChannel *slider = m_universeSliders[i];
×
694
        if (slider != NULL)
×
695
        {
696
            m_universeGroup->layout()->removeWidget(slider);
×
697
            disconnect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
698
                   this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
699
            disconnect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
700
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
701

702
            if (fxRemoveList.contains(slider->fixture()) == false)
×
703
            {
704
                Fixture *currFx = m_doc->fixture(slider->fixture());
×
705
                if (currFx != NULL)
×
706
                {
707
                    disconnect(currFx, SIGNAL(aliasChanged()), this, SLOT(slotAliasChanged()));
×
708
                    fxRemoveList.append(slider->fixture());
×
709
                }
710
            }
711
            delete slider;
×
712
            m_universeSliders[i] = NULL;
×
713
        }
714
        Fixture *fx = m_doc->fixture(m_doc->fixtureForAddress(absoluteAddr + i));
×
715
        if (fx == NULL)
×
716
        {
717
            slider = new ConsoleChannel(this, m_doc, Fixture::invalidId(), start + i, false);
×
718
            slider->setVisible(false);
×
719
            if (m_engine->hasChannel((m_currentUniverse << 9) + (start + i)))
×
720
                slider->setChannelStyleSheet(ssOverride);
×
721
            else
722
                slider->setChannelStyleSheet(ssNone);
×
723
        }
724
        else
725
        {
726
            uint ch = (absoluteAddr + i) - fx->universeAddress();
×
727
            slider = new ConsoleChannel(this, m_doc, fx->id(), ch, false);
×
728
            slider->setVisible(false);
×
729
            if (m_engine->hasChannel(absoluteAddr + i))
×
730
            {
731
                slider->setChannelStyleSheet(ssOverride);
×
732
            }
733
            else
734
            {
735
                if (fx->id() % 2 == 0)
×
736
                    slider->setChannelStyleSheet(ssOdd);
×
737
                else
738
                    slider->setChannelStyleSheet(ssEven);
×
739
                slider->setValue(uchar(fx->channelValueAt(ch)));
×
740
            }
741
            if (fxAddList.contains(fx->id()) == false)
×
742
            {
743
                connect(fx, SIGNAL(aliasChanged()), this, SLOT(slotAliasChanged()));
×
744
                fxAddList.append(fx->id());
×
745
            }
746
        }
747
        slider->showResetButton(true);
×
748
        slider->setVisible(true);
×
749

750
        if ((start + i) < 512)
×
751
        {
752
            slider->setEnabled(true);
×
753
            slider->setProperty(PROP_ADDRESS, absoluteAddr + i);
×
754
            slider->setLabel(QString::number(start + i + 1));
×
755
            //qDebug() << "Set slider value[" << (absoluteAddr + i) << "] = " << m_engine->value(absoluteAddr + i);
756
            if (m_engine->hasChannel(absoluteAddr + i))
×
757
                slider->setValue(m_engine->value(absoluteAddr + i), false);
×
758
            connect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
759
                    this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
760
            connect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
761
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
762
        }
763
        else
764
        {
765
            slider->setEnabled(false);
×
766
            slider->setProperty(PROP_ADDRESS, QVariant());
×
767
            slider->setValue(0);
×
768
            slider->setLabel("---");
×
769
            slider->setPalette(this->palette());
×
770
        }
771

772
        m_universeGroup->layout()->addWidget(slider);
×
773
        m_universeSliders[i] = slider;
×
774
    }
775
}
×
776

777
void SimpleDesk::slotUniverseResetClicked()
×
778
{
779
    qDebug() << Q_FUNC_INFO;
780
    m_engine->resetUniverse(m_currentUniverse);
×
781
    m_universePageSpin->setValue(1);
×
782
    if (m_viewModeButton->isChecked() == false)
×
783
        slotUniversePageChanged(1);
×
784
    else
785
    {
786
        QHashIterator <quint32,FixtureConsole*> it(m_consoleList);
×
787

788
        while (it.hasNext() == true)
×
789
        {
790
            it.next();
791
            FixtureConsole *fc = it.value();
×
792
            Q_ASSERT(fc != NULL);
793
            fc->resetChannelsStylesheet();
×
794
        }
795
    }
796
}
×
797

798
void SimpleDesk::slotChannelResetClicked(quint32 fxID, quint32 channel)
×
799
{
800
    if (fxID != Fixture::invalidId())
×
801
    {
802
        Fixture *fixture = m_doc->fixture(fxID);
×
803
        if (fixture == NULL)
×
804
            return;
805

806
        quint32 absAddr = fixture->universeAddress() + channel;
×
807
        m_engine->resetChannel(absAddr);
×
808

809
        if (m_viewModeButton->isChecked() == true)
×
810
        {
811
            Fixture *fixture = m_doc->fixture(fxID);
×
812
            if (fixture == NULL)
×
813
                return;
814

815
            if (m_consoleList.contains(fxID))
×
816
            {
817
                FixtureConsole *fc = m_consoleList[fxID];
×
818
                if (fc != NULL)
×
819
                {
820
                    if (fixture->id() % 2 == 0)
×
821
                        fc->setChannelStylesheet(channel, ssOdd);
×
822
                    else
823
                        fc->setChannelStylesheet(channel, ssEven);
×
824
                }
825
            }
826
        }
827
        else
828
        {
829
            ConsoleChannel *slider = qobject_cast<ConsoleChannel *>(sender());
×
830
            if (fixture->id() % 2 == 0)
×
831
                slider->setChannelStyleSheet(ssOdd);
×
832
            else
833
                slider->setChannelStyleSheet(ssEven);
×
834
        }
835
    }
836
    else
837
    {
838
        ConsoleChannel *slider = qobject_cast<ConsoleChannel *>(sender());
×
839
        m_engine->resetChannel(channel);
×
840
        slider->setChannelStyleSheet(ssNone);
×
841
    }
842
}
843

844
void SimpleDesk::slotAliasChanged()
×
845
{
846
    Fixture *fxi = qobject_cast<Fixture *>(sender());
×
847
    int i = 0;
848

849
    foreach (ConsoleChannel *cc, m_universeSliders)
×
850
    {
851
        quint32 chIndex = cc->channelIndex();
×
852

853
        if (cc->fixture() == fxi->id() && cc->channel() != fxi->channel(chIndex))
×
854
        {
855
            disconnect(cc, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
856
                       this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
857
            disconnect(cc, SIGNAL(resetRequest(quint32,quint32)),
×
858
                       this, SLOT(slotChannelResetClicked(quint32,quint32)));
859

860
            ConsoleChannel *newCC = new ConsoleChannel(this, m_doc, fxi->id(), chIndex, false);
×
861
            newCC->setVisible(false);
×
862

863
            if (m_engine->hasChannel(fxi->universeAddress() + chIndex))
×
864
            {
865
                newCC->setChannelStyleSheet(ssOverride);
×
866
            }
867
            else
868
            {
869
                if (fxi->id() % 2 == 0)
×
870
                    newCC->setChannelStyleSheet(ssOdd);
×
871
                else
872
                    newCC->setChannelStyleSheet(ssEven);
×
873
            }
874

875
            newCC->setValue(cc->value());
×
876
            newCC->showResetButton(true);
×
877
            newCC->setProperty(PROP_ADDRESS, fxi->universeAddress() + chIndex);
×
878
            newCC->setVisible(true);
×
879

880
            connect(newCC, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
881
                    this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
882
            connect(newCC, SIGNAL(resetRequest(quint32,quint32)),
×
883
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
884

885
            QLayoutItem *item = m_universeGroup->layout()->replaceWidget(cc, newCC);
×
886
            delete item;
×
887
            delete cc;
×
888
            m_universeSliders.replace(i, newCC);
889
        }
890
        i++;
×
891
    }
892
}
×
893

894
void SimpleDesk::slotUniverseSliderValueChanged(quint32 fid, quint32 chan, uchar value)
×
895
{
896
    QVariant var(sender()->property(PROP_ADDRESS));
×
897
    if (var.isValid()) // Not true with disabled sliders
×
898
    {
899
        quint32 chanAbsAddr = var.toUInt();
×
900
        if (m_viewModeButton->isChecked() == false &&
×
901
            m_engine->hasChannel(chanAbsAddr) == false)
×
902
        {
903
            quint32 chanAddr = (chanAbsAddr & 0x01FF) - ((m_universePageSpin->value() - 1) * m_channelsPerPage);
×
904
            if (chanAddr < (quint32)m_universeSliders.count())
×
905
            {
906
                ConsoleChannel *chan = m_universeSliders.at(chanAddr);
×
907
                chan->setChannelStyleSheet(ssOverride);
×
908
            }
909
        }
910
        m_engine->setValue(chanAbsAddr, value);
×
911

912
        if (m_editCueStackButton->isChecked() == true)
×
913
            replaceCurrentCue();
×
914
    }
915
    else // calculate the absolute address from the given parameters
916
    {
917
        Fixture *fixture = m_doc->fixture(fid);
×
918
        if (fixture == NULL)
×
919
            return;
×
920

921
        quint32 chanAbsAddr = fixture->universeAddress() + chan;
×
922
        if (m_viewModeButton->isChecked() == true &&
×
923
            m_engine->hasChannel(chanAbsAddr) == false)
×
924
        {
925
            if (m_consoleList.contains(fid))
×
926
            {
927
                FixtureConsole *fc = m_consoleList[fid];
×
928
                if (fc != NULL)
×
929
                    fc->setChannelStylesheet(chan, ssOverride);
×
930
            }
931
        }
932
        m_engine->setValue(chanAbsAddr, value);
×
933

934
        if (m_editCueStackButton->isChecked() == true)
×
935
            replaceCurrentCue();
×
936
    }
937
}
938

939
void SimpleDesk::slotUniverseWritten(quint32 idx, const QByteArray& universeData)
×
940
{
941
    // If Simple Desk is not visible, don't even waste CPU
942
    if (isVisible() == false)
×
943
        return;
944

945
    if (idx != (quint32)m_currentUniverse)
×
946
        return;
947

948
    //qDebug() << "SIMPLE DESK UNIVERSE WRITTEN" << idx;
949

950
    if (m_viewModeButton->isChecked() == false)
×
951
    {
952
        quint32 start = (m_universePageSpin->value() - 1) * m_channelsPerPage;
×
953

954
        // update current page sliders
955
        for (quint32 i = start; i < start + (quint32)m_channelsPerPage; i++)
×
956
        {
957
            if (i >= (quint32)universeData.length())
×
958
                break;
959

960
            quint32 absAddr = i + (idx << 9);
×
961
            ConsoleChannel *cc = m_universeSliders[i - start];
×
962
            if (cc == NULL)
×
963
                continue;
×
964

965
            if (m_engine->hasChannel(absAddr) == true)
×
966
            {
967
                if (cc->value() != m_engine->value(absAddr))
×
968
                {
969
                    cc->blockSignals(true);
×
970
                    cc->setValue(m_engine->value(absAddr), false);
×
971
                    cc->setChannelStyleSheet(ssOverride);
×
972
                    cc->blockSignals(false);
×
973
                }
974
                continue;
×
975
            }
976

977
            cc->blockSignals(true);
×
978
            cc->setValue(universeData.at(i), false);
×
979
            cc->blockSignals(false);
×
980
        }
981
    }
982
    else
983
    {
984
        foreach (FixtureConsole *fc, m_consoleList.values())
×
985
        {
986
            if (fc == NULL)
×
987
                continue;
×
988

989
            quint32 fxi = fc->fixture();
×
990
            Fixture *fixture = m_doc->fixture(fxi);
×
991
            if (fixture != NULL)
×
992
            {
993
                quint32 startAddr = fixture->address();
×
994
                for (quint32 c = 0; c < fixture->channels(); c++)
×
995
                {
996
                    if (startAddr + c >= (quint32)universeData.length())
×
997
                        break;
998

999
                    if (m_engine->hasChannel((startAddr + c) + (idx << 9)) == true)
×
1000
                        continue;
×
1001

1002
                    fc->blockSignals(true);
×
1003
                    fc->setValue(c, universeData.at(startAddr + c), false);
×
1004
                    fc->blockSignals(false);
×
1005
                }
1006
            }
1007
        }
1008
    }
1009
}
1010

1011
void SimpleDesk::slotUpdateUniverseSliders()
×
1012
{
1013
    //qDebug() << Q_FUNC_INFO;
1014
    if (m_viewModeButton->isChecked() == true)
×
1015
    {
1016
        m_universeGroup->layout()->removeWidget(scrollArea);
×
1017
        delete scrollArea;
×
1018
        initSliderView(true);
×
1019
    }
1020
    else
1021
    {
1022
        slotUniversePageChanged(m_universePageSpin->value());
×
1023
    }
1024
}
×
1025

1026
/****************************************************************************
1027
 * Playback Sliders
1028
 ****************************************************************************/
1029

1030
void SimpleDesk::initPlaybackSliders()
×
1031
{
1032
    //qDebug() << Q_FUNC_INFO;
1033
    for (uint i = 0; i < m_playbacksPerPage; i++)
×
1034
    {
1035
        PlaybackSlider* slider = new PlaybackSlider(m_playbackGroup);
×
1036
        m_playbackGroup->layout()->addWidget(slider);
×
1037
        slider->setLabel(QString::number(i + 1));
×
1038
        slider->setProperty(PROP_PLAYBACK, uint(i));
×
1039
        m_playbackSliders << slider;
×
1040
        connect(slider, SIGNAL(selected()), this, SLOT(slotPlaybackSelected()));
×
1041
        connect(slider, SIGNAL(started()), this, SLOT(slotPlaybackStarted()));
×
1042
        connect(slider, SIGNAL(stopped()), this, SLOT(slotPlaybackStopped()));
×
1043
        connect(slider, SIGNAL(flashing(bool)), this, SLOT(slotPlaybackFlashing(bool)));
×
1044
        connect(slider, SIGNAL(valueChanged(uchar)), this, SLOT(slotPlaybackValueChanged(uchar)));
×
1045
    }
1046
}
×
1047

1048
void SimpleDesk::resetPlaybackSliders()
×
1049
{
1050
    //qDebug() << Q_FUNC_INFO;
1051
    QListIterator <PlaybackSlider*> it(m_playbackSliders);
×
1052
    while (it.hasNext() == true)
×
1053
        it.next()->setValue(0);
×
1054
}
×
1055

1056
void SimpleDesk::slotPlaybackSelected()
×
1057
{
1058
    //qDebug() << Q_FUNC_INFO;
1059
    Q_ASSERT(sender() != NULL);
1060
    uint pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1061
    if (m_selectedPlayback == pb)
×
1062
        return;
1063

1064
    slotSelectPlayback(pb);
×
1065
}
1066

1067
void SimpleDesk::slotSelectPlayback(uint pb)
×
1068
{
1069
    //qDebug() << Q_FUNC_INFO;
1070

1071
    if (m_selectedPlayback != UINT_MAX)
×
1072
        m_playbackSliders[m_selectedPlayback]->setSelected(false);
×
1073

1074
    if (pb != UINT_MAX)
×
1075
        m_playbackSliders[pb]->setSelected(true);
×
1076
    m_selectedPlayback = pb;
×
1077

1078
    CueStack* cueStack = m_engine->cueStack(pb);
×
1079
    Q_ASSERT(cueStack != NULL);
1080

1081
    CueStackModel* model = qobject_cast<CueStackModel*> (m_cueStackView->model());
×
1082
    Q_ASSERT(model != NULL);
1083
    model->setCueStack(cueStack);
×
1084

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

1087
    updateCueStackButtons();
×
1088
}
×
1089

1090
void SimpleDesk::slotPlaybackStarted()
×
1091
{
1092
    //qDebug() << Q_FUNC_INFO;
1093
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1094
    CueStack* cueStack = m_engine->cueStack(pb);
×
1095
    Q_ASSERT(cueStack != NULL);
1096

1097
    if (!cueStack->isRunning())
×
1098
        cueStack->nextCue();
×
1099
}
×
1100

1101
void SimpleDesk::slotPlaybackStopped()
×
1102
{
1103
    //qDebug() << Q_FUNC_INFO;
1104
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1105
    CueStack* cueStack = m_engine->cueStack(pb);
×
1106
    Q_ASSERT(cueStack != NULL);
1107

1108
    if (cueStack->isRunning())
×
1109
        cueStack->stop();
×
1110
}
×
1111

1112
void SimpleDesk::slotPlaybackFlashing(bool enabled)
×
1113
{
1114
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1115
    CueStack* cueStack = m_engine->cueStack(pb);
×
1116
    Q_ASSERT(cueStack != NULL);
1117

1118
    cueStack->setFlashing(enabled);
×
1119
}
×
1120

1121
void SimpleDesk::slotPlaybackValueChanged(uchar value)
×
1122
{
1123
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1124
    CueStack* cueStack = m_engine->cueStack(pb);
×
1125
    Q_ASSERT(cueStack != NULL);
1126

1127
    cueStack->adjustIntensity(qreal(value) / qreal(UCHAR_MAX));
×
1128
}
×
1129

1130
void SimpleDesk::slotGroupValueChanged(quint32 groupID, uchar value)
×
1131
{
1132
    ChannelsGroup *group = m_doc->channelsGroup(groupID);
×
1133
    if (group == NULL)
×
1134
        return;
1135
    quint32 start = (m_universePageSpin->value() - 1) * m_channelsPerPage;
×
1136

1137
    foreach (SceneValue scv, group->getChannels())
×
1138
    {
1139
        Fixture *fixture = m_doc->fixture(scv.fxi);
×
1140
        if (fixture == NULL)
×
1141
            continue;
×
1142
        quint32 absAddr = fixture->universeAddress() + scv.channel;
×
1143

1144
        // Update sliders on screen
1145
        if (m_viewModeButton->isChecked() == false)
×
1146
        {
1147
            if (fixture->universe() == (quint32)m_currentUniverse &&
×
1148
                absAddr >= start &&
×
1149
                absAddr < start + m_channelsPerPage)
×
1150
            {
1151
                ConsoleChannel *cc = m_universeSliders[absAddr - start];
×
1152
                if (cc != NULL)
×
1153
                {
1154
                    cc->blockSignals(true);
×
1155
                    cc->setValue(value, false);
×
1156
                    cc->blockSignals(false);
×
1157
                }
1158
            }
1159
        }
1160
        else
1161
        {
1162
            if (m_consoleList.contains(fixture->id()))
×
1163
            {
1164
                FixtureConsole *fc = m_consoleList[fixture->id()];
×
1165
                if (fc != NULL)
×
1166
                {
1167
                    fc->blockSignals(true);
×
1168
                    if (m_engine->hasChannel(absAddr) == false)
×
1169
                        fc->setChannelStylesheet(scv.channel, ssOverride);
×
1170
                    fc->setValue(scv.channel, value, false);
×
1171
                    fc->blockSignals(false);
×
1172
                }
1173
            }
1174
        }
1175

1176
        m_engine->setValue(absAddr, value);
×
1177
    }
1178
}
1179

1180
/****************************************************************************
1181
 * Cue Stack controls
1182
 ****************************************************************************/
1183

1184
void SimpleDesk::initCueStack()
×
1185
{
1186
    //qDebug() << Q_FUNC_INFO;
1187
    CueStackModel* model = new CueStackModel(this);
×
1188
    m_cueStackView->setModel(model);
×
1189

1190
    connect(m_previousCueButton, SIGNAL(clicked()), this, SLOT(slotPreviousCueClicked()));
×
1191
    connect(m_nextCueButton, SIGNAL(clicked()), this, SLOT(slotNextCueClicked()));
×
1192
    connect(m_stopCueStackButton, SIGNAL(clicked()), this, SLOT(slotStopCueStackClicked()));
×
1193
    connect(m_cloneCueStackButton, SIGNAL(clicked()), this, SLOT(slotCloneCueStackClicked()));
×
1194
    connect(m_editCueStackButton, SIGNAL(toggled(bool)), this, SLOT(slotEditCueStackClicked(bool)));
×
1195
    connect(m_recordCueButton, SIGNAL(clicked()), this, SLOT(slotRecordCueClicked()));
×
1196

1197
    connect(m_cueStackView->selectionModel(),
×
1198
            SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),
1199
            this, SLOT(slotCueStackSelectionChanged()));
1200
}
×
1201

1202
void SimpleDesk::updateCueStackButtons()
×
1203
{
1204
    //qDebug() << Q_FUNC_INFO;
1205
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1206
    if (cueStack == NULL)
×
1207
        return;
1208

1209
    m_stopCueStackButton->setEnabled(cueStack->isRunning());
×
1210
    m_nextCueButton->setEnabled(cueStack->cues().size() > 0);
×
1211
    m_previousCueButton->setEnabled(cueStack->cues().size() > 0);
×
1212
}
1213

1214
void SimpleDesk::replaceCurrentCue()
×
1215
{
1216
    qDebug() << Q_FUNC_INFO;
1217
    Q_ASSERT(m_selectedPlayback < uint(m_playbackSliders.size()));
1218

1219
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1220
    Q_ASSERT(cueStack != NULL);
1221

1222
    QItemSelectionModel* selectionModel = m_cueStackView->selectionModel();
×
1223
    if (selectionModel->hasSelection() == true)
×
1224
    {
1225
        // Replace current cue values
1226
        QModelIndex index = m_cueStackView->currentIndex();
×
1227
        QString name = cueStack->cues().at(index.row()).name();
×
1228
        Cue cue = m_engine->cue();
×
1229
        cue.setName(name);
×
1230
        cueStack->replaceCue(index.row(), cue);
×
1231
    }
1232
}
×
1233

1234
void SimpleDesk::createSpeedDials()
×
1235
{
1236
    if (m_speedDials != NULL)
×
1237
        return;
1238

1239
    m_speedDials = new SpeedDialWidget(this);
×
1240
    m_speedDials->setAttribute(Qt::WA_DeleteOnClose);
×
1241
    connect(m_speedDials, SIGNAL(fadeInChanged(int)),
×
1242
            this, SLOT(slotFadeInDialChanged(int)));
1243
    connect(m_speedDials, SIGNAL(fadeOutChanged(int)),
×
1244
            this, SLOT(slotFadeOutDialChanged(int)));
1245
    connect(m_speedDials, SIGNAL(holdChanged(int)),
×
1246
            this, SLOT(slotHoldDialChanged(int)));
1247
    connect(m_speedDials, SIGNAL(destroyed(QObject*)),
×
1248
            this, SLOT(slotDialDestroyed(QObject*)));
1249
    connect(m_speedDials, SIGNAL(optionalTextEdited(const QString&)),
×
1250
            this, SLOT(slotCueNameEdited(const QString&)));
1251
    m_speedDials->raise();
×
1252
    m_speedDials->show();
×
1253
}
1254

1255
void SimpleDesk::updateSpeedDials()
×
1256
{
1257
    qDebug() << Q_FUNC_INFO;
1258

1259
    if (m_speedDials == NULL)
×
1260
        return;
×
1261

1262
    Q_ASSERT(m_cueStackView != NULL);
1263
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1264
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1265

1266
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1267
    Q_ASSERT(cueStack != NULL);
1268

1269
    if (selected.size() == 0)
×
1270
    {
1271
        m_speedDials->setEnabled(false);
×
1272

1273
        m_speedDials->setWindowTitle(tr("No selection"));
×
1274
        m_speedDials->setFadeInSpeed(0);
×
1275
        m_speedDials->setFadeOutSpeed(0);
×
1276
        m_speedDials->setDuration(0);
×
1277

1278
        m_speedDials->setOptionalTextTitle(QString());
×
1279
        m_speedDials->setOptionalText(QString());
×
1280
    }
1281
    else if (selected.size() == 1)
×
1282
    {
1283
        m_speedDials->setEnabled(true);
×
1284

1285
        QModelIndex index = selected.first();
×
1286
        Q_ASSERT(index.row() >= 0 && index.row() < cueStack->cues().size());
1287
        Cue cue = cueStack->cues()[index.row()];
×
1288
        m_speedDials->setWindowTitle(cue.name());
×
1289
        m_speedDials->setFadeInSpeed(cue.fadeInSpeed());
×
1290
        m_speedDials->setFadeOutSpeed(cue.fadeOutSpeed());
×
1291
        if ((int)cue.duration() < 0)
×
1292
            m_speedDials->setDuration(cue.duration());
×
1293
        else
1294
            m_speedDials->setDuration(cue.duration() - cue.fadeInSpeed() - cue.fadeOutSpeed());
×
1295

1296
        m_speedDials->setOptionalTextTitle(tr("Cue name"));
×
1297
        m_speedDials->setOptionalText(cue.name());
×
1298
    }
1299
    else
1300
    {
1301
        m_speedDials->setEnabled(true);
×
1302

1303
        m_speedDials->setWindowTitle(tr("Multiple Cues"));
×
1304
        m_speedDials->setFadeInSpeed(0);
×
1305
        m_speedDials->setFadeOutSpeed(0);
×
1306
        m_speedDials->setDuration(0);
×
1307

1308
        m_speedDials->setOptionalTextTitle(QString());
×
1309
        m_speedDials->setOptionalText(QString());
×
1310
    }
1311
}
1312

1313
CueStack* SimpleDesk::currentCueStack() const
×
1314
{
1315
    Q_ASSERT(m_engine != NULL);
1316
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1317
    Q_ASSERT(cueStack != NULL);
1318
    return cueStack;
×
1319
}
1320

1321
int SimpleDesk::currentCueIndex() const
×
1322
{
1323
    Q_ASSERT(m_cueStackView != NULL);
1324
    return m_cueStackView->currentIndex().row();
×
1325
}
1326

1327
void SimpleDesk::slotCueStackStarted(uint stack)
×
1328
{
1329
    qDebug() << Q_FUNC_INFO;
1330
    if (stack != m_selectedPlayback)
×
1331
        return;
1332

1333
    PlaybackSlider* slider = m_playbackSliders[m_selectedPlayback];
×
1334
    Q_ASSERT(slider != NULL);
1335
    if (slider->value() == 0)
×
1336
        slider->setValue(UCHAR_MAX);
×
1337
    updateCueStackButtons();
×
1338
}
1339

1340
void SimpleDesk::slotCueStackStopped(uint stack)
×
1341
{
1342
    qDebug() << Q_FUNC_INFO;
1343
    if (stack != m_selectedPlayback)
×
1344
        return;
1345

1346
    PlaybackSlider* slider = m_playbackSliders[m_selectedPlayback];
×
1347
    Q_ASSERT(slider != NULL);
1348
    if (slider->value() != 0)
×
1349
        slider->setValue(0);
×
1350
    updateCueStackButtons();
×
1351
}
1352

1353
void SimpleDesk::slotCueStackSelectionChanged()
×
1354
{
1355
    qDebug() << Q_FUNC_INFO;
1356

1357
    Q_ASSERT(m_cueStackView != NULL);
1358
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1359
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1360

1361
    updateCueStackButtons();
×
1362

1363
    // Destroy the existing delete icon
1364
    if (m_cueDeleteIconIndex.isValid() == true)
1365
        m_cueStackView->setIndexWidget(m_cueDeleteIconIndex, NULL);
×
1366
    m_cueDeleteIconIndex = QModelIndex();
×
1367

1368
    if (m_editCueStackButton->isChecked() == true)
×
1369
    {
1370
        CueStack* cueStack = currentCueStack();
×
1371
        if (selected.size() == 0)
×
1372
        {
1373
            resetUniverseSliders();
×
1374
            m_universeGroup->setEnabled(false);
×
1375
        }
1376
        else if (selected.size() == 1)
×
1377
        {
1378
            m_universeGroup->setEnabled(true);
×
1379
            QModelIndex index = selected.first();
×
1380
            if (index.row() >= 0 && index.row() < cueStack->cues().size())
×
1381
            {
1382
                Cue cue = cueStack->cues()[index.row()];
×
1383
                m_engine->setCue(cue);
×
1384
                slotUniversePageChanged(m_universePageSpin->value());
×
1385
            }
1386
        }
1387
        else
1388
        {
1389
            m_universeGroup->setEnabled(false);
×
1390
            resetUniverseSliders();
×
1391
        }
1392

1393
        // Put a delete button on the first selected item
1394
        if (selected.size() > 0)
×
1395
        {
1396
            QModelIndex index = selected.first();
×
1397
            if (index.row() >= 0 && index.row() < cueStack->cues().size())
×
1398
            {
1399
                QPushButton* btn = new QPushButton(m_cueStackView);
×
1400
                btn->setToolTip(tr("Delete cue"));
×
1401
                btn->setFlat(true);
×
1402
                btn->setFixedSize(m_cueStackView->sizeHintForIndex(index));
×
1403
                btn->setIcon(QIcon(":/delete.png"));
×
1404
                m_cueStackView->setIndexWidget(index, btn);
×
1405
                m_cueDeleteIconIndex = index;
×
1406
                connect(btn, SIGNAL(clicked()), this, SLOT(slotDeleteCueClicked()));
×
1407
            }
1408
        }
1409
    }
1410
    else
1411
    {
1412
        m_universeGroup->setEnabled(true);
×
1413
    }
1414

1415
    updateSpeedDials();
×
1416
}
×
1417

1418
void SimpleDesk::slotPreviousCueClicked()
×
1419
{
1420
    qDebug() << Q_FUNC_INFO;
1421
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1422
    Q_ASSERT(cueStack != NULL);
1423
    cueStack->previousCue();
×
1424
}
×
1425

1426
void SimpleDesk::slotNextCueClicked()
×
1427
{
1428
    qDebug() << Q_FUNC_INFO;
1429
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1430
    Q_ASSERT(cueStack != NULL);
1431
    cueStack->nextCue();
×
1432
}
×
1433

1434
void SimpleDesk::slotStopCueStackClicked()
×
1435
{
1436
    qDebug() << Q_FUNC_INFO;
1437
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1438
    Q_ASSERT(cueStack != NULL);
1439
    cueStack->stop();
×
1440
}
×
1441

1442
void SimpleDesk::slotCloneCueStackClicked()
×
1443
{
1444
    qDebug() << Q_FUNC_INFO;
1445

1446
    QStringList items;
1447
    for (uint i = 0; i < m_playbacksPerPage; i++)
×
1448
    {
1449
        if (i != m_selectedPlayback)
×
1450
            items << QString::number(i + 1);
×
1451
    }
1452

1453
    bool ok = false;
×
1454
    QString text = QInputDialog::getItem(this, tr("Clone Cue Stack"), tr("Clone To Playback#"),
×
1455
                                         items, 0, false, &ok);
×
1456
    if (ok == false)
×
1457
        return;
×
1458

1459
    uint pb = text.toUInt() - 1;
×
1460
    CueStack* cs = m_engine->cueStack(m_selectedPlayback);
×
1461
    CueStack* clone = m_engine->cueStack(pb);
×
1462
    Q_ASSERT(cs != NULL);
1463
    Q_ASSERT(clone != NULL);
1464

1465
    while (clone->cues().size() > 0)
×
1466
        clone->removeCue(0);
×
1467

1468
    QListIterator <Cue> it(cs->cues());
×
1469
    while (it.hasNext() == true)
×
1470
        clone->appendCue(it.next());
×
1471

1472
    slotSelectPlayback(pb);
×
1473
}
1474

1475
void SimpleDesk::slotDialDestroyed(QObject *)
×
1476
{
1477
    if (m_speedDials != NULL)
×
1478
        m_speedDials->deleteLater();
×
1479
    m_speedDials = NULL;
×
1480
    m_editCueStackButton->setChecked(false);
×
1481
}
×
1482

1483
void SimpleDesk::slotEditCueStackClicked(bool state)
×
1484
{
1485
    qDebug() << Q_FUNC_INFO;
1486

1487
    slotCueStackSelectionChanged();
×
1488

1489
    if (state == true)
×
1490
    {
1491
        createSpeedDials();
×
1492
        updateSpeedDials();
×
1493
    }
1494
    else
1495
    {
1496
        resetUniverseSliders();
×
1497
        if (m_speedDials != NULL)
×
1498
            m_speedDials->deleteLater();
×
1499
        m_speedDials = NULL;
×
1500
    }
1501
}
×
1502

1503
void SimpleDesk::slotRecordCueClicked()
×
1504
{
1505
    qDebug() << Q_FUNC_INFO;
1506
    Q_ASSERT(m_selectedPlayback < uint(m_playbackSliders.size()));
1507

1508
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1509
    Q_ASSERT(cueStack != NULL);
1510

1511
    QItemSelectionModel* selModel = m_cueStackView->selectionModel();
×
1512
    Q_ASSERT(selModel != NULL);
1513
    int index = 0;
1514
    if (selModel->hasSelection() == true)
×
1515
        index = selModel->currentIndex().row() + 1;
×
1516
    else
1517
        index = cueStack->cues().size();
×
1518

1519
    Cue cue = m_engine->cue();
×
1520
    cue.setName(tr("Cue %1").arg(cueStack->cues().size() + 1));
×
1521
    cueStack->insertCue(index, cue);
×
1522

1523
    // Select the newly-created Cue, all columns from 0 to last
1524
    const QAbstractItemModel* itemModel = selModel->model();
×
1525
    Q_ASSERT(itemModel != NULL);
1526
    int firstCol = 0;
1527
    int lastCol = itemModel->columnCount() - 1;
×
1528
    QItemSelection sel(itemModel->index(index, firstCol), itemModel->index(index, lastCol));
×
1529
    selModel->select(sel, QItemSelectionModel::ClearAndSelect);
×
1530
    selModel->setCurrentIndex(itemModel->index(index, firstCol), QItemSelectionModel::Current);
×
1531

1532
    updateCueStackButtons();
×
1533
}
×
1534

1535
void SimpleDesk::slotDeleteCueClicked()
×
1536
{
1537
    Q_ASSERT(m_cueStackView != NULL);
1538
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1539
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1540
    QModelIndex current = m_cueStackView->selectionModel()->currentIndex();
×
1541
    CueStack* cueStack = currentCueStack();
×
1542
    Q_ASSERT(cueStack != NULL);
1543
    QList <int> indexes;
×
1544
    foreach (QModelIndex index, selected)
×
1545
        indexes << index.row();
×
1546
    cueStack->removeCues(indexes);
×
1547

1548
    // Select an item ~at the current index
1549
    QAbstractItemModel* model = m_cueStackView->model();
×
1550
    if (model->hasIndex(current.row(), 0) == true)
×
1551
    {
1552
        m_cueStackView->setCurrentIndex(current);
×
1553
    }
1554
    else if (model->rowCount() != 0)
×
1555
    {
1556
        QModelIndex index = model->index(model->rowCount() - 1, 0);
×
1557
        m_cueStackView->setCurrentIndex(index);
×
1558
    }
1559
}
×
1560

1561
void SimpleDesk::slotFadeInDialChanged(int ms)
×
1562
{
1563
    Q_ASSERT(m_cueStackView != NULL);
1564
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1565
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1566
    CueStack* cueStack = currentCueStack();
×
1567
    foreach (QModelIndex index, selected)
×
1568
        cueStack->setFadeInSpeed(ms, index.row());
×
1569
}
×
1570

1571
void SimpleDesk::slotFadeOutDialChanged(int ms)
×
1572
{
1573
    Q_ASSERT(m_cueStackView != NULL);
1574
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1575
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1576
    CueStack* cueStack = currentCueStack();
×
1577
    foreach (QModelIndex index, selected)
×
1578
        cueStack->setFadeOutSpeed(ms, index.row());
×
1579
}
×
1580

1581
void SimpleDesk::slotHoldDialChanged(int ms)
×
1582
{
1583
    Q_ASSERT(m_cueStackView != NULL);
1584
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1585
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1586
    CueStack* cueStack = currentCueStack();
×
1587
    foreach (QModelIndex index, selected)
×
1588
    {
1589
        if (ms < 0)
×
1590
            cueStack->setDuration(ms, index.row());
×
1591
        else
1592
            cueStack->setDuration(cueStack->fadeInSpeed() + ms + cueStack->fadeOutSpeed(), index.row());
×
1593
    }
1594
}
×
1595

1596
void SimpleDesk::slotCueNameEdited(const QString& name)
×
1597
{
1598
    Q_ASSERT(m_cueStackView != NULL);
1599
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1600
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1601
    CueStack* cueStack = currentCueStack();
×
1602
    if (selected.size() == 1)
×
1603
        cueStack->setName(name, selected.first().row());
×
1604
}
×
1605

1606
void SimpleDesk::showEvent(QShowEvent* ev)
×
1607
{
1608
    if (m_docChanged == true)
×
1609
    {
1610
        if (m_editCueStackButton->isChecked() == true)
×
1611
            slotEditCueStackClicked(true);
×
1612
        initUniversesCombo();
×
1613
        initChannelGroupsView();
×
1614
        m_docChanged = false;
×
1615
    }
1616
    slotUpdateUniverseSliders();
×
1617
    QWidget::showEvent(ev);
×
1618
}
×
1619

1620
void SimpleDesk::hideEvent(QHideEvent* ev)
×
1621
{
1622
    if (m_speedDials != NULL)
×
1623
        m_speedDials->deleteLater();
×
1624
    m_speedDials = NULL;
×
1625
    QWidget::hideEvent(ev);
×
1626
}
×
1627

1628
void SimpleDesk::resizeEvent(QResizeEvent *ev)
×
1629
{
1630
    QWidget::resizeEvent(ev);
×
1631

1632
    QSettings settings;
×
1633
    QVariant var = settings.value(SETTINGS_PAGE_CHANNELS);
×
1634
    QSize newSize = ev->size();
×
1635
    //qDebug() << "Resize event. Frame size:" << newSize;
1636

1637
    // this block makes sense only in a fixed layout
1638
    if (m_viewModeButton->isChecked() == false)
×
1639
    {
1640
        // if channels per page are not forced by the user,
1641
        // perform an autodetection
1642
        if (var.isValid() == false || var.toUInt() == 0)
×
1643
        {
1644
            uint currChannels = m_channelsPerPage;
×
1645
            // 42 is the answer to life, the universe and everything...
1646
            // but also the width of a console channel slider :)
1647
            m_channelsPerPage = (newSize.width() - m_grandMasterSlider->width()) / 42;
×
1648
            //qDebug() << "Old channels per page:" << currChannels << ", new value:" << m_channelsPerPage;
1649
            if (m_channelsPerPage != currChannels)
×
1650
            {
1651
                int slidersDiff = (int)currChannels - (int)m_channelsPerPage;
×
1652
                if (slidersDiff < 0)
×
1653
                {
1654
                    for (int a = 0; a < -slidersDiff; a++)
×
1655
                        m_universeSliders.append(NULL);
×
1656
                }
1657
                else if (slidersDiff > 0)
×
1658
                {
1659
                    for (int r = 0; r < slidersDiff; r++)
×
1660
                    {
1661
                        ConsoleChannel* slider = m_universeSliders.takeLast();
×
1662
                        if (slider != NULL)
×
1663
                        {
1664
                            m_universeGroup->layout()->removeWidget(slider);
×
1665
                            disconnect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
1666
                                   this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
1667
                            disconnect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
1668
                                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
1669
                            delete slider;
×
1670
                        }
1671
                    }
1672
                }
1673
                m_universePageSpin->setRange(1, int((512 + m_channelsPerPage - 1) / m_channelsPerPage));
×
1674
                if (this->isVisible() == true)
×
1675
                    slotUniversePageChanged(m_universePageSpin->value());
×
1676
            }
1677
        }
1678
    }
1679

1680
    // check if the value has been forced by the user
1681
    var = settings.value(SETTINGS_PAGE_PLAYBACKS);
×
1682
    if (var.isValid() == true && var.toUInt() > 0)
×
1683
        return;
×
1684

1685
    uint currPlayback = m_playbacksPerPage;
×
1686
    // always have playback sliders to fill half of the window
1687
    m_playbacksPerPage = (newSize.width() / 2) / 42;
×
1688

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

1691
    if (currPlayback != m_playbacksPerPage)
×
1692
    {
1693
        int pbDiff = (int)currPlayback - (int)m_playbacksPerPage;
×
1694
        if (pbDiff < 0)
×
1695
        {
1696
            for (int a = 0; a < -pbDiff; a++)
×
1697
            {
1698
                PlaybackSlider* slider = new PlaybackSlider(m_playbackGroup);
×
1699
                m_playbackGroup->layout()->addWidget(slider);
×
1700
                slider->setLabel(QString::number(m_playbackSliders.count() + 1));
×
1701
                slider->setProperty(PROP_PLAYBACK, uint(m_playbackSliders.count()));
×
1702
                m_playbackSliders << slider;
×
1703
                connect(slider, SIGNAL(selected()), this, SLOT(slotPlaybackSelected()));
×
1704
                connect(slider, SIGNAL(started()), this, SLOT(slotPlaybackStarted()));
×
1705
                connect(slider, SIGNAL(stopped()), this, SLOT(slotPlaybackStopped()));
×
1706
                connect(slider, SIGNAL(flashing(bool)), this, SLOT(slotPlaybackFlashing(bool)));
×
1707
                connect(slider, SIGNAL(valueChanged(uchar)), this, SLOT(slotPlaybackValueChanged(uchar)));
×
1708
            }
1709
        }
1710
        else if (pbDiff > 0)
×
1711
        {
1712
            for (int r = 0; r < pbDiff; r++)
×
1713
            {
1714
                PlaybackSlider* slider = m_playbackSliders.takeLast();
×
1715
                if (slider == NULL)
×
1716
                    continue;
×
1717
                disconnect(slider, SIGNAL(selected()), this, SLOT(slotPlaybackSelected()));
×
1718
                disconnect(slider, SIGNAL(started()), this, SLOT(slotPlaybackStarted()));
×
1719
                disconnect(slider, SIGNAL(stopped()), this, SLOT(slotPlaybackStopped()));
×
1720
                disconnect(slider, SIGNAL(flashing(bool)), this, SLOT(slotPlaybackFlashing(bool)));
×
1721
                disconnect(slider, SIGNAL(valueChanged(uchar)), this, SLOT(slotPlaybackValueChanged(uchar)));
×
1722
                m_playbackGroup->layout()->removeWidget(slider);
×
1723
                delete slider;
×
1724
            }
1725
        }
1726
    }
1727

1728
}
1729

1730
/****************************************************************************
1731
 * Load & Save
1732
 ****************************************************************************/
1733

1734
bool SimpleDesk::loadXML(QXmlStreamReader &root)
×
1735
{
1736
    Q_ASSERT(m_engine != NULL);
1737

1738
    clearContents();
×
1739

1740
    if (root.name() != KXMLQLCSimpleDesk)
×
1741
    {
1742
        qWarning() << Q_FUNC_INFO << "Simple Desk node not found";
×
1743
        return false;
×
1744
    }
1745

1746
    while (root.readNextStartElement())
×
1747
    {
1748
        if (root.name() == KXMLQLCSimpleDeskEngine)
×
1749
        {
1750
            m_engine->loadXML(root);
×
1751
        }
1752
        else
1753
        {
1754
            qWarning() << Q_FUNC_INFO << "Unrecognized Simple Desk node:" << root.name();
×
1755
            root.skipCurrentElement();
×
1756
        }
1757
    }
1758

1759
    slotSelectPlayback(0);
×
1760

1761
    return true;
×
1762
}
1763

1764
bool SimpleDesk::saveXML(QXmlStreamWriter *doc) const
×
1765
{
1766
    Q_ASSERT(doc != NULL);
1767
    Q_ASSERT(m_engine != NULL);
1768

1769
    doc->writeStartElement(KXMLQLCSimpleDesk);
×
1770

1771
    if (m_engine->saveXML(doc) == false)
×
1772
        return false;
1773

1774
    doc->writeEndElement();
×
1775

1776
    return true;
×
1777
}
1778

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

© 2026 Coveralls, Inc