30 |
|
|
31 |
namespace QSampler { |
namespace QSampler { |
32 |
|
|
33 |
|
//------------------------------------------------------------------------- |
34 |
|
// QSampler::MidiActivityLED -- Graphical indicator for MIDI activity. |
35 |
|
// |
36 |
|
|
37 |
MidiActivityLED::MidiActivityLED(QString text, QWidget* parent) : QLabel(text, parent) { |
MidiActivityLED::MidiActivityLED(QString text, QWidget* parent) : QLabel(text, parent) { |
38 |
#if CONFIG_LSCP_DEVICE_MIDI |
#if CONFIG_LSCP_DEVICE_MIDI |
39 |
setPalette(MIDI_OFF_COLOR); |
setPalette(MIDI_OFF_COLOR); |
58 |
setPalette(MIDI_OFF_COLOR); |
setPalette(MIDI_OFF_COLOR); |
59 |
} |
} |
60 |
|
|
61 |
|
//------------------------------------------------------------------------- |
62 |
|
// QSampler::DeviceStatusForm -- Device status informations window. |
63 |
|
// |
64 |
|
|
65 |
std::map<int, DeviceStatusForm*> DeviceStatusForm::instances; |
std::map<int, DeviceStatusForm*> DeviceStatusForm::instances; |
66 |
|
|
69 |
: QMainWindow(pParent, wflags) |
: QMainWindow(pParent, wflags) |
70 |
{ |
{ |
71 |
m_pDevice = new Device(Device::Midi, DeviceID); |
m_pDevice = new Device(Device::Midi, DeviceID); |
|
DevicePortList ports = m_pDevice->ports(); |
|
72 |
|
|
73 |
if (!centralWidget()) setCentralWidget(new QWidget(this)); |
if (!centralWidget()) setCentralWidget(new QWidget(this)); |
74 |
|
|
75 |
QGridLayout* pLayout = new QGridLayout(centralWidget()); |
QGridLayout* pLayout = new QGridLayout(centralWidget()); |
|
for (int i = 0; i < ports.size(); ++i) { |
|
|
QLabel* pLabel = |
|
|
new QLabel(QString("MIDI port \"") + ports[i]->portName() + "\": "); |
|
|
pLabel->setToolTip(QString("Device ID ") + QString::number(ports[i]->portID())); |
|
|
pLayout->addWidget(pLabel, i, 0, Qt::AlignLeft); |
|
|
MidiActivityLED* pLED = new MidiActivityLED(); |
|
|
midiActivityLEDs.push_back(pLED); |
|
|
pLayout->addWidget(pLED, i, 1); |
|
|
} |
|
76 |
centralWidget()->setLayout(pLayout); |
centralWidget()->setLayout(pLayout); |
77 |
|
updateGUIPorts(); // build the GUI |
78 |
|
|
79 |
m_pVisibleAction = new QAction(this); |
m_pVisibleAction = new QAction(this); |
80 |
m_pVisibleAction->setCheckable(true); |
m_pVisibleAction->setCheckable(true); |
92 |
setWindowTitle(m_pDevice->deviceName() + " Status"); |
setWindowTitle(m_pDevice->deviceName() + " Status"); |
93 |
} |
} |
94 |
|
|
95 |
|
void DeviceStatusForm::updateGUIPorts() { |
96 |
|
// refresh device informations |
97 |
|
m_pDevice->setDevice(m_pDevice->deviceType(), m_pDevice->deviceID()); |
98 |
|
DevicePortList ports = m_pDevice->ports(); |
99 |
|
|
100 |
|
// clear the GUI |
101 |
|
QGridLayout* pLayout = (QGridLayout*) centralWidget()->layout(); |
102 |
|
for (int i = pLayout->count() - 1; i >= 0; --i) { |
103 |
|
QLayoutItem* pItem = pLayout->itemAt(i); |
104 |
|
if (!pItem) continue; |
105 |
|
pLayout->removeItem(pItem); |
106 |
|
if (pItem->widget()) delete pItem->widget(); |
107 |
|
delete pItem; |
108 |
|
} |
109 |
|
midiActivityLEDs.clear(); |
110 |
|
|
111 |
|
// rebuild the GUI |
112 |
|
for (int i = 0; i < ports.size(); ++i) { |
113 |
|
QLabel* pLabel = |
114 |
|
new QLabel(QString("MIDI port \"") + ports[i]->portName() + "\": "); |
115 |
|
pLabel->setToolTip(QString("Device ID ") + QString::number(ports[i]->portID())); |
116 |
|
pLayout->addWidget(pLabel, i, 0, Qt::AlignLeft); |
117 |
|
MidiActivityLED* pLED = new MidiActivityLED(); |
118 |
|
midiActivityLEDs.push_back(pLED); |
119 |
|
pLayout->addWidget(pLED, i, 1); |
120 |
|
} |
121 |
|
} |
122 |
|
|
123 |
DeviceStatusForm::~DeviceStatusForm() { |
DeviceStatusForm::~DeviceStatusForm() { |
124 |
if (m_pDevice) delete m_pDevice; |
if (m_pDevice) delete m_pDevice; |
125 |
} |
} |
148 |
return instances; |
return instances; |
149 |
} |
} |
150 |
|
|
151 |
|
void DeviceStatusForm::deleteAllInstances() { |
152 |
|
for ( |
153 |
|
std::map<int, DeviceStatusForm*>::iterator iter = instances.begin(); |
154 |
|
iter != instances.end(); ++iter |
155 |
|
) { |
156 |
|
iter->second->hide(); |
157 |
|
delete iter->second; |
158 |
|
} |
159 |
|
instances.clear(); |
160 |
|
} |
161 |
|
|
162 |
void DeviceStatusForm::onDevicesChanged() { |
void DeviceStatusForm::onDevicesChanged() { |
163 |
MainForm* pMainForm = MainForm::getInstance(); |
MainForm* pMainForm = MainForm::getInstance(); |
164 |
if (pMainForm && pMainForm->client()) { |
if (pMainForm && pMainForm->client()) { |
182 |
) { |
) { |
183 |
if (instances.find(*iter) == instances.end()) { |
if (instances.find(*iter) == instances.end()) { |
184 |
DeviceStatusForm* pStatusForm = |
DeviceStatusForm* pStatusForm = |
185 |
new DeviceStatusForm(*iter, pMainForm); |
new DeviceStatusForm(*iter); |
186 |
instances[*iter] = pStatusForm; |
instances[*iter] = pStatusForm; |
187 |
} |
} |
188 |
} |
} |
189 |
} |
} |
190 |
} |
} |
191 |
|
|
192 |
|
void DeviceStatusForm::onDeviceChanged(int iDeviceID) { |
193 |
|
DeviceStatusForm* pForm = DeviceStatusForm::getInstance(iDeviceID); |
194 |
|
if (!pForm) return; |
195 |
|
pForm->updateGUIPorts(); |
196 |
|
} |
197 |
|
|
198 |
} // namespace QSampler |
} // namespace QSampler |
199 |
|
|
200 |
// end of qsamplerDeviceStatusForm.cpp |
// end of qsamplerDeviceStatusForm.cpp |