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

mcallegari / qlcplus / 6796513551

08 Nov 2023 09:52AM CUT coverage: 28.09% (+0.02%) from 28.067%
6796513551

Pull #1462

github

web-flow
Merge b9be672c4 into 63469273b
Pull Request #1462: Overriding flash functionality

28 of 42 new or added lines in 5 files covered. (66.67%)

2 existing lines in 1 file now uncovered.

15407 of 54849 relevant lines covered (28.09%)

20304.0 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

NEW
80
    m_forceLTP->setChecked(m_button->flashForceLTP());
×
NEW
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());
×
86
    int intensity = int(floor(m_button->startupIntensity() * double(100)));
×
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()));
×
95
    connect(m_blackout, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
96
    connect(m_stopAll, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
97
    connect(m_flash, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
98

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

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

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

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

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

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

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

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

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

NEW
157
    m_forceLTP->setEnabled(m_flash->isChecked());
×
NEW
158
    m_overridePriority->setEnabled(m_flash->isChecked());
×
UNCOV
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);
×
169
        m_speedDials->setFadeOutSpeed(m_fadeOutTime);
×
170
        m_speedDials->setDurationEnabled(false);
×
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)
×
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;
×
188
}
×
189

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

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

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());
×
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
{
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);
×
224
    else if (m_blackout->isChecked() == true)
×
225
        m_button->setAction(VCButton::Blackout);
×
226
    else if (m_stopAll->isChecked() == true)
×
227
    {
228
        m_button->setAction(VCButton::StopAll);
×
229
        m_button->setStopAllFadeOutTime(m_fadeOutTime);
×
230
    }
231
    else
232
    {
UNCOV
233
        m_button->setAction(VCButton::Flash);
×
NEW
234
        m_button->setFlashOverride(m_overridePriority->isChecked());
×
NEW
235
        m_button->setFlashForceLTP(m_forceLTP->isChecked());
×
236
    }
237

238

239
    m_button->updateState();
×
240

241
    QDialog::accept();
×
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