svgui  1.9
LEDButton.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version. See the file
12  COPYING included with this distribution for more information.
13 */
14 
15 /*
16  This is a modified version of a source file from the KDE
17  libraries. Copyright (c) 1998-2004 Jörg Habenicht, Richard J
18  Moore and others, distributed under the GNU Lesser General Public
19  License.
20 
21  Ported to Qt4 by Chris Cannam.
22 
23  The original KDE widget comes in round and rectangular and flat,
24  raised, and sunken variants. This version retains only the round
25  sunken variant. This version also implements a simple button API.
26 */
27 
28 #ifndef _LED_BUTTON_H_
29 #define _LED_BUTTON_H_
30 
31 #include <QWidget>
32 #include "base/Debug.h"
33 
34 class QColor;
35 
36 class LEDButton : public QWidget
37 {
38  Q_OBJECT
39  Q_PROPERTY(QColor color READ color WRITE setColor)
40  Q_PROPERTY(int darkFactor READ darkFactor WRITE setDarkFactor)
41 
42 public:
43  LEDButton(QWidget *parent = 0);
44  LEDButton(const QColor &col, QWidget *parent = 0);
45  LEDButton(const QColor& col, bool state, QWidget *parent = 0);
46  ~LEDButton();
47 
48  bool state() const;
49  QColor color() const;
50  int darkFactor() const;
51 
52  virtual QSize sizeHint() const;
53  virtual QSize minimumSizeHint() const;
54 
55 signals:
56  void stateChanged(bool);
57 
58  void mouseEntered();
59  void mouseLeft();
60 
61 public slots:
62  void toggle();
63  void on();
64  void off();
65 
66  void setState(bool);
67  void toggleState();
68  void setColor(const QColor& color);
69  void setDarkFactor(int darkfactor);
70 
71 protected:
72  void paintEvent(QPaintEvent *);
73  void mousePressEvent(QMouseEvent *);
74  void enterEvent(QEvent *);
75  void leaveEvent(QEvent *);
76 
77  bool led_state;
78  QColor led_color;
79 
82 };
83 
84 #endif
void paintEvent(QPaintEvent *)
Definition: LEDButton.cpp:120
void mouseEntered()
virtual QSize minimumSizeHint() const
Definition: LEDButton.cpp:355
void enterEvent(QEvent *)
Definition: LEDButton.cpp:108
void on()
Definition: LEDButton.cpp:337
void leaveEvent(QEvent *)
Definition: LEDButton.cpp:114
LEDButtonPrivate * d
Definition: LEDButton.h:80
void mouseLeft()
void setDarkFactor(int darkfactor)
Definition: LEDButton.cpp:315
void toggle()
Definition: LEDButton.cpp:331
void off()
Definition: LEDButton.cpp:343
QColor led_color
Definition: LEDButton.h:78
int darkFactor() const
QColor color() const
bool led_state
Definition: LEDButton.h:77
void toggleState()
Definition: LEDButton.cpp:293
virtual QSize sizeHint() const
Definition: LEDButton.cpp:349
void setState(bool)
Definition: LEDButton.cpp:283
void stateChanged(bool)
void mousePressEvent(QMouseEvent *)
Definition: LEDButton.cpp:95
void setColor(const QColor &color)
Definition: LEDButton.cpp:301
bool state() const
Definition: LEDButton.cpp:271