• 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/trackitem.cpp
1
/*
2
  Q Light Controller Plus
3
  trackitem.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

21
#include <QGraphicsSceneMouseEvent>
22
#include <QApplication>
23
#include <QPainter>
24
#include <QMenu>
25

26
#include "trackitem.h"
27

28
TrackItem::TrackItem(Track *track, int number)
×
29
    : m_number(number)
×
30
    , m_isActive(false)
×
31
    , m_track(track)
×
32
    , m_isMute(false)
×
33
    , m_isSolo(false)
×
34
{
35
    m_font = qApp->font();
×
36
    m_font.setBold(true);
×
37
    m_font.setPixelSize(12);
×
38

39
    m_btnFont = qApp->font();
×
40
    m_btnFont.setBold(true);
×
41
    m_btnFont.setPixelSize(12);
×
42

43
    if (track != NULL)
×
44
    {
45
        m_name = m_track->name();
×
46
        m_isMute = m_track->isMute();
×
47
        connect(m_track, SIGNAL(changed(quint32)), this, SLOT(slotTrackChanged(quint32)));
×
48
    }
49
    else
50
        m_name = QString("Track %1").arg(m_number + 1);
×
51

52
    m_soloRegion = new QRectF(17.0, 10.0, 25.0, 16.0);
×
53
    m_muteRegion = new QRectF(45.0, 10.0, 25.0, 16.0);
×
54

55
    m_moveUp = new QAction(QIcon(":/up.png"), tr("Move up"), this);
×
56
    connect(m_moveUp, SIGNAL(triggered()),
×
57
            this, SLOT(slotMoveUpClicked()));
58
    m_moveDown = new QAction(QIcon(":/down.png"), tr("Move down"), this);
×
59
    connect(m_moveDown, SIGNAL(triggered()),
×
60
            this, SLOT(slotMoveDownClicked()));
61

62
    m_changeName = new QAction(QIcon(":/editclear.png"), tr("Change name"), this);
×
63
    connect(m_changeName, SIGNAL(triggered()),
×
64
            this, SLOT(slotChangeNameClicked()));
65

66
    m_delete = new QAction(QIcon(":/editdelete.png"), tr("Delete"), this);
×
67
    connect(m_delete, SIGNAL(triggered()),
×
68
            this, SLOT(slotDeleteTrackClicked()));
69
}
×
70

71
Track *TrackItem::getTrack()
×
72
{
73
    return m_track;
×
74
}
75

76
int TrackItem::getTrackNumber()
×
77
{
78
    return m_number;
×
79
}
80

81
void TrackItem::setName(QString name)
×
82
{
83
    if (!name.isEmpty())
×
84
        m_name = name;
×
85
    update();
×
86
}
×
87

88
void TrackItem::setActive(bool flag)
×
89
{
90
    m_isActive = flag;
×
91
    update();
×
92
}
×
93

94
bool TrackItem::isActive()
×
95
{
96
    return m_isActive;
×
97
}
98

99
void TrackItem::setFlags(bool solo, bool mute)
×
100
{
101
    m_isSolo = solo;
×
102
    m_isMute = mute;
×
103
    update();
×
104
}
×
105

106
bool TrackItem::isMute()
×
107
{
108
    return m_isMute;
×
109
}
110

111
void TrackItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
×
112
{
113
    m_isActive = true;
×
114
    QGraphicsItem::mousePressEvent(event);
×
115
    if (m_soloRegion->contains(event->pos().toPoint()))
×
116
    {
117
        m_isSolo = !m_isSolo;
×
118
        emit itemSoloFlagChanged(this, m_isSolo);
×
119
    }
120
    if (m_muteRegion->contains(event->pos().toPoint()))
×
121
    {
122
        m_isMute = !m_isMute;
×
123
        emit itemMuteFlagChanged(this, m_isMute);
×
124
    }
125
    emit itemClicked(this);
×
126
}
×
127

128
void TrackItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *)
×
129
{
130
    QMenu menu;
×
131
    QFont menuFont = qApp->font();
×
132
    menuFont.setPixelSize(14);
×
133
    menu.setFont(menuFont);
×
134

135
    if (m_number > 0)
×
136
        menu.addAction(m_moveUp);
×
137
    menu.addAction(m_moveDown);
×
138
    menu.addAction(m_changeName);
×
139
    menu.addAction(m_delete);
×
140
    menu.exec(QCursor::pos());
×
141
}
×
142

143
void TrackItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *)
×
144
{
145
    emit itemDoubleClicked(this);
×
146
}
×
147

148
QRectF TrackItem::boundingRect() const
×
149
{
150
    return QRectF(0, 0, TRACK_WIDTH - 4, TRACK_HEIGHT);
×
151
}
152

153
void TrackItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
×
154
{
155
    Q_UNUSED(option);
156
    Q_UNUSED(widget);
157

158
    // draw background gradient
159
    QLinearGradient linearGrad(QPointF(0, 0), QPointF(0, TRACK_HEIGHT));
×
160
    linearGrad.setColorAt(0, QColor(50, 64, 75, 255));
×
161
    //linearGrad.setColorAt(1, QColor(99, 127, 148, 255));
162
    linearGrad.setColorAt(1, QColor(76, 98, 115, 255));
×
163
    painter->setBrush(linearGrad);
×
164
    painter->drawRect(0, 0, TRACK_WIDTH - 4, TRACK_HEIGHT - 1);
×
165

166
    // Draw left bar that shows if the track is active or not
167
    painter->setPen(QPen(QColor(48, 61, 72, 255), 1));
×
168
    if (m_isActive == true)
×
169
        painter->setBrush(QBrush(QColor(0, 255, 0, 255)));
×
170
    else
171
        painter->setBrush(QBrush(QColor(129, 145, 160, 255)));
×
172
    painter->drawRoundedRect(1, 1, 10, 40, 2, 2);
×
173

174
    // draw solo button
175
    if (m_isSolo)
×
176
        painter->setBrush(QBrush(QColor(255, 255, 0, 255)));
×
177
    else
178
        painter->setBrush(QBrush(QColor(129, 145, 160, 255)));
×
179
    painter->drawRoundedRect(m_soloRegion->toRect(), 3.0, 3.0);
×
180
    painter->setFont(m_btnFont);
×
181
    painter->drawText(25, 23, "S");
×
182

183
    // draw mute button
184
    if (m_isMute)
×
185
        painter->setBrush(QBrush(QColor(255, 0, 0, 255)));
×
186
    else
187
        painter->setBrush(QBrush(QColor(129, 145, 160, 255)));
×
188
    painter->drawRoundedRect(m_muteRegion->toRect(), 3.0, 3.0);
×
189
    painter->drawText(51, 23, "M");
×
190

191
    // draw bound Scene indicator
192
    if (m_track->getSceneID() != Function::invalidId())
×
193
        painter->drawPixmap(TRACK_WIDTH - 33, 5, 24, 24, QIcon(":/scene.png").pixmap(24, 24));
×
194

195
    painter->setFont(m_font);
×
196
    // draw shadow
197
    painter->setPen(QPen(QColor(10, 10, 10, 150), 2));
×
198
    painter->drawText(QRect(5, 47, TRACK_WIDTH - 7, 28), Qt::AlignLeft | Qt::TextWordWrap | Qt::AlignBottom, m_name);
×
199
    // draw track name
200
    painter->setPen(QPen(QColor(200, 200, 200, 255), 2));
×
201
    painter->drawText(QRect(4, 47, TRACK_WIDTH - 7, 28), Qt::AlignLeft | Qt::TextWordWrap | Qt::AlignBottom, m_name);
×
202
}
×
203

204
void TrackItem::slotTrackChanged(quint32 id)
×
205
{
206
    Q_UNUSED(id);
207

208
    m_name = m_track->name();
×
209
    update();
×
210
}
×
211

212
void TrackItem::slotMoveUpClicked()
×
213
{
214
    emit itemMoveUpDown(m_track, -1);
×
215
}
×
216

217
void TrackItem::slotMoveDownClicked()
×
218
{
219
    emit itemMoveUpDown(m_track, 1);
×
220
}
×
221

222
void TrackItem::slotChangeNameClicked()
×
223
{
224
    emit itemDoubleClicked(this);
×
225
}
×
226

227
void TrackItem::slotDeleteTrackClicked()
×
228
{
229
    emit itemRequestDelete(m_track);
×
230
}
×
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