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

mcallegari / qlcplus / 12534701676

29 Dec 2024 10:38AM UTC coverage: 31.963%. Remained the same
12534701676

push

github

mcallegari
ui: update simple desk slider stylesheet on reset via web API (fix #1647)

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

1 existing line in 1 file now uncovered.

14045 of 43942 relevant lines covered (31.96%)

27319.94 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);
×
NEW
413
    slotUniversePageChanged(m_universePageSpin->value());
×
UNCOV
414
}
×
415

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

425
void SimpleDesk::resetUniverse(int index)
×
426
{
427
    m_universesCombo->setCurrentIndex(index);
×
428
    resetUniverse();
×
429
}
×
430

431
/****************************************************************************
432
 * Universe controls
433
 ****************************************************************************/
434

435
void SimpleDesk::initUniversesCombo()
×
436
{
437
    disconnect(m_universesCombo, SIGNAL(currentIndexChanged(int)),
×
438
            this, SLOT(slotUniversesComboChanged(int)));
439
    int currIdx = m_universesCombo->currentIndex();
×
440
    m_universesCombo->clear();
×
441
    m_universesCombo->addItems(m_doc->inputOutputMap()->universeNames());
×
442
    if (currIdx != -1)
×
443
        m_universesCombo->setCurrentIndex(currIdx);
×
444
    while (m_universesPage.length() < m_universesCombo->count())
×
445
        m_universesPage.append(1);
×
446
    connect(m_universesCombo, SIGNAL(currentIndexChanged(int)),
×
447
            this, SLOT(slotUniversesComboChanged(int)));
448
}
×
449

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

476
void SimpleDesk::initUniversePager()
×
477
{
478
    //qDebug() << Q_FUNC_INFO;
479
    m_universePageSpin->setRange(1, int((512 + m_channelsPerPage - 1) / m_channelsPerPage));
×
480
    m_universePageSpin->setValue(1);
×
481
    slotUniversePageChanged(1);
×
482

483
    connect(m_viewModeButton, SIGNAL(clicked(bool)), this, SLOT(slotViewModeClicked(bool)));
×
484
    connect(m_universePageUpButton, SIGNAL(clicked()), this, SLOT(slotUniversePageUpClicked()));
×
485
    connect(m_universePageDownButton, SIGNAL(clicked()), this, SLOT(slotUniversePageDownClicked()));
×
486
    connect(m_universePageSpin, SIGNAL(valueChanged(int)), this, SLOT(slotUniversePageChanged(int)));
×
487
    connect(m_universeResetButton, SIGNAL(clicked()), this, SLOT(slotUniverseResetClicked()));
×
488
}
×
489

490
void SimpleDesk::resetUniverseSliders()
×
491
{
492
    //qDebug() << Q_FUNC_INFO;
493
    foreach (ConsoleChannel *channel, m_universeSliders)
×
494
    {
495
        if (channel != NULL)
×
496
            channel->setValue(0);
×
497
    }
498
}
×
499

500
void SimpleDesk::initSliderView(bool fullMode)
×
501
{
502
    m_consoleList.clear();
×
503

504
    if (fullMode == true)
×
505
    {
506
        scrollArea = new QScrollArea();
×
507
        scrollArea->setWidgetResizable(true);
×
508

509
        QFrame* grpBox = new QFrame(scrollArea);
×
510
        grpBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Preferred);
×
511
        QHBoxLayout* fixturesLayout = new QHBoxLayout(grpBox);
×
512
        grpBox->setLayout(fixturesLayout);
×
513
        fixturesLayout->setSpacing(2);
×
514
        fixturesLayout->setContentsMargins(2, 2, 2, 2);
×
515

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

555
        m_universeGroup->layout()->addWidget(scrollArea);
×
556
    }
557
    else
558
    {
559
        int page = m_universesPage.at(m_universesCombo->currentIndex());
×
560
        slotUniversePageChanged(page);
×
561
    }
562
}
×
563

564
void SimpleDesk::initChannelGroupsView()
×
565
{
566
    if (m_chGroupsArea != NULL)
×
567
    {
568
        delete m_chGroupsArea;
×
569
        m_chGroupsArea = NULL;
×
570
    }
571

572
    if (m_doc->channelsGroups().count() > 0)
×
573
    {
574
        m_chGroupsArea = new QScrollArea();
×
575
        QList<quint32> chGrpIDs;
×
576
        foreach (ChannelsGroup *grp, m_doc->channelsGroups())
×
577
            chGrpIDs.append(grp->id());
×
578
        GroupsConsole* console = new GroupsConsole(m_chGroupsArea, m_doc, chGrpIDs, QList<uchar>());
×
579
        m_chGroupsArea->setWidget(console);
×
580
        m_chGroupsArea->setWidgetResizable(true);
×
581
        m_tabs->addTab(m_chGroupsArea, tr("Channel groups"));
×
582
        connect(console, SIGNAL(groupValueChanged(quint32,uchar)),
×
583
                this, SLOT(slotGroupValueChanged(quint32,uchar)));
584
    }
585
}
×
586

