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

mcallegari / qlcplus / 20794594664

07 Jan 2026 07:52PM UTC coverage: 34.17% (-0.1%) from 34.276%
20794594664

push

github

mcallegari
Back to 5.1.1 debug

17716 of 51846 relevant lines covered (34.17%)

19821.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

20.54
/ui/src/virtualconsole/vcsoloframe.cpp
1
/*
2
  Q Light Controller Plus
3
  vcsoloframe.cpp
4

5
  Copyright (c) Anders Thomsen
6
                Massimo Callegari
7

8
  Licensed under the Apache License, Version 2.0 (the "License");
9
  you may not use this file except in compliance with the License.
10
  You may obtain a copy of the License at
11

12
      http://www.apache.org/licenses/LICENSE-2.0.txt
13

14
  Unless required by applicable law or agreed to in writing, software
15
  distributed under the License is distributed on an "AS IS" BASIS,
16
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
  See the License for the specific language governing permissions and
18
  limitations under the License.
19
*/
20

21
#include <QMetaObject>
22
#include <QMessageBox>
23
#include <QSettings>
24
#include <QPainter>
25
#include <QAction>
26
#include <QStyle>
27
#include <QDebug>
28
#include <QPoint>
29
#include <QSize>
30
#include <QMenu>
31
#include <QList>
32

33
#include "vcpropertieseditor.h"
34
#include "virtualconsole.h"
35
#include "vcsoloframe.h"
36
#include "vcsoloframeproperties.h"
37
#include "vcbutton.h"
38
#include "doc.h"
39

40
VCSoloFrame::VCSoloFrame(QWidget* parent, Doc* doc, bool canCollapse)
1✔
41
    : VCFrame(parent, doc, canCollapse)
42
    , m_soloframeMixing(false)
1✔
43
    , m_excludeMonitored(false)
1✔
44
{
45
    /* Set the class name "VCSoloFrame" as the object name as well */
46
    setObjectName(VCSoloFrame::staticMetaObject.className());
1✔
47
    setType(VCWidget::SoloFrameWidget);
1✔
48

49
    m_frameStyle = KVCFrameStyleSunken;
1✔
50

51
    if (canCollapse == true)
1✔
52
    {
53
        QString txtColor = "white";
1✔
54
        if (m_hasCustomForegroundColor)
1✔
55
            txtColor = this->foregroundColor().name();
×
56
        m_label->setStyleSheet("QLabel { background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #BC0A0A, stop: 1 #370303); "
1✔
57
                               "color: " + txtColor + "; border-radius: 3px; padding: 3px; margin-left: 2px; }");
2✔
58
    }
1✔
59

60
    QSettings settings;
1✔
61
    QVariant var = settings.value(SETTINGS_SOLOFRAME_SIZE);
1✔
62
    if (var.isValid() == true)
1✔
63
        resize(var.toSize());
×
64
    else
65
        resize(defaultSize);
1✔
66
    m_width = this->width();
1✔
67
    m_height = this->height();
1✔
68
}
1✔
69

70
VCSoloFrame::~VCSoloFrame()
2✔
71
{
72
}
2✔
73

74
/*****************************************************************************
75
 * Clipboard
76
 *****************************************************************************/
77

78
VCWidget* VCSoloFrame::createCopy(VCWidget* parent)
×
79
{
80
    Q_ASSERT(parent != NULL);
×
81

82
    VCSoloFrame* frame = new VCSoloFrame(parent, m_doc, true);
×
83
    if (frame->copyFrom(this) == false)
×
84
    {
85
        delete frame;
×
86
        frame = NULL;
×
87
    }
88

89
    return frame;
×
90
}
91

92
bool VCSoloFrame::copyFrom(const VCWidget* widget)
×
93
{
94
    const VCSoloFrame* frame = qobject_cast<const VCSoloFrame*> (widget);
×
95
    if (frame == NULL)
×
96
        return false;
×
97

98
    setSoloframeMixing(frame->soloframeMixing());
×
99

100
    return VCFrame::copyFrom(widget);
×
101
}
102

103
/*****************************************************************************
104
* Solo behaviour
105
*****************************************************************************/
106

107
void VCSoloFrame::updateChildrenConnection(bool doConnect)
×
108
{
109
    QListIterator <VCWidget*> it(findChildren<VCWidget*>());
×
110
    while (it.hasNext())
×
111
    {
112
        VCWidget* widget = it.next();
×
113
        if (widget != NULL && thisIsNearestSoloFrameParent(widget))
×
114
        {
115
            if (doConnect)
×
116
            {
117
                connect(widget, SIGNAL(functionStarting(quint32, qreal)),
×
118
                        this, SLOT(slotWidgetFunctionStarting(quint32, qreal)));
119
            }
120
            else
121
            {
122
                disconnect(widget, SIGNAL(functionStarting(quint32, qreal)),
×
123
                        this, SLOT(slotWidgetFunctionStarting(quint32, qreal)));
124
            }
125
        }
126
    }
127
}
×
128

