annotate widgets/LEDButton.h @ 742:d7e8cefedbbc

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