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

mcallegari / qlcplus / 9573323472

18 Jun 2024 10:59PM UTC coverage: 32.056% (+0.02%) from 32.034%
9573323472

Pull #1586

github

web-flow
Merge e0912e5a0 into c1f5846de
Pull Request #1586: Introduce keyboard scroll flag in Virtual Console

25 of 34 new or added lines in 5 files covered. (73.53%)

1 existing line in 1 file now uncovered.

14042 of 43805 relevant lines covered (32.06%)

27030.04 hits per line

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

0.0
/ui/src/virtualconsole/vcpropertieseditor.cpp
1
/*
2
  Q Light Controller
3
  vcpropertieseditor.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 <QRadioButton>
21
#include <QSettings>
22
#include <QCheckBox>
23
#include <QSpinBox>
24
#include <QAction>
25

26
#include "vcpropertieseditor.h"
27
#include "selectinputchannel.h"
28
#include "inputoutputmap.h"
29
#include "qlcinputsource.h"
30
#include "vcproperties.h"
31
#include "inputpatch.h"
32
#include "function.h"
33

34
#define SETTINGS_GEOMETRY "vcpropertieseditor/geometry"
35

36
/*****************************************************************************
37
 * Initialization
38
 *****************************************************************************/
39

40
VCPropertiesEditor::VCPropertiesEditor(QWidget* parent, const VCProperties& properties,
×
41
                                       InputOutputMap *ioMap)
×
42
    : QDialog(parent)
43
    , m_ioMap(ioMap)
