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

mcallegari / qlcplus / 12612549457

04 Jan 2025 05:54PM UTC coverage: 31.468% (-0.03%) from 31.502%
12612549457

Pull #1649

github

web-flow
Merge 132474303 into 3ed321c32
Pull Request #1649: Function Wizard: create Effects

2 of 53 new or added lines in 2 files covered. (3.77%)

32 existing lines in 1 file now uncovered.

14093 of 44785 relevant lines covered (31.47%)

26791.82 hits per line

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

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

5
  Copyright (C) Heikki Junnila
6

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

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

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

20
#include <QMessageBox>
21
#include <QString>
22
#include <QDebug>
23
#include <QHash>
24
#include <QAction>
25
#include <QSettings>
26

27
#include "palettegenerator.h"
28
#include "fixtureselection.h"
29
#include "functionwizard.h"
30
#include "virtualconsole.h"
31
#include "vcsoloframe.h"
32
#include "vccuelist.h"
33
#include "rgbmatrix.h"
34
#include "efx.h"
35
#include "vcwidget.h"
36
#include "vcbutton.h"
37
#include "vcslider.h"
38
#include "vcxypad.h"
39
#include "vcframe.h"
40
#include "fixture.h"
41
#include "chaser.h"
42
#include "scene.h"
43
#include "doc.h"
44

45
#include "qlcfixturedef.h"
46
#include "qlcfixturehead.h"
47
#include "qlccapability.h"
48
#include "qlcchannel.h"
49
#include "vcframepageshortcut.h"
50

51
#define KFixtureColumnName          0
52
#define KFixtureColumnCaps          1
53
#define KFixtureColumnManufacturer  2
54
#define KFixtureColumnModel         3
55

56
#define KFunctionName               0
57
#define KFunctionOddEven            1
58

59
#define KWidgetName                 0
60

61
#define SETTINGS_GEOMETRY "functionwizard/geometry"
62

63
FunctionWizard::FunctionWizard(QWidget* parent, Doc* doc)
×
64
    : QDialog(parent)
65
    , m_doc(doc)
×
66
{
67
    Q_ASSERT(doc != NULL);
68
    setupUi(this);
×
69

70
    QString trbgSS = "background-color: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0 rgba(0, 0, 0, 0), stop:1 rgba(255, 255, 255, 0));";
×
71
    m_wizardLogo->setStyleSheet(trbgSS);
×
72
    m_introText->setStyleSheet(trbgSS);
×
73

74
    QAction* action = new QAction(this);
×
75
    action->setShortcut(QKeySequence(QKeySequence::Close));
×
76
    connect(action, SIGNAL(triggered(bool)), this, SLOT(reject()));
×
77
    addAction(action);
×
78

79
    m_fixtureTree->sortItems(KFixtureColumnName, Qt::AscendingOrder);
×
80

81
    QSettings settings;
×
82
    QVariant geometrySettings = settings.value(SETTINGS_GEOMETRY);
×
83
    if (geometrySettings.isValid() == true)
×
84
        restoreGeometry(geometrySettings.toByteArray());
×
85

86
    connect(m_nextButton, SIGNAL(clicked()),
×
87
            this, SLOT(slotNextPageClicked()));
88

89
    connect(m_tabWidget, SIGNAL(currentChanged(int)),
×
90
            this, SLOT(slotTabClicked()));
91

92
    checkTabsAndButtons();
×
93
}
×
94

95
FunctionWizard::~FunctionWizard()
×
96
{
97
    QSettings settings;
×
98
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
×
99

100
    m_paletteList.clear();
×
101
}
×
102

103
void FunctionWizard::slotNextPageClicked()
×
104
{
105
    int newIdx = m_tabWidget->currentIndex() + 1;
×
106
    if (newIdx == 4)
×
107
        return;
108

109
    m_tabWidget->setCurrentIndex(newIdx);
×
110
    checkTabsAndButtons();
×
111
}
112

113
void FunctionWizard::slotTabClicked()
×
114
{
115
    checkTabsAndButtons();
×
116
}
×
117

118
void FunctionWizard::accept()
×
119
{
120

121
    foreach (PaletteGenerator *palette, m_paletteList)
×
122
        palette->addToDoc();
×
123

124
    addWidgetsToVirtualConsole();
×
125

126
    m_doc->setModified();
×
127

128
    QDialog::accept();
×
129
}
×
130

131
void FunctionWizard::checkTabsAndButtons()
×
132
{
133
    switch(m_tabWidget->currentIndex())
×
134
    {
135
        case 0:
×
136
        {
137
            m_nextButton->setEnabled(true);
×
138
            m_tabWidget->setTabEnabled(2, false);
×
139
            m_tabWidget->setTabEnabled(3, false);
×
140
        }
141
        break;
×
142
        case 1:
×
143
        {
144
            if (m_allFuncsTree->topLevelItemCount() == 0)
×
145
            {
146
                m_nextButton->setEnabled(false);
×
147
                m_tabWidget->setTabEnabled(2, false);
×
148
            }
149
            else
150
            {
151
                m_nextButton->setEnabled(true);
×
152
                m_tabWidget->setTabEnabled(2, true);
×
153
            }
154
        }
155
        break;
156
        case 2:
×
157
        {
158
            m_nextButton->setEnabled(m_widgetsTree->topLevelItemCount() > 0);            
×
159
        }
160
        break;
×
161
        case 3:
×
162
            m_nextButton->setEnabled(false);
×
163
        break;
×
164
    }
165

166
    // enable VC Widget Page if tree not empty
167
    m_tabWidget->setTabEnabled(3, m_widgetsTree->topLevelItemCount() > 0);
×
168
}
×
169

170
/****************************************************************************
171
 * Fixtures
172
 ****************************************************************************/
173

174
QTreeWidgetItem *FunctionWizard::getFixtureGroupItem(QString manufacturer, QString model)
×
175
{
176
    for (int i = 0; i < m_fixtureTree->topLevelItemCount(); i++)
×
177
    {
178
        QTreeWidgetItem *item = m_fixtureTree->topLevelItem(i);
×
179
        if (item->text(KFixtureColumnManufacturer) == manufacturer &&
×
180
            item->text(KFixtureColumnModel) == model)
×
181
                return item;
×
182
    }
183
    // if we're here then the group doesn't exist. Create it
184
    QTreeWidgetItem* newGrp = new QTreeWidgetItem(m_fixtureTree);
×
185
    newGrp->setText(KFixtureColumnName, tr("%1 group").arg(model));
×
186
    newGrp->setIcon(KFixtureColumnName, QIcon(":/group.png"));
×
187
    newGrp->setText(KFixtureColumnManufacturer, manufacturer);
×
188
    newGrp->setText(KFixtureColumnModel, model);
×
189
    newGrp->setExpanded(true);
×
190
    return newGrp;
×
191
}
192

