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

mcallegari / qlcplus / 6683238402

29 Oct 2023 12:10PM UTC coverage: 28.07%. Remained the same
6683238402

push

github

mcallegari
engine: fix build

15385 of 54809 relevant lines covered (28.07%)

20267.63 hits per line

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

0.0
/ui/src/virtualconsole/vcaudiotriggers.cpp
1
/*
2
  Q Light Controller Plus
3
  vcaudiotriggers.cpp
4

5
  Copyright (c) Massimo Callegari
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 <QXmlStreamReader>
21
#include <QXmlStreamWriter>
22
#include <QMessageBox>
23
#include <QSettings>
24
#include <QDebug>
25

26
#include "vcaudiotriggersproperties.h"
27
#include "vcpropertieseditor.h"
28
#include "vcaudiotriggers.h"
29
#include "audiocapture.h"
30
#include "genericfader.h"
31
#include "fadechannel.h"
32
#include "universe.h"
33
#include "audiobar.h"
34
#include "apputil.h"
35
#include "doc.h"
36

37
#define KXMLQLCVCATKey          QString("Key")
38
#define KXMLQLCVCATBarsNumber   QString("BarsNumber")
39

40
#define KXMLQLCVolumeBar    QString("VolumeBar")
41
#define KXMLQLCSpectrumBar  QString("SpectrumBar")
42

43
const QSize VCAudioTriggers::defaultSize(QSize(300, 200));
44

45
VCAudioTriggers::VCAudioTriggers(QWidget* parent, Doc* doc)
×
46
    : VCWidget(parent, doc)
47
    , m_hbox(NULL)
48
    , m_button(NULL)
49
    , m_label(NULL)
50
    , m_spectrum(NULL)
51
    , m_volumeSlider(NULL)
52
    , m_inputCapture(NULL)
×
53
{
54
    /* Set the class name "VCAudioTriggers" as the object name as well */
55
    setObjectName(VCAudioTriggers::staticMetaObject.className());
×
56

57
    setType(VCWidget::AudioTriggersWidget);
×
58
    setFrameStyle(KVCFrameStyleSunken);
×
59

60
    new QVBoxLayout(this);
×
61

62
    /* Main HBox */
63
    m_hbox = new QHBoxLayout();
×
64
    m_hbox->setGeometry(QRect(0, 0, 300, 40));
×
65

66
    layout()->setSpacing(2);
×
67
    layout()->setContentsMargins(4, 4, 4, 4);
×
68
    layout()->addItem(m_hbox);
×
69

70
    m_button = new QToolButton(this);
×
71
    m_button->setStyle(AppUtil::saneStyle());
×
72
    m_button->setIconSize(QSize(32, 32));
×
73
    m_button->setMinimumSize(QSize(32, 32));
×
74
    m_button->setMaximumSize(QSize(32, 32));
×
75
    m_button->setIcon(QIcon(":/check.png"));
×
76
    m_button->setCheckable(true);
×
77
    QString btnSS = "QToolButton { background-color: #E0DFDF; border: 1px solid gray; border-radius: 3px; padding: 3px; } ";
×
78
    btnSS += "QToolButton:checked { background-color: #D7DE75; border: 1px solid gray; border-radius: 3px; padding: 3px; } ";
×
79
    m_button->setStyleSheet(btnSS);
×
80
    m_button->setEnabled(false);
×
81

82
    m_hbox->addWidget(m_button);
×
83
    connect(m_button, SIGNAL(toggled(bool)), this, SLOT(slotEnableButtonToggled(bool)));
×
84

85
    m_label = new QLabel(this);
×
86
    m_label->setText(this->caption());
×
87
    QString txtColor = "white";
×
88
    if (m_hasCustomForegroundColor)
×
89
        txtColor = this->foregroundColor().name();
×
90
    m_label->setStyleSheet("QLabel { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #345D27, stop: 1 #0E1A0A); "
×
91
                           "color: " + txtColor + "; border-radius: 3px; padding: 3px; margin-left: 2px; }");
