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

mcallegari / qlcplus / 26064181639

18 May 2026 10:29PM UTC coverage: 35.004% (-0.03%) from 35.037%
26064181639

Pull #2025

github

web-flow
Merge 108f14ffe into 2aa9da5af
Pull Request #2025: Fix Show Manager edge cases around timing and previews

0 of 70 new or added lines in 6 files covered. (0.0%)

6 existing lines in 1 file now uncovered.

18293 of 52259 relevant lines covered (35.0%)

41120.83 hits per line

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

0.0
/ui/src/showmanager/rgbmatrixitem.cpp
1
/*
2
  Q Light Controller Plus
3
  rgbmatrixitem.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 <qmath.h>
23
#include <QDebug>
24
#include <QMenu>
25

26
#include "rgbmatrixitem.h"
27
#include "trackitem.h"
28

29
RGBMatrixItem::RGBMatrixItem(RGBMatrix *rgbm, ShowFunction *func)
×
30
    : ShowItem(func)
31
    , m_matrix(rgbm)
×
32
{
33
    Q_ASSERT(rgbm != NULL);
×
34

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

40
    calculateWidth();
×
41
    connect(m_matrix, SIGNAL(changed(quint32)), this, SLOT(slotRGBMatrixChanged(quint32)));
×
42
}
×
43

44
void RGBMatrixItem::calculateWidth()
×
45
{
46
    int newWidth = 0;
×
47
    qint64 matrixDuration = getDuration();
×
48

49
    if (matrixDuration != 0)
×
50
        newWidth = ((50 / float(getTimeScale())) * float(matrixDuration)) / 1000;
×
51
    else
52
        newWidth = 100;
×
53

54
    if (newWidth < (50 / m_timeScale))
×
55
        newWidth = 50 / m_timeScale;
×
56
    setWidth(newWidth);
×
57
}
×
58

59
void RGBMatrixItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
×
60
{
61
    Q_UNUSED(option);
62
    Q_UNUSED(widget);
63

64
    float xpos = 0;
×
65
    float timeUnit = 50.0 / float(getTimeScale());
×
66

67
    ShowItem::paint(painter, option, widget);
×
68

69
    int loopCount = 0;
×
NEW
70
    quint32 loopDuration = m_matrix->totalDuration();
×
NEW
71
    if (loopDuration > 0)
×
72
    {
NEW
73
        if (getDuration() == Function::infiniteSpeed())
×
NEW
74
            loopCount = 10000 / loopDuration;
×
NEW
75
        else if (getDuration() > 0)
×
NEW
76
            loopCount = qFloor(getDuration() / loopDuration);
×
77
    }
78

79
    for (int i = 0; i < loopCount; i++)
×
80
    {
NEW
81
        xpos += ((timeUnit * float(loopDuration)) / 1000);
×
82
        // draw loop vertical delimiter
83
        painter->setPen(QPen(Qt::white, 1));
×
84
        painter->drawLine(int(xpos), 1, int(xpos), TRACK_HEIGHT - 5);
×
85
    }
86

87
    ShowItem::postPaint(painter);
×
88
}
×
89

90
void RGBMatrixItem::setTimeScale(int val)
×
91
{
92
    ShowItem::setTimeScale(val);
×
93
    calculateWidth();
×
94
}
×
95

96
void RGBMatrixItem::setDuration(quint32 msec, bool stretch)
×
97
{
98
    if (stretch == true)
×
99
    {
100
        m_matrix->setTotalDuration(msec);
×
101
    }
102
    else
103
    {
104
        if (m_function)
×
105
            m_function->setDuration(msec);
×
106
        prepareGeometryChange();
×
107
        calculateWidth();
×
108
        updateTooltip();
×
109
    }
110
}
×
111

112
quint32 RGBMatrixItem::getDuration() const
×
113
{
114
    return m_function->duration() ? m_function->duration() : m_matrix->totalDuration();
×
115
}
116

117
QString RGBMatrixItem::functionName() const
×
118
{
119
    if (m_matrix)
×
120
        return m_matrix->name();
×
121
    return QString();
×
122
}
123

124
RGBMatrix *RGBMatrixItem::getRGBMatrix() const
×
125
{
126
    return m_matrix;
×
127
}
128

129
void RGBMatrixItem::slotRGBMatrixChanged(quint32)
×
130
{
131
    prepareGeometryChange();
×
132
    calculateWidth();
×
133
    updateTooltip();
×
134
}
×
135

136
void RGBMatrixItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *)
×
137
{
138
    QMenu menu;
×
139
    QFont menuFont = qApp->font();
×
140
    menuFont.setPixelSize(14);
×
141
    menu.setFont(menuFont);
×
142

143
    foreach (QAction *action, getDefaultActions())
×
144
        menu.addAction(action);
×
145

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