20 |
|
|
21 |
*****************************************************************************/ |
*****************************************************************************/ |
22 |
|
|
23 |
|
#include "qsamplerAbout.h" |
24 |
#include "qsamplerChannelStrip.h" |
#include "qsamplerChannelStrip.h" |
25 |
|
|
26 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
27 |
|
|
28 |
#include <q3dragobject.h> |
#include <QDragEnterEvent> |
|
|
|
29 |
#include <QUrl> |
#include <QUrl> |
30 |
|
|
31 |
#include <math.h> |
#include <math.h> |
74 |
} |
} |
75 |
|
|
76 |
|
|
77 |
// Drag'n'drop file handler. |
// Window drag-n-drop event handlers. |
78 |
bool ChannelStrip::decodeDragFile ( const QMimeSource *pEvent, QString& sInstrumentFile ) |
void ChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
79 |
{ |
{ |
80 |
if (m_pChannel == NULL) |
if (m_pChannel == NULL) |
81 |
return false; |
return; |
82 |
if (Q3TextDrag::canDecode(pEvent)) { |
|
83 |
QString sText; |
bool bAccept = false; |
84 |
if (Q3TextDrag::decode(pEvent, sText)) { |
|
85 |
QStringList files = QStringList::split('\n', sText); |
if (pDragEnterEvent->source() == NULL) { |
86 |
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) { |
const QMimeData *pMimeData = pDragEnterEvent->mimeData(); |
87 |
*iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path(); |
if (pMimeData && pMimeData->hasUrls()) { |
88 |
if (qsamplerChannel::isInstrumentFile(*iter)) { |
QListIterator<QUrl> iter(pMimeData->urls()); |
89 |
sInstrumentFile = *iter; |
while (iter.hasNext()) { |
90 |
return true; |
const QString& sFilename = iter.next().toLocalFile(); |
91 |
|
if (!sFilename.isEmpty()) { |
92 |
|
bAccept = qsamplerChannel::isInstrumentFile(sFilename); |
93 |
|
break; |
94 |
} |
} |
95 |
} |
} |
96 |
} |
} |
97 |
} |
} |
|
// Fail. |
|
|
return false; |
|
|
} |
|
|
|
|
98 |
|
|
99 |
// Window drag-n-drop event handlers. |
if (bAccept) |
100 |
void ChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
pDragEnterEvent->accept(); |
101 |
{ |
else |
102 |
QString sInstrumentFile; |
pDragEnterEvent->ignore(); |
|
pDragEnterEvent->accept(decodeDragFile(pDragEnterEvent, sInstrumentFile)); |
|
103 |
} |
} |
104 |
|
|
105 |
|
|
106 |
void ChannelStrip::dropEvent ( QDropEvent* pDropEvent ) |
void ChannelStrip::dropEvent ( QDropEvent* pDropEvent ) |
107 |
{ |
{ |
108 |
QString sInstrumentFile; |
if (m_pChannel == NULL) |
109 |
|
return; |
110 |
|
|
111 |
|
if (pDropEvent->source()) |
112 |
|
return; |
113 |
|
|
114 |
if (decodeDragFile(pDropEvent, sInstrumentFile)) { |
const QMimeData *pMimeData = pDropEvent->mimeData(); |
115 |
// Go and set the dropped instrument filename... |
if (pMimeData && pMimeData->hasUrls()) { |
116 |
m_pChannel->setInstrument(sInstrumentFile, 0); |
QStringList files; |
117 |
// Open up the channel dialog. |
QListIterator<QUrl> iter(pMimeData->urls()); |
118 |
channelSetup(); |
while (iter.hasNext()) { |
119 |
|
const QString& sFilename = iter.next().toLocalFile(); |
120 |
|
if (!sFilename.isEmpty()) { |
121 |
|
// Go and set the dropped instrument filename... |
122 |
|
m_pChannel->setInstrument(sFilename, 0); |
123 |
|
// Open up the channel dialog. |
124 |
|
channelSetup(); |
125 |
|
break; |
126 |
|
} |
127 |
|
} |
128 |
} |
} |
129 |
} |
} |
130 |
|
|
173 |
// Channel display background effect. |
// Channel display background effect. |
174 |
void ChannelStrip::setDisplayEffect ( bool bDisplayEffect ) |
void ChannelStrip::setDisplayEffect ( bool bDisplayEffect ) |
175 |
{ |
{ |
176 |
QPixmap pm = |
QPalette pal; |
177 |
(bDisplayEffect) ? |
pal.setColor(QPalette::Foreground, Qt::green); |
178 |
QPixmap(":/icons/displaybg1.png") : QPixmap(); |
if (bDisplayEffect) { |
179 |
setDisplayBackground(pm); |
QPixmap pm(":/icons/displaybg1.png"); |
180 |
} |
pal.setBrush(QPalette::Background, QBrush(pm)); |
181 |
|
} else { |
182 |
|
pal.setColor(QPalette::Background, Qt::black); |
183 |
// Update main display background pixmap. |
} |
184 |
void ChannelStrip::setDisplayBackground ( const QPixmap& pm ) |
ui.ChannelInfoFrame->setPalette(pal); |
185 |
{ |
ui.StreamVoiceCountTextLabel->setPalette(pal); |
|
// Set the main origin... |
|
|
ui.ChannelInfoFrame->setPaletteBackgroundPixmap(pm); |
|
|
|
|
|
// Iterate for every child text label... |
|
|
QList<QObject*> list = ui.ChannelInfoFrame->queryList("QLabel"); |
|
|
for (QList<QObject*>::iterator iter = list.begin(); iter != list.end(); iter++) { |
|
|
static_cast<QLabel*>(*iter)->setPaletteBackgroundPixmap(pm); |
|
|
} |
|
|
|
|
|
// And this standalone too. |
|
|
ui.StreamVoiceCountTextLabel->setPaletteBackgroundPixmap(pm); |
|
186 |
} |
} |
187 |
|
|
188 |
|
|
339 |
|
|
340 |
// Update strip caption. |
// Update strip caption. |
341 |
QString sText = m_pChannel->channelName(); |
QString sText = m_pChannel->channelName(); |
342 |
setCaption(sText); |
setWindowTitle(sText); |
343 |
ui.ChannelSetupPushButton->setText(sText); |
ui.ChannelSetupPushButton->setText(sText); |
344 |
|
|
345 |
// Check if we're up and connected. |
// Check if we're up and connected. |
367 |
sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1); |
sMidiPortChannel += QString::number(m_pChannel->midiChannel() + 1); |
368 |
ui.MidiPortChannelTextLabel->setText(sMidiPortChannel); |
ui.MidiPortChannelTextLabel->setText(sMidiPortChannel); |
369 |
|
|
370 |
|
// Common palette... |
371 |
|
QPalette pal; |
372 |
|
const QColor& rgbFore = pal.color(QPalette::Foreground); |
373 |
|
|
374 |
// Instrument status... |
// Instrument status... |
375 |
int iInstrumentStatus = m_pChannel->instrumentStatus(); |
int iInstrumentStatus = m_pChannel->instrumentStatus(); |
376 |
if (iInstrumentStatus < 0) { |
if (iInstrumentStatus < 0) { |
377 |
ui.InstrumentStatusTextLabel->setPaletteForegroundColor(Qt::red); |
pal.setColor(QPalette::Foreground, Qt::red); |
378 |
|
ui.InstrumentStatusTextLabel->setPalette(pal); |
379 |
ui.InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus)); |
ui.InstrumentStatusTextLabel->setText(tr("ERR%1").arg(iInstrumentStatus)); |
380 |
m_iErrorCount++; |
m_iErrorCount++; |
381 |
return false; |
return false; |
382 |
} |
} |
383 |
// All seems normal... |
// All seems normal... |
384 |
ui.InstrumentStatusTextLabel->setPaletteForegroundColor(iInstrumentStatus < 100 ? Qt::yellow : Qt::green); |
pal.setColor(QPalette::Foreground, |
385 |
|
iInstrumentStatus < 100 ? Qt::yellow : Qt::green); |
386 |
|
ui.InstrumentStatusTextLabel->setPalette(pal); |
387 |
ui.InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%'); |
ui.InstrumentStatusTextLabel->setText(QString::number(iInstrumentStatus) + '%'); |
388 |
m_iErrorCount = 0; |
m_iErrorCount = 0; |
389 |
|
|
390 |
#ifdef CONFIG_MUTE_SOLO |
#ifdef CONFIG_MUTE_SOLO |
391 |
// Mute/Solo button state coloring... |
// Mute/Solo button state coloring... |
|
const QColor& rgbNormal = ChannelSetupPushButton->paletteBackgroundColor(); |
|
392 |
bool bMute = m_pChannel->channelMute(); |
bool bMute = m_pChannel->channelMute(); |
393 |
ChannelMutePushButton->setPaletteBackgroundColor(bMute ? Qt::yellow : rgbNormal); |
const QColor& rgbButton = pal.color(QPalette::Button); |
394 |
ChannelMutePushButton->setDown(bMute); |
pal.setColor(QPalette::Foreground, rgbFore); |
395 |
|
pal.setColor(QPalette::Button, bMute ? Qt::yellow : rgbButton); |
396 |
|
ui.ChannelMutePushButton->setPalette(pal); |
397 |
|
ui.ChannelMutePushButton->setDown(bMute); |
398 |
bool bSolo = m_pChannel->channelSolo(); |
bool bSolo = m_pChannel->channelSolo(); |
399 |
ChannelSoloPushButton->setPaletteBackgroundColor(bSolo ? Qt::cyan : rgbNormal); |
pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton); |
400 |
ChannelSoloPushButton->setDown(bSolo); |
ui.ChannelSoloPushButton->setPalette(pal); |
401 |
|
ui.ChannelSoloPushButton->setDown(bSolo); |
402 |
#else |
#else |
403 |
ui.ChannelMutePushButton->setEnabled(false); |
ui.ChannelMutePushButton->setEnabled(false); |
404 |
ui.ChannelSoloPushButton->setEnabled(false); |
ui.ChannelSoloPushButton->setEnabled(false); |
426 |
|
|
427 |
// Get current channel voice count. |
// Get current channel voice count. |
428 |
int iVoiceCount = ::lscp_get_channel_voice_count(pMainForm->client(), m_pChannel->channelID()); |
int iVoiceCount = ::lscp_get_channel_voice_count(pMainForm->client(), m_pChannel->channelID()); |
429 |
// Get current stream count. |
// Get current stream count. |
430 |
int iStreamCount = ::lscp_get_channel_stream_count(pMainForm->client(), m_pChannel->channelID()); |
int iStreamCount = ::lscp_get_channel_stream_count(pMainForm->client(), m_pChannel->channelID()); |
431 |
// Get current channel buffer fill usage. |
// Get current channel buffer fill usage. |
432 |
// As benno has suggested this is the percentage usage |
// As benno has suggested this is the percentage usage |