×
92

93
    if (m_hasCustomFont)
×
94
        m_label->setFont(font());
×
95
    else
96
    {
97
        QFont m_font = QApplication::font();
×
98
        m_font.setBold(true);
×
99
        m_font.setPixelSize(12);
×
100
        m_label->setFont(m_font);
×
101
    }
102
    m_hbox->addWidget(m_label);
×
103

104
    QSharedPointer<AudioCapture> capture(m_doc->audioInputCapture());
×
105
    m_inputCapture = capture.data();
×
106

107
    // create the  AudioBar items to hold the spectrum data.
108
    // To be loaded from the project
109
    m_volumeBar = new AudioBar(AudioBar::None, 0, id());
×
110
    for (int i = 0; i < m_inputCapture->defaultBarsNumber(); i++)
×
111
    {
112
        AudioBar *asb = new AudioBar(AudioBar::None, 0, id());
×
113
        m_spectrumBars.append(asb);
×
114
    }
115

116
    QHBoxLayout *hbox2 = new QHBoxLayout();
×
117
    m_volumeSlider = new ClickAndGoSlider(this);
×
118
    m_volumeSlider->setOrientation(Qt::Vertical);
×
119
    m_volumeSlider->setRange(0, 100);
×
120
    m_volumeSlider->setSliderStyleSheet(CNG_DEFAULT_STYLE);
×
121
    m_volumeSlider->setValue(100);
×
122
    m_volumeSlider->setFixedWidth(32);
×
123
    m_volumeSlider->setEnabled(false);
×
124

125
    connect(m_volumeSlider, SIGNAL(valueChanged(int)),
×
126
            this, SLOT(slotVolumeChanged(int)));
127

128
    m_spectrum = new AudioTriggerWidget(this);
×
129
    m_spectrum->setBarsNumber(m_inputCapture->defaultBarsNumber());
×
130
    m_spectrum->setMaxFrequency(AudioCapture::maxFrequency());
×
131
    m_spectrum->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
×
132

133
    layout()->addItem(hbox2);
×
134
    hbox2->addWidget(m_spectrum);
×
135
    hbox2->addWidget(m_volumeSlider);
×
136

137
    /* Initial size */
138
    QSettings settings;
×
139
    QVariant var = settings.value(SETTINGS_AUDIOTRIGGERS_SIZE);
×
140
    if (var.isValid() == true)
×
141
        resize(var.toSize());
×
142
    else
143
        resize(defaultSize);
×
144

145
    slotModeChanged(m_doc->mode());
×
146
}
×
147

148
VCAudioTriggers::~VCAudioTriggers()
×
149
{
150
    QSharedPointer<AudioCapture> capture(m_doc->audioInputCapture());
×
151

152
    if (m_inputCapture == capture.data())
×
153
        m_inputCapture->unregisterBandsNumber(m_spectrum->barsNumber());
×
154
}
×
155

156
void VCAudioTriggers::enableWidgetUI(bool enable)
×
157
{
158
    if (m_button)
×
159
        m_button->setEnabled(enable);
×
160

161
    m_volumeSlider->setEnabled(enable);
×
162
}
×
163

164
void VCAudioTriggers::notifyFunctionStarting(quint32 fid, qreal intensity)
×
165
{
166
    // Stop on any other function started
167
    Q_UNUSED(fid);
168
    Q_UNUSED(intensity);
169
    if (m_button->isChecked() == true)
×
170
        enableCapture(false);
×
171
}
×
172

