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

mcallegari / qlcplus / 13633248611

03 Mar 2025 02:31PM UTC coverage: 31.871% (+0.4%) from 31.5%
13633248611

push

github

web-flow
actions: add chrpath to profile

14689 of 46089 relevant lines covered (31.87%)

26426.11 hits per line

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

0.0
/ui/src/playbackslider.cpp
1
/*
2
  Q Light Controller
3
  playbackslider.cpp
4

5
  Copyright (C) Heikki Junnila
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 <QIntValidator>
21
#include <QApplication>
22
#include <QToolButton>
23
#include <QVBoxLayout>
24
#include <QLineEdit>
25
#include <QPainter>
26
#include <QLabel>
27
#include <QDebug>
28
#include <QSize>
29
#include <QIcon>
30

31
#include "playbackslider.h"
32
#include "clickandgoslider.h"
33

34
PlaybackSlider::PlaybackSlider(QWidget* parent)
×
35
    : QWidget(parent)
36
    , m_select(NULL)
×
37
    , m_value(NULL)
×
38
    , m_slider(NULL)
×
39
    , m_label(NULL)
×
40
    , m_flash(NULL)
×
41
    , m_previousValue(-1)
×
42
{
43
    new QVBoxLayout(this);
×
44
    layout()->setSpacing(1);
×
45
    layout()->setContentsMargins(1, 1, 1, 1);
×
46

47
    /* Select button */
48
    m_select = new QToolButton(this);
×
49
    m_select->setIcon(QIcon(":/check.png"));
×
50
    m_select->setIconSize(QSize(32, 32));
×
51
    m_select->setToolTip(tr("Select"));
×
52
    layout()->addWidget(m_select);
×
53
    layout()->setAlignment(m_select, Qt::AlignHCenter);
×
54
    connect(m_select, SIGNAL(clicked()), this, SIGNAL(selected()));
×
55

56
    /* Value label */
57
    m_value = new QLabel(this);
×
58
    m_value->setAlignment(Qt::AlignHCenter);
×
59
    layout()->addWidget(m_value);
×
60
    layout()->setAlignment(m_value, Qt::AlignHCenter);
×
61

62
    /* Value slider */
63
    m_slider = new ClickAndGoSlider(this);
×
64
    m_slider->setRange(0, UCHAR_MAX);
×
65
    //m_slider->setTickInterval(16);
66
    //m_slider->setTickPosition(QSlider::TicksBothSides);
67
    m_slider->setFixedWidth(32);
×
68
    m_slider->setSliderStyleSheet(CNG_DEFAULT_STYLE);
×
69
    layout()->addWidget(m_slider);
×
70
    layout()->setAlignment(m_slider, Qt::AlignHCenter);
×
71
    connect(m_slider, SIGNAL(valueChanged(int)), this, SLOT(slotSliderChanged(int)));
×
72

73
    /* Label */
74
    m_label = new QLabel(this);
×
75
    m_label->setWordWrap(true);
×
76
    layout()->addWidget(m_label);
×
77
    layout()->setAlignment(m_label, Qt::AlignHCenter);
×
78

79
    /* Flash button */
80
    m_flash = new QToolButton(this);
×
81
    m_flash->setIcon(QIcon(":/flash.png"));
×
82
    m_flash->setIconSize(QSize(32, 32));
×
83
    m_flash->setToolTip(tr("Flash"));
×
84
    layout()->addWidget(m_flash);
×
85
    layout()->setAlignment(m_flash, Qt::AlignHCenter);
×
86
    connect(m_flash, SIGNAL(pressed()), this, SLOT(slotFlashPressed()));
×
87
    connect(m_flash, SIGNAL(released()), this, SLOT(slotFlashReleased()));
×
88

89
    slotSliderChanged(0);
×
90
}
×
91

92
PlaybackSlider::~PlaybackSlider()
×
93
{
94
}
×
95

96
void PlaybackSlider::setValue(uchar value)
×
97
{
98
    m_slider->setValue(value);
×
99
}
×
100

101
uchar PlaybackSlider::value() const
×
102
{
103
    return m_slider->value();
×
104
}
105

106
void PlaybackSlider::setLabel(const QString& text)
×
107
{
108
    m_label->setText(text);
×
109
}
×
110

111
QString PlaybackSlider::label() const
×
112
{
113
    return m_label->text();
×
114
}
115

116
void PlaybackSlider::setSelected(bool sel)
×
117
{
118
    if (sel == true)
×
119
    {
120
        QPalette pal(QApplication::palette());
×
121
        pal.setColor(QPalette::Window, pal.color(QPalette::Highlight));
122
        setPalette(pal);
×
123
        setAutoFillBackground(true);
×
124
        m_slider->setFocus(Qt::MouseFocusReason);
×
125
    }
×
126
    else
127
    {
128
        setPalette(QApplication::palette());
×
129
        setAutoFillBackground(false);
×
130
    }
131
}
×
132

133
void PlaybackSlider::slotSliderChanged(int value)
×
134
{
135
    if (value == m_previousValue)
×
136
        return;
137

138
    m_value->setText(QString::number(value));
×
139

140
    if (value == 0)
×
141
        emit stopped();
×
142
    else if (value > 0 && m_previousValue == 0)
×
143
        emit started();
×
144

145
    m_previousValue = value;
×
146
    emit valueChanged(value);
×
147
}
148

149
void PlaybackSlider::slotFlashPressed()
×
150
{
151
    emit flashing(true);
×
152
}
×
153

154
void PlaybackSlider::slotFlashReleased()
×
155
{
156
    emit flashing(false);
×
157
}
×
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

© 2025 Coveralls, Inc