• 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/speeddialwidget.cpp
1
/*
2
  Q Light Controller
3
  speeddialwidget.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 <QSettings>
21
#include <QGroupBox>
22
#include <QLineEdit>
23
#include <QLayout>
24
#include <QDebug>
25

26
#include "speeddialwidget.h"
27
#include "speeddial.h"
28
#include "apputil.h"
29

30
#define WINDOW_FLAGS Qt::WindowFlags( \
31
    (Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::Window | \
32
     Qt::WindowStaysOnTopHint | Qt::WindowMinimizeButtonHint | Qt::WindowCloseButtonHint))
33

34
#define SETTINGS_GEOMETRY "speeddialwidget/geometry"
35
#define SETTINGS_DIRECTION "speeddialwidget/direction"
36

37
SpeedDialWidget::SpeedDialWidget(QWidget* parent)
×
38
    : QWidget(parent)
39
    , m_fadeIn(NULL)
×
40
    , m_fadeOut(NULL)
×
41
    , m_hold(NULL)
×
42
    , m_optionalTextGroup(NULL)
×
43
    , m_optionalTextEdit(NULL)
×
44
{
45
    QSettings settings;
×
46
    QVariant var;
47
    QBoxLayout* lay = NULL;
48

49
    setWindowFlags(WINDOW_FLAGS);
×
50

51
    /* Layout with customizable direction */
52
    var = settings.value(SETTINGS_DIRECTION);
×
53
    if (var.isValid() == true)
×
54
        lay = new QBoxLayout(QBoxLayout::Direction(var.toInt()), this);
×
55
    else
56
        lay = new QBoxLayout(QBoxLayout::TopToBottom, this);
×
57

58
    /* Create dials */
59
    m_fadeIn = new SpeedDial(this);
×
60
    m_fadeIn->setTitle(tr("Fade In"));
×
61
    layout()->addWidget(m_fadeIn);
×
62
    connect(m_fadeIn, SIGNAL(valueChanged(int)), this, SIGNAL(fadeInChanged(int)));
×
63
    connect(m_fadeIn, SIGNAL(tapped()), this, SIGNAL(fadeInTapped()));
×
64

65
    m_fadeOut = new SpeedDial(this);
×
66
    m_fadeOut->setTitle(tr("Fade Out"));
×
67
    layout()->addWidget(m_fadeOut);
×
68
    connect(m_fadeOut, SIGNAL(valueChanged(int)), this, SIGNAL(fadeOutChanged(int)));
×
69
    connect(m_fadeOut, SIGNAL(tapped()), this, SIGNAL(fadeOutTapped()));
×
70

71
    m_hold = new SpeedDial(this);
×
72
    m_hold->setTitle(tr("Hold"));
×
73
    layout()->addWidget(m_hold);
×
74
    connect(m_hold, SIGNAL(valueChanged(int)), this, SIGNAL(holdChanged(int)));
×
75
    connect(m_hold, SIGNAL(tapped()), this, SIGNAL(holdTapped()));
×
76

77
    /* Optional text */
78
    m_optionalTextGroup = new QGroupBox(this);
×
79
    layout()->addWidget(m_optionalTextGroup);
×
80
    new QVBoxLayout(m_optionalTextGroup);
×
81
    m_optionalTextEdit = new QLineEdit(m_optionalTextGroup);
×
82
    m_optionalTextGroup->layout()->addWidget(m_optionalTextEdit);
×
83
    m_optionalTextGroup->setVisible(false);
×
84
    connect(m_optionalTextEdit, SIGNAL(textEdited(const QString&)),
×
85
            this, SIGNAL(optionalTextEdited(const QString&)));
86

87
    lay->addStretch();
×
88

89
    /* Position */
90
    var = settings.value(SETTINGS_GEOMETRY);
×
91
    if (var.isValid() == true)
×
92
        this->restoreGeometry(var.toByteArray());
×
93
    AppUtil::ensureWidgetIsVisible(this);
×
94
}
×
95

96
SpeedDialWidget::~SpeedDialWidget()
×
97
{
98
    QSettings settings;
×
99
    settings.setValue(SETTINGS_GEOMETRY, saveGeometry());
×
100
}
×
101

102
/****************************************************************************
103
 * Speed settings
104
 ****************************************************************************/
105

106
void SpeedDialWidget::setFadeInTitle(const QString& title)
×
107
{
108
    m_fadeIn->setTitle(title);
×
109
}
×
110

111
void SpeedDialWidget::setFadeInEnabled(bool enable)
×
112
{
113
    m_fadeIn->setEnabled(enable);
×
114
}
×
115

116
void SpeedDialWidget::setFadeInVisible(bool set)
×
117
{
118
    m_fadeIn->setVisible(set);
×
119
}
×
120

121
void SpeedDialWidget::setFadeInSpeed(int ms)
×
122
{
123
    m_fadeIn->setValue(ms);
×
124
}
×
125

126
int SpeedDialWidget::fadeIn() const
×
127
{
128
    return m_fadeIn->value();
×
129
}
130

131
void SpeedDialWidget::setFadeOutTitle(const QString& title)
×
132
{
133
    m_fadeOut->setTitle(title);
×
134
}
×
135

136
void SpeedDialWidget::setFadeOutEnabled(bool enable)
×
137
{
138
    m_fadeOut->setEnabled(enable);
×
139
}
×
140

141
void SpeedDialWidget::setFadeOutVisible(bool set)
×
142
{
143
    m_fadeOut->setVisible(set);
×
144
}
×
145

146
void SpeedDialWidget::setFadeOutSpeed(int ms)
×
147
{
148
    m_fadeOut->setValue(ms);
×
149
}
×
150

151
int SpeedDialWidget::fadeOut() const
×
152
{
153
    return m_fadeOut->value();
×
154
}
155

156
void SpeedDialWidget::setDurationTitle(const QString& title)
×
157
{
158
    m_hold->setTitle(title);
×
159
}
×
160

161
void SpeedDialWidget::setDurationEnabled(bool enable)
×
162
{
163
    m_hold->setEnabled(enable);
×
164
}
×
165

166
void SpeedDialWidget::setDurationVisible(bool set)
×
167
{
168
    m_hold->setVisible(set);
×
169
}
×
170

171
void SpeedDialWidget::setDuration(int ms)
×
172
{
173
    m_hold->setValue(ms);
×
174
}
×
175

176
int SpeedDialWidget::duration() const
×
177
{
178
    return m_hold->value();
×
179
}
180

181
/************************************************************************
182
 * Optional text
183
 ************************************************************************/
184

185
void SpeedDialWidget::setOptionalTextTitle(const QString& title)
×
186
{
187
    m_optionalTextGroup->setTitle(title);
×
188
    m_optionalTextGroup->setVisible(!title.isEmpty());
×
189
}
×
190

191
QString SpeedDialWidget::optionalTextTitle() const
×
192
{
193
    return m_optionalTextGroup->title();
×
194
}
195

196
void SpeedDialWidget::setOptionalText(const QString& text)
×
197
{
198
    m_optionalTextEdit->setText(text);
×
199
}
×
200

201
QString SpeedDialWidget::optionalText() const
×
202
{
203
    return m_optionalTextEdit->text();
×
204
}
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