173
void VCAudioTriggers::enableCapture(bool enable)
×
174
{
175
    // in case the audio input device has been changed in the meantime...
176
    QSharedPointer<AudioCapture> capture(m_doc->audioInputCapture());
×
177
    bool captureIsNew = m_inputCapture != capture.data();
×
178
    m_inputCapture = capture.data();
×
179

180
    if (enable == true)
×
181
    {
182
        connect(m_inputCapture, SIGNAL(dataProcessed(double*,int,double,quint32)),
×
183
                this, SLOT(slotDisplaySpectrum(double*,int,double,quint32)));
184
        m_inputCapture->registerBandsNumber(m_spectrum->barsNumber());
×
185

186
        m_button->blockSignals(true);
×
187
        m_button->setChecked(true);
×
188
        m_button->blockSignals(false);
×
189

190
        emit captureEnabled(true);
×
191

192
        // Invalid ID: Stop every other widget
193
        emit functionStarting(Function::invalidId());
×
194
    }
195
    else
196
    {
197
        if (!captureIsNew)
×
198
        {
199
            m_inputCapture->unregisterBandsNumber(m_spectrum->barsNumber());
×
200
            disconnect(m_inputCapture, SIGNAL(dataProcessed(double*,int,double,quint32)),
×
201
                       this, SLOT(slotDisplaySpectrum(double*,int,double,quint32)));
202
        }
203

204
        m_button->blockSignals(true);
×
205
        m_button->setChecked(false);
×
206
        m_button->blockSignals(false);
×
207

208
        emit captureEnabled(false);
×
209
    }
210
}
×
211

212
void VCAudioTriggers::toggleEnableButton(bool toggle)
×
213
{
214
    if (mode() == Doc::Design)
×
215
        return;
×
216

217
    if (m_button)
×
218
        m_button->setChecked(toggle);
×
219
}
220

221
void VCAudioTriggers::slotEnableButtonToggled(bool toggle)
×
222
{
223
    if (mode() == Doc::Design)
×
224
        return;
×
225

226
    enableCapture(toggle);
×
227
}
228

229
void VCAudioTriggers::slotDisplaySpectrum(double *spectrumBands, int size,
×
230
                                          double maxMagnitude, quint32 power)
231
{
232
    qDebug() << "Display spectrum ----- bars:" << size;
×
233
    if (size != m_spectrum->barsNumber())
×
234
        return;
×
235

236
    m_spectrum->displaySpectrum(spectrumBands, maxMagnitude, power);
×
237
    m_volumeBar->m_value = m_spectrum->getUcharVolume();
×
238

239
    if (mode() == Doc::Design)
×
240
        return;
×
241

242
    if (m_volumeBar->m_type == AudioBar::FunctionBar)
×
243
        m_volumeBar->checkFunctionThresholds(m_doc);
×
244
    else if (m_volumeBar->m_type == AudioBar::VCWidgetBar)
×
245
        m_volumeBar->checkWidgetFunctionality();
×
246

247
    for (int i = 0; i < m_spectrumBars.count(); i++)
×
248
    {
249
        m_spectrumBars[i]->m_value = m_spectrum->getUcharBand(i);
×
250
        if (m_spectrumBars[i]->m_type == AudioBar::FunctionBar)
×
251
            m_spectrumBars[i]->checkFunctionThresholds(m_doc);
×
252
        else if (m_spectrumBars[i]->m_type == AudioBar::VCWidgetBar)
×
253
            m_spectrumBars[i]->checkWidgetFunctionality();
×
254
    }
255
}
256

257
#if QT_VERSION >= 0x050000
258
void VCAudioTriggers::slotVolumeChanged(int volume)
×
259
{
260
    m_doc->audioInputCapture()->setVolume(intensity() * (qreal)volume / 100);
×
261
}
×
262
#endif
263

264
/*********************************************************************
265
 * DMXSource
266
 *********************************************************************/
267