193
void FunctionWizard::addFixture(quint32 fxi_id)
×
194
{
195
    Fixture* fxi = m_doc->fixture(fxi_id);
×
196
    Q_ASSERT(fxi != NULL);
197

198
    QStringList caps = PaletteGenerator::getCapabilities(fxi);
×
199

200
    if (caps.join(", ").isEmpty())
×
201
    {
202
        QMessageBox::warning(this, tr("Error"), tr("%1 has no capability supported by this wizard.").arg(fxi->name()));
×
203
        return;
204
    }
205
    else
206
    {
207
        QTreeWidgetItem *groupItem = getFixtureGroupItem(fxi->fixtureDef()->manufacturer(), fxi->fixtureDef()->model());
×
208
        Q_ASSERT(groupItem != NULL);
209

210
        QTreeWidgetItem* item = new QTreeWidgetItem(groupItem);
×
211
        item->setText(KFixtureColumnName, fxi->name());
×
212
        item->setIcon(KFixtureColumnName, fxi->getIconFromType());
×
213
        item->setData(KFixtureColumnName, Qt::UserRole, fxi_id);
×
214
        item->setText(KFixtureColumnCaps, caps.join(", "));
×
215
    }
216
    m_fixtureTree->resizeColumnToContents(KFixtureColumnName);
×
217
}
218

219
void FunctionWizard::slotAddClicked()
×
220
{
221
    FixtureSelection fs(this, m_doc);
×
222
    fs.setMultiSelection(true);
×
223
    fs.setDisabledFixtures(fixtureIds());
×
224
    if (fs.exec() == QDialog::Accepted)
×
225
    {
226
        QListIterator <quint32> it(fs.selection());
×
227
        while (it.hasNext() == true)
×
228
            addFixture(it.next());
×
229

230
        if (m_fixtureTree->topLevelItemCount() > 0)
×
231
        {
232
            updateAvailableFunctionsTree();
×
233
            updateWidgetsTree();
×
234
        }
235
    }
236
    checkTabsAndButtons();
×
237
}
×
238

239
void FunctionWizard::slotRemoveClicked()
×
240
{
241
    QListIterator <QTreeWidgetItem*> it(m_fixtureTree->selectedItems());
×
242
    while (it.hasNext() == true)
×
243
        delete it.next();
×
244
    
245
    updateWidgetsTree();
×
246
    checkTabsAndButtons();
×
247
}
×
248

249
void FunctionWizard::slotPageCheckboxChanged()
×
250
{
251
    updateWidgetsTree();
×
252
}
×
253

254
QList <quint32> FunctionWizard::fixtureIds() const
×
255
{
256
    QList <quint32> list;
257
    for (int i = 0; i < m_fixtureTree->topLevelItemCount(); i++)
×
258
    {
259
        QTreeWidgetItem* item(m_fixtureTree->topLevelItem(i));
×
260
        Q_ASSERT(item != NULL);
261

262
        for (int j = 0; j < item->childCount(); j++)
×
263
        {
264
            QTreeWidgetItem *child = item->child(j);
×
265
            Q_ASSERT(child != NULL);
266

267
            list << child->data(KFixtureColumnName, Qt::UserRole).toInt();
×
268
        }
269
    }
270

271
    return list;
×
272
}
273

274
/********************************************************************
275
 * Functions
276
 ********************************************************************/
277

278
void FunctionWizard::addFunctionsGroup(QTreeWidgetItem *fxGrpItem, QTreeWidgetItem *grpItem,
×
279
                                       QString name, PaletteGenerator::PaletteType type)
280
{
281
    if (grpItem == NULL)
×
282
        return;
283

284
    QTreeWidgetItem *item = new QTreeWidgetItem(grpItem);
×
285
    item->setText(KFunctionName, name);
×
286
    item->setCheckState(KFunctionName, Qt::Unchecked);
×
287
    item->setData(KFunctionName, Qt::UserRole, type);
×
288

289
    if (fxGrpItem != NULL && fxGrpItem->childCount() > 1)
×
290
    {
291
        item->setCheckState(KFunctionOddEven, Qt::Unchecked);
×
292
    }
293
}
294

295
void FunctionWizard::updateAvailableFunctionsTree()
×
296
{
297
    disconnect(m_allFuncsTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
×
298
            this, SLOT(slotFunctionItemChanged(QTreeWidgetItem*,int)));
299

300
    m_allFuncsTree->clear();
×
301
    m_resFuncsTree->clear();
×
302

303
    for (int i = 0; i < m_fixtureTree->topLevelItemCount(); i++)
×
304
    {
305
        QTreeWidgetItem *fxGrpItem = m_fixtureTree->topLevelItem(i);
×
306
        Q_ASSERT(fxGrpItem != NULL);
307

308
        if (fxGrpItem->childCount() == 0)
×
309
            continue;
×
310

311
        QTreeWidgetItem *grpItem = new QTreeWidgetItem(m_allFuncsTree);
×
312
        grpItem->setText(KFunctionName, fxGrpItem->text(KFixtureColumnName));
×
313
        grpItem->setIcon(KFunctionName, fxGrpItem->icon(KFixtureColumnName));
×
314
        grpItem->setExpanded(true);
×
315

316
        // since groups contain fixture of the same type, get the first
317
        // child and create categories on its capabilities
318
        QTreeWidgetItem *fxItem = fxGrpItem->child(0);
×
319
        quint32 fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
320
        Fixture* fxi = m_doc->fixture(fxID);
×
321
        Q_ASSERT(fxi != NULL);
322

323
        QStringList caps = PaletteGenerator::getCapabilities(fxi);
×
324

325
        foreach (QString cap, caps)
×
326
        {
327
            if (cap == KQLCChannelRGB || cap == KQLCChannelCMY)
×
328
            {
329
                addFunctionsGroup(fxGrpItem, grpItem,
×
330
                                  PaletteGenerator::typetoString(PaletteGenerator::PrimaryColors),
×
331
                                  PaletteGenerator::PrimaryColors);
NEW
332
                addFunctionsGroup(fxGrpItem, grpItem,
×
NEW
333
                                  PaletteGenerator::typetoString(PaletteGenerator::SixteenColors),
×
334
                                  PaletteGenerator::SixteenColors);
NEW
335
                addFunctionsGroup(fxGrpItem, grpItem,
×
NEW
336
                                  PaletteGenerator::typetoString(PaletteGenerator::Animation),
×
337
                                  PaletteGenerator::Animation);
NEW
338
                addFunctionsGroup(fxGrpItem, grpItem,
×
NEW
339
                                  PaletteGenerator::typetoString(PaletteGenerator::Effect),
×
340
                                  PaletteGenerator::Effect);
341
            }
342
            else if (cap == QLCChannel::groupToString(QLCChannel::Pan))
×
343
            {
344
                addFunctionsGroup(fxGrpItem, grpItem,
×
345
                                  PaletteGenerator::typetoString(PaletteGenerator::Effect),
×
346
                                  PaletteGenerator::Effect);
347
            }
348
            else if (cap == QLCChannel::groupToString(QLCChannel::Gobo))
×
349
                addFunctionsGroup(fxGrpItem, grpItem,
×
350
                                  PaletteGenerator::typetoString(PaletteGenerator::Gobos),
×
351
                                  PaletteGenerator::Gobos);
352
            else if (cap == QLCChannel::groupToString(QLCChannel::Shutter))
×
353
                addFunctionsGroup(fxGrpItem, grpItem,
×
354
                                  PaletteGenerator::typetoString(PaletteGenerator::Shutter),
×
355
                                  PaletteGenerator::Shutter);
356
            else if (cap == QLCChannel::groupToString(QLCChannel::Colour))
×
357
                addFunctionsGroup(fxGrpItem, grpItem,
×
358
                                  PaletteGenerator::typetoString(PaletteGenerator::ColourMacro),
×
359
                                  PaletteGenerator::ColourMacro);
360
        }
361
    }
362

363
    m_allFuncsTree->resizeColumnToContents(KFunctionName);
×
364

365
    connect(m_allFuncsTree, SIGNAL(itemChanged(QTreeWidgetItem*, int)),
×
366
            this, SLOT(slotFunctionItemChanged(QTreeWidgetItem*,int)));
367
}
×
368

