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

mcallegari / qlcplus / 6628997562

24 Oct 2023 03:21PM UTC coverage: 28.085% (+0.05%) from 28.038%
6628997562

Pull #1462

github

web-flow
Merge 231f6a87e into 646f68840
Pull Request #1462: Overriding flash functionality

91 of 91 new or added lines in 9 files covered. (100.0%)

15382 of 54770 relevant lines covered (28.08%)

20312.39 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 "qlcinputchannel.h"
33
#include "qlcinputprofile.h"
34
#include "qlcfixturedef.h"
35

36
#include "inputselectionwidget.h"
37
#include "vcbuttonproperties.h"
38
#include "functionselection.h"
39
#include "speeddialwidget.h"
40
#include "virtualconsole.h"
41
#include "function.h"
42
#include "fixture.h"
43
#include "doc.h"
44

45
VCButtonProperties::VCButtonProperties(VCButton* button, Doc* doc)
×
46
    : QDialog(button)
47
    , m_button(button)
48
    , m_doc(doc)
49
    , m_speedDials(NULL)
×
50
{
51
    Q_ASSERT(button != NULL);
×
52
    Q_ASSERT(doc != NULL);
×
53

54
    setupUi(this);
×
55

56
    m_inputSelWidget = new InputSelectionWidget(m_doc, this);
×
57
    m_inputSelWidget->setCustomFeedbackVisibility(true);
×
58
    m_inputSelWidget->setKeySequence(m_button->keySequence());
×
59
    m_inputSelWidget->setInputSource(m_button->inputSource());
×
60
    m_inputSelWidget->setWidgetPage(m_button->page());
×
61
    m_inputSelWidget->show();
×
62
    m_extControlLayout->addWidget(m_inputSelWidget);
×
63

64
    QAction* action = new QAction(this);
×
65
    action->setShortcut(QKeySequence(QKeySequence::Close));
×
66
    connect(action, SIGNAL(triggered(bool)), this, SLOT(reject()));
×
67
    addAction(action);
×
68

69
    /* Button text and function */
70
    m_nameEdit->setText(m_button->caption());
×
71
    slotSetFunction(button->function());
×
72

73
    /* Press action */
74
    if (button->action() == VCButton::Flash)
×
75
        m_flash->setChecked(true);
×
76
    else if (button->action() == VCButton::Blackout)
×
77
        m_blackout->setChecked(true);
×
78
    else if (button->action() == VCButton::StopAll)
×
79
        m_stopAll->setChecked(true);
×
80
    else
81
        m_toggle->setChecked(true);
×
82
    m_fadeOutTime = m_button->stopAllFadeTime();
×
83
    m_fadeOutEdit->setText(Function::speedToString(m_fadeOutTime));
×
84
    slotActionToggled();
×
85

86
    m_forceLTP->setChecked(m_button->flashForceLTP());
×
87
    m_overridePriority->setChecked(m_button->flashOverrides());
×
88

89
    /* Intensity adjustment */
90
    m_intensityEdit->setValidator(new QIntValidator(0, 100, this));
×
91
    m_intensityGroup->setChecked(m_button->isStartupIntensityEnabled());
×
92
    int intensity = int(floor(m_button->startupIntensity() * double(100)));
×
93
    m_intensityEdit->setText(QString::number(intensity));
×
94
    m_intensitySlider->setValue(intensity);
×
95

96
    /* Button connections */
97
    connect(m_attachFunction, SIGNAL(clicked()), this, SLOT(slotAttachFunction()));
×
98
    connect(m_detachFunction, SIGNAL(clicked()), this, SLOT(slotSetFunction()));
×
99

100
    connect(m_toggle, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
101
    connect(m_blackout, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
102
    connect(m_stopAll, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
103
    connect(m_flash, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
104

105
    connect(m_speedDialButton, SIGNAL(toggled(bool)),
×
106
            this, SLOT(slotSpeedDialToggle(bool)));
107

108
    connect(m_intensitySlider, SIGNAL(valueChanged(int)),
×
109
            this, SLOT(slotIntensitySliderMoved(int)));
110
    connect(m_intensityEdit, SIGNAL(textEdited(QString)),
×
111
            this, SLOT(slotIntensityEdited(QString)));
112

113
    connect(m_fadeOutEdit, SIGNAL(editingFinished()),
×
114
            this, SLOT(slotFadeOutTextEdited()));
115
}
×
116

117
VCButtonProperties::~VCButtonProperties()
×
118
{
119
}
×
120

121
void VCButtonProperties::slotAttachFunction()
×
122
{
123
    FunctionSelection fs(this, m_doc);
×
124
    fs.setMultiSelection(false);
×
125
    if (fs.exec() == QDialog::Accepted && fs.selection().size() > 0)
×
126
        slotSetFunction(fs.selection().first());
×
127
}
×
128

129
void VCButtonProperties::slotSetFunction(quint32 fid)
×
130
{
131
    m_function = fid;
×
132
    Function* func = m_doc->function(m_function);
×
133

134
    if (func == NULL)
×
135
    {
136
        m_functionEdit->setText(tr("No function"));
×
137
    }
138
    else
139
    {
140
        m_functionEdit->setText(func->name());
×
141
        if (m_nameEdit->text().simplified().contains(QString::number(m_button->id())))
×
142
            m_nameEdit->setText(func->name());
×
143
    }
144
}
×
145

146
void VCButtonProperties::slotActionToggled()
×
147
{
148
    if (m_blackout->isChecked() == true || m_stopAll->isChecked() == true)
×
149
    {
150
        m_generalGroup->setEnabled(false);
×
151
        m_intensityGroup->setEnabled(false);
×
152
    }
153
    else
154
    {
155
        m_generalGroup->setEnabled(true);
×
156
        m_intensityGroup->setEnabled(true);
×
157
    }
158

159
    m_fadeOutEdit->setEnabled(m_stopAll->isChecked());
×
160
    m_safFadeLabel->setEnabled(m_stopAll->isChecked());
×
161
    m_speedDialButton->setEnabled(m_stopAll->isChecked());
×
162

163
    m_forceLTP->setEnabled(m_flash->isChecked());
×
164
    m_overridePriority->setEnabled(m_flash->isChecked());
×
165
}
×
166

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

190
void VCButtonProperties::slotFadeOutDialChanged(int ms)
×
191
{
192
    m_fadeOutEdit->setText(Function::speedToString(ms));
×
193
    m_fadeOutTime = ms;
×
194
}
×
195

196
void VCButtonProperties::slotDialDestroyed(QObject *)
×
197
{
198
    m_speedDialButton->setChecked(false);
×
199
}
×
200

201
void VCButtonProperties::slotIntensitySliderMoved(int value)
×
202
{
203
    m_intensityEdit->setText(QString::number(value));
×
204
}
×
205

206
void VCButtonProperties::slotIntensityEdited(const QString& text)
×
207
{
208
    m_intensitySlider->setValue(text.toInt());
×
209
}
×
210

211
void VCButtonProperties::slotFadeOutTextEdited()
×
212
{
213
    m_fadeOutTime = Function::stringToSpeed(m_fadeOutEdit->text());
×
214
    m_fadeOutEdit->setText(Function::speedToString(m_fadeOutTime));
×
215
    if (m_speedDials != NULL)
×
216
        m_speedDials->setFadeOutSpeed(m_fadeOutTime);
×
217
}
×
218

219
void VCButtonProperties::accept()
×
220
{
221
    m_button->setCaption(m_nameEdit->text());
×
222
    m_button->setFunction(m_function);
×
223
    m_button->setKeySequence(m_inputSelWidget->keySequence());
×
224
    m_button->setInputSource(m_inputSelWidget->inputSource());
×
225
    m_button->enableStartupIntensity(m_intensityGroup->isChecked());
×
226
    m_button->setStartupIntensity(qreal(m_intensitySlider->value()) / qreal(100));
×
227

228
    if (m_toggle->isChecked() == true)
×
229
        m_button->setAction(VCButton::Toggle);
×
230
    else if (m_blackout->isChecked() == true)
×
231
        m_button->setAction(VCButton::Blackout);
×
232
    else if (m_stopAll->isChecked() == true)
×
233
    {
234
        m_button->setAction(VCButton::StopAll);
×
235
        m_button->setStopAllFadeOutTime(m_fadeOutTime);
×
236
    }
237
    else
238
    {
239
        m_button->setAction(VCButton::Flash);
×
240
        m_button->setFlashOverride(m_overridePriority->isChecked());
×
241
        m_button->setFlashForceLTP(m_forceLTP->isChecked());
×
242
    }
243

244

245
    m_button->updateState();
×
246

247
    QDialog::accept();
×
248
}
×
249

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