268
void VCAudioTriggers::writeDMX(MasterTimer *timer, QList<Universe *> universes)
×
269
{
270
    Q_UNUSED(timer);
271

272
    if (mode() == Doc::Design)
×
273
        return;
×
274

275
    quint32 lastUniverse = Universe::invalid();
×
276
    QSharedPointer<GenericFader> fader;
×
277

278
    if (m_volumeBar->m_type == AudioBar::DMXBar)
×
279
    {
280
        for (int i = 0; i < m_volumeBar->m_absDmxChannels.count(); i++)
×
281
        {
282
            int absAddress = m_volumeBar->m_absDmxChannels.at(i);
×
283
            //quint32 address = absAddress & 0x01FF;
284
            quint32 universe = absAddress >> 9;
×
285
            if (universe != lastUniverse)
×
286
            {
287
                fader = m_fadersMap.value(universe, QSharedPointer<GenericFader>());
×
288
                if (fader.isNull())
×
289
                {
290
                    fader = universes[universe]->requestFader();
×
291
                    fader->adjustIntensity(intensity());
×
292
                    m_fadersMap[universe] = fader;
×
293
                }
294
                lastUniverse = universe;
×
295
                fader->setEnabled(m_button->isChecked() ? true : false);
×
296
            }
297

298
            FadeChannel *fc = fader->getChannelFader(m_doc, universes[universe], Fixture::invalidId(), absAddress);           
×
299
            fc->setStart(fc->current());
×
300
            fc->setTarget(m_volumeBar->m_value);
×
301
            fc->setReady(false);
×
302
            fc->setElapsed(0);
×
303
        }
304
    }
305
    foreach(AudioBar *sb, m_spectrumBars)
×
306
    {
307
        if (sb->m_type == AudioBar::DMXBar)
×
308
        {
309
            for (int i = 0; i < sb->m_absDmxChannels.count(); i++)
×
310
            {
311
                int absAddress = sb->m_absDmxChannels.at(i);
×
312
                //quint32 address = absAddress & 0x01FF;
313
                quint32 universe = absAddress >> 9;
×
314
                if (universe != lastUniverse)
×
315
                {
316
                    fader = m_fadersMap.value(universe, QSharedPointer<GenericFader>());
×
317
                    if (fader == NULL)
×
318
                    {
319
                        fader = universes[universe]->requestFader();
×
320
                        fader->adjustIntensity(intensity());
×
321
                        m_fadersMap[universe] = fader;
×
322
                    }
323
                    fader->setEnabled(m_button->isChecked() ? true : false);
×
324
                    lastUniverse = universe;
×
325
                }
326

327
                FadeChannel *fc = fader->getChannelFader(m_doc, universes[universe], Fixture::invalidId(), absAddress);
×
328
                fc->setStart(fc->current());
×
329
                fc->setTarget(sb->m_value);
×
330
                fc->setReady(false);
×
331
                fc->setElapsed(0);
×
332
            }
333
        }
334
    }
335
}
336

337
/*********************************************************************
338
 * Key sequence handler
339
 *********************************************************************/
340

341
void VCAudioTriggers::setKeySequence(const QKeySequence& keySequence)
×
342
{
343
    m_keySequence = QKeySequence(keySequence);
×
344
}
×
345

346
QKeySequence VCAudioTriggers::keySequence() const
×
347
{
348
    return m_keySequence;
×
349
}
350

351
void VCAudioTriggers::slotKeyPressed(const QKeySequence& keySequence)
×
352
{
353
    if (acceptsInput() == false)
×
354
        return;
×
355

356
    if (m_keySequence == keySequence)
×
357
    {
358
        if (m_button->isChecked())
×
359
            slotEnableButtonToggled(false);
×
360
        else
361
            slotEnableButtonToggled(true);
×
362
    }
363
}
364

365
void VCAudioTriggers::slotInputValueChanged(quint32 universe, quint32 channel, uchar value)
×
366
{
367
    /* Don't let input data through in design mode or if disabled */
368
    if (acceptsInput() == false)
×
369
        return;
×
370

371
    if (checkInputSource(universe, (page() << 16) | channel, value, sender()) && value > 0)
×
372
    {
373
        if (m_button->isChecked())
×
374
            slotEnableButtonToggled(false);
×
375
        else
376
            slotEnableButtonToggled(true);
×
377
    }
378
}
379

380
/*********************************************************************
381
 * Clipboard
382
 *********************************************************************/
383