369
QTreeWidgetItem *FunctionWizard::getFunctionGroupItem(const Function *func)
×
370
{
371
    for (int i = 0; i < m_resFuncsTree->topLevelItemCount(); i++)
×
372
    {
373
        QTreeWidgetItem *item = m_resFuncsTree->topLevelItem(i);
×
374
        int grpType = item->data(KFunctionName, Qt::UserRole).toInt();
×
375
        if (grpType == func->type())
×
376
            return item;
×
377
    }
378
    // if we're here then the group doesn't exist. Create it
379
    QTreeWidgetItem* newGrp = new QTreeWidgetItem(m_resFuncsTree);
×
380
    newGrp->setText(KFixtureColumnName, Function::typeToString(func->type()));
×
381
    newGrp->setIcon(KFixtureColumnName, func->getIcon());
×
382
    newGrp->setData(KFunctionName, Qt::UserRole, func->type());
×
383
    newGrp->setExpanded(true);
×
384
    return newGrp;
×
385
}
386

387
void FunctionWizard::updateResultFunctionsTree()
×
388
{
389
    m_resFuncsTree->clear();
×
390
    m_paletteList.clear();
×
391

392
    for (int i = 0; i < m_allFuncsTree->topLevelItemCount(); i++)
×
393
    {
394
        QTreeWidgetItem *funcGrpItem = m_allFuncsTree->topLevelItem(i);
×
395
        Q_ASSERT(funcGrpItem != NULL);
396

397
        if (funcGrpItem->childCount() == 0)
×
398
            continue;
×
399

400
        // retrieve the list of fixtures involved in this group
401
        QList <Fixture *> fxList;
×
402
        QTreeWidgetItem *fxiGrpItem = m_fixtureTree->topLevelItem(i);
×
403

404
        for (int f = 0; f < fxiGrpItem->childCount(); f++)
×
405
        {
406
            QTreeWidgetItem *fItem = fxiGrpItem->child(f);
×
407
            quint32 fxID = fItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
408
            Fixture *fixture = m_doc->fixture(fxID);
×
409
            if (fixture != NULL)
×
410
                fxList.append(fixture);
×
411
        }
412

413
        // iterate through the function group children to see which are checked
414
        for (int c = 0; c < funcGrpItem->childCount(); c++)
×
415
        {
416
            QTreeWidgetItem *funcItem = funcGrpItem->child(c);
×
417
            if (funcItem->checkState(KFunctionName) == Qt::Checked)
×
418
            {
419
                int type = funcItem->data(KFunctionName, Qt::UserRole).toInt();
×
420
                int subType = PaletteGenerator::All;
421
                if (funcItem->checkState(KFunctionOddEven) == Qt::Checked)
×
422
                    subType = PaletteGenerator::OddEven;
423
                PaletteGenerator *palette = new PaletteGenerator(m_doc, fxList,
424
                                                                 (PaletteGenerator::PaletteType)type,
425
                                                                 (PaletteGenerator::PaletteSubType)subType);
×
426
                m_paletteList.append(palette);
×
427

428
                foreach (Scene *scene, palette->scenes())
×
429
                {
430
                    QTreeWidgetItem *item = new QTreeWidgetItem(getFunctionGroupItem(scene));
×
431
                    item->setText(KFunctionName, scene->name());
×
432
                    item->setIcon(KFunctionName, scene->getIcon());
×
433
                }
434
                foreach (Chaser *chaser, palette->chasers())
×
435
                {
436
                    QTreeWidgetItem *item = new QTreeWidgetItem(getFunctionGroupItem(chaser));
×
437
                    item->setText(KFunctionName, chaser->name());
×
438
                    item->setIcon(KFunctionName, chaser->getIcon());
×
439
                }
NEW
440
                foreach (RGBMatrix *matrix, palette->matrices())
×
441
                {
NEW
442
                    QTreeWidgetItem *item = new QTreeWidgetItem(getFunctionGroupItem(matrix));
×
NEW
443
                    item->setText(KFunctionName, matrix->name());
×
NEW
444
                    item->setIcon(KFunctionName, matrix->getIcon());
×
445
                }
UNCOV
446
                foreach (EFX *effect, palette->effects())
×
447
                {
448
                    QTreeWidgetItem *item = new QTreeWidgetItem(getFunctionGroupItem(effect));
×
449
                    item->setText(KFunctionName, effect->name());
×
450
                    item->setIcon(KFunctionName, effect->getIcon());
×
451
                }
452
            }
453
        }
454
    }
455
}
×
456

457
void FunctionWizard::slotFunctionItemChanged(QTreeWidgetItem *item, int col)
×
458
{
459
    Q_UNUSED(col)
460
    Q_UNUSED(item)
461

462
    updateResultFunctionsTree();
×
463
    updateWidgetsTree();
×
464

465
    checkTabsAndButtons();
×
466
}
×
467

468
/********************************************************************
469
 * Widgets
470
 ********************************************************************/
471

