annotate widgets/LEDButton.h @ 349:369a197737c7

* Various fixes to object lifetime management, particularly in the spectrum layer and for notification of main model deletion. The main purpose of this is to improve the behaviour of the spectrum, but I think it may also help with #1840922 Various crashes in Layer Summary window.
author Chris Cannam
date Wed, 23 Jan 2008 15:43:27 +0000
parents 5b7472db612b
children f4960f8ce798
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@32 32
Chris@32 33 class QColor;
Chris@32 34
Chris@32 35 class LEDButton : public QWidget
Chris@32 36 {
Chris@32 37 Q_OBJECT
Chris@32 38 Q_PROPERTY(QColor color READ color WRITE setColor)
Chris@32 39 Q_PROPERTY(int darkFactor READ darkFactor WRITE setDarkFactor)
Chris@32 40
Chris@32 41 public:
Chris@32 42 LEDButton(QWidget *parent = 0);
Chris@32 43 LEDButton(const QColor &col, QWidget *parent = 0);
Chris@34 44 LEDButton(const QColor& col, bool state, QWidget *parent = 0);
Chris@32 45 ~LEDButton();
Chris@32 46
Chris@34 47 bool state() const;
Chris@32 48 QColor color() const;
Chris@32 49 int darkFactor() const;
Chris@32 50
Chris@32 51 virtual QSize sizeHint() const;
Chris@32 52 virtual QSize minimumSizeHint() const;
Chris@32 53
Chris@33 54 signals:
Chris@33 55 void stateChanged(bool);
Chris@33 56
Chris@189 57 void mouseEntered();
Chris@189 58 void mouseLeft();
Chris@189 59
Chris@32 60 public slots:
Chris@32 61 void toggle();
Chris@32 62 void on();
Chris@32 63 void off();
Chris@32 64
Chris@34 65 void setState(bool);
Chris@34 66 void toggleState();
Chris@34 67 void setColor(const QColor& color);
Chris@34 68 void setDarkFactor(int darkfactor);
Chris@34 69
Chris@32 70 protected:
Chris@32 71 void paintEvent(QPaintEvent *);
Chris@33 72 void mousePressEvent(QMouseEvent *);
Chris@189 73 void enterEvent(QEvent *);
Chris@189 74 void leaveEvent(QEvent *);
Chris@32 75
Chris@34 76 bool led_state;
Chris@32 77 QColor led_color;
Chris@32 78
Chris@32 79 class LEDButtonPrivate;
Chris@32 80 LEDButtonPrivate *d;
Chris@32 81 };
Chris@32 82
Chris@32 83 #endif