384
VCWidget *VCAudioTriggers::createCopy(VCWidget *parent)
×
385
{
386
    Q_ASSERT(parent != NULL);
×
387

388
    VCAudioTriggers* triggers = new VCAudioTriggers(parent, m_doc);
×
389
    if (triggers->copyFrom(this) == false)
×
390
    {
391
        delete triggers;
×
392
        triggers = NULL;
×
393
    }
394

395
    return triggers;
×
396
}
397

398
bool VCAudioTriggers::copyFrom(const VCWidget *widget)
×
399
{
400
    const VCAudioTriggers* triggers = qobject_cast <const VCAudioTriggers*> (widget);
×
401
    if (triggers == NULL)
×
402
        return false;
×
403

404
    /* TODO: Copy triggers-specific stuff */
405

406
    /* Copy common stuff */
407
    return VCWidget::copyFrom(widget);
×
408
}
409

410

411
/*************************************************************************
412
 * VCWidget-inherited
413
 *************************************************************************/
414

415
void VCAudioTriggers::setCaption(const QString &text)
×
416
{
417
    if (m_label != NULL)
×
418
        m_label->setText(text);
×
419

420
    VCWidget::setCaption(text);
×
421
}
×
422

423
void VCAudioTriggers::setForegroundColor(const QColor &color)
×
424
{
425
    if (m_label != NULL)
×
426
    {
427
        m_label->setStyleSheet("QLabel { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #345D27, stop: 1 #0E1A0A); "
×
428
                               "color: " + color.name() + "; border-radius: 3px; padding: 3px; margin-left: 2px; }");
×
429
        m_hasCustomForegroundColor = true;
×
430
        m_doc->setModified();
×
431
    }
432
}
×
433

434
QColor VCAudioTriggers::foregroundColor() const
×
435
{
436
    if (m_label != NULL)
×
437
        return m_label->palette().color(m_label->foregroundRole());
×
438
    else
439
        return VCWidget::foregroundColor();
×
440
}
441

442
void VCAudioTriggers::slotModeChanged(Doc::Mode mode)
×
443
{
444
    if (mode == Doc::Operate)
×
445
    {
446
        enableWidgetUI(true);
×
447

448
        foreach(AudioBar *bar, getAudioBars())
×
449
        {
450
            if (bar->m_type == AudioBar::DMXBar)
×
451
            {
452
                m_doc->masterTimer()->registerDMXSource(this);
×
453
                break;
×
454
            }
455
        }
456
    }
457
    else
458
    {
459
        enableWidgetUI(false);
×
460
        enableCapture(false);
×
461
        m_doc->masterTimer()->unregisterDMXSource(this);
×
462

463
        // request to delete all the active faders
464
        foreach (QSharedPointer<GenericFader> fader, m_fadersMap.values())
×
465
        {
466
            if (!fader.isNull())
×
467
                fader->requestDelete();
×
468
        }
469
        m_fadersMap.clear();
×
470
    }
471
    VCWidget::slotModeChanged(mode);
×
472
}
×
473

474
/*************************************************************************
475
 * Configuration
476
 *************************************************************************/
477

478
AudioBar *VCAudioTriggers::getSpectrumBar(int index)
×
479
{
480
    if (index == volumeBarIndex())
×
481
        return m_volumeBar;
×
482
    if (index >= 0 && index < m_spectrumBars.size())
×
483
        return m_spectrumBars.at(index);
×
484

485
    return NULL;
×
486
}
487

488
QList<AudioBar *> VCAudioTriggers::getAudioBars()
×
489
{
490
    QList <AudioBar *> list;
×
491
    list.append(m_volumeBar);
×
492
    list.append(m_spectrumBars);
×
493

494
    return list;
×
495
}
496

