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 |
|
|
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)) |
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 |
} |
} |
642 |
} |
} |
643 |
|
|
644 |
// Write the file. |
// Write the file. |
645 |
int iErrors = 0; |
int iErrors = 0; |
646 |
QTextStream ts(&file); |
QTextStream ts(&file); |
647 |
ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl; |
ts << "# " << QSAMPLER_TITLE " - " << tr(QSAMPLER_SUBTITLE) << endl; |
648 |
ts << "# " << tr("Version") |
ts << "# " << tr("Version") |
653 |
ts << "# " << tr("File") |
ts << "# " << tr("File") |
654 |
<< ": " << QFileInfo(sFilename).fileName() << endl; |
<< ": " << QFileInfo(sFilename).fileName() << endl; |
655 |
ts << "# " << tr("Date") |
ts << "# " << tr("Date") |
656 |
<< ": " << QDate::currentDate().toString("MMMM dd yyyy") |
<< ": " << QDate::currentDate().toString("MMM dd yyyy") |
657 |
<< " " << QTime::currentTime().toString("hh:mm:ss") << endl; |
<< " " << QTime::currentTime().toString("hh:mm:ss") << endl; |
658 |
ts << "#" << endl; |
ts << "#" << endl; |
659 |
ts << endl; |
ts << endl; |
660 |
|
// It is assumed that this new kind of device+session file |
661 |
|
// will be loaded from a complete |
662 |
|
int *piDeviceIDs; |
663 |
|
int iDevice; |
664 |
|
ts << "RESET" << endl; |
665 |
|
// Audio device mapping. |
666 |
|
QMap<int, int> audioDeviceMap; |
667 |
|
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Audio); |
668 |
|
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
669 |
|
ts << endl; |
670 |
|
qsamplerDevice device(m_pClient, qsamplerDevice::Audio, piDeviceIDs[iDevice]); |
671 |
|
// Audio device specification... |
672 |
|
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
673 |
|
<< " " << tr("Device") << " " << iDevice << endl; |
674 |
|
ts << "CREATE AUDIO_OUTPUT_DEVICE " << device.driverName(); |
675 |
|
qsamplerDeviceParamMap::ConstIterator deviceParam; |
676 |
|
for (deviceParam = device.params().begin(); |
677 |
|
deviceParam != device.params().end(); |
678 |
|
++deviceParam) { |
679 |
|
ts << " " << deviceParam.key() |
680 |
|
<< "='" << deviceParam.data().value << "'"; |
681 |
|
} |
682 |
|
ts << endl; |
683 |
|
// Audio channel parameters... |
684 |
|
int iPort = 0; |
685 |
|
for (qsamplerDevicePort *pPort = device.ports().first(); |
686 |
|
pPort; |
687 |
|
pPort = device.ports().next(), ++iPort) { |
688 |
|
qsamplerDeviceParamMap::ConstIterator portParam; |
689 |
|
for (portParam = pPort->params().begin(); |
690 |
|
portParam != pPort->params().end(); |
691 |
|
++portParam) { |
692 |
|
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
693 |
|
<< " " << iPort << " " << portParam.key() |
694 |
|
<< "='" << portParam.data().value << "'" << endl; |
695 |
|
} |
696 |
|
} |
697 |
|
// Audio device index/id mapping. |
698 |
|
audioDeviceMap[device.deviceID()] = iDevice; |
699 |
|
// Try to keep it snappy :) |
700 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
701 |
|
} |
702 |
|
// MIDI device mapping. |
703 |
|
QMap<int, int> midiDeviceMap; |
704 |
|
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
705 |
|
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
706 |
|
ts << endl; |
707 |
|
qsamplerDevice device(m_pClient, qsamplerDevice::Midi, piDeviceIDs[iDevice]); |
708 |
|
// MIDI device specification... |
709 |
|
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
710 |
|
<< " " << tr("Device") << " " << iDevice << endl; |
711 |
|
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
712 |
|
qsamplerDeviceParamMap::ConstIterator deviceParam; |
713 |
|
for (deviceParam = device.params().begin(); |
714 |
|
deviceParam != device.params().end(); |
715 |
|
++deviceParam) { |
716 |
|
ts << " " << deviceParam.key() |
717 |
|
<< "='" << deviceParam.data().value << "'"; |
718 |
|
} |
719 |
|
ts << endl; |
720 |
|
// MIDI port parameters... |
721 |
|
int iPort = 0; |
722 |
|
for (qsamplerDevicePort *pPort = device.ports().first(); |
723 |
|
pPort; |
724 |
|
pPort = device.ports().next(), ++iPort) { |
725 |
|
qsamplerDeviceParamMap::ConstIterator portParam; |
726 |
|
for (portParam = pPort->params().begin(); |
727 |
|
portParam != pPort->params().end(); |
728 |
|
++portParam) { |
729 |
|
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
730 |
|
<< " " << iPort << " " << portParam.key() |
731 |
|
<< "='" << portParam.data().value << "'" << endl; |
732 |
|
} |
733 |
|
} |
734 |
|
// MIDI device index/id mapping. |
735 |
|
midiDeviceMap[device.deviceID()] = iDevice; |
736 |
|
// Try to keep it snappy :) |
737 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
738 |
|
} |
739 |
|
ts << endl; |
740 |
|
// Sampler channel mapping. |
741 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
742 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
743 |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
744 |
if (pChannelStrip) { |
if (pChannelStrip) { |
745 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
746 |
if (pChannel) { |
if (pChannel) { |
747 |
int iChannelID = pChannel->channelID(); |
ts << "# " << tr("Channel") << " " << iChannel << endl; |
|
ts << "# " << pChannelStrip->caption() << endl; |
|
748 |
ts << "ADD CHANNEL" << endl; |
ts << "ADD CHANNEL" << endl; |
749 |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl; |
if (audioDeviceMap.isEmpty()) { |
750 |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl; |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel |
751 |
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl; |
<< " " << pChannel->audioDriver() << endl; |
752 |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " "; |
} else { |
753 |
|
ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannel |
754 |
|
<< " " << audioDeviceMap[pChannel->audioDevice()] << endl; |
755 |
|
} |
756 |
|
if (midiDeviceMap.isEmpty()) { |
757 |
|
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel |
758 |
|
<< " " << pChannel->midiDriver() << endl; |
759 |
|
} else { |
760 |
|
ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannel |
761 |
|
<< " " << midiDeviceMap[pChannel->midiDevice()] << endl; |
762 |
|
} |
763 |
|
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel |
764 |
|
<< " " << pChannel->midiPort() << endl; |
765 |
|
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " "; |
766 |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
767 |
ts << "ALL"; |
ts << "ALL"; |
768 |
else |
else |
769 |
ts << pChannel->midiChannel(); |
ts << pChannel->midiChannel(); |
770 |
ts << endl; |
ts << endl; |
771 |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl; |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl; |
772 |
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannelID << endl; |
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl; |
773 |
ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl; |
ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl; |
774 |
ts << endl; |
ts << endl; |
775 |
} |
} |
776 |
} |
} |
799 |
} |
} |
800 |
|
|
801 |
|
|
802 |
|
// Session change receiver slot. |
803 |
|
void qsamplerMainForm::sessionDirty (void) |
804 |
|
{ |
805 |
|
// Just mark the dirty form. |
806 |
|
m_iDirtyCount++; |
807 |
|
// and update the form status... |
808 |
|
stabilizeForm(); |
809 |
|
} |
810 |
|
|
811 |
|
|
812 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
813 |
// qsamplerMainForm -- File Action slots. |
// qsamplerMainForm -- File Action slots. |
814 |
|
|
953 |
|
|
954 |
// Make that an overall update. |
// Make that an overall update. |
955 |
m_iDirtyCount++; |
m_iDirtyCount++; |
|
m_iChangeCount++; |
|
956 |
stabilizeForm(); |
stabilizeForm(); |
957 |
} |
} |
958 |
|
|
1024 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
1025 |
return; |
return; |
1026 |
|
|
1027 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
// Just invoque the channel strip procedure. |
1028 |
if (pChannel == NULL) |
pChannelStrip->channelReset(); |
1029 |
return; |
} |
1030 |
|
|
|
// Reset the existing sampler channel. |
|
|
pChannel->resetChannel(); |
|
1031 |
|
|
1032 |
// And force a deferred update. |
// Reset all sampler channels. |
1033 |
m_iChangeCount++; |
void qsamplerMainForm::editResetAllChannels (void) |
1034 |
|
{ |
1035 |
|
if (m_pClient == NULL) |
1036 |
|
return; |
1037 |
|
|
1038 |
|
// Invoque the channel strip procedure, |
1039 |
|
// for all channels out there... |
1040 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1041 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1042 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1043 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1044 |
|
if (pChannelStrip) |
1045 |
|
pChannelStrip->channelReset(); |
1046 |
|
} |
1047 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1048 |
} |
} |
1049 |
|
|
1050 |
|
|
1096 |
} |
} |
1097 |
|
|
1098 |
|
|
1099 |
|
// Show/hide the device configurator form. |
1100 |
|
void qsamplerMainForm::viewDevices (void) |
1101 |
|
{ |
1102 |
|
if (m_pOptions == NULL) |
1103 |
|
return; |
1104 |
|
|
1105 |
|
if (m_pDeviceForm) { |
1106 |
|
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
1107 |
|
m_pDeviceForm->setClient(m_pClient); |
1108 |
|
if (m_pDeviceForm->isVisible()) { |
1109 |
|
m_pDeviceForm->hide(); |
1110 |
|
} else { |
1111 |
|
m_pDeviceForm->show(); |
1112 |
|
m_pDeviceForm->raise(); |
1113 |
|
m_pDeviceForm->setActiveWindow(); |
1114 |
|
} |
1115 |
|
} |
1116 |
|
} |
1117 |
|
|
1118 |
|
|
1119 |
// Show options dialog. |
// Show options dialog. |
1120 |
void qsamplerMainForm::viewOptions (void) |
void qsamplerMainForm::viewOptions (void) |
1121 |
{ |
{ |
1140 |
bool bOldDisplayEffect = m_pOptions->bDisplayEffect; |
bool bOldDisplayEffect = m_pOptions->bDisplayEffect; |
1141 |
int iOldMaxVolume = m_pOptions->iMaxVolume; |
int iOldMaxVolume = m_pOptions->iMaxVolume; |
1142 |
QString sOldMessagesFont = m_pOptions->sMessagesFont; |
QString sOldMessagesFont = m_pOptions->sMessagesFont; |
1143 |
|
bool bOldKeepOnTop = m_pOptions->bKeepOnTop; |
1144 |
bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
1145 |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
1146 |
int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
1153 |
if (pOptionsForm->exec()) { |
if (pOptionsForm->exec()) { |
1154 |
// Warn if something will be only effective on next run. |
// Warn if something will be only effective on next run. |
1155 |
if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) || |
if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) || |
1156 |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture)) { |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture) || |
1157 |
|
( bOldKeepOnTop && !m_pOptions->bKeepOnTop) || |
1158 |
|
(!bOldKeepOnTop && m_pOptions->bKeepOnTop)) { |
1159 |
QMessageBox::information(this, tr("Information"), |
QMessageBox::information(this, tr("Information"), |
1160 |
tr("Some settings may be only effective\n" |
tr("Some settings may be only effective\n" |
1161 |
"next time you start this program."), tr("OK")); |
"next time you start this program."), tr("OK")); |
1311 |
void qsamplerMainForm::stabilizeForm (void) |
void qsamplerMainForm::stabilizeForm (void) |
1312 |
{ |
{ |
1313 |
// Update the main application caption... |
// Update the main application caption... |
1314 |
QString sSessioName = sessionName(m_sFilename); |
QString sSessionName = sessionName(m_sFilename); |
1315 |
if (m_iDirtyCount > 0) |
if (m_iDirtyCount > 0) |
1316 |
sSessioName += '*'; |
sSessionName += '*'; |
1317 |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName)); |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName)); |
1318 |
|
|
1319 |
// Update the main menu state... |
// Update the main menu state... |
1320 |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
1330 |
editRemoveChannelAction->setEnabled(bHasChannel); |
editRemoveChannelAction->setEnabled(bHasChannel); |
1331 |
editSetupChannelAction->setEnabled(bHasChannel); |
editSetupChannelAction->setEnabled(bHasChannel); |
1332 |
editResetChannelAction->setEnabled(bHasChannel); |
editResetChannelAction->setEnabled(bHasChannel); |
1333 |
channelsArrangeAction->setEnabled(bHasChannel); |
editResetAllChannelsAction->setEnabled(bHasChannel); |
1334 |
viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible()); |
viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible()); |
1335 |
|
viewDevicesAction->setOn(m_pDeviceForm && m_pDeviceForm->isVisible()); |
1336 |
|
viewDevicesAction->setEnabled(bHasClient); |
1337 |
|
channelsArrangeAction->setEnabled(bHasChannel); |
1338 |
|
|
1339 |
// Client/Server status... |
// Client/Server status... |
1340 |
if (bHasClient) { |
if (bHasClient) { |
1341 |
m_status[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected")); |
m_statusItem[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected")); |
1342 |
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)); |
1343 |
} else { |
} else { |
1344 |
m_status[QSAMPLER_STATUS_CLIENT]->clear(); |
m_statusItem[QSAMPLER_STATUS_CLIENT]->clear(); |
1345 |
m_status[QSAMPLER_STATUS_SERVER]->clear(); |
m_statusItem[QSAMPLER_STATUS_SERVER]->clear(); |
1346 |
} |
} |
1347 |
// Channel status... |
// Channel status... |
1348 |
if (bHasChannel) |
if (bHasChannel) |
1349 |
m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption()); |
m_statusItem[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption()); |
1350 |
else |
else |
1351 |
m_status[QSAMPLER_STATUS_CHANNEL]->clear(); |
m_statusItem[QSAMPLER_STATUS_CHANNEL]->clear(); |
1352 |
// Session status... |
// Session status... |
1353 |
if (m_iDirtyCount > 0) |
if (m_iDirtyCount > 0) |
1354 |
m_status[QSAMPLER_STATUS_SESSION]->setText(tr("MOD")); |
m_statusItem[QSAMPLER_STATUS_SESSION]->setText(tr("MOD")); |
1355 |
else |
else |
1356 |
m_status[QSAMPLER_STATUS_SESSION]->clear(); |
m_statusItem[QSAMPLER_STATUS_SESSION]->clear(); |
1357 |
|
|
1358 |
// Recent files menu. |
// Recent files menu. |
1359 |
m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0); |
m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0); |
1365 |
|
|
1366 |
|
|
1367 |
// Channel change receiver slot. |
// Channel change receiver slot. |
1368 |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip * ) |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip ) |
1369 |
{ |
{ |
1370 |
// Flag that we're update those channel strips. |
// Add this strip to the changed list... |
1371 |
m_iChangeCount++; |
if (m_changedStrips.containsRef(pChannelStrip) == 0) |
1372 |
|
m_changedStrips.append(pChannelStrip); |
1373 |
|
|
1374 |
// Just mark the dirty form. |
// Just mark the dirty form. |
1375 |
m_iDirtyCount++; |
m_iDirtyCount++; |
1376 |
// and update the form status... |
// and update the form status... |
1401 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1402 |
} |
} |
1403 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1404 |
|
|
1405 |
|
// Remember to refresh devices |
1406 |
|
if (m_pDeviceForm) |
1407 |
|
m_pDeviceForm->refreshDevices(); |
1408 |
} |
} |
1409 |
|
|
1410 |
|
|
1684 |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
1685 |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
1686 |
} |
} |
1687 |
|
|
1688 |
|
// This is pretty new, so we'll watch for it closely. |
1689 |
|
channelStripChanged(pChannelStrip); |
1690 |
|
|
1691 |
// Return our successful reference... |
// Return our successful reference... |
1692 |
return pChannelStrip; |
return pChannelStrip; |
1693 |
} |
} |
1800 |
} |
} |
1801 |
|
|
1802 |
// Refresh each channel usage, on each period... |
// Refresh each channel usage, on each period... |
1803 |
if (m_pClient && (m_iChangeCount > 0 || m_pOptions->bAutoRefresh)) { |
if (m_pClient && (m_changedStrips.count() > 0 || m_pOptions->bAutoRefresh)) { |
1804 |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
1805 |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled()) { |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled()) { |
1806 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
1807 |
m_iChangeCount = 0; |
// Update the channel information for each pending strip... |
1808 |
|
for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first(); |
1809 |
|
pChannelStrip; |
1810 |
|
pChannelStrip = m_changedStrips.next()) { |
1811 |
|
// If successfull, remove from pending list... |
1812 |
|
if (pChannelStrip->updateChannelInfo()) |
1813 |
|
m_changedStrips.remove(pChannelStrip); |
1814 |
|
} |
1815 |
|
// Update the channel stream usage for each strip... |
1816 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1817 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1818 |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1819 |
if (pChannelStrip && pChannelStrip->isVisible()) { |
if (pChannelStrip && pChannelStrip->isVisible()) |
1820 |
// If we can't make it clean, try next time. |
pChannelStrip->updateChannelUsage(); |
|
if (!pChannelStrip->updateChannelUsage()) |
|
|
m_iChangeCount++; |
|
|
} |
|
1821 |
} |
} |
1822 |
} |
} |
1823 |
} |
} |
2010 |
// Log success here. |
// Log success here. |
2011 |
appendMessages(tr("Client connected.")); |
appendMessages(tr("Client connected.")); |
2012 |
|
|
2013 |
|
// Hard-notify device configuration form, |
2014 |
|
// if visible, that we're ready... |
2015 |
|
if (m_pDeviceForm && m_pDeviceForm->isVisible()) |
2016 |
|
m_pDeviceForm->setClient(m_pClient); |
2017 |
|
|
2018 |
// Is any session pending to be loaded? |
// Is any session pending to be loaded? |
2019 |
if (!m_pOptions->sSessionFile.isEmpty()) { |
if (!m_pOptions->sSessionFile.isEmpty()) { |
2020 |
// Just load the prabably startup session... |
// Just load the prabably startup session... |
2035 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
2036 |
return; |
return; |
2037 |
|
|
2038 |
|
// Hard-notify device configuration form, |
2039 |
|
// if visible, that we're running out... |
2040 |
|
if (m_pDeviceForm && m_pDeviceForm->isVisible()) |
2041 |
|
m_pDeviceForm->setClient(NULL); |
2042 |
|
|
2043 |
// Log prepare here. |
// Log prepare here. |
2044 |
appendMessages(tr("Client disconnecting...")); |
appendMessages(tr("Client disconnecting...")); |
2045 |
|
|