1 |
// qsamplerDeviceStatusForm.h |
2 |
// |
3 |
/**************************************************************************** |
4 |
Copyright (C) 2008, Christian Schoenebeck |
5 |
Copyright (C) 2010, rncbc aka Rui Nuno Capela. All rights reserved. |
6 |
|
7 |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
9 |
as published by the Free Software Foundation; either version 2 |
10 |
of the License, or (at your option) any later version. |
11 |
|
12 |
This program is distributed in the hope that it will be useful, |
13 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
GNU General Public License for more details. |
16 |
|
17 |
You should have received a copy of the GNU General Public License |
18 |
along with this program; if not, write to the Free Software |
19 |
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
20 |
|
21 |
*****************************************************************************/ |
22 |
|
23 |
#ifndef __qsamplerDeviceStatusForm_h |
24 |
#define __qsamplerDeviceStatusForm_h |
25 |
|
26 |
#include "qsamplerDevice.h" |
27 |
|
28 |
#include <QMainWindow> |
29 |
#include <QAction> |
30 |
#include <QCloseEvent> |
31 |
#include <QLabel> |
32 |
#include <QTimer> |
33 |
|
34 |
#include <map> |
35 |
|
36 |
|
37 |
namespace QSampler { |
38 |
|
39 |
class MidiActivityLED : public QLabel |
40 |
{ |
41 |
Q_OBJECT |
42 |
|
43 |
public: |
44 |
|
45 |
MidiActivityLED(QString sText = QString(), QWidget *pParent = 0); |
46 |
~MidiActivityLED(); |
47 |
|
48 |
void midiActivityLedOn(); |
49 |
|
50 |
protected slots: |
51 |
|
52 |
void midiActivityLedOff(); |
53 |
|
54 |
private: |
55 |
|
56 |
QTimer m_timer; |
57 |
|
58 |
// MIDI activity pixmap common resources. |
59 |
static int g_iMidiActivityRefCount; |
60 |
static QPixmap *g_pMidiActivityLedOn; |
61 |
static QPixmap *g_pMidiActivityLedOff; |
62 |
}; |
63 |
|
64 |
|
65 |
class DeviceStatusForm : public QWidget |
66 |
{ |
67 |
Q_OBJECT |
68 |
|
69 |
public: |
70 |
|
71 |
DeviceStatusForm(int DeviceID, |
72 |
QWidget* pParent = NULL, Qt::WindowFlags wflags = 0); |
73 |
~DeviceStatusForm(); |
74 |
|
75 |
QAction *visibleAction(); |
76 |
|
77 |
void midiArrived(int iPort); |
78 |
|
79 |
static DeviceStatusForm *getInstance(int iDeviceID); |
80 |
static const std::map<int, DeviceStatusForm *>& getInstances(); |
81 |
|
82 |
static void onDevicesChanged(); |
83 |
static void onDeviceChanged(int iDeviceID); |
84 |
|
85 |
static void deleteAllInstances(); |
86 |
|
87 |
protected: |
88 |
|
89 |
void closeEvent(QCloseEvent *pCloseEvent); |
90 |
void updateGUIPorts(); |
91 |
|
92 |
private: |
93 |
|
94 |
int m_DeviceID; |
95 |
Device *m_pDevice; |
96 |
QAction *m_pVisibleAction; |
97 |
|
98 |
std::vector<MidiActivityLED *> m_midiActivityLEDs; |
99 |
|
100 |
static std::map<int, DeviceStatusForm*> g_instances; |
101 |
}; |
102 |
|
103 |
} // namespace QSampler |
104 |
|
105 |
|
106 |
#endif // __qsamplerDeviceStatusForm_h |
107 |
|
108 |
// end of qsamplerDeviceStatusForm.h |