587
void SimpleDesk::slotUniversesComboChanged(int index)
×
588
{
589
    m_currentUniverse = index;
×
590
    if (m_viewModeButton->isChecked() == true)
×
591
    {
592
        m_universeGroup->layout()->removeWidget(scrollArea);
×
593
        delete scrollArea;
×
594
        initSliderView(true);
×
595
    }
596
    else
597
    {
598
        int page = m_universesPage.at(index);
×
599
        slotUniversePageChanged(m_universesPage.at(index));
×
600
        m_universePageSpin->setValue(page);
×
601
    }
602
}
×
603

604
void SimpleDesk::slotViewModeClicked(bool toggle)
×
605
{
606
    if (toggle == true)
×
607
    {
608
        QList<quint32> fxRemoveList;
×
609

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

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

652
void SimpleDesk::slotUniversePageDownClicked()
×
653
{
654
    qDebug() << Q_FUNC_INFO;
655
    m_universePageSpin->setValue(m_universePageSpin->value() - 1);
×
656
}
×
657

658
void SimpleDesk::slotUniversePageChanged(int page)
×
659
{
660
    qDebug() << Q_FUNC_INFO;
661
    QList<quint32> fxAddList, fxRemoveList;
×
662
    quint32 start = (page - 1) * m_channelsPerPage;
×
663

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

667
    /* Set the new page for this universe */
668
    m_universesPage.replace(m_currentUniverse, page);
×
669

670
    //qDebug() << "[slotUniversePageChanged] start: " << start << ", absoluteAddr: " << absoluteAddr;
671

672
    for (quint32 i = 0; i < m_channelsPerPage; i++)
×
673
    {
674
        ConsoleChannel *slider = m_universeSliders[i];
×
675
        if (slider != NULL)
×
676
        {
677
            m_universeGroup->layout()->removeWidget(slider);
×
678
            disconnect(slider, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
679
                   this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
680
            disconnect(slider, SIGNAL(resetRequest(quint32,quint32)),
×
681
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
682

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

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

753
        m_universeGroup->layout()->addWidget(slider);
×
754
        m_universeSliders[i] = slider;
×
755
    }
756
}
×
757

758
void SimpleDesk::slotUniverseResetClicked()
×
759
{
760
    qDebug() << Q_FUNC_INFO;
761
    m_engine->resetUniverse(m_currentUniverse);
×
762
    m_universePageSpin->setValue(1);
×
763
    if (m_viewModeButton->isChecked() == false)
×
764
        slotUniversePageChanged(1);
×
765
    else
766
    {
767
        QHashIterator <quint32,FixtureConsole*> it(m_consoleList);
×
768

769
        while (it.hasNext() == true)
×
770
        {
771
            it.next();
772
            FixtureConsole *fc = it.value();
×
773
            Q_ASSERT(fc != NULL);
774
            fc->resetChannelsStylesheet();
×
775
        }
776
    }
777
}
×
778

779
void SimpleDesk::slotChannelResetClicked(quint32 fxID, quint32 channel)
×
780
{
781
    if (fxID != Fixture::invalidId())
×
782
    {
783
        Fixture *fixture = m_doc->fixture(fxID);
×
784
        if (fixture == NULL)
×
785
            return;
786

787
        quint32 absAddr = fixture->universeAddress() + channel;
×
788
        m_engine->resetChannel(absAddr);
×
789

790
        if (m_viewModeButton->isChecked() == true)
×
791
        {
792
            Fixture *fixture = m_doc->fixture(fxID);
×
793
            if (fixture == NULL)
×
794
                return;
795

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

825
void SimpleDesk::slotAliasChanged()
×
826
{
827
    Fixture *fxi = qobject_cast<Fixture *>(sender());
×
828
    int i = 0;
829

830
    foreach (ConsoleChannel *cc, m_universeSliders)
×
831
    {
832
        quint32 chIndex = cc->channelIndex();
×
833

834
        if (cc->fixture() == fxi->id() && cc->channel() != fxi->channel(chIndex))
×
835
        {
836
            disconnect(cc, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
837
                       this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
838
            disconnect(cc, SIGNAL(resetRequest(quint32,quint32)),
×
839
                       this, SLOT(slotChannelResetClicked(quint32,quint32)));
840

841
            ConsoleChannel *newCC = new ConsoleChannel(this, m_doc, fxi->id(), chIndex, false);
×
842
            newCC->setVisible(false);
×
843

844
            if (m_engine->hasChannel(fxi->universeAddress() + chIndex))
×
845
            {
846
                newCC->setChannelStyleSheet(ssOverride);
×
847
            }
848
            else
849
            {
850
                if (fxi->id() % 2 == 0)
×
851
                    newCC->setChannelStyleSheet(ssOdd);
×
852
                else
853
                    newCC->setChannelStyleSheet(ssEven);
×
854
            }
855

856
            newCC->setValue(cc->value());
×
857
            newCC->showResetButton(true);
×
858
            newCC->setProperty(PROP_ADDRESS, fxi->universeAddress() + chIndex);
×
859
            newCC->setVisible(true);
×
860

861
            connect(newCC, SIGNAL(valueChanged(quint32,quint32,uchar)),
×
862
                    this, SLOT(slotUniverseSliderValueChanged(quint32,quint32,uchar)));
863
            connect(newCC, SIGNAL(resetRequest(quint32,quint32)),
×
864
                    this, SLOT(slotChannelResetClicked(quint32,quint32)));
865

866
            QLayoutItem *item = m_universeGroup->layout()->replaceWidget(cc, newCC);
×
867
            delete item;
×
868
            delete cc;
×
869
            m_universeSliders.replace(i, newCC);
870
        }
871
        i++;
×
872
    }
873
}
×
874

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

893
        if (m_editCueStackButton->isChecked() == true)
×
894
            replaceCurrentCue();
×
895
    }
896
    else // calculate the absolute address from the given parameters
897
    {
898
        Fixture *fixture = m_doc->fixture(fid);
×
899
        if (fixture == NULL)
×
900
            return;
×
901

902
        quint32 chanAbsAddr = fixture->universeAddress() + chan;
×
903
        if (m_viewModeButton->isChecked() == true &&
×
904
            m_engine->hasChannel(chanAbsAddr) == false)
×
905
        {
906
            if (m_consoleList.contains(fid))
×
907
            {
908
                FixtureConsole *fc = m_consoleList[fid];
×
909
                if (fc != NULL)
×
910
                    fc->setChannelStylesheet(chan, ssOverride);
×
911
            }
912
        }
913
        m_engine->setValue(chanAbsAddr, value);
×
914

915
        if (m_editCueStackButton->isChecked() == true)
×
916
            replaceCurrentCue();
×
917
    }
918
}
919

920
void SimpleDesk::slotUniverseWritten(quint32 idx, const QByteArray& universeData)
×
921
{
922
    // If Simple Desk is not visible, don't even waste CPU
923
    if (isVisible() == false)
×
924
        return;
925

926
    if (idx != (quint32)m_currentUniverse)
×
927
        return;
928

929
    //qDebug() << "SIMPLE DESK UNIVERSE WRITTEN" << idx;
930

931
    if (m_viewModeButton->isChecked() == false)
×
932
    {
933
        quint32 start = (m_universePageSpin->value() - 1) * m_channelsPerPage;
×
934

935
        // update current page sliders
936
        for (quint32 i = start; i < start + (quint32)m_channelsPerPage; i++)
×
937
        {
938
            if (i >= (quint32)universeData.length())
×
939
                break;
940

941
            quint32 absAddr = i + (idx << 9);
×
942
            ConsoleChannel *cc = m_universeSliders[i - start];
×
943
            if (cc == NULL)
×
944
                continue;
×
945

946
            if (m_engine->hasChannel(absAddr) == true)
×
947
            {
948
                if (cc->value() != m_engine->value(absAddr))
×
949
                {
950
                    cc->blockSignals(true);
×
951
                    cc->setValue(m_engine->value(absAddr), false);
×
952
                    cc->setChannelStyleSheet(ssOverride);
×
953
                    cc->blockSignals(false);
×
954
                }
955
                continue;
×
956
            }
957

958
            cc->blockSignals(true);
×
959
            cc->setValue(universeData.at(i), false);
×
960
            cc->blockSignals(false);
×
961
        }
962
    }
963
    else
964
    {
965
        foreach (FixtureConsole *fc, m_consoleList.values())
×
966
        {
967
            if (fc == NULL)
×
968
                continue;
×
969

970
            quint32 fxi = fc->fixture();
×
971
            Fixture *fixture = m_doc->fixture(fxi);
×
972
            if (fixture != NULL)
×
973
            {
974
                quint32 startAddr = fixture->address();
×
975
                for (quint32 c = 0; c < fixture->channels(); c++)
×
976
                {
977
                    if (startAddr + c >= (quint32)universeData.length())
×
978
                        break;
979

980
                    if (m_engine->hasChannel((startAddr + c) + (idx << 9)) == true)
×
981
                        continue;
×
982

983
                    fc->blockSignals(true);
×
984
                    fc->setValue(c, universeData.at(startAddr + c), false);
×
985
                    fc->blockSignals(false);
×
986
                }
987
            }
988
        }
989
    }
990
}
991

992
void SimpleDesk::slotUpdateUniverseSliders()
×
993
{
994
    //qDebug() << Q_FUNC_INFO;
995
    if (m_viewModeButton->isChecked() == true)
×
996
    {
997
        m_universeGroup->layout()->removeWidget(scrollArea);
×
998
        delete scrollArea;
×
999
        initSliderView(true);
×
1000
    }
1001
    else
1002
    {
1003
        slotUniversePageChanged(m_universePageSpin->value());
×
1004
    }
1005
}
×
1006

1007
/****************************************************************************
1008
 * Playback Sliders
1009
 ****************************************************************************/
1010

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

1029
void SimpleDesk::resetPlaybackSliders()
×
1030
{
1031
    //qDebug() << Q_FUNC_INFO;
1032
    QListIterator <PlaybackSlider*> it(m_playbackSliders);
×
1033
    while (it.hasNext() == true)
×
1034
        it.next()->setValue(0);
×
1035
}
×
1036

1037
void SimpleDesk::slotPlaybackSelected()
×
1038
{
1039
    //qDebug() << Q_FUNC_INFO;
1040
    Q_ASSERT(sender() != NULL);
1041
    uint pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1042
    if (m_selectedPlayback == pb)
×
1043
        return;
1044

1045
    slotSelectPlayback(pb);
×
1046
}
1047

1048
void SimpleDesk::slotSelectPlayback(uint pb)
×
1049
{
1050
    //qDebug() << Q_FUNC_INFO;
1051

1052
    if (m_selectedPlayback != UINT_MAX)
×
1053
        m_playbackSliders[m_selectedPlayback]->setSelected(false);
×
1054

1055
    if (pb != UINT_MAX)
×
1056
        m_playbackSliders[pb]->setSelected(true);
×
1057
    m_selectedPlayback = pb;
×
1058

1059
    CueStack* cueStack = m_engine->cueStack(pb);
×
1060
    Q_ASSERT(cueStack != NULL);
1061

1062
    CueStackModel* model = qobject_cast<CueStackModel*> (m_cueStackView->model());
×
1063
    Q_ASSERT(model != NULL);
1064
    model->setCueStack(cueStack);
×
1065

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

1068
    updateCueStackButtons();
×
1069
}
×
1070

1071
void SimpleDesk::slotPlaybackStarted()
×
1072
{
1073
    //qDebug() << Q_FUNC_INFO;
1074
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1075
    CueStack* cueStack = m_engine->cueStack(pb);
×
1076
    Q_ASSERT(cueStack != NULL);
1077

1078
    if (!cueStack->isRunning())
×
1079
        cueStack->nextCue();
×
1080
}
×
1081

1082
void SimpleDesk::slotPlaybackStopped()
×
1083
{
1084
    //qDebug() << Q_FUNC_INFO;
1085
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1086
    CueStack* cueStack = m_engine->cueStack(pb);
×
1087
    Q_ASSERT(cueStack != NULL);
1088

1089
    if (cueStack->isRunning())
×
1090
        cueStack->stop();
×
1091
}
×
1092

1093
void SimpleDesk::slotPlaybackFlashing(bool enabled)
×
1094
{
1095
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1096
    CueStack* cueStack = m_engine->cueStack(pb);
×
1097
    Q_ASSERT(cueStack != NULL);
1098

1099
    cueStack->setFlashing(enabled);
×
1100
}
×
1101

1102
void SimpleDesk::slotPlaybackValueChanged(uchar value)
×
1103
{
1104
    int pb = sender()->property(PROP_PLAYBACK).toUInt();
×
1105
    CueStack* cueStack = m_engine->cueStack(pb);
×
1106
    Q_ASSERT(cueStack != NULL);
1107

1108
    cueStack->adjustIntensity(qreal(value) / qreal(UCHAR_MAX));
×
1109
}
×
1110

1111
void SimpleDesk::slotGroupValueChanged(quint32 groupID, uchar value)
×
1112
{
1113
    ChannelsGroup *group = m_doc->channelsGroup(groupID);
×
1114
    if (group == NULL)
×
1115
        return;
1116
    quint32 start = (m_universePageSpin->value() - 1) * m_channelsPerPage;
×
1117

1118
    foreach (SceneValue scv, group->getChannels())
×
1119
    {
1120
        Fixture *fixture = m_doc->fixture(scv.fxi);
×
1121
        if (fixture == NULL)
×
1122
            continue;
×
1123
        quint32 absAddr = fixture->universeAddress() + scv.channel;
×
1124

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

1157
        m_engine->setValue(absAddr, value);
×
1158
    }
1159
}
1160

1161
/****************************************************************************
1162
 * Cue Stack controls
1163
 ****************************************************************************/
1164

1165
void SimpleDesk::initCueStack()
×
1166
{
1167
    //qDebug() << Q_FUNC_INFO;
1168
    CueStackModel* model = new CueStackModel(this);
×
1169
    m_cueStackView->setModel(model);
×
1170

1171
    connect(m_previousCueButton, SIGNAL(clicked()), this, SLOT(slotPreviousCueClicked()));
×
1172
    connect(m_nextCueButton, SIGNAL(clicked()), this, SLOT(slotNextCueClicked()));
×
1173
    connect(m_stopCueStackButton, SIGNAL(clicked()), this, SLOT(slotStopCueStackClicked()));
×
1174
    connect(m_cloneCueStackButton, SIGNAL(clicked()), this, SLOT(slotCloneCueStackClicked()));
×
1175
    connect(m_editCueStackButton, SIGNAL(toggled(bool)), this, SLOT(slotEditCueStackClicked(bool)));
×
1176
    connect(m_recordCueButton, SIGNAL(clicked()), this, SLOT(slotRecordCueClicked()));
×
1177

1178
    connect(m_cueStackView->selectionModel(),
×
1179
            SIGNAL(selectionChanged(const QItemSelection&,const QItemSelection&)),
1180
            this, SLOT(slotCueStackSelectionChanged()));
1181
}
×
1182

1183
void SimpleDesk::updateCueStackButtons()
×
1184
{
1185
    //qDebug() << Q_FUNC_INFO;
1186
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1187
    if (cueStack == NULL)
×
1188
        return;
1189

1190
    m_stopCueStackButton->setEnabled(cueStack->isRunning());
×
1191
    m_nextCueButton->setEnabled(cueStack->cues().size() > 0);
×
1192
    m_previousCueButton->setEnabled(cueStack->cues().size() > 0);
×
1193
}
1194

1195
void SimpleDesk::replaceCurrentCue()
×
1196
{
1197
    qDebug() << Q_FUNC_INFO;
1198
    Q_ASSERT(m_selectedPlayback < uint(m_playbackSliders.size()));
1199

1200
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1201
    Q_ASSERT(cueStack != NULL);
1202

1203
    QItemSelectionModel* selectionModel = m_cueStackView->selectionModel();
×
1204
    if (selectionModel->hasSelection() == true)
×
1205
    {
1206
        // Replace current cue values
1207
        QModelIndex index = m_cueStackView->currentIndex();
×
1208
        QString name = cueStack->cues().at(index.row()).name();
×
1209
        Cue cue = m_engine->cue();
×
1210
        cue.setName(name);
×
1211
        cueStack->replaceCue(index.row(), cue);
×
1212
    }
1213
}
×
1214

1215
void SimpleDesk::createSpeedDials()
×
1216
{
1217
    if (m_speedDials != NULL)
×
1218
        return;
1219

1220
    m_speedDials = new SpeedDialWidget(this);
×
1221
    m_speedDials->setAttribute(Qt::WA_DeleteOnClose);
×
1222
    connect(m_speedDials, SIGNAL(fadeInChanged(int)),
×
1223
            this, SLOT(slotFadeInDialChanged(int)));
1224
    connect(m_speedDials, SIGNAL(fadeOutChanged(int)),
×
1225
            this, SLOT(slotFadeOutDialChanged(int)));
1226
    connect(m_speedDials, SIGNAL(holdChanged(int)),
×
1227
            this, SLOT(slotHoldDialChanged(int)));
1228
    connect(m_speedDials, SIGNAL(destroyed(QObject*)),
×
1229
            this, SLOT(slotDialDestroyed(QObject*)));
1230
    connect(m_speedDials, SIGNAL(optionalTextEdited(const QString&)),
×
1231
            this, SLOT(slotCueNameEdited(const QString&)));
1232
    m_speedDials->raise();
×
1233
    m_speedDials->show();
×
1234
}
1235

1236
void SimpleDesk::updateSpeedDials()
×
1237
{
1238
    qDebug() << Q_FUNC_INFO;
1239

1240
    if (m_speedDials == NULL)
×
1241
        return;
×
1242

1243
    Q_ASSERT(m_cueStackView != NULL);
1244
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1245
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1246

1247
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1248
    Q_ASSERT(cueStack != NULL);
1249

1250
    if (selected.size() == 0)
×
1251
    {
1252
        m_speedDials->setEnabled(false);
×
1253

1254
        m_speedDials->setWindowTitle(tr("No selection"));
×
1255
        m_speedDials->setFadeInSpeed(0);
×
1256
        m_speedDials->setFadeOutSpeed(0);
×
1257
        m_speedDials->setDuration(0);
×
1258

1259
        m_speedDials->setOptionalTextTitle(QString());
×
1260
        m_speedDials->setOptionalText(QString());
×
1261
    }
1262
    else if (selected.size() == 1)
×
1263
    {
1264
        m_speedDials->setEnabled(true);
×
1265

1266
        QModelIndex index = selected.first();
×
1267
        Q_ASSERT(index.row() >= 0 && index.row() < cueStack->cues().size());
1268
        Cue cue = cueStack->cues()[index.row()];
×
1269
        m_speedDials->setWindowTitle(cue.name());
×
1270
        m_speedDials->setFadeInSpeed(cue.fadeInSpeed());
×
1271
        m_speedDials->setFadeOutSpeed(cue.fadeOutSpeed());
×
1272
        if ((int)cue.duration() < 0)
×
1273
            m_speedDials->setDuration(cue.duration());
×
1274
        else
1275
            m_speedDials->setDuration(cue.duration() - cue.fadeInSpeed() - cue.fadeOutSpeed());
×
1276

1277
        m_speedDials->setOptionalTextTitle(tr("Cue name"));
×
1278
        m_speedDials->setOptionalText(cue.name());
×
1279
    }
1280
    else
1281
    {
1282
        m_speedDials->setEnabled(true);
×
1283

1284
        m_speedDials->setWindowTitle(tr("Multiple Cues"));
×
1285
        m_speedDials->setFadeInSpeed(0);
×
1286
        m_speedDials->setFadeOutSpeed(0);
×
1287
        m_speedDials->setDuration(0);
×
1288

1289
        m_speedDials->setOptionalTextTitle(QString());
×
1290
        m_speedDials->setOptionalText(QString());
×
1291
    }
1292
}
1293

1294
CueStack* SimpleDesk::currentCueStack() const
×
1295
{
1296
    Q_ASSERT(m_engine != NULL);
1297
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1298
    Q_ASSERT(cueStack != NULL);
1299
    return cueStack;
×
1300
}
1301

1302
int SimpleDesk::currentCueIndex() const
×
1303
{
1304
    Q_ASSERT(m_cueStackView != NULL);
1305
    return m_cueStackView->currentIndex().row();
×
1306
}
1307

1308
void SimpleDesk::slotCueStackStarted(uint stack)
×
1309
{
1310
    qDebug() << Q_FUNC_INFO;
1311
    if (stack != m_selectedPlayback)
×
1312
        return;
1313

1314
    PlaybackSlider* slider = m_playbackSliders[m_selectedPlayback];
×
1315
    Q_ASSERT(slider != NULL);
1316
    if (slider->value() == 0)
×
1317
        slider->setValue(UCHAR_MAX);
×
1318
    updateCueStackButtons();
×
1319
}
1320

1321
void SimpleDesk::slotCueStackStopped(uint stack)
×
1322
{
1323
    qDebug() << Q_FUNC_INFO;
1324
    if (stack != m_selectedPlayback)
×
1325
        return;
1326

1327
    PlaybackSlider* slider = m_playbackSliders[m_selectedPlayback];
×
1328
    Q_ASSERT(slider != NULL);
1329
    if (slider->value() != 0)
×
1330
        slider->setValue(0);
×
1331
    updateCueStackButtons();
×
1332
}
1333

1334
void SimpleDesk::slotCueStackSelectionChanged()
×
1335
{
1336
    qDebug() << Q_FUNC_INFO;
1337

1338
    Q_ASSERT(m_cueStackView != NULL);
1339
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1340
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1341

1342
    updateCueStackButtons();
×
1343

1344
    // Destroy the existing delete icon
1345
    if (m_cueDeleteIconIndex.isValid() == true)
1346
        m_cueStackView->setIndexWidget(m_cueDeleteIconIndex, NULL);
×
1347
    m_cueDeleteIconIndex = QModelIndex();
×
1348

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

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

1396
    updateSpeedDials();
×
1397
}
×
1398

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

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

1415
void SimpleDesk::slotStopCueStackClicked()
×
1416
{
1417
    qDebug() << Q_FUNC_INFO;
1418
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1419
    Q_ASSERT(cueStack != NULL);
1420
    cueStack->stop();
×
1421
}
×
1422

1423
void SimpleDesk::slotCloneCueStackClicked()
×
1424
{
1425
    qDebug() << Q_FUNC_INFO;
1426

1427
    QStringList items;
1428
    for (uint i = 0; i < m_playbacksPerPage; i++)
×
1429
    {
1430
        if (i != m_selectedPlayback)
×
1431
            items << QString::number(i + 1);
×
1432
    }
1433

1434
    bool ok = false;
×
1435
    QString text = QInputDialog::getItem(this, tr("Clone Cue Stack"), tr("Clone To Playback#"),
×
1436
                                         items, 0, false, &ok);
×
1437
    if (ok == false)
×
1438
        return;
×
1439

1440
    uint pb = text.toUInt() - 1;
×
1441
    CueStack* cs = m_engine->cueStack(m_selectedPlayback);
×
1442
    CueStack* clone = m_engine->cueStack(pb);
×
1443
    Q_ASSERT(cs != NULL);
1444
    Q_ASSERT(clone != NULL);
1445

1446
    while (clone->cues().size() > 0)
×
1447
        clone->removeCue(0);
×
1448

1449
    QListIterator <Cue> it(cs->cues());
×
1450
    while (it.hasNext() == true)
×
1451
        clone->appendCue(it.next());
×
1452

1453
    slotSelectPlayback(pb);
×
1454
}
1455

1456
void SimpleDesk::slotDialDestroyed(QObject *)
×
1457
{
1458
    if (m_speedDials != NULL)
×
1459
        m_speedDials->deleteLater();
×
1460
    m_speedDials = NULL;
×
1461
    m_editCueStackButton->setChecked(false);
×
1462
}
×
1463

1464
void SimpleDesk::slotEditCueStackClicked(bool state)
×
1465
{
1466
    qDebug() << Q_FUNC_INFO;
1467

1468
    slotCueStackSelectionChanged();
×
1469

1470
    if (state == true)
×
1471
    {
1472
        createSpeedDials();
×
1473
        updateSpeedDials();
×
1474
    }
1475
    else
1476
    {
1477
        resetUniverseSliders();
×
1478
        if (m_speedDials != NULL)
×
1479
            m_speedDials->deleteLater();
×
1480
        m_speedDials = NULL;
×
1481
    }
1482
}
×
1483

1484
void SimpleDesk::slotRecordCueClicked()
×
1485
{
1486
    qDebug() << Q_FUNC_INFO;
1487
    Q_ASSERT(m_selectedPlayback < uint(m_playbackSliders.size()));
1488

1489
    CueStack* cueStack = m_engine->cueStack(m_selectedPlayback);
×
1490
    Q_ASSERT(cueStack != NULL);
1491

1492
    QItemSelectionModel* selModel = m_cueStackView->selectionModel();
×
1493
    Q_ASSERT(selModel != NULL);
1494
    int index = 0;
1495
    if (selModel->hasSelection() == true)
×
1496
        index = selModel->currentIndex().row() + 1;
×
1497
    else
1498
        index = cueStack->cues().size();
×
1499

1500
    Cue cue = m_engine->cue();
×
1501
    cue.setName(tr("Cue %1").arg(cueStack->cues().size() + 1));
×
1502
    cueStack->insertCue(index, cue);
×
1503

1504
    // Select the newly-created Cue, all columns from 0 to last
1505
    const QAbstractItemModel* itemModel = selModel->model();
×
1506
    Q_ASSERT(itemModel != NULL);
1507
    int firstCol = 0;
1508
    int lastCol = itemModel->columnCount() - 1;
×
1509
    QItemSelection sel(itemModel->index(index, firstCol), itemModel->index(index, lastCol));
×
1510
    selModel->select(sel, QItemSelectionModel::ClearAndSelect);
×
1511
    selModel->setCurrentIndex(itemModel->index(index, firstCol), QItemSelectionModel::Current);
×
1512

1513
    updateCueStackButtons();
×
1514
}
×
1515

1516
void SimpleDesk::slotDeleteCueClicked()
×
1517
{
1518
    Q_ASSERT(m_cueStackView != NULL);
1519
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1520
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1521
    QModelIndex current = m_cueStackView->selectionModel()->currentIndex();
×
1522
    CueStack* cueStack = currentCueStack();
×
1523
    Q_ASSERT(cueStack != NULL);
1524
    QList <int> indexes;
×
1525
    foreach (QModelIndex index, selected)
×
1526
        indexes << index.row();
×
1527
    cueStack->removeCues(indexes);
×
1528

1529
    // Select an item ~at the current index
1530
    QAbstractItemModel* model = m_cueStackView->model();
×
1531
    if (model->hasIndex(current.row(), 0) == true)
×
1532
    {
1533
        m_cueStackView->setCurrentIndex(current);
×
1534
    }
1535
    else if (model->rowCount() != 0)
×
1536
    {
1537
        QModelIndex index = model->index(model->rowCount() - 1, 0);
×
1538
        m_cueStackView->setCurrentIndex(index);
×
1539
    }
1540
}
×
1541

1542
void SimpleDesk::slotFadeInDialChanged(int ms)
×
1543
{
1544
    Q_ASSERT(m_cueStackView != NULL);
1545
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1546
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1547
    CueStack* cueStack = currentCueStack();
×
1548
    foreach (QModelIndex index, selected)
×
1549
        cueStack->setFadeInSpeed(ms, index.row());
×
1550
}
×
1551

1552
void SimpleDesk::slotFadeOutDialChanged(int ms)
×
1553
{
1554
    Q_ASSERT(m_cueStackView != NULL);
1555
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1556
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1557
    CueStack* cueStack = currentCueStack();
×
1558
    foreach (QModelIndex index, selected)
×
1559
        cueStack->setFadeOutSpeed(ms, index.row());
×
1560
}
×
1561

1562
void SimpleDesk::slotHoldDialChanged(int ms)
×
1563
{
1564
    Q_ASSERT(m_cueStackView != NULL);
1565
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1566
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1567
    CueStack* cueStack = currentCueStack();
×
1568
    foreach (QModelIndex index, selected)
×
1569
    {
1570
        if (ms < 0)
×
1571
            cueStack->setDuration(ms, index.row());
×
1572
        else
1573
            cueStack->setDuration(cueStack->fadeInSpeed() + ms + cueStack->fadeOutSpeed(), index.row());
×
1574
    }
1575
}
×
1576

1577
void SimpleDesk::slotCueNameEdited(const QString& name)
×
1578
{
1579
    Q_ASSERT(m_cueStackView != NULL);
1580
    Q_ASSERT(m_cueStackView->selectionModel() != NULL);
1581
    QModelIndexList selected(m_cueStackView->selectionModel()->selectedRows());
×
1582
    CueStack* cueStack = currentCueStack();
×
1583
    if (selected.size() == 1)
×
1584
        cueStack->setName(name, selected.first().row());
×
1585
}
×
1586

1587
void SimpleDesk::showEvent(QShowEvent* ev)
×
1588
{
1589
    if (m_docChanged == true)
×
1590
    {
1591
        if (m_editCueStackButton->isChecked() == true)
×
1592
            slotEditCueStackClicked(true);
×
1593
        initUniversesCombo();
×
1594
        initChannelGroupsView();
×
1595
        m_docChanged = false;
×
1596
    }
1597
    slotUpdateUniverseSliders();
×
1598
    QWidget::showEvent(ev);
×
1599
}
×
1600

1601
void SimpleDesk::hideEvent(QHideEvent* ev)
×
1602
{
1603
    if (m_speedDials != NULL)
×
1604
        m_speedDials->deleteLater();
×
1605
    m_speedDials = NULL;
×
1606
    QWidget::hideEvent(ev);
×
1607
}
×
1608

1609
void SimpleDesk::resizeEvent(QResizeEvent *ev)
×
1610
{
1611
    QWidget::resizeEvent(ev);
×
1612

1613
    QSettings settings;
×
1614
    QVariant var = settings.value(SETTINGS_PAGE_CHANNELS);
×
1615
    QSize newSize = ev->size();
×
1616
    //qDebug() << "Resize event. Frame size:" << newSize;
1617

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

1661
    // check if the value has been forced by the user
1662
    var = settings.value(SETTINGS_PAGE_PLAYBACKS);
×
1663
    if (var.isValid() == true && var.toUInt() > 0)
×
1664
        return;
×
1665

1666
    uint currPlayback = m_playbacksPerPage;
×
1667
    // always have playback sliders to fill half of the window
1668
    m_playbacksPerPage = (newSize.width() / 2) / 42;
×
1669

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

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

1709
}
1710

1711
/****************************************************************************
1712
 * Load & Save
1713
 ****************************************************************************/
1714

1715
bool SimpleDesk::loadXML(QXmlStreamReader &root)
×
1716
{
1717
    Q_ASSERT(m_engine != NULL);
1718

1719
    clearContents();
×
1720

1721
    if (root.name() != KXMLQLCSimpleDesk)
×
1722
    {
1723
        qWarning() << Q_FUNC_INFO << "Simple Desk node not found";
×
1724
        return false;
×
1725
    }
1726

1727
    while (root.readNextStartElement())
×
1728
    {
1729
        if (root.name() == KXMLQLCSimpleDeskEngine)
×
1730
        {
1731
            m_engine->loadXML(root);
×
1732
        }
1733
        else
1734
        {
1735
            qWarning() << Q_FUNC_INFO << "Unrecognized Simple Desk node:" << root.name();
×
1736
            root.skipCurrentElement();
×
1737
        }
1738
    }
1739

1740
    slotSelectPlayback(0);
×
1741

1742
    return true;
×
1743
}
1744

1745
bool SimpleDesk::saveXML(QXmlStreamWriter *doc) const
×
1746
{
1747
    Q_ASSERT(doc != NULL);
1748
    Q_ASSERT(m_engine != NULL);
1749

1750
    doc->writeStartElement(KXMLQLCSimpleDesk);
×
1751

1752
    if (m_engine->saveXML(doc) == false)
×
1753
        return false;
1754

1755
    doc->writeEndElement();
×
1756

1757
    return true;
×
1758
}
1759

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