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

mcallegari / qlcplus / 8961243534

05 May 2024 09:23PM UTC coverage: 32.068% (+4.0%) from 28.094%
8961243534

push

github

mcallegari
Merge branch 'master' into qmltoqt6

902 of 2557 new or added lines in 140 files covered. (35.28%)

166 existing lines in 76 files now uncovered.

15395 of 48008 relevant lines covered (32.07%)

22949.67 hits per line

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

0.0
/ui/src/showmanager/efxitem.cpp
1
/*
2
  Q Light Controller Plus
3
  efxitem.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
#include <qmath.h>
26

27
#include "efxitem.h"
28
#include "trackitem.h"
29

UNCOV
30
EFXItem::EFXItem(EFX *efx, ShowFunction *func)
×
31
    : ShowItem(func)
32
    , m_efx(efx)
×
33
{
34
    Q_ASSERT(efx != NULL);
×
35

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

41
    calculateWidth();
×
42
    connect(m_efx, SIGNAL(changed(quint32)), this, SLOT(slotEFXChanged(quint32)));
×
43
}
×
44

45
void EFXItem::calculateWidth()
×
46
{
47
    int newWidth = 0;
×
48
    qint64 efxDuration = getDuration();
×
49

50
    if (efxDuration != 0)
×
51
        newWidth = ((50.0 / float(getTimeScale())) * float(efxDuration)) / 1000.0;
×
52
    else
53
        newWidth = 100;
×
54

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

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

65
    float xpos = 0;
×
66
    float timeScale = 50 / float(m_timeScale);
×
67

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

70
    int loopCount = m_function->duration() ? qFloor(m_function->duration() / m_efx->duration()) : 0;
×
71
    for (int i = 0; i < loopCount; i++)
×
72
    {
73
        xpos += ((timeScale * float(m_efx->duration())) / 1000);
×
74
        // draw loop vertical delimiter
75
        painter->setPen(QPen(Qt::white, 1));
×
76
        painter->drawLine(int(xpos), 1, int(xpos), TRACK_HEIGHT - 5);
×
77
    }
78

79
    ShowItem::postPaint(painter);
×
80
}
×
81

82
void EFXItem::setTimeScale(int val)
×
83
{
84
    ShowItem::setTimeScale(val);
×
85
    calculateWidth();
×
86
}
×
87

88
void EFXItem::setDuration(quint32 msec, bool stretch)
×
89
{
90
    if (stretch == true)
×
91
    {
92
        m_efx->setDuration(msec);
×
93
    }
94
    else
95
    {
96
        if (m_function)
×
97
            m_function->setDuration(msec);
×
98
        prepareGeometryChange();
×
99
        calculateWidth();
×
100
        updateTooltip();
×
101
    }
102
}
×
103

104
quint32 EFXItem::getDuration()
×
105
{
106
    return m_function->duration() ? m_function->duration() : m_efx->duration();
×
107
}
108

109
QString EFXItem::functionName()
×
110
{
111
    if (m_efx)
×
112
        return m_efx->name();
×
113
    return QString();
×
114
}
115

116
EFX *EFXItem::getEFX()
×
117
{
118
    return m_efx;
×
119
}
120

121
void EFXItem::slotEFXChanged(quint32)
×
122
{
123
    prepareGeometryChange();
×
124
    calculateWidth();
×
125
    updateTooltip();
×
126
}
×
127

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

NEW
135
    foreach (QAction *action, getDefaultActions())
×
136
        menu.addAction(action);
×
137

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