472
void FunctionWizard::addWidgetItem(QTreeWidgetItem *grpItem, QString name, int type,
×
473
                             QTreeWidgetItem *fxGrpItem, quint32 *channels)
474
{
475
    if (grpItem == NULL)
×
476
        return;
477

478
    QTreeWidgetItem *item = new QTreeWidgetItem(grpItem);
×
479
    item->setText(KWidgetName, name );
×
480
    item->setCheckState(KWidgetName, Qt::Unchecked);
×
481
    item->setData(KWidgetName, Qt::UserRole, type);
×
482
    item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void*)fxGrpItem));
×
483
    item->setData(KWidgetName, Qt::UserRole + 2, QVariant::fromValue(channels[0]));
×
484
    item->setIcon(KWidgetName, VCWidget::typeToIcon(type));
×
485
    if(name.toLower().contains("speed")) item->setIcon(KWidgetName, QIcon(":/knob.png"));
×
486
    
487
}
488

489
void FunctionWizard::checkPanTilt(QTreeWidgetItem *grpItem,
×
490
                            QTreeWidgetItem *fxGrpItem, qint32* channels)
491
{
492
    //Check if all required Channels are set
493
    if (channels[0] < 0) return;
×
494
    if (channels[2] < 0) return;
×
495
    if (channels[1] > 0 && channels[3] < 0) return;
×
496
    
497
    quint32 panTiltChannels[4] = {};
×
498
    for (size_t i = 0; i < 4; i++)
×
499
        panTiltChannels[i] = channels[i];
×
500

501
    addWidgetItem(grpItem, "XY PAD", VCWidget::XYPadWidget, fxGrpItem, panTiltChannels);
×
502

503
    channels[0] = -1;
×
504
    channels[1] = -1;
×
505
    channels[2] = -1;
×
506
    channels[3] = -1;
×
507
}
508

509
void FunctionWizard::checkRGB(QTreeWidgetItem *grpItem, 
×
510
                            QTreeWidgetItem *fxGrpItem, qint32* channels)
511
{
512
    // Check if all required Channels are set
513
    for (size_t i = 0; i < 3; i++) if(channels[i] < 0) return;
×
514

515
    quint32 RGB[3] = {};
×
516
    for (size_t i = 0; i < 3; i++)
×
517
        RGB[i] = channels[i];
×
518

519
    addWidgetItem(grpItem, "RGB - Click & Go", VCWidget::SliderWidget, fxGrpItem, RGB);
×
520

521
    RGB[0] = -1;
522
    RGB[1] = -1;
523
    RGB[2] = -1;
524
}
525

526
void FunctionWizard::addChannelsToTree(QTreeWidgetItem *frame, QTreeWidgetItem *fxGrpItem, QList<quint32> channels)
×
527
{
528
    QTreeWidgetItem *fxItem = fxGrpItem->child(0);
×
529
    quint32 fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
530
    Fixture *fxi = m_doc->fixture(fxID);
×
531
    Q_ASSERT(fxi != NULL);
532

533
    qint32 lastPanTilt[] = {-1, -1, -1, -1};
×
534
    qint32 lastRGB[] = {-1, -1, -1};
×
535

536
    
537
    for (auto &&ch : channels)
×
538
    //for (quint32 ch = 0; ch < fxi->channels(); ch++)
539
    {
NEW
540
        const QLCChannel *channel(fxi->channel(ch));
×
541
        Q_ASSERT(channel != NULL);
542

NEW
543
        switch (channel->group())
×
544
        {
NEW
545
        case QLCChannel::Pan: {
×
NEW
546
            if (channel->preset() == QLCChannel::PositionPan)
×
NEW
547
                lastPanTilt[0] = ch;
×
NEW
548
            if (channel->preset() == QLCChannel::PositionPanFine)
×
NEW
549
                lastPanTilt[1] = ch;
×
550

NEW
551
            checkPanTilt(frame, fxGrpItem, lastPanTilt);
×
552
        }
553
        break;
UNCOV
554
        case QLCChannel::Tilt: {
×
UNCOV
555
            if (channel->preset() == QLCChannel::PositionTilt)
×
UNCOV
556
                lastPanTilt[2] = ch;
×
557
            if (channel->preset() == QLCChannel::PositionTiltFine)
×
UNCOV
558
                lastPanTilt[3] = ch;
×
559

560
            checkPanTilt(frame, fxGrpItem, lastPanTilt);
×
561
        }
562
        break;
563

564
        // Glick & Go's
565
        case QLCChannel::Gobo:
×
566
        case QLCChannel::Shutter:
567
        case QLCChannel::Prism:
568
        case QLCChannel::Beam:
569
        case QLCChannel::Effect:
570
        case QLCChannel::Colour:
571
            addWidgetItem(frame, QLCChannel::groupToString(channel->group()) + " - Click & Go",
×
572
                          VCWidget::SliderWidget, fxGrpItem, &ch);
UNCOV
573
            break;
×
574

UNCOV
575
        case QLCChannel::Intensity: {
×
UNCOV
576
            QLCChannel::PrimaryColour col = channel->colour();
×
577
            switch (col)
578
            {
579
            case QLCChannel::Red: {
×
UNCOV
580
                lastRGB[0] = ch;
×
UNCOV
581
                checkRGB(frame, fxGrpItem, lastRGB);
×
582
            }
583
            break;
UNCOV
584
            case QLCChannel::Green: {
×
585
                lastRGB[1] = ch;
×
UNCOV
586
                checkRGB(frame, fxGrpItem, lastRGB);
×
587
            }
588
            break;
589
            case QLCChannel::Blue: {
×
590
                lastRGB[2] = ch;
×
UNCOV
591
                checkRGB(frame, fxGrpItem, lastRGB);
×
592
            }
593
            break;
594
            default: {
×
595
                addWidgetItem(frame, channel->name() + " - Intensity", VCWidget::SliderWidget,
×
596
                              fxGrpItem, &ch);
597
            }
598
            break;
×
599
            }
600
        }
601
        break;
UNCOV
602
        case QLCChannel::Speed:
×
603
            addWidgetItem(frame,
×
604
                          channel->name() + " - " + QLCChannel::groupToString(channel->group()),
×
605
                          VCWidget::SliderWidget, fxGrpItem, &ch);
UNCOV
606
            break;
×
607
            break;
608
        default:
×
609
            addWidgetItem(frame,
×
UNCOV
610
                          channel->name() + " - " + QLCChannel::groupToString(channel->group()),
×
611
                          VCWidget::SliderWidget, fxGrpItem, &ch);
612
            break;
×
613
            break;
614
        }
615
    }
616
}
×
617