497
void VCAudioTriggers::setSpectrumBarsNumber(int num)
×
498
{
499
    if (num > m_spectrumBars.count())
×
500
    {
501
        int barsToAdd = num - m_spectrumBars.count();
×
502
        for (int i = 0 ; i < barsToAdd; i++)
×
503
        {
504
            AudioBar *asb = new AudioBar(AudioBar::None, 0, id());
×
505
            m_spectrumBars.append(asb);
×
506
        }
507
    }
508
    else if (num < m_spectrumBars.count())
×
509
    {
510
        int barsToRemove = m_spectrumBars.count() - num;
×
511
        for (int i = 0 ; i < barsToRemove; i++)
×
512
            m_spectrumBars.removeLast();
×
513
    }
514

515
    if (m_spectrum != NULL)
×
516
        m_spectrum->setBarsNumber(num);
×
517
}
×
518

519
void VCAudioTriggers::setSpectrumBarType(int index, int type)
×
520
{
521
    if (index == volumeBarIndex())
×
522
    {
523
        m_volumeBar->setType(type);
×
524
        return;
×
525
    }
526
    if (index >= 0 && index < m_spectrumBars.size())
×
527
    {
528
        m_spectrumBars[index]->setType(type);
×
529
    }
530
}
531

532

533
void VCAudioTriggers::editProperties()
×
534
{
535
    // make a backup copy of the current bars
536
    AudioBar *tmpVolume = m_volumeBar->createCopy();
×
537
    QList <AudioBar *> tmpSpectrumBars;
×
538
    foreach(AudioBar *bar, m_spectrumBars)
×
539
        tmpSpectrumBars.append(bar->createCopy());
×
540
    int barsNumber = m_spectrumBars.count();
×
541

542
    AudioTriggersConfiguration atc(this, m_doc, barsNumber,
543
                                   AudioCapture::maxFrequency());
×
544

545
    if (atc.exec() == QDialog::Rejected)
×
546
    {
547
        // restore the previous bars backup
548
        delete m_volumeBar;
×
549
        m_volumeBar = tmpVolume;
×
550
        m_spectrumBars.clear();
×
551
        foreach(AudioBar *bar, tmpSpectrumBars)
×
552
            m_spectrumBars.append(bar);
×
553
    }
554
    m_spectrum->setBarsNumber(m_spectrumBars.count());
×
555
    if (barsNumber != m_spectrumBars.count())
×
556
    {
557
        QSharedPointer<AudioCapture> capture(m_doc->audioInputCapture());
×
558
        bool captureIsNew = m_inputCapture != capture.data();
×
559
        m_inputCapture = capture.data();
×
560

561
        if (m_button->isChecked())
×
562
        {
563
            if (!captureIsNew)
×
564
                m_inputCapture->unregisterBandsNumber(barsNumber);
×
565
            m_inputCapture->registerBandsNumber(m_spectrumBars.count());
×
566
            if (captureIsNew)
×
567
                connect(m_inputCapture, SIGNAL(dataProcessed(double*,int,double,quint32)),
×
568
                        this, SLOT(slotDisplaySpectrum(double*,int,double,quint32)));
569
        }
570
    }
571
}
×
572

573

574
void VCAudioTriggers::adjustIntensity(qreal val)
×
575
{
576
    VCWidget::adjustIntensity(val);
×
577
    slotVolumeChanged(m_volumeSlider->value());
×
578
}
×
579

580
/*********************************************************************
581
 * Load & Save
582
 *********************************************************************/
583

