• 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

23.16
/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
{
44
    /* Set the class name "VCSoloFrame" as the object name as well */
45
    setObjectName(VCSoloFrame::staticMetaObject.className());
1✔
46
    setType(VCWidget::SoloFrameWidget);
1✔
47

48
    m_frameStyle = KVCFrameStyleSunken;
1✔
49

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

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

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

73
/*****************************************************************************
74
 * Clipboard
75
 *****************************************************************************/
76

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

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

88
    return frame;
×
89
}
90

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

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

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

102
/*****************************************************************************
103
* Solo behaviour
104
*****************************************************************************/
105

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

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

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

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

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

142
    updateChildrenConnection(!liveEdit);
×
143
}
144

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

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

158
    return false;
159
}
160

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

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

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

180
/*****************************************************************************
181
 * Properties
182
 *****************************************************************************/
183

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

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

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

203
/*****************************************************************************
204
 * Load & Save
205
 *****************************************************************************/
206

207
QString VCSoloFrame::xmlTagName() const
1✔
208
{
209
    return KXMLQLCVCSoloFrame;
1✔
210
}
211

212
/*****************************************************************************
213
 * Event handling
214
 *****************************************************************************/
215

216
void VCSoloFrame::paintEvent(QPaintEvent* e)
×
217
{
218
    /* No point coming here if there is no VC instance */
219
    VirtualConsole* vc = VirtualConsole::instance();
×
220
    if (vc == NULL)
×
221
        return;
×
222

223
    QPainter painter(this);
×
224

225
    QWidget::paintEvent(e);
×
226

227
    /* Draw selection frame */
228
    bool drawSelectionFrame = false;
229
    if (mode() == Doc::Design && vc->isWidgetSelected(this) == true)
×
230
        drawSelectionFrame = true;
231

232
    /* Draw a dotted line around the widget */
233
    QPen pen(drawSelectionFrame ? Qt::DashLine : Qt::SolidLine);
×
234
    pen.setColor(Qt::red);
×
235

236
    if (drawSelectionFrame == true)
×
237
    {
238
        pen.setCapStyle(Qt::RoundCap);
×
239
        pen.setWidth(0);
×
240
    }
241
    else
242
    {
243
        pen.setCapStyle(Qt::FlatCap);
×
244
        pen.setWidth(1);
×
245
    }
246

247
    painter.setPen(pen);
×
248
    painter.drawRect(0, 0, rect().width()-1, rect().height()-1);
×
249

250
    if (drawSelectionFrame)
×
251
    {
252
        /* Draw a resize handle */
253
        QIcon icon(":/resize.png");
×
254
        painter.drawPixmap(rect().width() - 16, rect().height() - 16,
×
255
                           icon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On));
×
256
    }
×
257
}
×
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