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

mcallegari / qlcplus / 20710371529

05 Jan 2026 09:06AM UTC coverage: 34.17% (-0.09%) from 34.256%
20710371529

Pull #1865

github

web-flow
Merge 63a0ef496 into f926bbb3a
Pull Request #1865: New Fixtures for 6 ProLights devices

17716 of 51846 relevant lines covered (34.17%)

19737.47 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;
×
70
    if (getDuration() == Function::infiniteSpeed())
×
71
        loopCount = 10000 / m_matrix->duration();
×
72
    else if (getDuration() > 0)
×
73
        loopCount = qFloor(getDuration() / m_matrix->duration());
×
74

75
    for (int i = 0; i < loopCount; i++)
×
76
    {
77
        xpos += ((timeUnit * float(m_matrix->totalDuration())) / 1000);
×
78
        // draw loop vertical delimiter
79
        painter->setPen(QPen(Qt::white, 1));
×
80
        painter->drawLine(int(xpos), 1, int(xpos), TRACK_HEIGHT - 5);
×
81
    }
82

83
    ShowItem::postPaint(painter);
×
84
}
×
85

86
void RGBMatrixItem::setTimeScale(int val)
×
87
{
88
    ShowItem::setTimeScale(val);
×
89
    calculateWidth();
×
90
}
×
91

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

108
quint32 RGBMatrixItem::getDuration()
×
109
{
110
    return m_function->duration() ? m_function->duration() : m_matrix->totalDuration();
×
111
}
112

113
QString RGBMatrixItem::functionName()
×
114
{
115
    if (m_matrix)
×
116
        return m_matrix->name();
×
117
    return QString();
×
118
}
119

120
RGBMatrix *RGBMatrixItem::getRGBMatrix()
×
121
{
122
    return m_matrix;
×
123
}
124

125
void RGBMatrixItem::slotRGBMatrixChanged(quint32)
×
126
{
127
    prepareGeometryChange();
×
128
    calculateWidth();
×
129
    updateTooltip();
×
130
}
×
131

132
void RGBMatrixItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *)
×
133
{
134
    QMenu menu;
×
135
    QFont menuFont = qApp->font();
×
136
    menuFont.setPixelSize(14);
×
137
    menu.setFont(menuFont);
×
138

139
    foreach (QAction *action, getDefaultActions())
×
140
        menu.addAction(action);
×
141

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