41 |
#include "qsamplerMessages.h" |
#include "qsamplerMessages.h" |
42 |
|
|
43 |
#include "qsamplerChannelStrip.h" |
#include "qsamplerChannelStrip.h" |
44 |
|
|
45 |
|
#include "qsamplerDeviceForm.h" |
46 |
#include "qsamplerOptionsForm.h" |
#include "qsamplerOptionsForm.h" |
47 |
|
|
48 |
#include "config.h" |
#include "config.h" |
107 |
m_pOptions = NULL; |
m_pOptions = NULL; |
108 |
|
|
109 |
// All child forms are to be created later, not earlier than setup. |
// All child forms are to be created later, not earlier than setup. |
110 |
m_pMessages = NULL; |
m_pMessages = NULL; |
111 |
|
m_pDeviceForm = NULL; |
112 |
|
|
113 |
// We'll start clean. |
// We'll start clean. |
114 |
m_iUntitled = 0; |
m_iUntitled = 0; |
115 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
|
m_iChangeCount = 0; |
|
116 |
|
|
117 |
m_pServer = NULL; |
m_pServer = NULL; |
118 |
m_pClient = NULL; |
m_pClient = NULL; |
141 |
pLabel = new QLabel(tr("Connected"), this); |
pLabel = new QLabel(tr("Connected"), this); |
142 |
pLabel->setAlignment(Qt::AlignLeft); |
pLabel->setAlignment(Qt::AlignLeft); |
143 |
pLabel->setMinimumSize(pLabel->sizeHint()); |
pLabel->setMinimumSize(pLabel->sizeHint()); |
144 |
m_status[QSAMPLER_STATUS_CLIENT] = pLabel; |
m_statusItem[QSAMPLER_STATUS_CLIENT] = pLabel; |
145 |
statusBar()->addWidget(pLabel); |
statusBar()->addWidget(pLabel); |
146 |
// Server address. |
// Server address. |
147 |
pLabel = new QLabel(this); |
pLabel = new QLabel(this); |
148 |
pLabel->setAlignment(Qt::AlignLeft); |
pLabel->setAlignment(Qt::AlignLeft); |
149 |
m_status[QSAMPLER_STATUS_SERVER] = pLabel; |
m_statusItem[QSAMPLER_STATUS_SERVER] = pLabel; |
150 |
statusBar()->addWidget(pLabel, 1); |
statusBar()->addWidget(pLabel, 1); |
151 |
// Channel title. |
// Channel title. |
152 |
pLabel = new QLabel(this); |
pLabel = new QLabel(this); |
153 |
pLabel->setAlignment(Qt::AlignLeft); |
pLabel->setAlignment(Qt::AlignLeft); |
154 |
m_status[QSAMPLER_STATUS_CHANNEL] = pLabel; |
m_statusItem[QSAMPLER_STATUS_CHANNEL] = pLabel; |
155 |
statusBar()->addWidget(pLabel, 2); |
statusBar()->addWidget(pLabel, 2); |
156 |
// Session modification status. |
// Session modification status. |
157 |
pLabel = new QLabel(tr("MOD"), this); |
pLabel = new QLabel(tr("MOD"), this); |
158 |
pLabel->setAlignment(Qt::AlignHCenter); |
pLabel->setAlignment(Qt::AlignHCenter); |
159 |
pLabel->setMinimumSize(pLabel->sizeHint()); |
pLabel->setMinimumSize(pLabel->sizeHint()); |
160 |
m_status[QSAMPLER_STATUS_SESSION] = pLabel; |
m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel; |
161 |
statusBar()->addWidget(pLabel); |
statusBar()->addWidget(pLabel); |
162 |
|
|
163 |
// Create the recent files sub-menu. |
// Create the recent files sub-menu. |
176 |
{ |
{ |
177 |
// Do final processing anyway. |
// Do final processing anyway. |
178 |
processServerExit(); |
processServerExit(); |
179 |
|
|
180 |
// Delete recentfiles menu. |
#if defined(WIN32) |
181 |
if (m_pRecentFilesMenu) |
WSACleanup(); |
182 |
delete m_pRecentFilesMenu; |
#endif |
|
// Delete status item labels one by one. |
|
|
if (m_status[QSAMPLER_STATUS_CLIENT]) |
|
|
delete m_status[QSAMPLER_STATUS_CLIENT]; |
|
|
if (m_status[QSAMPLER_STATUS_SERVER]) |
|
|
delete m_status[QSAMPLER_STATUS_SERVER]; |
|
|
if (m_status[QSAMPLER_STATUS_CHANNEL]) |
|
|
delete m_status[QSAMPLER_STATUS_CHANNEL]; |
|
|
if (m_status[QSAMPLER_STATUS_SESSION]) |
|
|
delete m_status[QSAMPLER_STATUS_SESSION]; |
|
183 |
|
|
184 |
// Finally drop any widgets around... |
// Finally drop any widgets around... |
185 |
|
if (m_pDeviceForm) |
186 |
|
delete m_pDeviceForm; |
187 |
if (m_pMessages) |
if (m_pMessages) |
188 |
delete m_pMessages; |
delete m_pMessages; |
189 |
if (m_pWorkspace) |
if (m_pWorkspace) |
190 |
delete m_pWorkspace; |
delete m_pWorkspace; |
191 |
|
|
192 |
#if defined(WIN32) |
// Delete status item labels one by one. |
193 |
WSACleanup(); |
if (m_statusItem[QSAMPLER_STATUS_CLIENT]) |
194 |
#endif |
delete m_statusItem[QSAMPLER_STATUS_CLIENT]; |
195 |
|
if (m_statusItem[QSAMPLER_STATUS_SERVER]) |
196 |
|
delete m_statusItem[QSAMPLER_STATUS_SERVER]; |
197 |
|
if (m_statusItem[QSAMPLER_STATUS_CHANNEL]) |
198 |
|
delete m_statusItem[QSAMPLER_STATUS_CHANNEL]; |
199 |
|
if (m_statusItem[QSAMPLER_STATUS_SESSION]) |
200 |
|
delete m_statusItem[QSAMPLER_STATUS_SESSION]; |
201 |
|
|
202 |
|
// Delete recentfiles menu. |
203 |
|
if (m_pRecentFilesMenu) |
204 |
|
delete m_pRecentFilesMenu; |
205 |
} |
} |
206 |
|
|
207 |
|
|
211 |
// We got options? |
// We got options? |
212 |
m_pOptions = pOptions; |
m_pOptions = pOptions; |
213 |
|
|
214 |
|
// What style do we create these forms? |
215 |
|
WFlags wflags = Qt::WType_TopLevel; |
216 |
|
if (m_pOptions->bKeepOnTop) |
217 |
|
wflags |= Qt::WStyle_Tool; |
218 |
// Some child forms are to be created right now. |
// Some child forms are to be created right now. |
219 |
m_pMessages = new qsamplerMessages(this); |
m_pMessages = new qsamplerMessages(this); |
220 |
|
m_pDeviceForm = new qsamplerDeviceForm(this, 0, wflags); |
221 |
// Set message defaults... |
// Set message defaults... |
222 |
updateMessagesFont(); |
updateMessagesFont(); |
223 |
updateMessagesLimit(); |
updateMessagesLimit(); |
246 |
QTextIStream istr(&sDockables); |
QTextIStream istr(&sDockables); |
247 |
istr >> *this; |
istr >> *this; |
248 |
} |
} |
249 |
// Try to restore old window positioning. |
// Try to restore old window positioning and initial visibility. |
250 |
m_pOptions->loadWidgetGeometry(this); |
m_pOptions->loadWidgetGeometry(this); |
251 |
|
m_pOptions->loadWidgetGeometry(m_pDeviceForm); |
252 |
|
|
253 |
// Final startup stabilization... |
// Final startup stabilization... |
254 |
updateRecentFilesMenu(); |
updateRecentFilesMenu(); |
286 |
QTextOStream ostr(&sDockables); |
QTextOStream ostr(&sDockables); |
287 |
ostr << *this; |
ostr << *this; |
288 |
m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables); |
m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables); |
289 |
// And the main windows state. |
// And the children, and the main windows state,. |
290 |
|
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
291 |
m_pOptions->saveWidgetGeometry(this); |
m_pOptions->saveWidgetGeometry(this); |
292 |
|
// Close popup widgets. |
293 |
|
if (m_pDeviceForm) |
294 |
|
m_pDeviceForm->close(); |
295 |
// Stop client and/or server, gracefully. |
// Stop client and/or server, gracefully. |
296 |
stopServer(); |
stopServer(); |
297 |
} |
} |
321 |
if (bDecode) { |
if (bDecode) { |
322 |
files = QStringList::split('\n', sText); |
files = QStringList::split('\n', sText); |
323 |
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) |
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) |
324 |
*iter = (*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null); |
*iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path(); |
325 |
} |
} |
326 |
} |
} |
327 |
|
|
332 |
// Window drag-n-drop event handlers. |
// Window drag-n-drop event handlers. |
333 |
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
334 |
{ |
{ |
335 |
QStringList files; |
QStringList files; |
336 |
|
pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files)); |
|
pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files)); |
|
337 |
} |
} |
338 |
|
|
339 |
|
|
345 |
return; |
return; |
346 |
|
|
347 |
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) { |
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) { |
348 |
const QString& sPath = QUrl(*iter).path(); |
const QString& sPath = *iter; |
349 |
if (qsamplerChannel::isInstrumentFile(sPath)) { |
if (qsamplerChannel::isInstrumentFile(sPath)) { |
350 |
// Try to create a new channel from instrument file... |
// Try to create a new channel from instrument file... |
351 |
qsamplerChannel *pChannel = new qsamplerChannel(this); |
qsamplerChannel *pChannel = new qsamplerChannel(this); |
366 |
} |
} |
367 |
// Make that an overall update. |
// Make that an overall update. |
368 |
m_iDirtyCount++; |
m_iDirtyCount++; |
|
m_iChangeCount++; |
|
369 |
stabilizeForm(); |
stabilizeForm(); |
370 |
} // Otherwise, load an usual session file (LSCP script)... |
} // Otherwise, load an usual session file (LSCP script)... |
371 |
else if (closeSession(true)) |
else if (closeSession(true)) |
437 |
if (!closeSession(true)) |
if (!closeSession(true)) |
438 |
return false; |
return false; |
439 |
|
|
440 |
|
// Give us what the server has, right now... |
441 |
|
updateSession(); |
442 |
|
|
443 |
// Ok increment untitled count. |
// Ok increment untitled count. |
444 |
m_iUntitled++; |
m_iUntitled++; |
445 |
|
|
612 |
if (iErrors > 0) |
if (iErrors > 0) |
613 |
appendMessagesError(tr("Session could not be loaded\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
appendMessagesError(tr("Session could not be loaded\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
614 |
|
|
615 |
// Now we'll try to create the whole GUI session. |
// Now we'll try to create (update) the whole GUI session. |
616 |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
updateSession(); |
|
if (piChannelIDs == NULL) { |
|
|
appendMessagesClient("lscp_list_channels"); |
|
|
appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); |
|
|
} else { |
|
|
// Try to (re)create each channel. |
|
|
m_pWorkspace->setUpdatesEnabled(false); |
|
|
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
|
|
createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel])); |
|
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
|
|
} |
|
|
m_pWorkspace->setUpdatesEnabled(true); |
|
|
} |
|
617 |
|
|
618 |
// Save as default session directory. |
// Save as default session directory. |
619 |
if (m_pOptions) |
if (m_pOptions) |
626 |
appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename))); |
appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename))); |
627 |
|
|
628 |
// Make that an overall update. |
// Make that an overall update. |
|
m_iChangeCount++; |
|
629 |
stabilizeForm(); |
stabilizeForm(); |
630 |
return true; |
return true; |
631 |
} |
} |
663 |
if (pChannelStrip) { |
if (pChannelStrip) { |
664 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
665 |
if (pChannel) { |
if (pChannel) { |
666 |
int iChannelID = pChannel->channelID(); |
ts << "# Channel " << iChannel << endl; |
|
ts << "# " << pChannelStrip->caption() << endl; |
|
667 |
ts << "ADD CHANNEL" << endl; |
ts << "ADD CHANNEL" << endl; |
668 |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl; |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel << " " << pChannel->audioDriver() << endl; |
669 |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl; |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel << " " << pChannel->midiDriver() << endl; |
670 |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl; |
// ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel << " " << pChannel->midiPort() << endl; |
671 |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " "; |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " "; |
672 |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
673 |
ts << "ALL"; |
ts << "ALL"; |
674 |
else |
else |
675 |
ts << pChannel->midiChannel(); |
ts << pChannel->midiChannel(); |
676 |
ts << endl; |
ts << endl; |
677 |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl; |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl; |
678 |
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl; |
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl; |
679 |
ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl; |
ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl; |
680 |
ts << endl; |
ts << endl; |
681 |
} |
} |
682 |
} |
} |
705 |
} |
} |
706 |
|
|
707 |
|
|
708 |
|
// Session change receiver slot. |
709 |
|
void qsamplerMainForm::sessionDirty (void) |
710 |
|
{ |
711 |
|
// Just mark the dirty form. |
712 |
|
m_iDirtyCount++; |
713 |
|
// and update the form status... |
714 |
|
stabilizeForm(); |
715 |
|
} |
716 |
|
|
717 |
|
|
718 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
719 |
// qsamplerMainForm -- File Action slots. |
// qsamplerMainForm -- File Action slots. |
720 |
|
|
786 |
|
|
787 |
// Log this. |
// Log this. |
788 |
appendMessages(tr("Sampler reset.")); |
appendMessages(tr("Sampler reset.")); |
789 |
|
|
790 |
|
// Make it a new session... |
791 |
|
newSession(); |
792 |
} |
} |
793 |
|
|
794 |
|
|
859 |
|
|
860 |
// Make that an overall update. |
// Make that an overall update. |
861 |
m_iDirtyCount++; |
m_iDirtyCount++; |
|
m_iChangeCount++; |
|
862 |
stabilizeForm(); |
stabilizeForm(); |
863 |
} |
} |
864 |
|
|
930 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
931 |
return; |
return; |
932 |
|
|
933 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
// Just invoque the channel strip procedure. |
934 |
if (pChannel == NULL) |
pChannelStrip->channelReset(); |
935 |
return; |
} |
936 |
|
|
937 |
|
|
938 |
// Reset the existing sampler channel. |
// Reset all sampler channels. |
939 |
pChannel->resetChannel(); |
void qsamplerMainForm::editResetAllChannels (void) |
940 |
|
{ |
941 |
|
if (m_pClient == NULL) |
942 |
|
return; |
943 |
|
|
944 |
// And force a deferred update. |
// Invoque the channel strip procedure, |
945 |
m_iChangeCount++; |
// for all channels out there... |
946 |
|
m_pWorkspace->setUpdatesEnabled(false); |
947 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
948 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
949 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
950 |
|
if (pChannelStrip) |
951 |
|
pChannelStrip->channelReset(); |
952 |
|
} |
953 |
|
m_pWorkspace->setUpdatesEnabled(true); |
954 |
} |
} |
955 |
|
|
956 |
|
|
1002 |
} |
} |
1003 |
|
|
1004 |
|
|
1005 |
|
// Show/hide the device configurator form. |
1006 |
|
void qsamplerMainForm::viewDevices (void) |
1007 |
|
{ |
1008 |
|
if (m_pOptions == NULL) |
1009 |
|
return; |
1010 |
|
|
1011 |
|
if (m_pDeviceForm) { |
1012 |
|
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
1013 |
|
m_pDeviceForm->setClient(m_pClient); |
1014 |
|
if (m_pDeviceForm->isVisible()) { |
1015 |
|
m_pDeviceForm->hide(); |
1016 |
|
} else { |
1017 |
|
m_pDeviceForm->show(); |
1018 |
|
m_pDeviceForm->raise(); |
1019 |
|
m_pDeviceForm->setActiveWindow(); |
1020 |
|
} |
1021 |
|
} |
1022 |
|
} |
1023 |
|
|
1024 |
|
|
1025 |
// Show options dialog. |
// Show options dialog. |
1026 |
void qsamplerMainForm::viewOptions (void) |
void qsamplerMainForm::viewOptions (void) |
1027 |
{ |
{ |
1046 |
bool bOldDisplayEffect = m_pOptions->bDisplayEffect; |
bool bOldDisplayEffect = m_pOptions->bDisplayEffect; |
1047 |
int iOldMaxVolume = m_pOptions->iMaxVolume; |
int iOldMaxVolume = m_pOptions->iMaxVolume; |
1048 |
QString sOldMessagesFont = m_pOptions->sMessagesFont; |
QString sOldMessagesFont = m_pOptions->sMessagesFont; |
1049 |
|
bool bOldKeepOnTop = m_pOptions->bKeepOnTop; |
1050 |
bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
1051 |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
1052 |
int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
1059 |
if (pOptionsForm->exec()) { |
if (pOptionsForm->exec()) { |
1060 |
// Warn if something will be only effective on next run. |
// Warn if something will be only effective on next run. |
1061 |
if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) || |
if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) || |
1062 |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture)) { |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture) || |
1063 |
|
( bOldKeepOnTop && !m_pOptions->bKeepOnTop) || |
1064 |
|
(!bOldKeepOnTop && m_pOptions->bKeepOnTop)) { |
1065 |
QMessageBox::information(this, tr("Information"), |
QMessageBox::information(this, tr("Information"), |
1066 |
tr("Some settings may be only effective\n" |
tr("Some settings may be only effective\n" |
1067 |
"next time you start this program."), tr("OK")); |
"next time you start this program."), tr("OK")); |
1217 |
void qsamplerMainForm::stabilizeForm (void) |
void qsamplerMainForm::stabilizeForm (void) |
1218 |
{ |
{ |
1219 |
// Update the main application caption... |
// Update the main application caption... |
1220 |
QString sSessioName = sessionName(m_sFilename); |
QString sSessionName = sessionName(m_sFilename); |
1221 |
if (m_iDirtyCount > 0) |
if (m_iDirtyCount > 0) |
1222 |
sSessioName += '*'; |
sSessionName += '*'; |
1223 |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName)); |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName)); |
1224 |
|
|
1225 |
// Update the main menu state... |
// Update the main menu state... |
1226 |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
1236 |
editRemoveChannelAction->setEnabled(bHasChannel); |
editRemoveChannelAction->setEnabled(bHasChannel); |
1237 |
editSetupChannelAction->setEnabled(bHasChannel); |
editSetupChannelAction->setEnabled(bHasChannel); |
1238 |
editResetChannelAction->setEnabled(bHasChannel); |
editResetChannelAction->setEnabled(bHasChannel); |
1239 |
channelsArrangeAction->setEnabled(bHasChannel); |
editResetAllChannelsAction->setEnabled(bHasChannel); |
1240 |
viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible()); |
viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible()); |
1241 |
|
viewDevicesAction->setOn(m_pDeviceForm && m_pDeviceForm->isVisible()); |
1242 |
|
viewDevicesAction->setEnabled(bHasClient); |
1243 |
|
channelsArrangeAction->setEnabled(bHasChannel); |
1244 |
|
|
1245 |
// Client/Server status... |
// Client/Server status... |
1246 |
if (bHasClient) { |
if (bHasClient) { |
1247 |
m_status[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected")); |
m_statusItem[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected")); |
1248 |
m_status[QSAMPLER_STATUS_SERVER]->setText(m_pOptions->sServerHost + ":" + QString::number(m_pOptions->iServerPort)); |
m_statusItem[QSAMPLER_STATUS_SERVER]->setText(m_pOptions->sServerHost + ":" + QString::number(m_pOptions->iServerPort)); |
1249 |
} else { |
} else { |
1250 |
m_status[QSAMPLER_STATUS_CLIENT]->clear(); |
m_statusItem[QSAMPLER_STATUS_CLIENT]->clear(); |
1251 |
m_status[QSAMPLER_STATUS_SERVER]->clear(); |
m_statusItem[QSAMPLER_STATUS_SERVER]->clear(); |
1252 |
} |
} |
1253 |
// Channel status... |
// Channel status... |
1254 |
if (bHasChannel) |
if (bHasChannel) |
1255 |
m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption()); |
m_statusItem[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption()); |
1256 |
else |
else |
1257 |
m_status[QSAMPLER_STATUS_CHANNEL]->clear(); |
m_statusItem[QSAMPLER_STATUS_CHANNEL]->clear(); |
1258 |
// Session status... |
// Session status... |
1259 |
if (m_iDirtyCount > 0) |
if (m_iDirtyCount > 0) |
1260 |
m_status[QSAMPLER_STATUS_SESSION]->setText(tr("MOD")); |
m_statusItem[QSAMPLER_STATUS_SESSION]->setText(tr("MOD")); |
1261 |
else |
else |
1262 |
m_status[QSAMPLER_STATUS_SESSION]->clear(); |
m_statusItem[QSAMPLER_STATUS_SESSION]->clear(); |
1263 |
|
|
1264 |
// Recent files menu. |
// Recent files menu. |
1265 |
m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0); |
m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0); |
1271 |
|
|
1272 |
|
|
1273 |
// Channel change receiver slot. |
// Channel change receiver slot. |
1274 |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip * ) |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip ) |
1275 |
{ |
{ |
1276 |
// Flag that we're update those channel strips. |
// Add this strip to the changed list... |
1277 |
m_iChangeCount++; |
if (m_changedStrips.containsRef(pChannelStrip) == 0) |
1278 |
|
m_changedStrips.append(pChannelStrip); |
1279 |
|
|
1280 |
// Just mark the dirty form. |
// Just mark the dirty form. |
1281 |
m_iDirtyCount++; |
m_iDirtyCount++; |
1282 |
// and update the form status... |
// and update the form status... |
1284 |
} |
} |
1285 |
|
|
1286 |
|
|
1287 |
|
// Grab and restore current sampler channels session. |
1288 |
|
void qsamplerMainForm::updateSession (void) |
1289 |
|
{ |
1290 |
|
// Retrieve the current channel list. |
1291 |
|
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
1292 |
|
if (piChannelIDs == NULL) { |
1293 |
|
if (::lscp_client_get_errno(m_pClient)) { |
1294 |
|
appendMessagesClient("lscp_list_channels"); |
1295 |
|
appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); |
1296 |
|
} |
1297 |
|
return; |
1298 |
|
} |
1299 |
|
|
1300 |
|
// Try to (re)create each channel. |
1301 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1302 |
|
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
1303 |
|
// Check if theres already a channel strip for this one... |
1304 |
|
if (!channelStrip(piChannelIDs[iChannel])) |
1305 |
|
createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel])); |
1306 |
|
// Make it visibly responsive... |
1307 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1308 |
|
} |
1309 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1310 |
|
} |
1311 |
|
|
1312 |
|
|
1313 |
// Update the recent files list and menu. |
// Update the recent files list and menu. |
1314 |
void qsamplerMainForm::updateRecentFiles ( const QString& sFilename ) |
void qsamplerMainForm::updateRecentFiles ( const QString& sFilename ) |
1315 |
{ |
{ |
1549 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1550 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1551 |
pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1552 |
// y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
if (pChannelStrip) { |
1553 |
y += pChannelStrip->parentWidget()->frameGeometry().height(); |
// y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
1554 |
|
y += pChannelStrip->parentWidget()->frameGeometry().height(); |
1555 |
|
} |
1556 |
} |
} |
1557 |
} |
} |
1558 |
|
|
1586 |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
1587 |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
1588 |
} |
} |
1589 |
|
|
1590 |
|
// This is pretty new, so we'll watch for it closely. |
1591 |
|
channelStripChanged(pChannelStrip); |
1592 |
|
|
1593 |
// Return our successful reference... |
// Return our successful reference... |
1594 |
return pChannelStrip; |
return pChannelStrip; |
1595 |
} |
} |
1607 |
{ |
{ |
1608 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1609 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
1610 |
return 0; |
return NULL; |
1611 |
|
|
1612 |
return (qsamplerChannelStrip *) wlist.at(iChannel); |
return (qsamplerChannelStrip *) wlist.at(iChannel); |
1613 |
} |
} |
1614 |
|
|
1615 |
|
|
1616 |
|
// Retrieve a channel strip by sampler channel id. |
1617 |
|
qsamplerChannelStrip *qsamplerMainForm::channelStrip ( int iChannelID ) |
1618 |
|
{ |
1619 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1620 |
|
if (wlist.isEmpty()) |
1621 |
|
return NULL; |
1622 |
|
|
1623 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1624 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1625 |
|
if (pChannelStrip) { |
1626 |
|
qsamplerChannel *pChannel = pChannelStrip->channel(); |
1627 |
|
if (pChannel && pChannel->channelID() == iChannelID) |
1628 |
|
return pChannelStrip; |
1629 |
|
} |
1630 |
|
} |
1631 |
|
|
1632 |
|
// Not found. |
1633 |
|
return NULL; |
1634 |
|
} |
1635 |
|
|
1636 |
|
|
1637 |
// Construct the windows menu. |
// Construct the windows menu. |
1638 |
void qsamplerMainForm::channelsMenuAboutToShow (void) |
void qsamplerMainForm::channelsMenuAboutToShow (void) |
1639 |
{ |
{ |
1702 |
} |
} |
1703 |
|
|
1704 |
// Refresh each channel usage, on each period... |
// Refresh each channel usage, on each period... |
1705 |
if (m_pClient && (m_iChangeCount > 0 || m_pOptions->bAutoRefresh)) { |
if (m_pClient && (m_changedStrips.count() > 0 || m_pOptions->bAutoRefresh)) { |
1706 |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
1707 |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled()) { |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled()) { |
1708 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
1709 |
m_iChangeCount = 0; |
// Update the channel information for each pending strip... |
1710 |
|
for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first(); |
1711 |
|
pChannelStrip; |
1712 |
|
pChannelStrip = m_changedStrips.next()) { |
1713 |
|
// If successfull, remove from pending list... |
1714 |
|
if (pChannelStrip->updateChannelInfo()) |
1715 |
|
m_changedStrips.remove(pChannelStrip); |
1716 |
|
} |
1717 |
|
// Update the channel stream usage for each strip... |
1718 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1719 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1720 |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1721 |
if (pChannelStrip && pChannelStrip->isVisible()) { |
if (pChannelStrip && pChannelStrip->isVisible()) |
1722 |
// If we can't make it clean, try next time. |
pChannelStrip->updateChannelUsage(); |
|
if (!pChannelStrip->updateChannelUsage()) |
|
|
m_iChangeCount++; |
|
|
} |
|
1723 |
} |
} |
1724 |
} |
} |
1725 |
} |
} |
1912 |
// Log success here. |
// Log success here. |
1913 |
appendMessages(tr("Client connected.")); |
appendMessages(tr("Client connected.")); |
1914 |
|
|
1915 |
|
// Hard-notify device configuration form, |
1916 |
|
// if visible, that we're ready... |
1917 |
|
if (m_pDeviceForm && m_pDeviceForm->isVisible()) |
1918 |
|
m_pDeviceForm->setClient(m_pClient); |
1919 |
|
|
1920 |
// Is any session pending to be loaded? |
// Is any session pending to be loaded? |
1921 |
if (!m_pOptions->sSessionFile.isEmpty()) { |
if (!m_pOptions->sSessionFile.isEmpty()) { |
1922 |
// Just load the prabably startup session... |
// Just load the prabably startup session... |
1937 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
1938 |
return; |
return; |
1939 |
|
|
1940 |
|
// Hard-notify device configuration form, |
1941 |
|
// if visible, that we're running out... |
1942 |
|
if (m_pDeviceForm && m_pDeviceForm->isVisible()) |
1943 |
|
m_pDeviceForm->setClient(NULL); |
1944 |
|
|
1945 |
// Log prepare here. |
// Log prepare here. |
1946 |
appendMessages(tr("Client disconnecting...")); |
appendMessages(tr("Client disconnecting...")); |
1947 |
|
|