Chris@58: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@32: Chris@32: /* Chris@59: Sonic Visualiser Chris@59: An audio file viewer and annotation editor. Chris@59: Centre for Digital Music, Queen Mary, University of London. Chris@32: Chris@59: This program is free software; you can redistribute it and/or Chris@59: modify it under the terms of the GNU General Public License as Chris@59: published by the Free Software Foundation; either version 2 of the Chris@59: License, or (at your option) any later version. See the file Chris@59: COPYING included with this distribution for more information. 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@1174: #ifndef SV_LED_BUTTON_H Chris@1174: #define SV_LED_BUTTON_H Chris@32: Chris@32: #include Chris@585: #include "base/Debug.h" 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@189: void mouseEntered(); Chris@189: void mouseLeft(); Chris@189: 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@189: void enterEvent(QEvent *); Chris@189: void leaveEvent(QEvent *); Chris@32: Chris@34: bool led_state; Chris@32: QColor led_color; Chris@32: Chris@32: class LEDButtonPrivate; Chris@32: LEDButtonPrivate *d; Chris@32: }; Chris@32: Chris@32: #endif