summaryrefslogtreecommitdiffstats
path: root/src/widget/wstatuslight.h
blob: ac7250dff50beba4d77a667cdbf412b75667ebb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/***************************************************************************
                          wstatuslight.h  -  A general purpose status light
                                        for indicating boolean events
                             -------------------
    begin                : Fri Jul 22 2007
    copyright            : (C) 2003 by Tue & Ken Haste Andersen
                           (C) 2007 by John Sully (derived from WVumeter)
    email                : jsully@scs.ryerson.ca
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef WSTATUSLIGHT_H
#define WSTATUSLIGHT_H

#include <QPaintEvent>
#include <QWidget>
#include <QString>
#include <QDomNode>
#include <QPixmap>
#include <QVector>

#include "widget/wwidget.h"
#include "widget/wpixmapstore.h"
#include "skin/skincontext.h"

class WStatusLight : public WWidget  {
   Q_OBJECT
  public:
    explicit WStatusLight(QWidget *parent=nullptr);

    void setup(const QDomNode& node, const SkinContext& context);

  public slots:
    void onConnectedControlChanged(double dParameter, double dValue) override;

  protected:
    void paintEvent(QPaintEvent * /*unused*/) override;

  private:
    void setPixmap(int iState, PixmapSource source,
                   Paintable::DrawMode mode, double scaleFactor);
    void setNoPos(int iNoPos);

    // Current position
    int m_iPos;

    PaintablePointer m_pPixmapBackground;

    // Associated pixmaps
    QVector<PaintablePointer> m_pixmaps;
};

#endif