618
void FunctionWizard::updateWidgetsTree()
×
619
{
620
    m_widgetsTree->clear();
×
621

622
    // Populate palette Widgets
623
    foreach (PaletteGenerator *palette, m_paletteList)
×
624
    {
UNCOV
625
        QTreeWidgetItem *frame = new QTreeWidgetItem(m_widgetsTree);
×
626
        frame->setText(KWidgetName, palette->fullName());
×
UNCOV
627
        if (palette->type() == PaletteGenerator::Animation)
×
628
        {
UNCOV
629
            frame->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::SoloFrameWidget));
×
630
            frame->setData(KWidgetName, Qt::UserRole, VCWidget::SoloFrameWidget);
×
631
        }
632
        else
633
        {
634
            frame->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
UNCOV
635
            frame->setData(KWidgetName, Qt::UserRole, VCWidget::FrameWidget);
×
636
        }
637
        frame->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)palette));
×
UNCOV
638
        frame->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
639
        frame->setCheckState(KWidgetName, Qt::Unchecked);
×
640

641
        QTreeWidgetItem *soloFrameItem = NULL;
UNCOV
642
        if (palette->scenes().count() > 0)
×
643
        {
644
            soloFrameItem = new QTreeWidgetItem(frame);
×
UNCOV
645
            soloFrameItem->setText(KWidgetName, tr("Presets solo frame"));
×
UNCOV
646
            soloFrameItem->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::SoloFrameWidget));
×
UNCOV
647
            soloFrameItem->setFlags(soloFrameItem->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
648
            soloFrameItem->setCheckState(KWidgetName, Qt::Unchecked);
×
649
            soloFrameItem->setData(KWidgetName, Qt::UserRole, VCWidget::SoloFrameWidget);
×
650
        }
651
        foreach (Scene *scene, palette->scenes())
×
652
        {
653
            QTreeWidgetItem *item = NULL;
UNCOV
654
            if (soloFrameItem != NULL)
×
UNCOV
655
                item = new QTreeWidgetItem(soloFrameItem);
×
656
            else
UNCOV
657
                item = new QTreeWidgetItem(frame);
×
658
            QString toRemove = " - " + palette->model();
×
659
            item->setText(KWidgetName, scene->name().remove(toRemove));
×
660
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::ButtonWidget));
×
661
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
662
            item->setData(KWidgetName, Qt::UserRole, VCWidget::ButtonWidget);
×
663
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)scene));
×
664

665
        }
UNCOV
666
        foreach (Chaser *chaser, palette->chasers())
×
667
        {
668
            QTreeWidgetItem *item = new QTreeWidgetItem(frame);
×
669
            QString toRemove = " - " + palette->model();
×
UNCOV
670
            item->setText(KWidgetName, chaser->name().remove(toRemove));
×
671
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::CueListWidget));
×
672
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
673
            item->setData(KWidgetName, Qt::UserRole, VCWidget::CueListWidget);
×
674
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)chaser));
×
675
        }
676

677
        foreach (RGBMatrix *matrix, palette->matrices())
×
678
        {
679
            QTreeWidgetItem *item = NULL;
680
            if (soloFrameItem != NULL)
×
UNCOV
681
                item = new QTreeWidgetItem(soloFrameItem);
×
682
            else
683
                item = new QTreeWidgetItem(frame);
×
684
            QString toRemove = " - " + palette->model();
×
685
            item->setText(KWidgetName, matrix->name().remove(toRemove));
×
686
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::ButtonWidget));
×
687
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
688
            item->setData(KWidgetName, Qt::UserRole, VCWidget::ButtonWidget);
×
UNCOV
689
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)matrix));
×
690
        }
691
        foreach (EFX *effect, palette->effects())
×
692
        {
693
            QTreeWidgetItem *item = NULL;
694
            if (soloFrameItem != NULL)
×
695
                item = new QTreeWidgetItem(soloFrameItem);
×
696
            else
697
                item = new QTreeWidgetItem(frame);
×
698
            QString toRemove = " - " + palette->model();
×
699
            item->setText(KWidgetName, effect->name().remove(toRemove));
×
700
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::ButtonWidget));
×
701
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
702
            item->setData(KWidgetName, Qt::UserRole, VCWidget::ButtonWidget);
×
703
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)effect));
×
704
        }
705

706
        if (palette->scenes().count() > 0)
×
707
        {
708
            int pType = palette->type();
×
709
            QTreeWidgetItem *item = new QTreeWidgetItem(frame);
×
710
            if (pType == PaletteGenerator::PrimaryColors ||
×
711
                pType == PaletteGenerator::SixteenColors)
712
                    item->setText(KWidgetName, tr("Click & Go RGB"));
×
713
            else if (pType == PaletteGenerator::Gobos ||
×
714
                     pType == PaletteGenerator::Shutter ||
×
715
                     pType == PaletteGenerator::ColourMacro)
716
                        item->setText(KWidgetName, tr("Click & Go Macro"));
×
717

718
            item->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::SliderWidget));
×
719
            item->setCheckState(KWidgetName, Qt::Unchecked);
×
720
            item->setData(KWidgetName, Qt::UserRole, VCWidget::SliderWidget);
×
721
            Scene *firstScene = palette->scenes().at(0);
×
722
            item->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)firstScene));
×
723
        }
724
    }
725

726
    // Populate Fixture channel Widgets
727
    if (m_checkBoxAll->checkState() == 0 && m_checkBoxHeads->checkState() == 0 &&
×
728
        m_checkBoxFixtures->checkState() == 0)
×
729
        return;
730

731
    for (int i = 0; i < m_fixtureTree->topLevelItemCount(); i++)
×
732
    {
733
        QTreeWidgetItem *fxGrpItem = m_fixtureTree->topLevelItem(i);
×
734
        Q_ASSERT(fxGrpItem != NULL);
735

736
        if (fxGrpItem->childCount() == 0)
×
737
            continue;
×
738

739
        QTreeWidgetItem *frame = new QTreeWidgetItem(m_widgetsTree);
×
740
        frame->setText(KWidgetName, "Channels - " + fxGrpItem->text(KFixtureColumnName));
×
741
        frame->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
742
        frame->setData(KWidgetName, Qt::UserRole, VCWidget::FrameWidget);
×
743
        frame->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)NULL));
×
744
        frame->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
745
        frame->setCheckState(KWidgetName, Qt::Unchecked);
×
746
        frame->setExpanded(true);
×
747

748
        // since groups contain fixture of the same type, get the first
749
        // child and create categories on its capabilities
750
        QTreeWidgetItem *fxItem = fxGrpItem->child(0);
×
751
        quint32 fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toUInt();
×
752
        Fixture* fxi = m_doc->fixture(fxID);
×
753
        Q_ASSERT(fxi != NULL);
754

755
        frame->setData(KWidgetName, Qt::UserRole + 1, QVariant::fromValue((void *)fxi));
