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

mcallegari / qlcplus / 13633248611

03 Mar 2025 02:31PM UTC coverage: 31.871% (+0.4%) from 31.5%
13633248611

push

github

web-flow
actions: add chrpath to profile

14689 of 46089 relevant lines covered (31.87%)

26426.11 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());
×
56
    m_inputSelWidget->show();
×
57
    m_extControlLayout->addWidget(m_inputSelWidget);
×
58

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

239

240
    m_button->updateState();
×
241

242
    QDialog::accept();
×
243
}
×
244

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