×
44
{
45
    Q_ASSERT(ioMap != NULL);
46

47
    setupUi(this);
×
48

49
    QAction* action = new QAction(this);
×
50
    action->setShortcut(QKeySequence(QKeySequence::Close));
×
51
    connect(action, SIGNAL(triggered(bool)), this, SLOT(reject()));
×
52
    addAction(action);
×
53

54
    m_properties = properties;
×
55

56
    /* General page */
57
    m_sizeXSpin->setValue(properties.size().width());
×
58
    m_sizeYSpin->setValue(properties.size().height());
×
NEW
59
    m_enableKeyboardScroll->setChecked(properties.keyboardScroll());
×
60

61
    /* Widgets page */
62
    QSettings settings;
×
63
    // ********************* BUTTON ****************************
64
    QVariant var = settings.value(SETTINGS_BUTTON_SIZE);
×
65
    if (var.isValid() == true)
×
66
    {
67
        QSize size = var.toSize();
×
68
        m_buttonWspin->setValue(size.width());
×
69
        m_buttonHspin->setValue(size.height());
×
70
    }
71
    else
72
    {
73
        m_buttonWspin->setValue(50);
×
74
        m_buttonHspin->setValue(50);
×
75
    }
76
    // ********************* BUTTON STATUS *********************
77
    var = settings.value(SETTINGS_BUTTON_STATUSLED);
×
78
    if (var.isValid() == true && var.toBool() == true)
×
79
            m_buttonStatusLEDRadio->setChecked(true);
×
80
    // ********************* SLIDER ****************************
81
    var = settings.value(SETTINGS_SLIDER_SIZE);
×
82
    if (var.isValid() == true)
×
83
    {
84
        QSize size = var.toSize();
×
85
        m_sliderWspin->setValue(size.width());
×
86
        m_sliderHspin->setValue(size.height());
×
87
    }
88
    else
89
    {
90
        m_sliderWspin->setValue(60);
×
91
        m_sliderHspin->setValue(200);
×
92
    }
93
    // ********************* SPEED DIAL ************************
94
    var = settings.value(SETTINGS_SPEEDDIAL_SIZE);
×
95
    if (var.isValid() == true)
×
96
    {
97
        QSize size = var.toSize();
×
98
        m_speedWspin->setValue(size.width());
×
99
        m_speedHspin->setValue(size.height());
×
100
    }
101
    else
102
    {
103
        m_speedWspin->setValue(200);
×
104
        m_speedHspin->setValue(175);
×
105
    }
106
    // ********************* SPEED DIAL VALUE ******************
107
    var = settings.value(SETTINGS_SPEEDDIAL_VALUE);
×
108
    if (var.isValid() == true)
×
109
        m_speedValueEdit->setText(Function::speedToString(var.toUInt()));
×
110
    else
111
        m_speedValueEdit->setText(Function::speedToString(0));
×
112

113
    connect(m_speedValueEdit, SIGNAL(editingFinished()),
×
114
            this, SLOT(slotSpeedDialConfirmed()));
115

116
    // ********************* XY PAD ****************************
117
    var = settings.value(SETTINGS_XYPAD_SIZE);
×
118
    if (var.isValid() == true)
×
119
    {
120
        QSize size = var.toSize();
×
121
        m_xypadWspin->setValue(size.width());
×
122
        m_xypadHspin->setValue(size.height());
×
123
    }
124
    else
125
    {
126
        m_xypadWspin->setValue(230);
×
127
        m_xypadHspin->setValue(230);
×
128
    }
129
    // ********************* CUE LIST **************************
130
    var = settings.value(SETTINGS_CUELIST_SIZE);
×
131
    if (var.isValid() == true)
×
132
    {
133
        QSize size = var.toSize();
×
134
        m_cuelistWspin->setValue(size.width());
×
135
        m_cuelistHspin->setValue(size.height());
×
136
    }
137
    else
138
    {
139
        m_cuelistWspin->setValue(300);
×
140
        m_cuelistHspin->setValue(220);
×
141
    }
142
    // ************************ FRAME **************************
143
    var = settings.value(SETTINGS_FRAME_SIZE);
×
144
    if (var.isValid() == true)
×
145
    {
146
        QSize size = var.toSize();
×
147
        m_frameWspin->setValue(size.width());
×
148
        m_frameHspin->setValue(size.height());
×
149
    }
150
    else
151
    {
152
        m_frameWspin->setValue(200);
×
153
        m_frameHspin->setValue(200);
×
154
    }
155
    // ********************* SOLO FRAME ************************
156
    var = settings.value(SETTINGS_SOLOFRAME_SIZE);
×
157
    if (var.isValid() == true)
×
158
    {
159
        QSize size = var.toSize();
×
160
        m_soloWspin->setValue(size.width());
×
161
        m_soloHspin->setValue(size.height());
×
162
    }
163
    else
164
    {
165
        m_soloWspin->setValue(200);
×
166
        m_soloHspin->setValue(200);
×
167
    }
168
    // ***************** AUDIO TRIGGERS ************************
169
    var = settings.value(SETTINGS_AUDIOTRIGGERS_SIZE);
×
170
    if (var.isValid() == true)
×
171
    {
172
        QSize size = var.toSize();
×
173
        m_audioWspin->setValue(size.width());
×
174
        m_audioHspin->setValue(size.height());
×
175
    }
176
    else
177
    {
178
        m_audioWspin->setValue(200);
×
179
        m_audioHspin->setValue(200);
×
180
    }
181
    // ***************** RGB MATRIX ************************
182
    var = settings.value(SETTINGS_RGBMATRIX_SIZE);
×
183
    if (var.isValid() == true)
×
184
    {
185
        QSize size = var.toSize();
×
186
        m_matrixWspin->setValue(size.width());
×
187
        m_matrixHspin->setValue(size.height());
×
188
    }
189
    else
190
    {
191
        m_matrixWspin->setValue(160);
×
192
        m_matrixHspin->setValue(120);
×
193
    }
194

195
    QVariant geometrySettings = settings.value(SETTINGS_GEOMETRY);
×
196
    if (geometrySettings.isValid() == true)
×
197
        restoreGeometry(geometrySettings.toByteArray());
×
198

199
    /* Grand Master page */
200
    switch (properties.grandMasterChannelMode())
×
201
    {
202
    default:
×
203
    case GrandMaster::Intensity:
204
        m_gmIntensityRadio->setChecked(true);
×
205
        break;
206
    case GrandMaster::AllChannels:
×
207
        m_gmAllChannelsRadio->setChecked(true);
×
208
        break;
209
    }
210

211
    switch (properties.grandMasterValueMode())
×
212
    {
213
    default:
×
214
    case GrandMaster::Reduce:
215
        m_gmReduceRadio->setChecked(true);
×
216
        break;
217
    case GrandMaster::Limit:
×
218
        m_gmLimitRadio->setChecked(true);
×
219
        break;
220
    }
221

222
    switch (properties.grandMasterSlideMode())
×
223
    {
224
    default:
×
225
    case GrandMaster::Normal:
226
        m_gmSliderModeNormalRadio->setChecked(true);
×
227
        break;
228
    case GrandMaster::Inverted:
×
229
        m_gmSliderModeInvertedRadio->setChecked(true);
×
230
        break;
231
    }
232

233
    updateGrandMasterInputSource();
×
234
}
×
235