×
756

757
        quint8 fixtureCount = fxGrpItem->childCount();
×
758
        quint8 headCount = fxi->heads();
×
759

760
        QList<quint32> headChannels = fxi->head(0).channels();
×
761
        QList<quint32> noHeadChannels;
×
762
        for (size_t i = 0; i < fxi->channels(); i++)
×
763
        {
764
            noHeadChannels.append(i);
×
765
        }
766
        for (int h = 0; h < fxi->heads(); h++)
×
767
        {
768
            for (auto &&ch : fxi->head(h).channels())
×
769
            {
770
                noHeadChannels.removeAll(ch);
×
771
            }
772
        }
773

774
        QList<quint32> allChannels = headChannels;
×
775
        allChannels.append(noHeadChannels);
776

777
        quint16 pageCount = 0;
778
        QString pageName = "%1 Pages - ";
×
779

780
        if (m_checkBoxFixtures->checkState())
×
781
        {
782
            pageName.append("[F]");
×
783
            pageCount = fixtureCount;
×
784
        }
785
        else
786
            fixtureCount = 0;
787
        if (headCount > 1 && m_checkBoxHeads->checkState() == 2)
×
788
        {
789
            if (pageCount > 0)
×
790
            {
791
                pageCount *= headCount;
×
792
                pageName.append("/");
×
793
            }
794
            else
795
                pageCount = headCount;
×
796
            pageName.append("[H]");
×
797
        }
798
        else
799
            headCount = 0;
800

801
        if (pageCount < 2)
×
802
        {
803
            // No Pages
804
            addChannelsToTree(frame, fxGrpItem, allChannels);
×
805
            continue;
×
806
        }
807

808
        if (m_checkBoxAll->checkState() == 2)
×
809
        {
810
            QTreeWidgetItem *page = new QTreeWidgetItem(frame);
×
811
            page->setText(KWidgetName, "Page - All");
×
812
            page->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
813
            page->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
814
            page->setCheckState(KWidgetName, Qt::Unchecked);
×
815
            page->setExpanded(true);
×
816

817
            addChannelsToTree(page, fxGrpItem, allChannels);
×
818
        }
819

820
        pageName = pageName.arg(pageCount);
×
821

822
        QTreeWidgetItem *page = new QTreeWidgetItem(frame);
×
823
        page->setText(KWidgetName, pageName);
×
824
        page->setIcon(KWidgetName, VCWidget::typeToIcon(VCWidget::FrameWidget));
×
825
        page->setData(KWidgetName, Qt::UserRole + 1, fixtureCount); // FixturePageCount
×
826
        page->setData(KWidgetName, Qt::UserRole + 2, headCount);    // HeadPageCount
×
827
        page->setFlags(frame->flags() | Qt::ItemIsUserCheckable | Qt::ItemIsAutoTristate);
×
828
        page->setCheckState(KWidgetName, Qt::Unchecked);
×
829
        page->setExpanded(true);
×
830

831
        addChannelsToTree(page, fxGrpItem,
×
832
                          (headCount > 1 && m_checkBoxHeads->checkState() == 2) ? headChannels
×
833
                                                                                : allChannels);
834
    }
835
}
836

837
VCWidget *FunctionWizard::createWidget(int type, VCWidget *parent, int xpos, int ypos,
×
838
                                       Function *func, int pType, QTreeWidgetItem *fxGrpItem,
839
                                       quint32 chan, qint32 fixtureNr, qint32 headId)
