2 |
// |
// |
3 |
// ui.h extension file, included from the uic-generated form implementation. |
// ui.h extension file, included from the uic-generated form implementation. |
4 |
/**************************************************************************** |
/**************************************************************************** |
5 |
Copyright (C) 2004, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2005, rncbc aka Rui Nuno Capela. All rights reserved. |
6 |
|
|
7 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
8 |
modify it under the terms of the GNU General Public License |
modify it under the terms of the GNU General Public License |
26 |
#include <qprocess.h> |
#include <qprocess.h> |
27 |
#include <qmessagebox.h> |
#include <qmessagebox.h> |
28 |
#include <qdragobject.h> |
#include <qdragobject.h> |
29 |
|
#include <qregexp.h> |
30 |
#include <qfiledialog.h> |
#include <qfiledialog.h> |
31 |
#include <qfileinfo.h> |
#include <qfileinfo.h> |
32 |
#include <qfile.h> |
#include <qfile.h> |
37 |
|
|
38 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
39 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
40 |
|
#include "qsamplerChannel.h" |
41 |
#include "qsamplerMessages.h" |
#include "qsamplerMessages.h" |
42 |
|
|
43 |
#include "qsamplerChannelStrip.h" |
#include "qsamplerChannelStrip.h" |
45 |
|
|
46 |
#include "config.h" |
#include "config.h" |
47 |
|
|
48 |
|
#ifdef HAVE_SIGNAL_H |
49 |
|
#include <signal.h> |
50 |
|
#endif |
51 |
|
|
52 |
// Timer constant stuff. |
// Timer constant stuff. |
53 |
#define QSAMPLER_TIMER_MSECS 200 |
#define QSAMPLER_TIMER_MSECS 200 |
59 |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
60 |
|
|
61 |
|
|
62 |
|
// All winsock apps needs this. |
63 |
#if defined(WIN32) |
#if defined(WIN32) |
64 |
static WSADATA _wsaData; |
static WSADATA _wsaData; |
65 |
#endif |
#endif |
66 |
|
|
67 |
|
|
68 |
|
//------------------------------------------------------------------------- |
69 |
|
// qsamplerCustomEvent -- specialty for callback comunication. |
70 |
|
|
71 |
|
#define QSAMPLER_CUSTOM_EVENT 1000 |
72 |
|
|
73 |
|
class qsamplerCustomEvent : public QCustomEvent |
74 |
|
{ |
75 |
|
public: |
76 |
|
|
77 |
|
// Constructor. |
78 |
|
qsamplerCustomEvent(lscp_event_t event, const char *pchData, int cchData) |
79 |
|
: QCustomEvent(QSAMPLER_CUSTOM_EVENT) |
80 |
|
{ |
81 |
|
m_event = event; |
82 |
|
m_data.setLatin1(pchData, cchData); |
83 |
|
} |
84 |
|
|
85 |
|
// Accessors. |
86 |
|
lscp_event_t event() { return m_event; } |
87 |
|
QString& data() { return m_data; } |
88 |
|
|
89 |
|
private: |
90 |
|
|
91 |
|
// The proper event type. |
92 |
|
lscp_event_t m_event; |
93 |
|
// The event data as a string. |
94 |
|
QString m_data; |
95 |
|
}; |
96 |
|
|
97 |
|
|
98 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
99 |
// qsamplerMainForm -- Main window form implementation. |
// qsamplerMainForm -- Main window form implementation. |
100 |
|
|
108 |
m_pMessages = NULL; |
m_pMessages = NULL; |
109 |
|
|
110 |
// We'll start clean. |
// We'll start clean. |
111 |
m_iUntitled = 0; |
m_iUntitled = 0; |
112 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
113 |
|
|
114 |
m_pServer = NULL; |
m_pServer = NULL; |
119 |
|
|
120 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
121 |
|
|
122 |
|
#ifdef HAVE_SIGNAL_H |
123 |
|
// Set to ignore any fatal "Broken pipe" signals. |
124 |
|
::signal(SIGPIPE, SIG_IGN); |
125 |
|
#endif |
126 |
|
|
127 |
// Make it an MDI workspace. |
// Make it an MDI workspace. |
128 |
m_pWorkspace = new QWorkspace(this); |
m_pWorkspace = new QWorkspace(this); |
129 |
m_pWorkspace->setScrollBarsEnabled(true); |
m_pWorkspace->setScrollBarsEnabled(true); |
294 |
} |
} |
295 |
|
|
296 |
|
|
297 |
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
// Drag'n'drop file handler. |
298 |
|
bool qsamplerMainForm::decodeDragFiles ( const QMimeSource *pEvent, QStringList& files ) |
299 |
{ |
{ |
300 |
bool bAccept = false; |
bool bDecode = false; |
301 |
|
|
302 |
if (QTextDrag::canDecode(pDragEnterEvent)) { |
if (QTextDrag::canDecode(pEvent)) { |
303 |
QString sUrl; |
QString sText; |
304 |
if (QTextDrag::decode(pDragEnterEvent, sUrl) && m_pClient) |
bDecode = QTextDrag::decode(pEvent, sText); |
305 |
bAccept = QFileInfo(QUrl(sUrl).path()).exists(); |
if (bDecode) { |
306 |
|
files = QStringList::split('\n', sText); |
307 |
|
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) |
308 |
|
*iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path(); |
309 |
|
} |
310 |
} |
} |
311 |
|
|
312 |
pDragEnterEvent->accept(bAccept); |
return bDecode; |
313 |
|
} |
314 |
|
|
315 |
|
|
316 |
|
// Window drag-n-drop event handlers. |
317 |
|
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
318 |
|
{ |
319 |
|
QStringList files; |
320 |
|
pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files)); |
321 |
} |
} |
322 |
|
|
323 |
|
|
324 |
void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent ) |
void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent ) |
325 |
{ |
{ |
326 |
if (QTextDrag::canDecode(pDropEvent)) { |
QStringList files; |
327 |
QString sUrl; |
|
328 |
if (QTextDrag::decode(pDropEvent, sUrl) && closeSession(true)) |
if (!decodeDragFiles(pDropEvent, files)) |
329 |
loadSessionFile(QUrl(sUrl).path()); |
return; |
330 |
|
|
331 |
|
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) { |
332 |
|
const QString& sPath = *iter; |
333 |
|
if (qsamplerChannel::isInstrumentFile(sPath)) { |
334 |
|
// Try to create a new channel from instrument file... |
335 |
|
qsamplerChannel *pChannel = new qsamplerChannel(this); |
336 |
|
if (pChannel == NULL) |
337 |
|
return; |
338 |
|
// Start setting the instrument filename... |
339 |
|
pChannel->setInstrument(sPath, 0); |
340 |
|
// Before we show it up, may be we'll |
341 |
|
// better ask for some initial values? |
342 |
|
if (!pChannel->channelSetup(this)) { |
343 |
|
delete pChannel; |
344 |
|
return; |
345 |
|
} |
346 |
|
// Finally, give it to a new channel strip... |
347 |
|
if (!createChannelStrip(pChannel)) { |
348 |
|
delete pChannel; |
349 |
|
return; |
350 |
|
} |
351 |
|
// Make that an overall update. |
352 |
|
m_iDirtyCount++; |
353 |
|
stabilizeForm(); |
354 |
|
} // Otherwise, load an usual session file (LSCP script)... |
355 |
|
else if (closeSession(true)) |
356 |
|
loadSessionFile(sPath); |
357 |
|
// Make it look responsive...:) |
358 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
359 |
|
} |
360 |
|
} |
361 |
|
|
362 |
|
|
363 |
|
// Custome event handler. |
364 |
|
void qsamplerMainForm::customEvent ( QCustomEvent *pCustomEvent ) |
365 |
|
{ |
366 |
|
// For the time being, just pump it to messages. |
367 |
|
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
368 |
|
qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent; |
369 |
|
appendMessagesColor(tr("Notify event: %1 data: %2") |
370 |
|
.arg(::lscp_event_to_text(pEvent->event())) |
371 |
|
.arg(pEvent->data()), "#996699"); |
372 |
} |
} |
373 |
} |
} |
374 |
|
|
375 |
|
|
376 |
|
// Context menu event handler. |
377 |
|
void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent ) |
378 |
|
{ |
379 |
|
stabilizeForm(); |
380 |
|
|
381 |
|
editMenu->exec(pEvent->globalPos()); |
382 |
|
} |
383 |
|
|
384 |
|
|
385 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
386 |
// qsamplerMainForm -- Brainless public property accessors. |
// qsamplerMainForm -- Brainless public property accessors. |
387 |
|
|
421 |
if (!closeSession(true)) |
if (!closeSession(true)) |
422 |
return false; |
return false; |
423 |
|
|
424 |
|
// Give us what the server has, right now... |
425 |
|
updateSession(); |
426 |
|
|
427 |
// Ok increment untitled count. |
// Ok increment untitled count. |
428 |
m_iUntitled++; |
m_iUntitled++; |
429 |
|
|
537 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
538 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
539 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
540 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
541 |
if (bForce && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK) |
if (pChannelStrip) { |
542 |
appendMessagesClient("lscp_remove_channel"); |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
543 |
delete pChannel; |
if (bForce && pChannel) |
544 |
|
pChannel->removeChannel(); |
545 |
|
delete pChannelStrip; |
546 |
|
} |
547 |
} |
} |
548 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
549 |
// We're now clean, for sure. |
// We're now clean, for sure. |
582 |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
583 |
appendMessagesClient("lscp_client_query"); |
appendMessagesClient("lscp_client_query"); |
584 |
iErrors++; |
iErrors++; |
585 |
|
break; |
586 |
} |
} |
587 |
} |
} |
588 |
// Try to make it snappy :) |
// Try to make it snappy :) |
594 |
|
|
595 |
// Have we any errors? |
// Have we any errors? |
596 |
if (iErrors > 0) |
if (iErrors > 0) |
597 |
appendMessagesError(tr("Some setttings could not be loaded\nfrom \"%1\" session file.\n\nSorry.").arg(sFilename)); |
appendMessagesError(tr("Session could not be loaded\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
598 |
|
|
599 |
// Now we'll try to create the whole GUI session. |
// Now we'll try to create (update) the whole GUI session. |
600 |
int iChannels = ::lscp_get_channels(m_pClient); |
updateSession(); |
|
if (iChannels < 0) { |
|
|
appendMessagesClient("lscp_get_channels"); |
|
|
appendMessagesError(tr("Could not get current number of channels.\n\nSorry.")); |
|
|
} |
|
|
|
|
|
// Try to (re)create each channel. |
|
|
m_pWorkspace->setUpdatesEnabled(false); |
|
|
for (int iChannelID = 0; iChannelID < iChannels; iChannelID++) { |
|
|
createChannel(iChannelID, false); |
|
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
|
|
} |
|
|
m_pWorkspace->setUpdatesEnabled(true); |
|
601 |
|
|
602 |
// Save as default session directory. |
// Save as default session directory. |
603 |
if (m_pOptions) |
if (m_pOptions) |
608 |
m_sFilename = sFilename; |
m_sFilename = sFilename; |
609 |
updateRecentFiles(sFilename); |
updateRecentFiles(sFilename); |
610 |
appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename))); |
appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename))); |
611 |
|
|
612 |
|
// Make that an overall update. |
613 |
stabilizeForm(); |
stabilizeForm(); |
614 |
return true; |
return true; |
615 |
} |
} |
643 |
ts << endl; |
ts << endl; |
644 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
645 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
646 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
647 |
int iChannelID = pChannel->channelID(); |
if (pChannelStrip) { |
648 |
ts << "# " << pChannel->caption() << endl; |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
649 |
ts << "ADD CHANNEL" << endl; |
if (pChannel) { |
650 |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl; |
ts << "# Channel " << iChannel << endl; |
651 |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl; |
ts << "ADD CHANNEL" << endl; |
652 |
// ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl; |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel << " " << pChannel->audioDriver() << endl; |
653 |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl; |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel << " " << pChannel->midiDriver() << endl; |
654 |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl; |
// ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel << " " << pChannel->midiPort() << endl; |
655 |
ts << "LOAD INSTRUMENT " << pChannel->instrumentFile() << " " << pChannel->instrumentNr() << " " << iChannelID << endl; |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " "; |
656 |
ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl; |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
657 |
ts << endl; |
ts << "ALL"; |
658 |
|
else |
659 |
|
ts << pChannel->midiChannel(); |
660 |
|
ts << endl; |
661 |
|
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl; |
662 |
|
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl; |
663 |
|
ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl; |
664 |
|
ts << endl; |
665 |
|
} |
666 |
|
} |
667 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
668 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
669 |
} |
} |
735 |
} |
} |
736 |
|
|
737 |
|
|
738 |
|
// Reset the sampler instance. |
739 |
|
void qsamplerMainForm::fileReset (void) |
740 |
|
{ |
741 |
|
if (m_pClient == NULL) |
742 |
|
return; |
743 |
|
|
744 |
|
// Ask user whether he/she want's an internal sampler reset... |
745 |
|
if (QMessageBox::warning(this, tr("Warning"), |
746 |
|
tr("Resetting the sampler instance will close\n" |
747 |
|
"all device and channel configurations.\n\n" |
748 |
|
"Please note that this operation may cause\n" |
749 |
|
"temporary MIDI and Audio disruption\n\n" |
750 |
|
"Do you want to reset the sampler engine now?"), |
751 |
|
tr("Reset"), tr("Cancel")) > 0) |
752 |
|
return; |
753 |
|
|
754 |
|
// Just do the reset, after closing down current session... |
755 |
|
if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
756 |
|
appendMessagesClient("lscp_reset_sampler"); |
757 |
|
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
758 |
|
return; |
759 |
|
} |
760 |
|
|
761 |
|
// Log this. |
762 |
|
appendMessages(tr("Sampler reset.")); |
763 |
|
|
764 |
|
// Make it a new session... |
765 |
|
newSession(); |
766 |
|
} |
767 |
|
|
768 |
|
|
769 |
// Restart the client/server instance. |
// Restart the client/server instance. |
770 |
void qsamplerMainForm::fileRestart (void) |
void qsamplerMainForm::fileRestart (void) |
771 |
{ |
{ |
813 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
814 |
return; |
return; |
815 |
|
|
816 |
// Create the new sampler channel. |
// Just create the channel instance... |
817 |
int iChannelID = ::lscp_add_channel(m_pClient); |
qsamplerChannel *pChannel = new qsamplerChannel(this); |
818 |
if (iChannelID < 0) { |
if (pChannel == NULL) |
|
appendMessagesClient("lscp_add_channel"); |
|
|
appendMessagesError(tr("Could not create the new channel.\n\nSorry.")); |
|
819 |
return; |
return; |
|
} |
|
|
|
|
|
// Log this happening. |
|
|
appendMessages(tr("Channel %1 created.").arg(iChannelID)); |
|
820 |
|
|
821 |
// Just create the channel strip with given id. |
// Before we show it up, may be we'll |
822 |
createChannel(iChannelID, true); |
// better ask for some initial values? |
823 |
|
if (!pChannel->channelSetup(this)) { |
824 |
|
delete pChannel; |
825 |
|
return; |
826 |
|
} |
827 |
|
|
828 |
|
// And give it to the strip (will own the channel instance, if successful). |
829 |
|
if (!createChannelStrip(pChannel)) { |
830 |
|
delete pChannel; |
831 |
|
return; |
832 |
|
} |
833 |
|
|
834 |
// We'll be dirty, for sure... |
// Make that an overall update. |
835 |
m_iDirtyCount++; |
m_iDirtyCount++; |
|
// Stabilize form anyway. |
|
836 |
stabilizeForm(); |
stabilizeForm(); |
837 |
} |
} |
838 |
|
|
843 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
844 |
return; |
return; |
845 |
|
|
846 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
847 |
|
if (pChannelStrip == NULL) |
848 |
|
return; |
849 |
|
|
850 |
|
qsamplerChannel *pChannel = pChannelStrip->channel(); |
851 |
if (pChannel == NULL) |
if (pChannel == NULL) |
852 |
return; |
return; |
853 |
|
|
857 |
tr("About to remove channel:\n\n" |
tr("About to remove channel:\n\n" |
858 |
"%1\n\n" |
"%1\n\n" |
859 |
"Are you sure?") |
"Are you sure?") |
860 |
.arg(pChannel->caption()), |
.arg(pChannelStrip->caption()), |
861 |
tr("OK"), tr("Cancel")) > 0) |
tr("OK"), tr("Cancel")) > 0) |
862 |
return; |
return; |
863 |
} |
} |
864 |
|
|
865 |
// Remove the existing sampler channel. |
// Remove the existing sampler channel. |
866 |
if (::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK) { |
if (!pChannel->removeChannel()) |
|
appendMessagesClient("lscp_remove_channel"); |
|
|
appendMessagesError(tr("Could not remove channel.\n\nSorry.")); |
|
867 |
return; |
return; |
|
} |
|
868 |
|
|
|
// Log this happening. |
|
|
appendMessages(tr("Channel %1 removed.").arg(pChannel->channelID())); |
|
|
|
|
869 |
// Just delete the channel strip. |
// Just delete the channel strip. |
870 |
delete pChannel; |
delete pChannelStrip; |
871 |
|
|
872 |
// Do we auto-arrange? |
// Do we auto-arrange? |
873 |
if (m_pOptions && m_pOptions->bAutoArrange) |
if (m_pOptions && m_pOptions->bAutoArrange) |
874 |
channelsArrange(); |
channelsArrange(); |
885 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
886 |
return; |
return; |
887 |
|
|
888 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
889 |
if (pChannel == NULL) |
if (pChannelStrip == NULL) |
890 |
return; |
return; |
891 |
|
|
892 |
// Just invoque the channel strip procedure. |
// Just invoque the channel strip procedure. |
893 |
pChannel->channelSetup(); |
pChannelStrip->channelSetup(); |
894 |
} |
} |
895 |
|
|
896 |
|
|
900 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
901 |
return; |
return; |
902 |
|
|
903 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
904 |
if (pChannel == NULL) |
if (pChannelStrip == NULL) |
905 |
return; |
return; |
906 |
|
|
907 |
// Remove the existing sampler channel. |
// Just invoque the channel strip procedure. |
908 |
if (::lscp_reset_channel(m_pClient, pChannel->channelID()) != LSCP_OK) { |
pChannelStrip->channelReset(); |
909 |
appendMessagesClient("lscp_reset_channel"); |
} |
|
appendMessagesError(tr("Could not reset channel.\n\nSorry.")); |
|
|
return; |
|
|
} |
|
910 |
|
|
|
// Log this. |
|
|
appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID())); |
|
911 |
|
|
912 |
// Refresh channel strip info. |
// Reset all sampler channels. |
913 |
pChannel->updateChannelInfo(); |
void qsamplerMainForm::editResetAllChannels (void) |
914 |
|
{ |
915 |
|
if (m_pClient == NULL) |
916 |
|
return; |
917 |
|
|
918 |
|
// Invoque the channel strip procedure, |
919 |
|
// for all channels out there... |
920 |
|
m_pWorkspace->setUpdatesEnabled(false); |
921 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
922 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
923 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
924 |
|
if (pChannelStrip) |
925 |
|
pChannelStrip->channelReset(); |
926 |
|
} |
927 |
|
m_pWorkspace->setUpdatesEnabled(true); |
928 |
} |
} |
929 |
|
|
930 |
|
|
985 |
qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this); |
qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this); |
986 |
if (pOptionsForm) { |
if (pOptionsForm) { |
987 |
// Check out some initial nullities(tm)... |
// Check out some initial nullities(tm)... |
988 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
989 |
if (m_pOptions->sDisplayFont.isEmpty() && pChannel) |
if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip) |
990 |
m_pOptions->sDisplayFont = pChannel->displayFont().toString(); |
m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString(); |
991 |
if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages) |
if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages) |
992 |
m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString(); |
m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString(); |
993 |
// To track down deferred or immediate changes. |
// To track down deferred or immediate changes. |
997 |
bool bOldServerStart = m_pOptions->bServerStart; |
bool bOldServerStart = m_pOptions->bServerStart; |
998 |
QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
999 |
QString sOldDisplayFont = m_pOptions->sDisplayFont; |
QString sOldDisplayFont = m_pOptions->sDisplayFont; |
1000 |
|
bool bOldDisplayEffect = m_pOptions->bDisplayEffect; |
1001 |
|
int iOldMaxVolume = m_pOptions->iMaxVolume; |
1002 |
QString sOldMessagesFont = m_pOptions->sMessagesFont; |
QString sOldMessagesFont = m_pOptions->sMessagesFont; |
1003 |
bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
1004 |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
1005 |
int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
1006 |
bool bOldCompletePath = m_pOptions->bCompletePath; |
bool bOldCompletePath = m_pOptions->bCompletePath; |
1007 |
|
bool bOldInstrumentNames = m_pOptions->bInstrumentNames; |
1008 |
int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
1009 |
// Load the current setup settings. |
// Load the current setup settings. |
1010 |
pOptionsForm->setup(m_pOptions); |
pOptionsForm->setup(m_pOptions); |
1023 |
(!bOldCompletePath && m_pOptions->bCompletePath) || |
(!bOldCompletePath && m_pOptions->bCompletePath) || |
1024 |
(iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles)) |
(iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles)) |
1025 |
updateRecentFilesMenu(); |
updateRecentFilesMenu(); |
1026 |
|
if (( bOldInstrumentNames && !m_pOptions->bInstrumentNames) || |
1027 |
|
(!bOldInstrumentNames && m_pOptions->bInstrumentNames)) |
1028 |
|
updateInstrumentNames(); |
1029 |
|
if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) || |
1030 |
|
(!bOldDisplayEffect && m_pOptions->bDisplayEffect)) |
1031 |
|
updateDisplayEffect(); |
1032 |
if (sOldDisplayFont != m_pOptions->sDisplayFont) |
if (sOldDisplayFont != m_pOptions->sDisplayFont) |
1033 |
updateDisplayFont(); |
updateDisplayFont(); |
1034 |
|
if (iOldMaxVolume != m_pOptions->iMaxVolume) |
1035 |
|
updateMaxVolume(); |
1036 |
if (sOldMessagesFont != m_pOptions->sMessagesFont) |
if (sOldMessagesFont != m_pOptions->sMessagesFont) |
1037 |
updateMessagesFont(); |
updateMessagesFont(); |
1038 |
if (( bOldMessagesLimit && !m_pOptions->bMessagesLimit) || |
if (( bOldMessagesLimit && !m_pOptions->bMessagesLimit) || |
1071 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
1072 |
int y = 0; |
int y = 0; |
1073 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1074 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1075 |
/* if (pChannel->testWState(WState_Maximized | WState_Minimized)) { |
/* if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) { |
1076 |
// Prevent flicker... |
// Prevent flicker... |
1077 |
pChannel->hide(); |
pChannelStrip->hide(); |
1078 |
pChannel->showNormal(); |
pChannelStrip->showNormal(); |
1079 |
} */ |
} */ |
1080 |
pChannel->adjustSize(); |
pChannelStrip->adjustSize(); |
1081 |
int iWidth = m_pWorkspace->width(); |
int iWidth = m_pWorkspace->width(); |
1082 |
if (iWidth < pChannel->width()) |
if (iWidth < pChannelStrip->width()) |
1083 |
iWidth = pChannel->width(); |
iWidth = pChannelStrip->width(); |
1084 |
// int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height(); |
// int iHeight = pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
1085 |
int iHeight = pChannel->parentWidget()->frameGeometry().height(); |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
1086 |
pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
1087 |
y += iHeight; |
y += iHeight; |
1088 |
} |
} |
1089 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1131 |
sText += tr("Debugging option enabled."); |
sText += tr("Debugging option enabled."); |
1132 |
sText += "</font></small><br />"; |
sText += "</font></small><br />"; |
1133 |
#endif |
#endif |
1134 |
|
#ifndef CONFIG_LIBGIG |
1135 |
|
sText += "<small><font color=\"red\">"; |
1136 |
|
sText += tr("GIG (libgig) file support disabled."); |
1137 |
|
sText += "</font></small><br />"; |
1138 |
|
#endif |
1139 |
|
#ifndef CONFIG_INSTRUMENT_NAME |
1140 |
|
sText += "<small><font color=\"red\">"; |
1141 |
|
sText += tr("LSCP (liblscp) instrument_name support disabled."); |
1142 |
|
sText += "</font></small><br />"; |
1143 |
|
#endif |
1144 |
sText += "<br />\n"; |
sText += "<br />\n"; |
1145 |
sText += tr("Using") + ": "; |
sText += tr("Using") + ": "; |
1146 |
sText += ::lscp_client_package(); |
sText += ::lscp_client_package(); |
1174 |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName)); |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName)); |
1175 |
|
|
1176 |
// Update the main menu state... |
// Update the main menu state... |
1177 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
1178 |
bool bHasClient = (m_pOptions != NULL && m_pClient != NULL); |
bool bHasClient = (m_pOptions != NULL && m_pClient != NULL); |
1179 |
bool bHasChannel = (bHasClient && pChannel != NULL); |
bool bHasChannel = (bHasClient && pChannelStrip != NULL); |
1180 |
fileNewAction->setEnabled(bHasClient); |
fileNewAction->setEnabled(bHasClient); |
1181 |
fileOpenAction->setEnabled(bHasClient); |
fileOpenAction->setEnabled(bHasClient); |
1182 |
fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0); |
fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0); |
1183 |
fileSaveAsAction->setEnabled(bHasClient); |
fileSaveAsAction->setEnabled(bHasClient); |
1184 |
|
fileResetAction->setEnabled(bHasClient); |
1185 |
fileRestartAction->setEnabled(bHasClient || m_pServer == NULL); |
fileRestartAction->setEnabled(bHasClient || m_pServer == NULL); |
1186 |
editAddChannelAction->setEnabled(bHasClient); |
editAddChannelAction->setEnabled(bHasClient); |
1187 |
editRemoveChannelAction->setEnabled(bHasChannel); |
editRemoveChannelAction->setEnabled(bHasChannel); |
1188 |
editSetupChannelAction->setEnabled(bHasChannel); |
editSetupChannelAction->setEnabled(bHasChannel); |
1189 |
editResetChannelAction->setEnabled(bHasChannel); |
editResetChannelAction->setEnabled(bHasChannel); |
1190 |
|
editResetAllChannelsAction->setEnabled(bHasChannel); |
1191 |
channelsArrangeAction->setEnabled(bHasChannel); |
channelsArrangeAction->setEnabled(bHasChannel); |
1192 |
viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible()); |
viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible()); |
1193 |
|
|
1201 |
} |
} |
1202 |
// Channel status... |
// Channel status... |
1203 |
if (bHasChannel) |
if (bHasChannel) |
1204 |
m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannel->caption()); |
m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption()); |
1205 |
else |
else |
1206 |
m_status[QSAMPLER_STATUS_CHANNEL]->clear(); |
m_status[QSAMPLER_STATUS_CHANNEL]->clear(); |
1207 |
// Session status... |
// Session status... |
1220 |
|
|
1221 |
|
|
1222 |
// Channel change receiver slot. |
// Channel change receiver slot. |
1223 |
void qsamplerMainForm::channelChanged( qsamplerChannelStrip * ) |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip ) |
1224 |
{ |
{ |
1225 |
|
// Add this strip to the changed list... |
1226 |
|
if (m_changedStrips.containsRef(pChannelStrip) == 0) |
1227 |
|
m_changedStrips.append(pChannelStrip); |
1228 |
|
|
1229 |
// Just mark the dirty form. |
// Just mark the dirty form. |
1230 |
m_iDirtyCount++; |
m_iDirtyCount++; |
1231 |
// and update the form status... |
// and update the form status... |
1233 |
} |
} |
1234 |
|
|
1235 |
|
|
1236 |
|
// Grab and restore current sampler channels session. |
1237 |
|
void qsamplerMainForm::updateSession (void) |
1238 |
|
{ |
1239 |
|
// Retrieve the current channel list. |
1240 |
|
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
1241 |
|
if (piChannelIDs == NULL) { |
1242 |
|
if (::lscp_client_get_errno(m_pClient)) { |
1243 |
|
appendMessagesClient("lscp_list_channels"); |
1244 |
|
appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); |
1245 |
|
} |
1246 |
|
return; |
1247 |
|
} |
1248 |
|
|
1249 |
|
// Try to (re)create each channel. |
1250 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1251 |
|
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
1252 |
|
// Check if theres already a channel strip for this one... |
1253 |
|
if (!channelStrip(piChannelIDs[iChannel])) |
1254 |
|
createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel])); |
1255 |
|
// Make it visibly responsive... |
1256 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1257 |
|
} |
1258 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1259 |
|
} |
1260 |
|
|
1261 |
|
|
1262 |
// Update the recent files list and menu. |
// Update the recent files list and menu. |
1263 |
void qsamplerMainForm::updateRecentFiles ( const QString& sFilename ) |
void qsamplerMainForm::updateRecentFiles ( const QString& sFilename ) |
1264 |
{ |
{ |
1303 |
} |
} |
1304 |
|
|
1305 |
|
|
1306 |
|
// Force update of the channels instrument names mode. |
1307 |
|
void qsamplerMainForm::updateInstrumentNames (void) |
1308 |
|
{ |
1309 |
|
// Full channel list update... |
1310 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1311 |
|
if (wlist.isEmpty()) |
1312 |
|
return; |
1313 |
|
|
1314 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1315 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1316 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1317 |
|
if (pChannelStrip) |
1318 |
|
pChannelStrip->updateInstrumentName(true); |
1319 |
|
} |
1320 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1321 |
|
} |
1322 |
|
|
1323 |
|
|
1324 |
// Force update of the channels display font. |
// Force update of the channels display font. |
1325 |
void qsamplerMainForm::updateDisplayFont (void) |
void qsamplerMainForm::updateDisplayFont (void) |
1326 |
{ |
{ |
1342 |
|
|
1343 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
1344 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1345 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1346 |
pChannel->setDisplayFont(font); |
if (pChannelStrip) |
1347 |
|
pChannelStrip->setDisplayFont(font); |
1348 |
|
} |
1349 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1350 |
|
} |
1351 |
|
|
1352 |
|
|
1353 |
|
// Update channel strips background effect. |
1354 |
|
void qsamplerMainForm::updateDisplayEffect (void) |
1355 |
|
{ |
1356 |
|
QPixmap pm; |
1357 |
|
if (m_pOptions->bDisplayEffect) |
1358 |
|
pm = QPixmap::fromMimeSource("displaybg1.png"); |
1359 |
|
|
1360 |
|
// Full channel list update... |
1361 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1362 |
|
if (wlist.isEmpty()) |
1363 |
|
return; |
1364 |
|
|
1365 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1366 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1367 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1368 |
|
if (pChannelStrip) |
1369 |
|
pChannelStrip->setDisplayBackground(pm); |
1370 |
|
} |
1371 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1372 |
|
} |
1373 |
|
|
1374 |
|
|
1375 |
|
// Force update of the channels maximum volume setting. |
1376 |
|
void qsamplerMainForm::updateMaxVolume (void) |
1377 |
|
{ |
1378 |
|
if (m_pOptions == NULL) |
1379 |
|
return; |
1380 |
|
|
1381 |
|
// Full channel list update... |
1382 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1383 |
|
if (wlist.isEmpty()) |
1384 |
|
return; |
1385 |
|
|
1386 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1387 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1388 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1389 |
|
if (pChannelStrip) |
1390 |
|
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
1391 |
} |
} |
1392 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1393 |
} |
} |
1486 |
// qsamplerMainForm -- MDI channel strip management. |
// qsamplerMainForm -- MDI channel strip management. |
1487 |
|
|
1488 |
// The channel strip creation executive. |
// The channel strip creation executive. |
1489 |
void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt ) |
qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel ) |
1490 |
{ |
{ |
1491 |
if (m_pClient == NULL) |
if (m_pClient == NULL || pChannel == NULL) |
1492 |
return; |
return NULL; |
1493 |
|
|
1494 |
// Prepare for auto-arrange? |
// Prepare for auto-arrange? |
1495 |
qsamplerChannelStrip *pChannel = NULL; |
qsamplerChannelStrip *pChannelStrip = NULL; |
1496 |
int y = 0; |
int y = 0; |
1497 |
if (m_pOptions && m_pOptions->bAutoArrange) { |
if (m_pOptions && m_pOptions->bAutoArrange) { |
1498 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1499 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1500 |
pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1501 |
// y += pChannel->height() + pChannel->parentWidget()->baseSize().height(); |
if (pChannelStrip) { |
1502 |
y += pChannel->parentWidget()->frameGeometry().height(); |
// y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
1503 |
|
y += pChannelStrip->parentWidget()->frameGeometry().height(); |
1504 |
|
} |
1505 |
} |
} |
1506 |
} |
} |
1507 |
|
|
1508 |
// Add a new channel itema... |
// Add a new channel itema... |
1509 |
WFlags wflags = Qt::WStyle_Customize | Qt::WStyle_Tool | Qt::WStyle_Title | Qt::WStyle_NoBorder; |
WFlags wflags = Qt::WStyle_Customize | Qt::WStyle_Tool | Qt::WStyle_Title | Qt::WStyle_NoBorder; |
1510 |
pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags); |
pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags); |
1511 |
pChannel->setup(this, iChannelID); |
if (pChannelStrip == NULL) |
1512 |
// We'll need a display font. |
return NULL; |
1513 |
QFont font; |
|
1514 |
if (m_pOptions && font.fromString(m_pOptions->sDisplayFont)) |
// Actual channel strip setup... |
1515 |
pChannel->setDisplayFont(font); |
pChannelStrip->setup(pChannel); |
1516 |
// Track channel setup changes. |
QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *))); |
1517 |
QObject::connect(pChannel, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelChanged(qsamplerChannelStrip *))); |
// Set some initial aesthetic options... |
1518 |
// Before we show it up, may be we'll |
if (m_pOptions) { |
1519 |
// better ask for some initial values? |
// Background display effect... |
1520 |
if (bPrompt) |
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
1521 |
pChannel->channelSetup(); |
// We'll need a display font. |
1522 |
|
QFont font; |
1523 |
|
if (font.fromString(m_pOptions->sDisplayFont)) |
1524 |
|
pChannelStrip->setDisplayFont(font); |
1525 |
|
// Maximum allowed volume setting. |
1526 |
|
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
1527 |
|
} |
1528 |
|
|
1529 |
// Now we show up us to the world. |
// Now we show up us to the world. |
1530 |
pChannel->show(); |
pChannelStrip->show(); |
1531 |
// Only then, we'll auto-arrange... |
// Only then, we'll auto-arrange... |
1532 |
if (m_pOptions && m_pOptions->bAutoArrange) { |
if (m_pOptions && m_pOptions->bAutoArrange) { |
1533 |
int iWidth = m_pWorkspace->width(); |
int iWidth = m_pWorkspace->width(); |
1534 |
// int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height(); |
// int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height(); |
1535 |
int iHeight = pChannel->parentWidget()->frameGeometry().height(); |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
1536 |
pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
1537 |
} |
} |
1538 |
|
|
1539 |
|
// This is pretty new, so we'll watch for it closely. |
1540 |
|
channelStripChanged(pChannelStrip); |
1541 |
|
|
1542 |
|
// Return our successful reference... |
1543 |
|
return pChannelStrip; |
1544 |
} |
} |
1545 |
|
|
1546 |
|
|
1547 |
// Retrieve the active channel strip. |
// Retrieve the active channel strip. |
1548 |
qsamplerChannelStrip *qsamplerMainForm::activeChannel (void) |
qsamplerChannelStrip *qsamplerMainForm::activeChannelStrip (void) |
1549 |
{ |
{ |
1550 |
return (qsamplerChannelStrip *) m_pWorkspace->activeWindow(); |
return (qsamplerChannelStrip *) m_pWorkspace->activeWindow(); |
1551 |
} |
} |
1552 |
|
|
1553 |
|
|
1554 |
// Retrieve a channel strip by index. |
// Retrieve a channel strip by index. |
1555 |
qsamplerChannelStrip *qsamplerMainForm::channelAt ( int iChannel ) |
qsamplerChannelStrip *qsamplerMainForm::channelStripAt ( int iChannel ) |
1556 |
{ |
{ |
1557 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1558 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
1559 |
return 0; |
return NULL; |
1560 |
|
|
1561 |
return (qsamplerChannelStrip *) wlist.at(iChannel); |
return (qsamplerChannelStrip *) wlist.at(iChannel); |
1562 |
} |
} |
1563 |
|
|
1564 |
|
|
1565 |
|
// Retrieve a channel strip by sampler channel id. |
1566 |
|
qsamplerChannelStrip *qsamplerMainForm::channelStrip ( int iChannelID ) |
1567 |
|
{ |
1568 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1569 |
|
if (wlist.isEmpty()) |
1570 |
|
return NULL; |
1571 |
|
|
1572 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1573 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1574 |
|
if (pChannelStrip) { |
1575 |
|
qsamplerChannel *pChannel = pChannelStrip->channel(); |
1576 |
|
if (pChannel && pChannel->channelID() == iChannelID) |
1577 |
|
return pChannelStrip; |
1578 |
|
} |
1579 |
|
} |
1580 |
|
|
1581 |
|
// Not found. |
1582 |
|
return NULL; |
1583 |
|
} |
1584 |
|
|
1585 |
|
|
1586 |
// Construct the windows menu. |
// Construct the windows menu. |
1587 |
void qsamplerMainForm::channelsMenuAboutToShow (void) |
void qsamplerMainForm::channelsMenuAboutToShow (void) |
1588 |
{ |
{ |
1594 |
if (!wlist.isEmpty()) { |
if (!wlist.isEmpty()) { |
1595 |
channelsMenu->insertSeparator(); |
channelsMenu->insertSeparator(); |
1596 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1597 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1598 |
int iItemID = channelsMenu->insertItem(pChannel->caption(), this, SLOT(channelsMenuActivated(int))); |
if (pChannelStrip) { |
1599 |
channelsMenu->setItemParameter(iItemID, iChannel); |
int iItemID = channelsMenu->insertItem(pChannelStrip->caption(), this, SLOT(channelsMenuActivated(int))); |
1600 |
channelsMenu->setItemChecked(iItemID, activeChannel() == pChannel); |
channelsMenu->setItemParameter(iItemID, iChannel); |
1601 |
|
channelsMenu->setItemChecked(iItemID, activeChannelStrip() == pChannelStrip); |
1602 |
|
} |
1603 |
} |
} |
1604 |
} |
} |
1605 |
} |
} |
1608 |
// Windows menu activation slot |
// Windows menu activation slot |
1609 |
void qsamplerMainForm::channelsMenuActivated ( int iChannel ) |
void qsamplerMainForm::channelsMenuActivated ( int iChannel ) |
1610 |
{ |
{ |
1611 |
qsamplerChannelStrip *pChannel = channelAt(iChannel); |
qsamplerChannelStrip *pChannelStrip = channelStripAt(iChannel); |
1612 |
if (pChannel) |
if (pChannelStrip) |
1613 |
pChannel->showNormal(); |
pChannelStrip->showNormal(); |
1614 |
pChannel->setFocus(); |
pChannelStrip->setFocus(); |
1615 |
} |
} |
1616 |
|
|
1617 |
|
|
1651 |
} |
} |
1652 |
|
|
1653 |
// Refresh each channel usage, on each period... |
// Refresh each channel usage, on each period... |
1654 |
if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) { |
if (m_pClient && (m_changedStrips.count() > 0 || m_pOptions->bAutoRefresh)) { |
1655 |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
1656 |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime) { |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled()) { |
1657 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
1658 |
|
// Update the channel information for each pending strip... |
1659 |
|
for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first(); |
1660 |
|
pChannelStrip; |
1661 |
|
pChannelStrip = m_changedStrips.next()) { |
1662 |
|
// If successfull, remove from pending list... |
1663 |
|
if (pChannelStrip->updateChannelInfo()) |
1664 |
|
m_changedStrips.remove(pChannelStrip); |
1665 |
|
} |
1666 |
|
// Update the channel stream usage for each strip... |
1667 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1668 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1669 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1670 |
if (pChannel->isVisible()) |
if (pChannelStrip && pChannelStrip->isVisible()) |
1671 |
pChannel->updateChannelUsage(); |
pChannelStrip->updateChannelUsage(); |
1672 |
} |
} |
1673 |
} |
} |
1674 |
} |
} |
1754 |
// And try to stop server. |
// And try to stop server. |
1755 |
if (m_pServer) { |
if (m_pServer) { |
1756 |
appendMessages(tr("Server is stopping...")); |
appendMessages(tr("Server is stopping...")); |
1757 |
if (m_pServer->isRunning()) { |
if (m_pServer->isRunning()) |
1758 |
m_pServer->tryTerminate(); |
m_pServer->tryTerminate(); |
|
return; |
|
|
} |
|
1759 |
} |
} |
1760 |
|
|
1761 |
|
// Give it some time to terminate gracefully and stabilize... |
1762 |
|
QTime t; |
1763 |
|
t.start(); |
1764 |
|
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
1765 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1766 |
|
|
1767 |
// Do final processing anyway. |
// Do final processing anyway. |
1768 |
processServerExit(); |
processServerExit(); |
1769 |
} |
} |
1805 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
1806 |
// qsamplerMainForm -- Client stuff. |
// qsamplerMainForm -- Client stuff. |
1807 |
|
|
|
|
|
1808 |
// The LSCP client callback procedure. |
// The LSCP client callback procedure. |
1809 |
lscp_status_t qsampler_client_callback ( lscp_client_t *pClient, const char *pchBuffer, int cchBuffer, void *pvData ) |
lscp_status_t qsampler_client_callback ( lscp_client_t */*pClient*/, lscp_event_t event, const char *pchData, int cchData, void *pvData ) |
1810 |
{ |
{ |
1811 |
qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData; |
qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData; |
1812 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
1813 |
return LSCP_FAILED; |
return LSCP_FAILED; |
1814 |
|
|
1815 |
char *pszBuffer = (char *) malloc(cchBuffer + 1); |
// ATTN: DO NOT EVER call any GUI code here, |
1816 |
if (pszBuffer == NULL) |
// as this is run under some other thread context. |
1817 |
return LSCP_FAILED; |
// A custom event must be posted here... |
1818 |
|
QApplication::postEvent(pMainForm, new qsamplerCustomEvent(event, pchData, cchData)); |
|
memcpy(pszBuffer, pchBuffer, cchBuffer); |
|
|
pszBuffer[cchBuffer] = (char) 0; |
|
|
pMainForm->appendMessagesColor(pszBuffer, "#996699"); |
|
|
free(pszBuffer); |
|
1819 |
|
|
1820 |
return LSCP_OK; |
return LSCP_OK; |
1821 |
} |
} |