236
VCPropertiesEditor::~VCPropertiesEditor()
×
237
{
238
    QSettings settings;
×
239
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
×
240
}
×
241

242
VCProperties VCPropertiesEditor::properties() const
×
243
{
244
    return m_properties;
×
245
}
246

247
QSize VCPropertiesEditor::buttonSize()
×
248
{
249
    return QSize(m_buttonWspin->value(), m_buttonHspin->value());
×
250
}
251

252
bool VCPropertiesEditor::buttonStatusLED()
×
253
{
254
    if (m_buttonStatusLEDRadio->isChecked())
×
255
        return true;
256
    else
257
        return false;
×
258
}
259

260
QSize VCPropertiesEditor::sliderSize()
×
261
{
262
    return QSize(m_sliderWspin->value(), m_sliderHspin->value());
×
263
}
264

265
QSize VCPropertiesEditor::speedDialSize()
×
266
{
267
    return QSize(m_speedWspin->value(), m_speedHspin->value());
×
268
}
269

270
uint VCPropertiesEditor::speedDialValue()
×
271
{
272
    return Function::stringToSpeed(m_speedValueEdit->text());
×
273
}
274

275
QSize VCPropertiesEditor::xypadSize()
×
276
{
277
    return QSize(m_xypadWspin->value(), m_xypadHspin->value());
×
278
}
279

280
QSize VCPropertiesEditor::cuelistSize()
×
281
{
282
    return QSize(m_cuelistWspin->value(), m_cuelistHspin->value());
×
283
}
284

285
QSize VCPropertiesEditor::frameSize()
×
286
{
287
    return QSize(m_frameWspin->value(), m_frameHspin->value());
×
288
}
289

290
QSize VCPropertiesEditor::soloFrameSize()
×
291
{
292
    return QSize(m_soloWspin->value(), m_soloHspin->value());
×
293
}
294

295
QSize VCPropertiesEditor::audioTriggersSize()
×
296
{
297
    return QSize(m_audioWspin->value(), m_audioHspin->value());
×
298
}
299

300
QSize VCPropertiesEditor::rgbMatrixSize()
×
301
{
302
    return QSize(m_matrixWspin->value(), m_matrixHspin->value());
×
303
}
304

305
/*****************************************************************************
306
 * Layout page
307
 *****************************************************************************/
308

309
void VCPropertiesEditor::slotSizeXChanged(int value)
×
310
{
311
    QSize sz(m_properties.size());
×
312
    sz.setWidth(value);
313
    m_properties.setSize(sz);
×
314
}
×
315

316
void VCPropertiesEditor::slotSizeYChanged(int value)
×
317
{
318
    QSize sz(m_properties.size());
×
319
    sz.setHeight(value);
320
    m_properties.setSize(sz);
×
321
}
×
322

