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

mcallegari / qlcplus / 19144422256

06 Nov 2025 05:33PM UTC coverage: 34.256% (-0.1%) from 34.358%
19144422256

push

github

mcallegari
Back to 5.1.0 debug

17718 of 51723 relevant lines covered (34.26%)

19528.23 hits per line

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

0.0
/ui/src/showmanager/videoitem.cpp
1
/*
2
  Q Light Controller Plus
3
  videoitem.cpp
4

5
  Copyright (C) Massimo Callegari
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 <QApplication>
21
#include <QPainter>
22
#include <QMenu>
23
#include <qmath.h>
24

25
#include "videoitem.h"
26
#include "trackitem.h"
27

28
VideoItem::VideoItem(Video *vid, ShowFunction *func)
×
29
    : ShowItem(func)
30
    , m_video(vid)
×
31
    , m_fullscreenAction(NULL)
×
32
{
33
    Q_ASSERT(vid != NULL);
×
34

35
    if (func->color().isValid())
×
36
        setColor(func->color());
×
37
    else
38
        setColor(ShowFunction::defaultColor(Function::VideoType));
×
39

40
    if (func->duration() == 0)
×
41
        func->setDuration(m_video->totalDuration());
×
42

43
    calculateWidth();
×
44
    connect(m_video, SIGNAL(changed(quint32)),
×
45
            this, SLOT(slotVideoChanged(quint32)));
46
    connect(m_video, SIGNAL(totalTimeChanged(qint64)),
×
47
            this, SLOT(slotVideoDurationChanged(qint64)));
48

49
    m_fullscreenAction = new QAction(tr("Fullscreen"), this);
×
50
    m_fullscreenAction->setCheckable(true);
×
51
    if (m_video->fullscreen() == true)
×
52
        m_fullscreenAction->setChecked(true);
×
53
    connect(m_fullscreenAction, SIGNAL(toggled(bool)),
×
54
            this, SLOT(slotFullscreenToggled(bool)));
55
}
×
56

57
void VideoItem::calculateWidth()
×
58
{
59
    int newWidth = 0;
×
60
    qint64 video_duration = m_function->duration();
×
61

62
    if (video_duration != 0)
×
63
        newWidth = ((50/(float)getTimeScale()) * (float)video_duration) / 1000;
×
64
    else
65
        newWidth = 100;
×
66

67
    if (newWidth < (50 / m_timeScale))
×
68
        newWidth = 50 / m_timeScale;
×
69
    setWidth(newWidth);
×
70
}
×
71

72
void VideoItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
×
73
{
74
    float timeScale = 50/(float)m_timeScale;
×
75
    quint32 videoDuration = m_video->totalDuration();
×
76

77
    ShowItem::paint(painter, option, widget);
×
78

79
    if (videoDuration > 0)
×
80
    {
81
        float xpos = 0;
×
82
        int loopCount = qFloor(m_function->duration() / videoDuration);
×
83

84
        for (int i = 0; i < loopCount; i++)
×
85
        {
86
            xpos += ((timeScale * (float)videoDuration) / 1000);
×
87
            // draw loop vertical delimiter
88
            painter->setPen(QPen(Qt::white, 1));
×
89
            painter->drawLine(xpos, 1, xpos, TRACK_HEIGHT - 5);
×
90
        }
91
    }
92

93
    if (m_video->fadeInSpeed() != 0)
×
94
    {
95
        int fadeXpos = (timeScale * (float)m_video->fadeInSpeed()) / 1000;
×
96
        painter->setPen(QPen(Qt::gray, 1));
×
97
        painter->drawLine(1, TRACK_HEIGHT - 4, fadeXpos, 2);
×
98
    }
99

100
    if (m_video->fadeOutSpeed() != 0)
×
101
    {
102
        int fadeXpos = (timeScale * (float)m_video->fadeOutSpeed()) / 1000;
×
103
        painter->setPen(QPen(Qt::gray, 1));
×
104
        painter->drawLine(m_width - fadeXpos, 2, m_width - 1, TRACK_HEIGHT - 4);
×
105
    }
106

107
    ShowItem::postPaint(painter);
×
108
}
×
109

110
void VideoItem::setTimeScale(int val)
×
111
{
112
    ShowItem::setTimeScale(val);
×
113
    calculateWidth();
×
114
}
×
115

116
void VideoItem::setDuration(quint32 msec, bool stretch)
×
117
{
118
    Q_UNUSED(msec)
119
    Q_UNUSED(stretch)
120
    if (m_function)
×
121
        m_function->setDuration(msec);
×
122
    prepareGeometryChange();
×
123
    calculateWidth();
×
124
    updateTooltip();
×
125
}
×
126

127
QString VideoItem::functionName()
×
128
{
129
    if (m_video)
×
130
        return m_video->name();
×
131
    return QString();
×
132
}
133

134
Video *VideoItem::getVideo()
×
135
{
136
    return m_video;
×
137
}
138

139
void VideoItem::slotVideoChanged(quint32)
×
140
{
141
    prepareGeometryChange();
×
142
    if (m_function)
×
143
        m_function->setDuration(m_video->totalDuration());
×
144
    calculateWidth();
×
145
    updateTooltip();
×
146
}
×
147

148
void VideoItem::slotVideoDurationChanged(qint64)
×
149
{
150
    prepareGeometryChange();
×
151
    if (m_function && m_function->duration() == 0)
×
152
        m_function->setDuration(m_video->totalDuration());
×
153
    calculateWidth();
×
154
    updateTooltip();
×
155
}
×
156

157
void VideoItem::slotScreenChanged()
×
158
{
159
    QAction *action = (QAction *)sender();
×
160
    int scrIdx = action->data().toInt();
×
161

162
    m_video->setScreen(scrIdx);
×
163
}
×
164

165
void VideoItem::slotFullscreenToggled(bool toggle)
×
166
{
167
    m_video->setFullscreen(toggle);
×
168
}
×
169

170
void VideoItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *)
×
171
{
172
    QMenu menu;
×
173
    QFont menuFont = qApp->font();
×
174
    menuFont.setPixelSize(14);
×
175
    menu.setFont(menuFont);
×
176

177
    int screenCount = QGuiApplication::screens().count();
×
178

179
    if (screenCount > 0)
×
180
    {
181
        for (int i = 0; i < screenCount; i++)
×
182
        {
183
            QAction *scrAction = new QAction(tr("Screen %1").arg(i + 1), this);
×
184
            scrAction->setCheckable(true);
×
185
            if (m_video->screen() == i)
×
186
                scrAction->setChecked(true);
×
187
            scrAction->setData(i);
×
188
            connect(scrAction, SIGNAL(triggered()),
×
189
                    this, SLOT(slotScreenChanged()));
190
            menu.addAction(scrAction);
×
191
        }
192
    }
193
    menu.addAction(m_fullscreenAction);
×
194
    foreach (QAction *action, getDefaultActions())
×
195
        menu.addAction(action);
×
196

197
    menu.exec(QCursor::pos());
×
198
}
×
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