584
bool VCAudioTriggers::loadXML(QXmlStreamReader &root)
×
585
{
586
    if (root.name() != KXMLQLCVCAudioTriggers)
×
587
    {
588
        qWarning() << Q_FUNC_INFO << "Audio Triggers node not found";
×
589
        return false;
×
590
    }
591
    if (root.attributes().hasAttribute(KXMLQLCVCATBarsNumber))
×
592
    {
593
        int barsNum = root.attributes().value(KXMLQLCVCATBarsNumber).toString().toInt();
×
594
        setSpectrumBarsNumber(barsNum);
×
595
    }
596

597
    /* Widget commons */
598
    loadXMLCommon(root);
×
599

600
    /* Children */
601
    while (root.readNextStartElement())
×
602
    {
603
        //qDebug() << "VC Audio triggers tag:" << root.name();
604
        QXmlStreamAttributes attrs = root.attributes();
×
605

606
        if (root.name() == KXMLQLCWindowState)
×
607
        {
608
            int x = 0, y = 0, w = 0, h = 0;
×
609
            bool visible = false;
×
610
            loadXMLWindowState(root, &x, &y, &w, &h, &visible);
×
611
            setGeometry(x, y, w, h);
×
612
        }
613
        else if (root.name() == KXMLQLCVCWidgetAppearance)
×
614
        {
615
            loadXMLAppearance(root);
×
616
        }
617
        else if (root.name() == KXMLQLCVCWidgetInput)
×
618
        {
619
            loadXMLInput(root);
×
620
        }
621
        else if (root.name() == KXMLQLCVCATKey)
×
622
        {
623
            setKeySequence(stripKeySequence(QKeySequence(root.readElementText())));
×
624
        }
625
        else if (root.name() == KXMLQLCVolumeBar)
×
626
        {
627
            m_volumeBar->loadXML(root, m_doc);
×
628
        }
629
        else if (root.name() == KXMLQLCSpectrumBar)
×
630
        {
631
            if (attrs.hasAttribute(KXMLQLCAudioBarIndex))
×
632
            {
633
                int idx = attrs.value(KXMLQLCAudioBarIndex).toString().toInt();
×
634
                if (idx >= 0 && idx < m_spectrumBars.count())
×
635
                    m_spectrumBars[idx]->loadXML(root, m_doc);
×
636
            }
637
        }
638
        else
639
        {
640
            qWarning() << Q_FUNC_INFO << "Unknown audio triggers tag:" << root.name().toString();
×
641
            root.skipCurrentElement();
×
642
        }
643
    }
644

645
    return true;
×
646
}
647

648
bool VCAudioTriggers::saveXML(QXmlStreamWriter *doc)
×
649
{
650
    Q_ASSERT(doc != NULL);
×
651

652
    /* VC button entry */
653
    doc->writeStartElement(KXMLQLCVCAudioTriggers);
×
654
    doc->writeAttribute(KXMLQLCVCATBarsNumber, QString::number(m_spectrumBars.count()));
×
655

656
    saveXMLCommon(doc);
×
657

658
    /* Window state */
659
    saveXMLWindowState(doc);
×
660

661
    /* Appearance */
662
    saveXMLAppearance(doc);
×
663

664
    /* Key sequence */
665
    if (m_keySequence.isEmpty() == false)
×
666
        doc->writeTextElement(KXMLQLCVCATKey, m_keySequence.toString());
×
667

668
    /* External input */
669
    saveXMLInput(doc);
×
670

671
    /* Lookup for any assigned bar */
672
    bool hasAssignment = false;
×
673
    if (m_volumeBar->m_type != AudioBar::None)
×
674
        hasAssignment = true;
×
675
    else
676
    {
677
        foreach(AudioBar *bar, m_spectrumBars)
×
678
        {
679
            if (bar->m_type != AudioBar::None)
×
680
            {
681
                hasAssignment = true;
×
682
                break;
×
683
            }
684
        }
685
    }
686

687
    if (hasAssignment == false)
×
688
    {
689
        /* End the <AudioTriggers> tag */
690
        doc->writeEndElement();
×
691
        return false;
×
692
    }
693

694
    if (m_volumeBar->m_type != AudioBar::None)
×
695
    {
696
        m_volumeBar->saveXML(doc, KXMLQLCVolumeBar, volumeBarIndex());
×
697
    }
698
    int idx = 0;
×
699
    foreach (AudioBar *bar, m_spectrumBars)
×
700
    {
701
        if (bar->m_type != AudioBar::None)
×
702
            bar->saveXML(doc, KXMLQLCSpectrumBar, idx);
×
703
        idx++;
×
704
    }
705

706
    /* End the <AudioTriggers> tag */
707
    doc->writeEndElement();
×
708

709
    return true;
×
710
}
711

712

713

714

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