840
{
841
    VirtualConsole *vc = VirtualConsole::instance();
×
842
    VCWidget *widget = NULL;
843

844
    if (parent == NULL)
×
845
        return NULL;
846

847
    switch(type)
×
848
    {
849
        case VCWidget::FrameWidget:
×
850
        {
851
            VCFrame* frame = new VCFrame(parent, m_doc, true);
×
852
            vc->setupWidget(frame, parent);
×
853
            frame->move(QPoint(xpos, ypos));
×
854
            widget = frame;
855
        }
856
        break;
×
857
        case VCWidget::SoloFrameWidget:
×
858
        {
859
            VCSoloFrame* frame = new VCSoloFrame(parent, m_doc, true);
×
860
            vc->setupWidget(frame, parent);
×
861
            frame->move(QPoint(xpos, ypos));
×
862
            widget = frame;
863
        }
864
        break;
×
865
        case VCWidget::ButtonWidget:
×
866
        {
867
            VCButton* button = new VCButton(parent, m_doc);
×
868
            vc->setupWidget(button, parent);
×
869
            button->move(QPoint(xpos, ypos));
×
870
            if (func != NULL)
×
871
                button->setFunction(func->id());
×
872

873
            widget = button;
874
        }
875
        break;
876
        case VCWidget::CueListWidget:
×
877
        {
878
            VCCueList* cuelist = new VCCueList(parent, m_doc);
×
879
            vc->setupWidget(cuelist, parent);
×
880
            cuelist->move(QPoint(xpos, ypos));
×
881
            if (func != NULL)
×
882
                cuelist->setChaser(func->id());
×
883
            cuelist->resize(QSize(300, m_sliderHeightSpin->value()));
×
884

885
            widget = cuelist;
886
        }
887
        break;
×
888
        case VCWidget::SliderWidget:
×
889
        {
890
            VCSlider* slider = new VCSlider(parent, m_doc);
×
891
            vc->setupWidget(slider, parent);
×
892
            slider->move(QPoint(xpos, ypos));
×
893
            // Click & Go Slider in Pallette Frames
894
            if (func != NULL)
×
895
            {
896
                Scene *scene = qobject_cast<Scene*> (func);
897
                foreach (SceneValue scv, scene->values())
×
898
                    slider->addLevelChannel(scv.fxi, scv.channel);
×
899

900
                if (pType == PaletteGenerator::PrimaryColors ||
×
901
                    pType == PaletteGenerator::SixteenColors)
902
                        slider->setClickAndGoType(ClickAndGoWidget::RGB);
×
903
                else
904
                    slider->setClickAndGoType(ClickAndGoWidget::Preset);
×
905
                slider->setSliderMode(VCSlider::Level);
×
906
            }
907
            else
908
            {
909
                // get channel of first Fixture
910
                int fxID = fxGrpItem->child(0)->data(KFixtureColumnName, Qt::UserRole).toInt();
×
911
                Fixture *fixture = m_doc->fixture(fxID);
×
912
                const QLCChannel *channel = fixture->channel(chan);
×
913

914
                bool isRGB = channel->colour()==QLCChannel::Red;
×
915

916
                for (int c = 0; c < fxGrpItem->childCount(); c++)
×
917
                {
918
                    if (fixtureNr >= 0 && c != fixtureNr)
×
919
                        continue;
×
920

921
                    QTreeWidgetItem *fxItem = fxGrpItem->child(c);
×
922
                    int fxi = fxItem->data(KFixtureColumnName, Qt::UserRole).toInt();
×
923
                    Fixture *fixture = m_doc->fixture(fxID);
×
924
                    qint16 chanIndex = fixture->head(0).channels().indexOf(chan);
×
925
                    for (qint32 h = 0; h < fixture->heads(); h++)
×
926
                    {
927
                        if (headId >= 0 && h != headId)
×
928
                            continue;
×
929

930
                        quint32 headChannel = chan;
931
                        if (chanIndex >= 0) // check if channel is in head
×
932
                            headChannel = fixture->head(h).channels().at(chanIndex);
×
933

934
                        slider->addLevelChannel(fxi, headChannel);
×
935
                        if (isRGB)
×
936
                        {
937
                            slider->addLevelChannel(fxi, headChannel + 1);
×
938
                            slider->addLevelChannel(fxi, headChannel + 2);
×
939
                        }
940
                    }
941
                }
942
                
943
                if (isRGB)
×
944
                {
945
                    slider->setClickAndGoType(ClickAndGoWidget::RGB);
×
946
                }
947
                else if (channel->group() == QLCChannel::Intensity)
×
948
                {
949
                    slider->setClickAndGoType(ClickAndGoWidget::None);
×
950
                }
951
                else
952
                {
953
                    slider->setClickAndGoType(ClickAndGoWidget::Preset);
×
954
                }
955
                
956
                if (channel->group() == QLCChannel::Speed)
×
957
                    slider->setWidgetStyle(VCSlider::WKnob);
×
958

959
                if ((fixtureNr >= 0 || headId >= 0) && m_checkBoxAll->checkState() == Qt::Checked)
×
960
                    slider->setChannelsMonitorEnabled(true);
×
961

962
                slider->setSliderMode(VCSlider::Level); 
×
963
            }
964

965
            slider->resize(QSize(m_sliderWidthSpin->value(), m_sliderHeightSpin->value()));
×
966

967
            widget = slider;
968
        }
969
        break;
×
970
        case VCWidget::XYPadWidget:
×
971
        {
972
            VCXYPad* XYPad = new VCXYPad(parent, m_doc);
×
973
            vc->setupWidget(XYPad, parent);
×
974
            XYPad->move(QPoint(xpos, ypos));
×
975

976
            for (int c = 0; c < fxGrpItem->childCount(); c++)
×
977
            {
978
                if (fixtureNr >= 0 && c != fixtureNr)
×
979
                    continue;
×
980

981
                QTreeWidgetItem *fxItem = fxGrpItem->child(c);
×
982
                int fxID = fxItem->data(KFixtureColumnName, Qt::UserRole).toInt();
×
983
                Fixture *fixture = m_doc->fixture(fxID);
×
984
                for (qint32 h = 0; h < fixture->heads(); h++)
×
985
                {
986
                    if (headId >= 0 && h != headId)
×
987
                        continue;
×
988

989
                    VCXYPadFixture fxi = VCXYPadFixture(m_doc);
×
990
                    fxi.setHead(GroupHead(fxID, h));
×
991
                    XYPad->appendFixture(fxi);
×
992
                }
993
            }
994
            XYPad->resize(QSize(m_sliderHeightSpin->value(), m_sliderHeightSpin->value()));
×
995
                      
996
            widget = XYPad;
997
        }
998
        break;
×
999
        default:
1000
        break;
1001
    }
1002

1003
    // Set Function
1004
    if (widget != NULL && func != NULL)
×
1005
    {
1006
        if (func->type() == Function::SceneType && type == VCWidget::ButtonWidget)
×
1007
        {
1008
            Scene *scene = qobject_cast<Scene*> (func);
1009

1010
            if (pType == PaletteGenerator::PrimaryColors ||
×
1011
                pType == PaletteGenerator::SixteenColors ||
×
1012
                pType == PaletteGenerator::ColourMacro)
×
1013
            {
1014
                QColor col = scene->colorValue();
×
1015
                if (col.isValid())
×
1016
                    widget->setBackgroundColor(col);
×
1017
            }
1018
            else if (pType == PaletteGenerator::Gobos)
×
1019
            {
1020
                foreach (SceneValue scv, scene->values())
×
1021
                {
1022
                    Fixture *fixture = m_doc->fixture(scv.fxi);
×
1023
                    if (fixture == NULL)
×
1024
                        continue;
×
1025

1026
                    const QLCChannel* channel(fixture->channel(scv.channel));
×
1027
                    if (channel->group() == QLCChannel::Gobo)
×
1028
                    {
1029
                        QLCCapability *cap = channel->searchCapability(scv.value);
×
1030
                        if (cap->resource(0).isValid())
×
1031
                        {
1032
                            widget->setBackgroundImage(cap->resource(0).toString());
×
1033
                            break;
×
1034
                        }
1035
                    }
1036
                }
1037
            }
1038
        }
1039
    }
1040

1041
    return widget;
1042
}
1043

