hydrogen 1.2.6
LED.h
Go to the documentation of this file.
1/*
2 * Hydrogen
3 * Copyright(c) 2008-2025 The hydrogen development team [hydrogen-devel@lists.sourceforge.net]
4 *
5 * http://www.hydrogen-music.org
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY, without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
22
23
24#ifndef LED_H
25#define LED_H
26
27#include <chrono>
28
29#include <core/Object.h>
31
32#include <QtGui>
33#include <QtWidgets>
34#include <QSvgRenderer>
35
36#include "../EventListener.h"
37
42class LED : public QWidget, public H2Core::Object<LED>
43{
45 Q_OBJECT
46
47public:
48 LED( QWidget *pParent, QSize size );
49 virtual ~LED();
50
51 LED(const LED&) = delete;
52 LED& operator=( const LED& rhs ) = delete;
53
54 bool getActivated() const;
55 void setActivated( bool bActivated );
56
57protected:
58 QSvgRenderer* m_background;
59
61 virtual void paintEvent( QPaintEvent* ev) override;
62
63};
64
65inline bool LED::getActivated() const {
66 return m_bActivated;
67}
68
71class MetronomeLED : public LED, public EventListener, public H2Core::Object<MetronomeLED>
72{
74 Q_OBJECT
75
76public:
77 MetronomeLED( QWidget *pParent, QSize size );
78 virtual ~MetronomeLED();
79
80public slots:
81 virtual void metronomeEvent( int nValue ) override;
82
83private slots:
84 void turnOff();
85
86private:
88 QTimer* m_pTimer;
89 std::chrono::milliseconds m_activityTimeout;
90
91 virtual void paintEvent( QPaintEvent* ev) override;
92};
93
94#endif
#define H2_OBJECT(name)
Definition Object.h:227
virtual ~LED()
Definition LED.cpp:60
bool m_bActivated
Definition LED.h:60
LED(QWidget *pParent, QSize size)
Definition LED.cpp:32
bool getActivated() const
Definition LED.h:65
void setActivated(bool bActivated)
Definition LED.cpp:63
LED(const LED &)=delete
QSvgRenderer * m_background
Definition LED.h:58
virtual void paintEvent(QPaintEvent *ev) override
Definition LED.cpp:68
LED & operator=(const LED &rhs)=delete
std::chrono::milliseconds m_activityTimeout
Definition LED.h:89
QTimer * m_pTimer
Definition LED.h:88
void turnOff()
Definition LED.cpp:127
virtual ~MetronomeLED()
Definition LED.cpp:108
bool m_bFirstBar
Definition LED.h:87
virtual void metronomeEvent(int nValue) override
Definition LED.cpp:111
MetronomeLED(QWidget *pParent, QSize size)
Definition LED.cpp:84
virtual void paintEvent(QPaintEvent *ev) override
Definition LED.cpp:133