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

mcallegari / qlcplus / 6683238402

29 Oct 2023 12:10PM UTC coverage: 28.07%. Remained the same
6683238402

push

github

mcallegari
engine: fix build

15385 of 54809 relevant lines covered (28.07%)

20267.63 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

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

87
    /* Button connections */
88
    connect(m_attachFunction, SIGNAL(clicked()), this, SLOT(slotAttachFunction()));
×
89
    connect(m_detachFunction, SIGNAL(clicked()), this, SLOT(slotSetFunction()));
×
90

91
    connect(m_toggle, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
92
    connect(m_blackout, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
93
    connect(m_stopAll, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
94
    connect(m_flash, SIGNAL(toggled(bool)), this, SLOT(slotActionToggled()));
×
95

96
    connect(m_speedDialButton, SIGNAL(toggled(bool)),
×
97
            this, SLOT(slotSpeedDialToggle(bool)));
98

99
    connect(m_intensitySlider, SIGNAL(valueChanged(int)),
×
100
            this, SLOT(slotIntensitySliderMoved(int)));
101
    connect(m_intensityEdit, SIGNAL(textEdited(QString)),
×
102
            this, SLOT(slotIntensityEdited(QString)));
103

104
    connect(m_fadeOutEdit, SIGNAL(editingFinished()),
×
105
            this, SLOT(slotFadeOutTextEdited()));
106
}
×
107

108
VCButtonProperties::~VCButtonProperties()
×
109
{
110
}
×
111

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

120
void VCButtonProperties::slotSetFunction(quint32 fid)
×
121
{
122
    m_function = fid;
×
123
    Function* func = m_doc->function(m_function);
×
124

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

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

150
    m_fadeOutEdit->setEnabled(m_stopAll->isChecked());
×
151
    m_safFadeLabel->setEnabled(m_stopAll->isChecked());
×
152
    m_speedDialButton->setEnabled(m_stopAll->isChecked());
×
153
}
×
154

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

178
void VCButtonProperties::slotFadeOutDialChanged(int ms)
×
179
{
180
    m_fadeOutEdit->setText(Function::speedToString(ms));
×
181
    m_fadeOutTime = ms;
×
182
}
×
183

184
void VCButtonProperties::slotDialDestroyed(QObject *)
×
185
{
186
    m_speedDialButton->setChecked(false);
×
187
}
×
188

189
void VCButtonProperties::slotIntensitySliderMoved(int value)
×
190
{
191
    m_intensityEdit->setText(QString::number(value));
×
192
}
×
193

194
void VCButtonProperties::slotIntensityEdited(const QString& text)
×
195
{
196
    m_intensitySlider->setValue(text.toInt());
×
197
}
×
198

199
void VCButtonProperties::slotFadeOutTextEdited()
×
200
{
201
    m_fadeOutTime = Function::stringToSpeed(m_fadeOutEdit->text());
×
202
    m_fadeOutEdit->setText(Function::speedToString(m_fadeOutTime));
×
203
    if (m_speedDials != NULL)
×
204
        m_speedDials->setFadeOutSpeed(m_fadeOutTime);
×
205
}
×
206

207
void VCButtonProperties::accept()
×
208
{
209
    m_button->setCaption(m_nameEdit->text());
×
210
    m_button->setFunction(m_function);
×
211
    m_button->setKeySequence(m_inputSelWidget->keySequence());
×
212
    m_button->setInputSource(m_inputSelWidget->inputSource());
×
213
    m_button->enableStartupIntensity(m_intensityGroup->isChecked());
×
214
    m_button->setStartupIntensity(qreal(m_intensitySlider->value()) / qreal(100));
×
215

216
    if (m_toggle->isChecked() == true)
×
217
        m_button->setAction(VCButton::Toggle);
×
218
    else if (m_blackout->isChecked() == true)
×
219
        m_button->setAction(VCButton::Blackout);
×
220
    else if (m_stopAll->isChecked() == true)
×
221
    {
222
        m_button->setAction(VCButton::StopAll);
×
223
        m_button->setStopAllFadeOutTime(m_fadeOutTime);
×
224
    }
225
    else
226
        m_button->setAction(VCButton::Flash);
×
227

228
    m_button->updateState();
×
229

230
    QDialog::accept();
×
231
}
×
232

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