129
void VCSoloFrame::slotModeChanged(Doc::Mode mode)
×
130
{
131
    VCFrame::slotModeChanged(mode);
×
132

133
    updateChildrenConnection(mode == Doc::Operate);
×
134
}
×
135

136
void VCSoloFrame::setLiveEdit(bool liveEdit)
×
137
{
138
    VCFrame::setLiveEdit(liveEdit);
×
139

140
    if (m_doc->mode() == Doc::Design)
×
141
        return;
×
142

143
    updateChildrenConnection(!liveEdit);
×
144
}
145

146
bool VCSoloFrame::thisIsNearestSoloFrameParent(QWidget* widget)
×
147
{
148
    while (widget != NULL)
×
149
    {
150
        widget = widget->parentWidget();
×
151

152
        VCSoloFrame *sf = qobject_cast<VCSoloFrame*>(widget);
×
153
        if (sf != NULL)
×
154
        {
155
            return sf == this;
×
156
        }
157
    }
158

159
    return false;
×
160
}
161

162
void VCSoloFrame::slotWidgetFunctionStarting(quint32 fid, qreal intensity)
×
163
{
164
    VCWidget* senderWidget = qobject_cast<VCWidget*>(sender());
×
165

166
    if (senderWidget != NULL)
×
167
    {
168
        // get every widget that is a child of this soloFrame and turn their
169
        // functions off
170
        QListIterator <VCWidget*> it(findChildren<VCWidget*>());
×
171

172
        while (it.hasNext() == true)
×
173
        {
174
            VCWidget *widget = it.next();
×
175
            if (widget != NULL && widget != senderWidget)
×
176
                widget->notifyFunctionStarting(fid, soloframeMixing() ? intensity : 1.0, m_excludeMonitored);
×
177
        }
178
    }
×
179
}
×
180

181
/*****************************************************************************
182
 * Properties
183
 *****************************************************************************/
184

185
void VCSoloFrame::editProperties()
×
186
{
187
    VCSoloFrameProperties prop(NULL, this, m_doc);
×
188
    if (prop.exec() == QDialog::Accepted)
×
189
    {
190
        applyProperties(prop);
×
191
    }
192
};
×
193

194
bool VCSoloFrame::soloframeMixing() const
×
195
{
196
    return m_soloframeMixing;
×
197
}
198

199
void VCSoloFrame::setSoloframeMixing(bool soloframeMixing)
×
200
{
201
    m_soloframeMixing = soloframeMixing;
×
202
}
×
203

204
bool VCSoloFrame::excludeMonitoredFunctions() const
×
205
{
206
    return m_excludeMonitored;
×
207
}
208

209
void VCSoloFrame::setExcludeMonitoredFunctions(bool exclude)
×
210
{
211
    m_excludeMonitored = exclude;
×
212
}
×
213

214
/*****************************************************************************
215
 * Load & Save
216
 *****************************************************************************/
217

218
QString VCSoloFrame::xmlTagName() const
1✔
219
{
220
    return KXMLQLCVCSoloFrame;
1✔
221
}
222

223
/*****************************************************************************
224
 * Event handling
225
 *****************************************************************************/
226

227
void VCSoloFrame::paintEvent(QPaintEvent* e)
×
228
{
229
    /* No point coming here if there is no VC instance */
230
    VirtualConsole* vc = VirtualConsole::instance();
×
231
    if (vc == NULL)
×
232
        return;
×
233

234
    QPainter painter(this);
×
235

236
    QWidget::paintEvent(e);
×
237

238
    /* Draw selection frame */
239
    bool drawSelectionFrame = false;
×
240
    if (mode() == Doc::Design && vc->isWidgetSelected(this) == true)
×
241
        drawSelectionFrame = true;
×
242

243
    /* Draw a dotted line around the widget */
244
    QPen pen(drawSelectionFrame ? Qt::DashLine : Qt::SolidLine);
×
245
    pen.setColor(Qt::red);
×
246

247
    if (drawSelectionFrame == true)
×
248
    {
249
        pen.setCapStyle(Qt::RoundCap);
×
250
        pen.setWidth(0);
×
251
    }
252
    else
253
    {
254
        pen.setCapStyle(Qt::FlatCap);
×
255
        pen.setWidth(1);
×
256
    }
257

258
    painter.setPen(pen);
×
259
    painter.drawRect(0, 0, rect().width()-1, rect().height()-1);
×
260

261
    if (drawSelectionFrame)
×
262
    {
263
        /* Draw a resize handle */
264
        QIcon icon(":/resize.png");
×
265
        painter.drawPixmap(rect().width() - 16, rect().height() - 16,
×
266
                           icon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On));
×
267
    }
×
268
}
×
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