NEW
323
void VCPropertiesEditor::slotKeyboardScrollToggled(bool checked)
×
324
{
NEW
325
    m_properties.setKeyboardScroll(checked);
×
NEW
326
}
×
327

UNCOV
328
void VCPropertiesEditor::slotSpeedDialConfirmed()
×
329
{
330
    if (m_speedValueEdit->text().contains(".") == false)
×
331
    {
332
        m_speedValueEdit->setText(Function::speedToString(m_speedValueEdit->text().toUInt()));
×
333
    }
334
}
×
335

336

337

338
/*****************************************************************************
339
 * Grand Master page
340
 *****************************************************************************/
341

342
void VCPropertiesEditor::slotGrandMasterIntensityToggled(bool checked)
×
343
{
344
    if (checked == true)
×
345
        m_properties.setGrandMasterChannelMode(GrandMaster::Intensity);
×
346
    else
347
        m_properties.setGrandMasterChannelMode(GrandMaster::AllChannels);
×
348
}
×
349

350
void VCPropertiesEditor::slotGrandMasterReduceToggled(bool checked)
×
351
{
352
    if (checked == true)
×
353
        m_properties.setGrandMasterValueMode(GrandMaster::Reduce);
×
354
    else
355
        m_properties.setGrandMasterValueMode(GrandMaster::Limit);
×
356
}
×
357

358
void VCPropertiesEditor::slotGrandMasterSliderNormalToggled(bool checked)
×
359
{
360
    if (checked == true)
×
361
        m_properties.setGrandMasterSliderMode(GrandMaster::Normal);
×
362
    else
363
        m_properties.setGrandMasterSliderMode(GrandMaster::Inverted);
×
364
}
×
365

366
void VCPropertiesEditor::slotAutoDetectGrandMasterInputToggled(bool checked)
×
367
{
368
    if (checked == true)
×
369
    {
370
        connect(m_ioMap, SIGNAL(inputValueChanged(quint32,quint32,uchar)),
×
371
                this, SLOT(slotGrandMasterInputValueChanged(quint32,quint32)));
372
    }
373
    else
374
    {
375
        disconnect(m_ioMap, SIGNAL(inputValueChanged(quint32,quint32,uchar)),
×
376
                   this, SLOT(slotGrandMasterInputValueChanged(quint32,quint32)));
377
    }
378
}
×
379

380
void VCPropertiesEditor::slotGrandMasterInputValueChanged(quint32 universe,
×
381
                                                          quint32 channel)
382
{
383
    m_properties.setGrandMasterInputSource(universe, channel);
×
384
    updateGrandMasterInputSource();
×
385
}
×
386

387
void VCPropertiesEditor::slotChooseGrandMasterInputClicked()
×
388
{
389
    SelectInputChannel sic(this, m_ioMap);
×
390
    if (sic.exec() == QDialog::Accepted)
×
391
    {
392
        m_properties.setGrandMasterInputSource(sic.universe(), sic.channel());
×
393
        updateGrandMasterInputSource();
×
394
    }
395
}
×
396

397
void VCPropertiesEditor::updateGrandMasterInputSource()
×
398
{
399
    QString uniName;
×
400
    QString chName;
×
401

402
    if (m_ioMap->inputSourceNames(
×
403
                QSharedPointer<QLCInputSource>(
×
404
                    new QLCInputSource(
405
                        m_properties.grandMasterInputUniverse(),
×
406
                        m_properties.grandMasterInputChannel())),
×
407
                uniName, chName) == true)
408
    {
409
        /* Display the gathered information */
410
        m_gmInputUniverseEdit->setText(uniName);
×
411
        m_gmInputChannelEdit->setText(chName);
×
412
    }
413
    else
414
    {
415
        m_gmInputUniverseEdit->setText(KInputNone);
×
416
        m_gmInputChannelEdit->setText(KInputNone);
×
417
    }
418
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc