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

mcallegari / qlcplus / 6810307726

09 Nov 2023 10:11AM UTC coverage: 28.086% (+0.02%) from 28.067%
6810307726

Pull #1477

github

web-flow
Merge c8f4c4dcb into 56a703a42
Pull Request #1477: Webaccess cuelist side fader

8 of 39 new or added lines in 1 file covered. (20.51%)

279 existing lines in 9 files now uncovered.

15420 of 54903 relevant lines covered (28.09%)

20284.04 hits per line

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

0.0
/ui/src/virtualconsole/vcbuttonproperties.cpp
1
/*
2
  Q Light Controller
3
  vcbuttonproperties.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 <QIntValidator>
21
#include <QKeySequence>
22
#include <QRadioButton>
23
#include <QMessageBox>
24
#include <QPushButton>
25
#include <QComboBox>
26
#include <QLineEdit>
27
#include <QCheckBox>
28
#include <QSpinBox>
29
#include <QAction>
30
#include <qmath.h>
31

32
#include "inputselectionwidget.h"
33
#include "vcbuttonproperties.h"
34
#include "functionselection.h"
35
#include "speeddialwidget.h"
36
#include "function.h"
37
#include "doc.h"
38

39
VCButtonProperties::VCButtonProperties(VCButton* button, Doc* doc)
×
40
    : QDialog(button)
41
    , m_button(button)
42
    , m_doc(doc)
43
    , m_speedDials(NULL)
×
44
{
45
    Q_ASSERT(button != NULL);
×
46
    Q_ASSERT(doc != NULL);
×
47

48
    setupUi(this);
×
49

50
    m_inputSelWidget = new InputSelectionWidget(m_doc, this);
×
51
    m_inputSelWidget->setCustomFeedbackVisibility(true);
×
52
    m_inputSelWidget->setKeySequence(m_button->keySequence());
×
53
    m_inputSelWidget->setInputSource(m_button->inputSource());
×
54
    m_inputSelWidget->setWidgetPage(m_button->page());
×
55
    m_inputSelWidget->show();
×
56
    m_extControlLayout->addWidget(m_inputSelWidget);
×
57

58
    QAction* action = new QAction(this);
×
59
    action->setShortcut(QKeySequence(QKeySequence::Close));
×
60
    connect(action, SIGNAL(triggered(bool)), this, SLOT(reject()));
×
61
    addAction(action);
×
62

63
    /* Button text and function */
64
    m_nameEdit->setText(m_button->caption());
×
65
    slotSetFunction(button->function());
×
66

67
    /* Press action */
68
    if (button->action() == VCButton::Flash)
×
69
        m_flash->setChecked(true);
×
70
    else if (button->action() == VCButton::Blackout)
×
71
        m_blackout->setChecked(true);
×
72
    else if (button->action() == VCButton::StopAll)
×
73
        m_stopAll->setChecked(true);
×
74
    else
75
        m_toggle->setChecked(true);
×
76
    m_fadeOutTime = m_button->stopAllFadeTime();
×
77
    m_fadeOutEdit->setText(Function::speedToString(m_fadeOutTime));
×
78
    slotActionToggled();
×
79

UNCOV
80
    m_forceLTP->setChecked(m_button->flashForceLTP());
×
81
    m_overridePriority->setChecked(m_button->flashOverrides());
×
82

83
    /* Intensity adjustment */
84
    m_intensityEdit->setValidator(new QIntValidator(0, 100, this));
×
85
    m_intensityGroup->setChecked(m_button->isStartupIntensityEnabled());
×
UNCOV
86
    int intensity = int(floor(m_button->startupIntensity() * double(100)));
×
UNCOV
87
    m_intensityEdit->setText(QString::number(intensity));
×
88
    m_intensitySlider->setValue(intensity);
×
89

90
    /* Button connections */
91
    connect(m_attachFunction, SIGNAL(clicked()), this, SLOT(slotAttachFunction()));
×
92
    connect(m_detachFunction, SIGNAL(clicked()), this, SLOT(slotSetFunction()));
×
93

94
    connect(m_toggle, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
UNCOV
95
    connect(m_blackout, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
96
    connect(m_stopAll, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
UNCOV
97
    connect(m_flash, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
98

99
    connect(m_speedDialButton, SIGNAL(toggled(bool)),
×
100
            this, SLOT(slotSpeedDialToggle(bool)));
101

UNCOV
102
    connect(m_intensitySlider, SIGNAL(valueChanged(int)),
×
103
            this, SLOT(slotIntensitySliderMoved(int)));
104
    connect(m_intensityEdit, SIGNAL(textEdited(QString)),
×
105
            this, SLOT(slotIntensityEdited(QString)));
106

UNCOV
107
    connect(m_fadeOutEdit, SIGNAL(editingFinished()),
×
108
            this, SLOT(slotFadeOutTextEdited()));
UNCOV
109
}
×
110

UNCOV
111
VCButtonProperties::~VCButtonProperties()
×
112
{
UNCOV
113
}
×
114

115
void VCButtonProperties::slotAttachFunction()
×
116
{
117
    FunctionSelection fs(this, m_doc);
×
118
    fs.setMultiSelection(false);
×
UNCOV
119
    if (fs.exec() == QDialog::Accepted && fs.selection().size() > 0)
×
120
        slotSetFunction(fs.selection().first());
×
UNCOV
121
}
×
122

123
void VCButtonProperties::slotSetFunction(quint32 fid)
×
124
{
125
    m_function = fid;
×
UNCOV
126
    Function* func = m_doc->function(m_function);
×
127

UNCOV
128
    if (func == NULL)
×
129
    {
UNCOV
130
        m_functionEdit->setText(tr("No function"));
×
131
    }
132
    else
133
    {
UNCOV
134
        m_functionEdit->setText(func->name());
×
135
        if (m_nameEdit->text().simplified().contains(QString::number(m_button->id())))
×
UNCOV
136
            m_nameEdit->setText(func->name());
×
137
    }
UNCOV
138
}
×
139

UNCOV
140
void VCButtonProperties::slotActionToggled()
×
141
{
142
    if (m_blackout->isChecked() == true || m_stopAll->isChecked() == true)
×
143
    {
UNCOV
144
        m_generalGroup->setEnabled(false);
×
UNCOV
145
        m_intensityGroup->setEnabled(false);
×
146
    }
147
    else
148
    {
UNCOV
149
        m_generalGroup->setEnabled(true);
×
150
        m_intensityGroup->setEnabled(true);
×
151
    }
152

153
    m_fadeOutEdit->setEnabled(m_stopAll->isChecked());
×
UNCOV
154
    m_safFadeLabel->setEnabled(m_stopAll->isChecked());
×
155
    m_speedDialButton->setEnabled(m_stopAll->isChecked());
×
156

157
    m_forceLTP->setEnabled(m_flash->isChecked());
×
UNCOV
158
    m_overridePriority->setEnabled(m_flash->isChecked());
×
159
}
×
160

161
void VCButtonProperties::slotSpeedDialToggle(bool state)
×
162
{
163
    if (state == true)
×
164
    {
165
        m_speedDials = new SpeedDialWidget(this);
×
166
        m_speedDials->setAttribute(Qt::WA_DeleteOnClose);
×
167
        m_speedDials->setWindowTitle(m_button->caption());
×
168
        m_speedDials->setFadeInVisible(false);
×
UNCOV
169
        m_speedDials->setFadeOutSpeed(m_fadeOutTime);
×
UNCOV
170
        m_speedDials->setDurationEnabled(false);
×
UNCOV
171
        m_speedDials->setDurationVisible(false);
×
172
        connect(m_speedDials, SIGNAL(fadeOutChanged(int)), this, SLOT(slotFadeOutDialChanged(int)));
×
173
        connect(m_speedDials, SIGNAL(destroyed(QObject*)), this, SLOT(slotDialDestroyed(QObject*)));
×
174
        m_speedDials->show();
×
175
    }
176
    else
177
    {
178
        if (m_speedDials != NULL)
×
UNCOV
179
            m_speedDials->deleteLater();
×
180
        m_speedDials = NULL;
×
181
    }
182
}
×
183

184
void VCButtonProperties::slotFadeOutDialChanged(int ms)
×
185
{
186
    m_fadeOutEdit->setText(Function::speedToString(ms));
×
187
    m_fadeOutTime = ms;
×
UNCOV
188
}
×
189

UNCOV
190
void VCButtonProperties::slotDialDestroyed(QObject *)
×
191
{
192
    m_speedDialButton->setChecked(false);
×
UNCOV
193
}
×
194

UNCOV
195
void VCButtonProperties::slotIntensitySliderMoved(int value)
×
196
{
197
    m_intensityEdit->setText(QString::number(value));
×
UNCOV
198
}
×
199

UNCOV
200
void VCButtonProperties::slotIntensityEdited(const QString& text)
×
201
{
202
    m_intensitySlider->setValue(text.toInt());
×
203
}
×
204

205
void VCButtonProperties::slotFadeOutTextEdited()
×
206
{
207
    m_fadeOutTime = Function::stringToSpeed(m_fadeOutEdit->text());
×
UNCOV
208
    m_fadeOutEdit->setText(Function::speedToString(m_fadeOutTime));
×
209
    if (m_speedDials != NULL)
×
210
        m_speedDials->setFadeOutSpeed(m_fadeOutTime);
×
211
}
×
212

213
void VCButtonProperties::accept()
×
214
{
UNCOV
215
    m_button->setCaption(m_nameEdit->text());
×
216
    m_button->setFunction(m_function);
×
217
    m_button->setKeySequence(m_inputSelWidget->keySequence());
×
218
    m_button->setInputSource(m_inputSelWidget->inputSource());
×
219
    m_button->enableStartupIntensity(m_intensityGroup->isChecked());
×
220
    m_button->setStartupIntensity(qreal(m_intensitySlider->value()) / qreal(100));
×
221

222
    if (m_toggle->isChecked() == true)
×
223
        m_button->setAction(VCButton::Toggle);
×
UNCOV
224
    else if (m_blackout->isChecked() == true)
×
UNCOV
225
        m_button->setAction(VCButton::Blackout);
×
226
    else if (m_stopAll->isChecked() == true)
×
227
    {
228
        m_button->setAction(VCButton::StopAll);
×
UNCOV
229
        m_button->setStopAllFadeOutTime(m_fadeOutTime);
×
230
    }
231
    else
232
    {
UNCOV
233
        m_button->setAction(VCButton::Flash);
×
UNCOV
234
        m_button->setFlashOverride(m_overridePriority->isChecked());
×
UNCOV
235
        m_button->setFlashForceLTP(m_forceLTP->isChecked());
×
236
    }
237

238

UNCOV
239
    m_button->updateState();
×
240

UNCOV
241
    QDialog::accept();
×
UNCOV
242
}
×
243

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