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

mcallegari / qlcplus / 17074071240

19 Aug 2025 03:18PM UTC coverage: 34.258% (-0.03%) from 34.287%
17074071240

Pull #1795

github

web-flow
Merge b8548c089 into 022b66999
Pull Request #1795: Fix/qt6 android build

22 of 111 new or added lines in 7 files covered. (19.82%)

2 existing lines in 1 file now uncovered.

17722 of 51731 relevant lines covered (34.26%)

19401.42 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->setMonitoringSupport(true);
×
53
    m_inputSelWidget->setKeySequence(m_button->keySequence());
×
54
    m_inputSelWidget->setInputSource(m_button->inputSource());
×
55
    m_inputSelWidget->setWidgetPage(m_button->page());
×
NEW
56
    m_inputSelWidget->setSyncStatus(m_button->syncStatus);
×
57
    m_inputSelWidget->show();
×
58
    m_extControlLayout->addWidget(m_inputSelWidget);
×
59

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

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

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

82
    m_forceLTP->setChecked(m_button->flashForceLTP());
×
83
    m_overridePriority->setChecked(m_button->flashOverrides());
×
84

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

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

96
    connect(m_toggle, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
97
    connect(m_blackout, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
98
    connect(m_stopAll, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
99
    connect(m_flash, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
100

101
    connect(m_speedDialButton, SIGNAL(toggled(bool)),
×
102
            this, SLOT(slotSpeedDialToggle(bool)));
103

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

109
    connect(m_fadeOutEdit, SIGNAL(editingFinished()),
×
110
            this, SLOT(slotFadeOutTextEdited()));
111
}
×
112

113
VCButtonProperties::~VCButtonProperties()
×
114
{
115
}
×
116

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

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

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

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

155
    m_fadeOutEdit->setEnabled(m_stopAll->isChecked());
×
156
    m_safFadeLabel->setEnabled(m_stopAll->isChecked());
×
157
    m_speedDialButton->setEnabled(m_stopAll->isChecked());
×
158

159
    m_forceLTP->setEnabled(m_flash->isChecked());
×
160
    m_overridePriority->setEnabled(m_flash->isChecked());
×
161
}
×
162

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

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

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

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

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

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

215
void VCButtonProperties::accept()
×
216
{
NEW
217
    m_button->syncStatus = m_inputSelWidget->isSyncColor();
×
218
    m_button->setCaption(m_nameEdit->text());
×
219
    m_button->setFunction(m_function);
×
220
    m_button->setKeySequence(m_inputSelWidget->keySequence());
×
221
    m_button->setInputSource(m_inputSelWidget->inputSource());
×
222
    m_button->enableStartupIntensity(m_intensityGroup->isChecked());
×
223
    m_button->setStartupIntensity(qreal(m_intensitySlider->value()) / qreal(100));
×
224

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

241

242
    m_button->updateState();
×
243

244
    QDialog::accept();
×
245
}
×
246

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