Chris@32: /* -*- c-basic-offset: 4 -*- vi:set ts=8 sts=4 sw=4: */ Chris@32: Chris@32: /* Chris@32: A waveform viewer and audio annotation editor. Chris@32: Chris Cannam, Queen Mary University of London, 2005-2006 Chris@32: Chris@32: This is experimental software. Not for distribution. Chris@32: */ Chris@32: Chris@32: /* Chris@32: This is a modified version of a source file from the KDE Chris@32: libraries. Copyright (c) 1998-2004 Jörg Habenicht, Richard J Chris@32: Moore and others, distributed under the GNU Lesser General Public Chris@32: License. Chris@32: Chris@32: Ported to Qt4 by Chris Cannam. Chris@32: Chris@32: The original KDE widget comes in round and rectangular and flat, Chris@32: raised, and sunken variants. This version retains only the round Chris@33: sunken variant. This version also implements a simple button API. Chris@32: */ Chris@32: Chris@32: #ifndef _LED_BUTTON_H_ Chris@32: #define _LED_BUTTON_H_ Chris@32: Chris@32: #include Chris@32: Chris@32: class QColor; Chris@32: Chris@32: class LEDButton : public QWidget Chris@32: { Chris@32: Q_OBJECT Chris@32: Q_PROPERTY(QColor color READ color WRITE setColor) Chris@32: Q_PROPERTY(int darkFactor READ darkFactor WRITE setDarkFactor) Chris@32: Chris@32: public: Chris@32: LEDButton(QWidget *parent = 0); Chris@32: LEDButton(const QColor &col, QWidget *parent = 0); Chris@34: LEDButton(const QColor& col, bool state, QWidget *parent = 0); Chris@32: ~LEDButton(); Chris@32: Chris@34: bool state() const; Chris@32: QColor color() const; Chris@32: int darkFactor() const; Chris@32: Chris@32: virtual QSize sizeHint() const; Chris@32: virtual QSize minimumSizeHint() const; Chris@32: Chris@33: signals: Chris@33: void stateChanged(bool); Chris@33: Chris@32: public slots: Chris@32: void toggle(); Chris@32: void on(); Chris@32: void off(); Chris@32: Chris@34: void setState(bool); Chris@34: void toggleState(); Chris@34: void setColor(const QColor& color); Chris@34: void setDarkFactor(int darkfactor); Chris@34: Chris@32: protected: Chris@32: void paintEvent(QPaintEvent *); Chris@33: void mousePressEvent(QMouseEvent *); Chris@32: Chris@32: private: Chris@34: bool led_state; Chris@32: QColor led_color; Chris@32: Chris@32: private: Chris@32: class LEDButtonPrivate; Chris@32: LEDButtonPrivate *d; Chris@32: }; Chris@32: Chris@32: #endif