1044
QSize FunctionWizard::recursiveCreateWidget(QTreeWidgetItem *item, VCWidget *parent, int type)
×
1045
{
1046
    QSize groupSize(100, 50);
×
1047
    int subX = 10, subY = 40;
1048

1049
    for (int c = 0; c < item->childCount(); c++)
×
1050
    {
1051
        QTreeWidgetItem *childItem = item->child(c);
×
1052

1053
        if (childItem->checkState(KWidgetName) == Qt::Checked ||
×
1054
            childItem->checkState(KWidgetName) == Qt::PartiallyChecked)
×
1055
        {
1056
            int cType = childItem->data(KWidgetName, Qt::UserRole).toInt();
×
1057
            Function *func = NULL;
1058
            QTreeWidgetItem *fxGrpItem  = NULL;
1059
            quint32 channel = 0;
1060

1061
            if (type)
×
1062
            {
1063
                func = (Function *) childItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
1064
            }
1065
            else
1066
            {
1067
                fxGrpItem = (QTreeWidgetItem *) childItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
1068
                channel = childItem->data(KWidgetName, Qt::UserRole + 2).toUInt();
×
1069
            }
1070

1071
            if (childItem->text(KWidgetName).contains("Page"))
×
1072
            {
1073
                VCFrame *frame = (VCFrame *)parent;
1074
                frame->setMultipageMode(true);
×
1075

1076
                if (childItem->childCount() > 0)
×
1077
                {
1078
                    if (childItem->text(KWidgetName).contains("All"))
×
1079
                    {
1080
                        // v page v
1081
                        childItem->setData(KWidgetName, Qt::UserRole + 1, -1); // all fixtures
×
1082
                        childItem->setData(KWidgetName, Qt::UserRole + 2, -1); // all heads
×
1083
                        
1084
                        groupSize = recursiveCreateWidget(childItem, parent, type);                         
×
1085
                        // v frame v
1086
                        childItem->parent()->setData(KWidgetName, Qt::UserRole + 3, groupSize);
×
1087
                        frame->shortcuts().at(frame->currentPage())->setName("All");
×
1088
                        frame->setTotalPagesNumber(frame->totalPagesNumber() + 1);
×
1089
                        frame->slotNextPage();
×
1090
                        continue;
×
1091
                    }
1092
                    else
1093
                    {
1094
                        qint32 fxPages = childItem->data(KWidgetName, Qt::UserRole + 1).toInt();
×
1095
                        qint32 headPages = childItem->data(KWidgetName, Qt::UserRole + 2).toInt();
×
1096
                        qint32 f = fxPages ? 0 : -1;
×
1097

1098
                        for (; f < fxPages; f++)
×
1099
                        {
1100
                            qint32 h = headPages ? 0 : -1;
×
1101
                            for (; h < headPages; h++)
×
1102
                            {
1103
                                // page
1104
                                childItem->setData(KWidgetName, Qt::UserRole + 1, f); // fixture
×
1105
                                childItem->setData(KWidgetName, Qt::UserRole + 2, h); // head
×
1106

1107
                                QSize size = recursiveCreateWidget(childItem, parent, type);
×
1108
                                groupSize = childItem->parent()
×
1109
                                                ->data(KWidgetName, Qt::UserRole + 3)
×
1110
                                                .toSize();
×
1111

1112
                                if (size.width() > groupSize.width())
×
1113
                                    groupSize.setWidth(size.width());
1114
                                if (size.height() > groupSize.height())
×
1115
                                    groupSize.setHeight(size.height());
1116

1117
                                QString pageName = "";
×
1118
                                if (f >= 0)
×
1119
                                    pageName.append(QString("F%1").arg(f));
×
1120

1121
                                if (h >= 0)
×
1122
                                    pageName.append(QString("%1H%2").arg((f >= 0) ? "/" : "").arg(h));
×
1123

1124
                                frame->shortcuts().at(frame->currentPage())->setName(pageName);
×
1125
                                frame->setTotalPagesNumber(frame->totalPagesNumber() + 1);
×
1126
                                frame->slotNextPage();
×
1127
                            }
1128
                        }
1129
                        frame->setTotalPagesNumber(frame->totalPagesNumber() - 1);
×
1130
                        frame->slotSetPage(0);
×
1131
                        frame->updatePageCombo();
×
1132
                    }
1133
                }
1134
                continue;
×
1135
            }
1136

1137
            qint32 fxNr = -1;
1138
            qint32 headId = -1;
1139
            if (childItem->parent()->text(KWidgetName).contains("Page"))
×
1140
            {
1141
                fxNr = childItem->parent()->data(KWidgetName, Qt::UserRole + 1).toInt();
×
1142
                headId = childItem->parent()->data(KWidgetName, Qt::UserRole + 2).toInt();
×
1143
            }
1144

1145
            VCWidget *childWidget = createWidget(cType, parent, subX, subY, func, type, fxGrpItem,
×
1146
                                                 channel, fxNr, headId);
1147
            if (childWidget != NULL)
×
1148
            {
1149
                if (childWidget->type() == VCWidget::SliderWidget)
×
1150
                    childWidget->setCaption(childItem->text(KWidgetName).split(" - ")[0]);
×
1151
                else
1152
                    childWidget->setCaption(childItem->text(KWidgetName));
×
1153

1154
                //qDebug() << childItem->text(KWidgetName);
1155
                //qDebug << "p:"<<parent->type() << " spin:" << m_lineCntSpin->value() << " per:" <<wPerLine << Qt::endl;
1156

1157
                if (childItem->childCount() > 0)
×
1158
                {
1159
                    childWidget->resize(QSize(2000, 1000));
×
1160
                    QSize size = recursiveCreateWidget(childItem, childWidget, type);
×
1161
                    childWidget->resize(size);
×
1162
                }
1163

1164
                if (subX + childWidget->width() > groupSize.width())
×
1165
                    groupSize.setWidth(subX + childWidget->width() + 10);
×
1166
                if (subY + childWidget->height() > groupSize.height())
×
1167
                    groupSize.setHeight(subY + childWidget->height() + 10);
×
1168

1169
                int wPerLine = parent->type() == VCWidget::SoloFrameWidget ? 4 : m_lineCntSpin->value();
×
1170
                if (c > 0 && (c + 1)%wPerLine == 0)
×
1171
                {
1172
                    subX = 10;
1173
                    subY += childWidget->height() + 10;
×
1174
                }
1175
                else
1176
                    subX += childWidget->width() + 10;
×
1177
            }
1178
        }
1179
    }
1180

1181
    return groupSize;
×
1182
}
1183

1184
void FunctionWizard::addWidgetsToVirtualConsole()
×
1185
{
1186
    int xPos = 10;
1187
    int yPos = 10;
1188

1189
    VirtualConsole *vc = VirtualConsole::instance();
×
1190
    VCFrame *mainFrame = vc->contents();
×
1191
    Q_ASSERT(mainFrame != NULL);
1192

1193
    for (int i = 0; i < m_widgetsTree->topLevelItemCount(); i++)
×
1194
    {
1195
        QTreeWidgetItem *wItem = m_widgetsTree->topLevelItem(i);
×
1196

1197
        if (wItem->checkState(KWidgetName) == Qt::Checked ||
×
1198
            wItem->checkState(KWidgetName) == Qt::PartiallyChecked)
×
1199
        {
1200
            int wType = wItem->data(KWidgetName, Qt::UserRole).toInt();
×
1201
            VCWidget *widget = createWidget(wType, mainFrame, xPos, yPos);
×
1202
            if (widget == NULL)
×
1203
                continue;
×
1204

1205
            widget->resize(QSize(2000, 1000));
×
1206

1207
            int pType = 0;
1208
            if (!wItem->text(KWidgetName).contains("Channels"))
×
1209
            {
1210
                PaletteGenerator *pal = (PaletteGenerator *) wItem->data(KWidgetName, Qt::UserRole + 1).value<void *>();
×
1211
                pType = pal->type();
×
1212
            }
1213

1214
            widget->setCaption(wItem->text(KWidgetName));
×
1215

1216
            QSize size = recursiveCreateWidget(wItem, widget, pType);
×
1217

1218
            widget->resize(size);
×
1219
            xPos += widget->width() + 10;
×
1220
        }
1221
    }
1222
}
×
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