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" |
44 |
|
|
45 |
|
#include "qsamplerDeviceForm.h" |
46 |
#include "qsamplerOptionsForm.h" |
#include "qsamplerOptionsForm.h" |
47 |
|
|
48 |
#include "config.h" |
#include "config.h" |
49 |
|
|
50 |
|
#ifdef HAVE_SIGNAL_H |
51 |
|
#include <signal.h> |
52 |
|
#endif |
53 |
|
|
54 |
// Timer constant stuff. |
// Timer constant stuff. |
55 |
#define QSAMPLER_TIMER_MSECS 200 |
#define QSAMPLER_TIMER_MSECS 200 |
61 |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
#define QSAMPLER_STATUS_SESSION 3 // Current session modification state. |
62 |
|
|
63 |
|
|
64 |
|
// All winsock apps needs this. |
65 |
#if defined(WIN32) |
#if defined(WIN32) |
66 |
static WSADATA _wsaData; |
static WSADATA _wsaData; |
67 |
#endif |
#endif |
68 |
|
|
69 |
|
|
70 |
|
//------------------------------------------------------------------------- |
71 |
|
// qsamplerCustomEvent -- specialty for callback comunication. |
72 |
|
|
73 |
|
#define QSAMPLER_CUSTOM_EVENT 1000 |
74 |
|
|
75 |
|
class qsamplerCustomEvent : public QCustomEvent |
76 |
|
{ |
77 |
|
public: |
78 |
|
|
79 |
|
// Constructor. |
80 |
|
qsamplerCustomEvent(lscp_event_t event, const char *pchData, int cchData) |
81 |
|
: QCustomEvent(QSAMPLER_CUSTOM_EVENT) |
82 |
|
{ |
83 |
|
m_event = event; |
84 |
|
m_data.setLatin1(pchData, cchData); |
85 |
|
} |
86 |
|
|
87 |
|
// Accessors. |
88 |
|
lscp_event_t event() { return m_event; } |
89 |
|
QString& data() { return m_data; } |
90 |
|
|
91 |
|
private: |
92 |
|
|
93 |
|
// The proper event type. |
94 |
|
lscp_event_t m_event; |
95 |
|
// The event data as a string. |
96 |
|
QString m_data; |
97 |
|
}; |
98 |
|
|
99 |
|
|
100 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
101 |
// qsamplerMainForm -- Main window form implementation. |
// qsamplerMainForm -- Main window form implementation. |
102 |
|
|
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; |
116 |
|
|
117 |
m_pServer = NULL; |
m_pServer = NULL; |
122 |
|
|
123 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
124 |
|
|
125 |
|
#ifdef HAVE_SIGNAL_H |
126 |
|
// Set to ignore any fatal "Broken pipe" signals. |
127 |
|
::signal(SIGPIPE, SIG_IGN); |
128 |
|
#endif |
129 |
|
|
130 |
// Make it an MDI workspace. |
// Make it an MDI workspace. |
131 |
m_pWorkspace = new QWorkspace(this); |
m_pWorkspace = new QWorkspace(this); |
132 |
m_pWorkspace->setScrollBarsEnabled(true); |
m_pWorkspace->setScrollBarsEnabled(true); |
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 |
|
m_pDeviceForm->setMainForm(this); // An important life immutable! |
222 |
// Set message defaults... |
// Set message defaults... |
223 |
updateMessagesFont(); |
updateMessagesFont(); |
224 |
updateMessagesLimit(); |
updateMessagesLimit(); |
247 |
QTextIStream istr(&sDockables); |
QTextIStream istr(&sDockables); |
248 |
istr >> *this; |
istr >> *this; |
249 |
} |
} |
250 |
// Try to restore old window positioning. |
// Try to restore old window positioning and initial visibility. |
251 |
m_pOptions->loadWidgetGeometry(this); |
m_pOptions->loadWidgetGeometry(this); |
252 |
|
m_pOptions->loadWidgetGeometry(m_pDeviceForm); |
253 |
|
|
254 |
// Final startup stabilization... |
// Final startup stabilization... |
255 |
updateRecentFilesMenu(); |
updateRecentFilesMenu(); |
287 |
QTextOStream ostr(&sDockables); |
QTextOStream ostr(&sDockables); |
288 |
ostr << *this; |
ostr << *this; |
289 |
m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables); |
m_pOptions->settings().writeEntry("/Layout/DockWindows", sDockables); |
290 |
// And the main windows state. |
// And the children, and the main windows state,. |
291 |
|
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
292 |
m_pOptions->saveWidgetGeometry(this); |
m_pOptions->saveWidgetGeometry(this); |
293 |
|
// Close popup widgets. |
294 |
|
if (m_pDeviceForm) |
295 |
|
m_pDeviceForm->close(); |
296 |
// Stop client and/or server, gracefully. |
// Stop client and/or server, gracefully. |
297 |
stopServer(); |
stopServer(); |
298 |
} |
} |
311 |
} |
} |
312 |
|
|
313 |
|
|
314 |
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
// Drag'n'drop file handler. |
315 |
|
bool qsamplerMainForm::decodeDragFiles ( const QMimeSource *pEvent, QStringList& files ) |
316 |
{ |
{ |
317 |
bool bAccept = false; |
bool bDecode = false; |
318 |
|
|
319 |
if (QTextDrag::canDecode(pDragEnterEvent)) { |
if (QTextDrag::canDecode(pEvent)) { |
320 |
QString sUrl; |
QString sText; |
321 |
if (QTextDrag::decode(pDragEnterEvent, sUrl) && m_pClient) |
bDecode = QTextDrag::decode(pEvent, sText); |
322 |
bAccept = QFileInfo(QUrl(sUrl).path()).exists(); |
if (bDecode) { |
323 |
|
files = QStringList::split('\n', sText); |
324 |
|
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) |
325 |
|
*iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path(); |
326 |
|
} |
327 |
} |
} |
328 |
|
|
329 |
pDragEnterEvent->accept(bAccept); |
return bDecode; |
330 |
|
} |
331 |
|
|
332 |
|
|
333 |
|
// Window drag-n-drop event handlers. |
334 |
|
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
335 |
|
{ |
336 |
|
QStringList files; |
337 |
|
pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files)); |
338 |
} |
} |
339 |
|
|
340 |
|
|
341 |
void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent ) |
void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent ) |
342 |
{ |
{ |
343 |
if (QTextDrag::canDecode(pDropEvent)) { |
QStringList files; |
344 |
QString sUrl; |
|
345 |
if (QTextDrag::decode(pDropEvent, sUrl) && closeSession(true)) |
if (!decodeDragFiles(pDropEvent, files)) |
346 |
loadSessionFile(QUrl(sUrl).path()); |
return; |
347 |
|
|
348 |
|
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) { |
349 |
|
const QString& sPath = *iter; |
350 |
|
if (qsamplerChannel::isInstrumentFile(sPath)) { |
351 |
|
// Try to create a new channel from instrument file... |
352 |
|
qsamplerChannel *pChannel = new qsamplerChannel(this); |
353 |
|
if (pChannel == NULL) |
354 |
|
return; |
355 |
|
// Start setting the instrument filename... |
356 |
|
pChannel->setInstrument(sPath, 0); |
357 |
|
// Before we show it up, may be we'll |
358 |
|
// better ask for some initial values? |
359 |
|
if (!pChannel->channelSetup(this)) { |
360 |
|
delete pChannel; |
361 |
|
return; |
362 |
|
} |
363 |
|
// Finally, give it to a new channel strip... |
364 |
|
if (!createChannelStrip(pChannel)) { |
365 |
|
delete pChannel; |
366 |
|
return; |
367 |
|
} |
368 |
|
// Make that an overall update. |
369 |
|
m_iDirtyCount++; |
370 |
|
stabilizeForm(); |
371 |
|
} // Otherwise, load an usual session file (LSCP script)... |
372 |
|
else if (closeSession(true)) |
373 |
|
loadSessionFile(sPath); |
374 |
|
// Make it look responsive...:) |
375 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
376 |
|
} |
377 |
|
} |
378 |
|
|
379 |
|
|
380 |
|
// Custome event handler. |
381 |
|
void qsamplerMainForm::customEvent ( QCustomEvent *pCustomEvent ) |
382 |
|
{ |
383 |
|
// For the time being, just pump it to messages. |
384 |
|
if (pCustomEvent->type() == QSAMPLER_CUSTOM_EVENT) { |
385 |
|
qsamplerCustomEvent *pEvent = (qsamplerCustomEvent *) pCustomEvent; |
386 |
|
appendMessagesColor(tr("Notify event: %1 data: %2") |
387 |
|
.arg(::lscp_event_to_text(pEvent->event())) |
388 |
|
.arg(pEvent->data()), "#996699"); |
389 |
} |
} |
390 |
} |
} |
391 |
|
|
392 |
|
|
393 |
|
// Context menu event handler. |
394 |
|
void qsamplerMainForm::contextMenuEvent( QContextMenuEvent *pEvent ) |
395 |
|
{ |
396 |
|
stabilizeForm(); |
397 |
|
|
398 |
|
editMenu->exec(pEvent->globalPos()); |
399 |
|
} |
400 |
|
|
401 |
|
|
402 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
403 |
// qsamplerMainForm -- Brainless public property accessors. |
// qsamplerMainForm -- Brainless public property accessors. |
404 |
|
|
438 |
if (!closeSession(true)) |
if (!closeSession(true)) |
439 |
return false; |
return false; |
440 |
|
|
441 |
|
// Give us what the server has, right now... |
442 |
|
updateSession(); |
443 |
|
|
444 |
// Ok increment untitled count. |
// Ok increment untitled count. |
445 |
m_iUntitled++; |
m_iUntitled++; |
446 |
|
|
554 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
555 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
556 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
557 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
558 |
if (bForce && ::lscp_remove_channel(m_pClient, pChannel->channelID()) != LSCP_OK) |
if (pChannelStrip) { |
559 |
appendMessagesClient("lscp_remove_channel"); |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
560 |
delete pChannel; |
if (bForce && pChannel) |
561 |
|
pChannel->removeChannel(); |
562 |
|
delete pChannelStrip; |
563 |
|
} |
564 |
} |
} |
565 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
566 |
// We're now clean, for sure. |
// We're now clean, for sure. |
608 |
// Ok. we've read it. |
// Ok. we've read it. |
609 |
file.close(); |
file.close(); |
610 |
|
|
611 |
// Have we any errors? |
// Now we'll try to create (update) the whole GUI session. |
612 |
if (iErrors > 0) |
updateSession(); |
|
appendMessagesError(tr("Some setttings could not be loaded\nfrom \"%1\" session file.\n\nSorry.").arg(sFilename)); |
|
613 |
|
|
614 |
// Now we'll try to create the whole GUI session. |
// Have we any errors? |
615 |
int iChannels = ::lscp_get_channels(m_pClient); |
if (iErrors > 0) |
616 |
if (iChannels < 0) { |
appendMessagesError(tr("Session loaded with errors\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
|
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); |
|
617 |
|
|
618 |
// Save as default session directory. |
// Save as default session directory. |
619 |
if (m_pOptions) |
if (m_pOptions) |
620 |
m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true); |
m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true); |
621 |
// We're not dirty anymore. |
// We're not dirty anymore, if loaded without errors, |
622 |
m_iDirtyCount = 0; |
m_iDirtyCount = iErrors; |
623 |
// Stabilize form... |
// Stabilize form... |
624 |
m_sFilename = sFilename; |
m_sFilename = sFilename; |
625 |
updateRecentFiles(sFilename); |
updateRecentFiles(sFilename); |
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. |
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(this, 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 |
|
const qsamplerDeviceParam& param = deviceParam.data(); |
680 |
|
if (param.value.isEmpty()) ts << "# "; |
681 |
|
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
682 |
|
} |
683 |
|
ts << endl; |
684 |
|
// Audio channel parameters... |
685 |
|
int iPort = 0; |
686 |
|
for (qsamplerDevicePort *pPort = device.ports().first(); |
687 |
|
pPort; |
688 |
|
pPort = device.ports().next(), ++iPort) { |
689 |
|
qsamplerDeviceParamMap::ConstIterator portParam; |
690 |
|
for (portParam = pPort->params().begin(); |
691 |
|
portParam != pPort->params().end(); |
692 |
|
++portParam) { |
693 |
|
const qsamplerDeviceParam& param = portParam.data(); |
694 |
|
if (param.fix || param.value.isEmpty()) ts << "# "; |
695 |
|
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
696 |
|
<< " " << iPort << " " << portParam.key() |
697 |
|
<< "='" << param.value << "'" << endl; |
698 |
|
} |
699 |
|
} |
700 |
|
// Audio device index/id mapping. |
701 |
|
audioDeviceMap[device.deviceID()] = iDevice; |
702 |
|
// Try to keep it snappy :) |
703 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
704 |
|
} |
705 |
|
// MIDI device mapping. |
706 |
|
QMap<int, int> midiDeviceMap; |
707 |
|
piDeviceIDs = qsamplerDevice::getDevices(m_pClient, qsamplerDevice::Midi); |
708 |
|
for (iDevice = 0; piDeviceIDs && piDeviceIDs[iDevice] >= 0; iDevice++) { |
709 |
|
ts << endl; |
710 |
|
qsamplerDevice device(this, qsamplerDevice::Midi, piDeviceIDs[iDevice]); |
711 |
|
// MIDI device specification... |
712 |
|
ts << "# " << device.deviceTypeName() << " " << device.driverName() |
713 |
|
<< " " << tr("Device") << " " << iDevice << endl; |
714 |
|
ts << "CREATE MIDI_INPUT_DEVICE " << device.driverName(); |
715 |
|
qsamplerDeviceParamMap::ConstIterator deviceParam; |
716 |
|
for (deviceParam = device.params().begin(); |
717 |
|
deviceParam != device.params().end(); |
718 |
|
++deviceParam) { |
719 |
|
const qsamplerDeviceParam& param = deviceParam.data(); |
720 |
|
if (param.value.isEmpty()) ts << "# "; |
721 |
|
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
722 |
|
} |
723 |
|
ts << endl; |
724 |
|
// MIDI port parameters... |
725 |
|
int iPort = 0; |
726 |
|
for (qsamplerDevicePort *pPort = device.ports().first(); |
727 |
|
pPort; |
728 |
|
pPort = device.ports().next(), ++iPort) { |
729 |
|
qsamplerDeviceParamMap::ConstIterator portParam; |
730 |
|
for (portParam = pPort->params().begin(); |
731 |
|
portParam != pPort->params().end(); |
732 |
|
++portParam) { |
733 |
|
const qsamplerDeviceParam& param = portParam.data(); |
734 |
|
if (param.fix || param.value.isEmpty()) ts << "# "; |
735 |
|
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
736 |
|
<< " " << iPort << " " << portParam.key() |
737 |
|
<< "='" << param.value << "'" << endl; |
738 |
|
} |
739 |
|
} |
740 |
|
// MIDI device index/id mapping. |
741 |
|
midiDeviceMap[device.deviceID()] = iDevice; |
742 |
|
// Try to keep it snappy :) |
743 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
744 |
|
} |
745 |
|
ts << endl; |
746 |
|
// Sampler channel mapping. |
747 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
748 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
749 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
750 |
int iChannelID = pChannel->channelID(); |
if (pChannelStrip) { |
751 |
ts << "# " << pChannel->caption() << endl; |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
752 |
ts << "ADD CHANNEL" << endl; |
if (pChannel) { |
753 |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannelID << " " << pChannel->audioDriver() << endl; |
ts << "# " << tr("Channel") << " " << iChannel << endl; |
754 |
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannelID << " " << pChannel->midiDriver() << endl; |
ts << "ADD CHANNEL" << endl; |
755 |
// ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannelID << " " << pChannel->midiPort() << endl; |
if (audioDeviceMap.isEmpty()) { |
756 |
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannelID << " " << pChannel->midiChannel() << endl; |
ts << "SET CHANNEL AUDIO_OUTPUT_TYPE " << iChannel |
757 |
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannelID << endl; |
<< " " << pChannel->audioDriver() << endl; |
758 |
ts << "LOAD INSTRUMENT " << pChannel->instrumentFile() << " " << pChannel->instrumentNr() << " " << iChannelID << endl; |
} else { |
759 |
ts << "SET CHANNEL VOLUME " << iChannelID << " " << pChannel->volume() << endl; |
ts << "SET CHANNEL AUDIO_OUTPUT_DEVICE " << iChannel |
760 |
ts << endl; |
<< " " << audioDeviceMap[pChannel->audioDevice()] << endl; |
761 |
|
} |
762 |
|
if (midiDeviceMap.isEmpty()) { |
763 |
|
ts << "SET CHANNEL MIDI_INPUT_TYPE " << iChannel |
764 |
|
<< " " << pChannel->midiDriver() << endl; |
765 |
|
} else { |
766 |
|
ts << "SET CHANNEL MIDI_INPUT_DEVICE " << iChannel |
767 |
|
<< " " << midiDeviceMap[pChannel->midiDevice()] << endl; |
768 |
|
} |
769 |
|
ts << "SET CHANNEL MIDI_INPUT_PORT " << iChannel |
770 |
|
<< " " << pChannel->midiPort() << endl; |
771 |
|
ts << "SET CHANNEL MIDI_INPUT_CHANNEL " << iChannel << " "; |
772 |
|
if (pChannel->midiChannel() == LSCP_MIDI_CHANNEL_ALL) |
773 |
|
ts << "ALL"; |
774 |
|
else |
775 |
|
ts << pChannel->midiChannel(); |
776 |
|
ts << endl; |
777 |
|
ts << "LOAD ENGINE " << pChannel->engineName() << " " << iChannel << endl; |
778 |
|
ts << "LOAD INSTRUMENT NON_MODAL '" << pChannel->instrumentFile() << "' " << pChannel->instrumentNr() << " " << iChannel << endl; |
779 |
|
ts << "SET CHANNEL VOLUME " << iChannel << " " << pChannel->volume() << endl; |
780 |
|
ts << endl; |
781 |
|
} |
782 |
|
} |
783 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
784 |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
785 |
} |
} |
805 |
} |
} |
806 |
|
|
807 |
|
|
808 |
|
// Session change receiver slot. |
809 |
|
void qsamplerMainForm::sessionDirty (void) |
810 |
|
{ |
811 |
|
// Just mark the dirty form. |
812 |
|
m_iDirtyCount++; |
813 |
|
// and update the form status... |
814 |
|
stabilizeForm(); |
815 |
|
} |
816 |
|
|
817 |
|
|
818 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
819 |
// qsamplerMainForm -- File Action slots. |
// qsamplerMainForm -- File Action slots. |
820 |
|
|
861 |
} |
} |
862 |
|
|
863 |
|
|
864 |
|
// Reset the sampler instance. |
865 |
|
void qsamplerMainForm::fileReset (void) |
866 |
|
{ |
867 |
|
if (m_pClient == NULL) |
868 |
|
return; |
869 |
|
|
870 |
|
// Ask user whether he/she want's an internal sampler reset... |
871 |
|
if (QMessageBox::warning(this, tr("Warning"), |
872 |
|
tr("Resetting the sampler instance will close\n" |
873 |
|
"all device and channel configurations.\n\n" |
874 |
|
"Please note that this operation may cause\n" |
875 |
|
"temporary MIDI and Audio disruption\n\n" |
876 |
|
"Do you want to reset the sampler engine now?"), |
877 |
|
tr("Reset"), tr("Cancel")) > 0) |
878 |
|
return; |
879 |
|
|
880 |
|
// Just do the reset, after closing down current session... |
881 |
|
if (closeSession(true) && ::lscp_reset_sampler(m_pClient) != LSCP_OK) { |
882 |
|
appendMessagesClient("lscp_reset_sampler"); |
883 |
|
appendMessagesError(tr("Could not reset sampler instance.\n\nSorry.")); |
884 |
|
return; |
885 |
|
} |
886 |
|
|
887 |
|
// Log this. |
888 |
|
appendMessages(tr("Sampler reset.")); |
889 |
|
|
890 |
|
// Make it a new session... |
891 |
|
newSession(); |
892 |
|
} |
893 |
|
|
894 |
|
|
895 |
// Restart the client/server instance. |
// Restart the client/server instance. |
896 |
void qsamplerMainForm::fileRestart (void) |
void qsamplerMainForm::fileRestart (void) |
897 |
{ |
{ |
939 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
940 |
return; |
return; |
941 |
|
|
942 |
// Create the new sampler channel. |
// Just create the channel instance... |
943 |
int iChannelID = ::lscp_add_channel(m_pClient); |
qsamplerChannel *pChannel = new qsamplerChannel(this); |
944 |
if (iChannelID < 0) { |
if (pChannel == NULL) |
|
appendMessagesClient("lscp_add_channel"); |
|
|
appendMessagesError(tr("Could not create the new channel.\n\nSorry.")); |
|
945 |
return; |
return; |
|
} |
|
946 |
|
|
947 |
// Log this happening. |
// Before we show it up, may be we'll |
948 |
appendMessages(tr("Channel %1 created.").arg(iChannelID)); |
// better ask for some initial values? |
949 |
|
if (!pChannel->channelSetup(this)) { |
950 |
// Just create the channel strip with given id. |
delete pChannel; |
951 |
createChannel(iChannelID, true); |
return; |
952 |
|
} |
953 |
|
|
954 |
|
// And give it to the strip (will own the channel instance, if successful). |
955 |
|
if (!createChannelStrip(pChannel)) { |
956 |
|
delete pChannel; |
957 |
|
return; |
958 |
|
} |
959 |
|
|
960 |
// We'll be dirty, for sure... |
// Make that an overall update. |
961 |
m_iDirtyCount++; |
m_iDirtyCount++; |
|
// Stabilize form anyway. |
|
962 |
stabilizeForm(); |
stabilizeForm(); |
963 |
} |
} |
964 |
|
|
969 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
970 |
return; |
return; |
971 |
|
|
972 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
973 |
|
if (pChannelStrip == NULL) |
974 |
|
return; |
975 |
|
|
976 |
|
qsamplerChannel *pChannel = pChannelStrip->channel(); |
977 |
if (pChannel == NULL) |
if (pChannel == NULL) |
978 |
return; |
return; |
979 |
|
|
983 |
tr("About to remove channel:\n\n" |
tr("About to remove channel:\n\n" |
984 |
"%1\n\n" |
"%1\n\n" |
985 |
"Are you sure?") |
"Are you sure?") |
986 |
.arg(pChannel->caption()), |
.arg(pChannelStrip->caption()), |
987 |
tr("OK"), tr("Cancel")) > 0) |
tr("OK"), tr("Cancel")) > 0) |
988 |
return; |
return; |
989 |
} |
} |
990 |
|
|
991 |
// Remove the existing sampler channel. |
// Remove the existing sampler channel. |
992 |
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.")); |
|
993 |
return; |
return; |
|
} |
|
994 |
|
|
|
// Log this happening. |
|
|
appendMessages(tr("Channel %1 removed.").arg(pChannel->channelID())); |
|
|
|
|
995 |
// Just delete the channel strip. |
// Just delete the channel strip. |
996 |
delete pChannel; |
delete pChannelStrip; |
997 |
|
|
998 |
// Do we auto-arrange? |
// Do we auto-arrange? |
999 |
if (m_pOptions && m_pOptions->bAutoArrange) |
if (m_pOptions && m_pOptions->bAutoArrange) |
1000 |
channelsArrange(); |
channelsArrange(); |
1011 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
1012 |
return; |
return; |
1013 |
|
|
1014 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
1015 |
if (pChannel == NULL) |
if (pChannelStrip == NULL) |
1016 |
return; |
return; |
1017 |
|
|
1018 |
// Just invoque the channel strip procedure. |
// Just invoque the channel strip procedure. |
1019 |
pChannel->channelSetup(); |
pChannelStrip->channelSetup(); |
1020 |
} |
} |
1021 |
|
|
1022 |
|
|
1026 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
1027 |
return; |
return; |
1028 |
|
|
1029 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
1030 |
if (pChannel == NULL) |
if (pChannelStrip == NULL) |
1031 |
return; |
return; |
1032 |
|
|
1033 |
// Remove the existing sampler channel. |
// Just invoque the channel strip procedure. |
1034 |
if (::lscp_reset_channel(m_pClient, pChannel->channelID()) != LSCP_OK) { |
pChannelStrip->channelReset(); |
1035 |
appendMessagesClient("lscp_reset_channel"); |
} |
|
appendMessagesError(tr("Could not reset channel.\n\nSorry.")); |
|
|
return; |
|
|
} |
|
1036 |
|
|
|
// Log this. |
|
|
appendMessages(tr("Channel %1 reset.").arg(pChannel->channelID())); |
|
1037 |
|
|
1038 |
// Refresh channel strip info. |
// Reset all sampler channels. |
1039 |
pChannel->updateChannelInfo(); |
void qsamplerMainForm::editResetAllChannels (void) |
1040 |
|
{ |
1041 |
|
if (m_pClient == NULL) |
1042 |
|
return; |
1043 |
|
|
1044 |
|
// Invoque the channel strip procedure, |
1045 |
|
// for all channels out there... |
1046 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1047 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1048 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1049 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1050 |
|
if (pChannelStrip) |
1051 |
|
pChannelStrip->channelReset(); |
1052 |
|
} |
1053 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1054 |
} |
} |
1055 |
|
|
1056 |
|
|
1102 |
} |
} |
1103 |
|
|
1104 |
|
|
1105 |
|
// Show/hide the device configurator form. |
1106 |
|
void qsamplerMainForm::viewDevices (void) |
1107 |
|
{ |
1108 |
|
if (m_pOptions == NULL) |
1109 |
|
return; |
1110 |
|
|
1111 |
|
if (m_pDeviceForm) { |
1112 |
|
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
1113 |
|
m_pDeviceForm->setClient(m_pClient); |
1114 |
|
if (m_pDeviceForm->isVisible()) { |
1115 |
|
m_pDeviceForm->hide(); |
1116 |
|
} else { |
1117 |
|
m_pDeviceForm->show(); |
1118 |
|
m_pDeviceForm->raise(); |
1119 |
|
m_pDeviceForm->setActiveWindow(); |
1120 |
|
} |
1121 |
|
} |
1122 |
|
} |
1123 |
|
|
1124 |
|
|
1125 |
// Show options dialog. |
// Show options dialog. |
1126 |
void qsamplerMainForm::viewOptions (void) |
void qsamplerMainForm::viewOptions (void) |
1127 |
{ |
{ |
1131 |
qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this); |
qsamplerOptionsForm *pOptionsForm = new qsamplerOptionsForm(this); |
1132 |
if (pOptionsForm) { |
if (pOptionsForm) { |
1133 |
// Check out some initial nullities(tm)... |
// Check out some initial nullities(tm)... |
1134 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
1135 |
if (m_pOptions->sDisplayFont.isEmpty() && pChannel) |
if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip) |
1136 |
m_pOptions->sDisplayFont = pChannel->displayFont().toString(); |
m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString(); |
1137 |
if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages) |
if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages) |
1138 |
m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString(); |
m_pOptions->sMessagesFont = m_pMessages->messagesFont().toString(); |
1139 |
// To track down deferred or immediate changes. |
// To track down deferred or immediate changes. |
1143 |
bool bOldServerStart = m_pOptions->bServerStart; |
bool bOldServerStart = m_pOptions->bServerStart; |
1144 |
QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
QString sOldServerCmdLine = m_pOptions->sServerCmdLine; |
1145 |
QString sOldDisplayFont = m_pOptions->sDisplayFont; |
QString sOldDisplayFont = m_pOptions->sDisplayFont; |
1146 |
|
bool bOldDisplayEffect = m_pOptions->bDisplayEffect; |
1147 |
int iOldMaxVolume = m_pOptions->iMaxVolume; |
int iOldMaxVolume = m_pOptions->iMaxVolume; |
1148 |
QString sOldMessagesFont = m_pOptions->sMessagesFont; |
QString sOldMessagesFont = m_pOptions->sMessagesFont; |
1149 |
|
bool bOldKeepOnTop = m_pOptions->bKeepOnTop; |
1150 |
bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
bool bOldStdoutCapture = m_pOptions->bStdoutCapture; |
1151 |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
1152 |
int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
1153 |
bool bOldCompletePath = m_pOptions->bCompletePath; |
bool bOldCompletePath = m_pOptions->bCompletePath; |
1154 |
|
bool bOldInstrumentNames = m_pOptions->bInstrumentNames; |
1155 |
int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
1156 |
// Load the current setup settings. |
// Load the current setup settings. |
1157 |
pOptionsForm->setup(m_pOptions); |
pOptionsForm->setup(m_pOptions); |
1159 |
if (pOptionsForm->exec()) { |
if (pOptionsForm->exec()) { |
1160 |
// Warn if something will be only effective on next run. |
// Warn if something will be only effective on next run. |
1161 |
if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) || |
if (( bOldStdoutCapture && !m_pOptions->bStdoutCapture) || |
1162 |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture)) { |
(!bOldStdoutCapture && m_pOptions->bStdoutCapture) || |
1163 |
|
( bOldKeepOnTop && !m_pOptions->bKeepOnTop) || |
1164 |
|
(!bOldKeepOnTop && m_pOptions->bKeepOnTop)) { |
1165 |
QMessageBox::information(this, tr("Information"), |
QMessageBox::information(this, tr("Information"), |
1166 |
tr("Some settings may be only effective\n" |
tr("Some settings may be only effective\n" |
1167 |
"next time you start this program."), tr("OK")); |
"next time you start this program."), tr("OK")); |
1172 |
(!bOldCompletePath && m_pOptions->bCompletePath) || |
(!bOldCompletePath && m_pOptions->bCompletePath) || |
1173 |
(iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles)) |
(iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles)) |
1174 |
updateRecentFilesMenu(); |
updateRecentFilesMenu(); |
1175 |
|
if (( bOldInstrumentNames && !m_pOptions->bInstrumentNames) || |
1176 |
|
(!bOldInstrumentNames && m_pOptions->bInstrumentNames)) |
1177 |
|
updateInstrumentNames(); |
1178 |
|
if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) || |
1179 |
|
(!bOldDisplayEffect && m_pOptions->bDisplayEffect)) |
1180 |
|
updateDisplayEffect(); |
1181 |
if (sOldDisplayFont != m_pOptions->sDisplayFont) |
if (sOldDisplayFont != m_pOptions->sDisplayFont) |
1182 |
updateDisplayFont(); |
updateDisplayFont(); |
1183 |
if (iOldMaxVolume != m_pOptions->iMaxVolume) |
if (iOldMaxVolume != m_pOptions->iMaxVolume) |
1220 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
1221 |
int y = 0; |
int y = 0; |
1222 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1223 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1224 |
/* if (pChannel->testWState(WState_Maximized | WState_Minimized)) { |
/* if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) { |
1225 |
// Prevent flicker... |
// Prevent flicker... |
1226 |
pChannel->hide(); |
pChannelStrip->hide(); |
1227 |
pChannel->showNormal(); |
pChannelStrip->showNormal(); |
1228 |
} */ |
} */ |
1229 |
pChannel->adjustSize(); |
pChannelStrip->adjustSize(); |
1230 |
int iWidth = m_pWorkspace->width(); |
int iWidth = m_pWorkspace->width(); |
1231 |
if (iWidth < pChannel->width()) |
if (iWidth < pChannelStrip->width()) |
1232 |
iWidth = pChannel->width(); |
iWidth = pChannelStrip->width(); |
1233 |
// int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height(); |
// int iHeight = pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
1234 |
int iHeight = pChannel->parentWidget()->frameGeometry().height(); |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
1235 |
pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
1236 |
y += iHeight; |
y += iHeight; |
1237 |
} |
} |
1238 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1280 |
sText += tr("Debugging option enabled."); |
sText += tr("Debugging option enabled."); |
1281 |
sText += "</font></small><br />"; |
sText += "</font></small><br />"; |
1282 |
#endif |
#endif |
1283 |
|
#ifndef CONFIG_LIBGIG |
1284 |
|
sText += "<small><font color=\"red\">"; |
1285 |
|
sText += tr("GIG (libgig) file support disabled."); |
1286 |
|
sText += "</font></small><br />"; |
1287 |
|
#endif |
1288 |
|
#ifndef CONFIG_INSTRUMENT_NAME |
1289 |
|
sText += "<small><font color=\"red\">"; |
1290 |
|
sText += tr("LSCP (liblscp) instrument_name support disabled."); |
1291 |
|
sText += "</font></small><br />"; |
1292 |
|
#endif |
1293 |
sText += "<br />\n"; |
sText += "<br />\n"; |
1294 |
sText += tr("Using") + ": "; |
sText += tr("Using") + ": "; |
1295 |
sText += ::lscp_client_package(); |
sText += ::lscp_client_package(); |
1317 |
void qsamplerMainForm::stabilizeForm (void) |
void qsamplerMainForm::stabilizeForm (void) |
1318 |
{ |
{ |
1319 |
// Update the main application caption... |
// Update the main application caption... |
1320 |
QString sSessioName = sessionName(m_sFilename); |
QString sSessionName = sessionName(m_sFilename); |
1321 |
if (m_iDirtyCount > 0) |
if (m_iDirtyCount > 0) |
1322 |
sSessioName += '*'; |
sSessionName += '*'; |
1323 |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessioName)); |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName)); |
1324 |
|
|
1325 |
// Update the main menu state... |
// Update the main menu state... |
1326 |
qsamplerChannelStrip *pChannel = activeChannel(); |
qsamplerChannelStrip *pChannelStrip = activeChannelStrip(); |
1327 |
bool bHasClient = (m_pOptions != NULL && m_pClient != NULL); |
bool bHasClient = (m_pOptions != NULL && m_pClient != NULL); |
1328 |
bool bHasChannel = (bHasClient && pChannel != NULL); |
bool bHasChannel = (bHasClient && pChannelStrip != NULL); |
1329 |
fileNewAction->setEnabled(bHasClient); |
fileNewAction->setEnabled(bHasClient); |
1330 |
fileOpenAction->setEnabled(bHasClient); |
fileOpenAction->setEnabled(bHasClient); |
1331 |
fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0); |
fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0); |
1332 |
fileSaveAsAction->setEnabled(bHasClient); |
fileSaveAsAction->setEnabled(bHasClient); |
1333 |
|
fileResetAction->setEnabled(bHasClient); |
1334 |
fileRestartAction->setEnabled(bHasClient || m_pServer == NULL); |
fileRestartAction->setEnabled(bHasClient || m_pServer == NULL); |
1335 |
editAddChannelAction->setEnabled(bHasClient); |
editAddChannelAction->setEnabled(bHasClient); |
1336 |
editRemoveChannelAction->setEnabled(bHasChannel); |
editRemoveChannelAction->setEnabled(bHasChannel); |
1337 |
editSetupChannelAction->setEnabled(bHasChannel); |
editSetupChannelAction->setEnabled(bHasChannel); |
1338 |
editResetChannelAction->setEnabled(bHasChannel); |
editResetChannelAction->setEnabled(bHasChannel); |
1339 |
channelsArrangeAction->setEnabled(bHasChannel); |
editResetAllChannelsAction->setEnabled(bHasChannel); |
1340 |
viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible()); |
viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible()); |
1341 |
|
viewDevicesAction->setOn(m_pDeviceForm && m_pDeviceForm->isVisible()); |
1342 |
|
viewDevicesAction->setEnabled(bHasClient); |
1343 |
|
channelsArrangeAction->setEnabled(bHasChannel); |
1344 |
|
|
1345 |
// Client/Server status... |
// Client/Server status... |
1346 |
if (bHasClient) { |
if (bHasClient) { |
1347 |
m_status[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected")); |
m_statusItem[QSAMPLER_STATUS_CLIENT]->setText(tr("Connected")); |
1348 |
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)); |
1349 |
} else { |
} else { |
1350 |
m_status[QSAMPLER_STATUS_CLIENT]->clear(); |
m_statusItem[QSAMPLER_STATUS_CLIENT]->clear(); |
1351 |
m_status[QSAMPLER_STATUS_SERVER]->clear(); |
m_statusItem[QSAMPLER_STATUS_SERVER]->clear(); |
1352 |
} |
} |
1353 |
// Channel status... |
// Channel status... |
1354 |
if (bHasChannel) |
if (bHasChannel) |
1355 |
m_status[QSAMPLER_STATUS_CHANNEL]->setText(pChannel->caption()); |
m_statusItem[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption()); |
1356 |
else |
else |
1357 |
m_status[QSAMPLER_STATUS_CHANNEL]->clear(); |
m_statusItem[QSAMPLER_STATUS_CHANNEL]->clear(); |
1358 |
// Session status... |
// Session status... |
1359 |
if (m_iDirtyCount > 0) |
if (m_iDirtyCount > 0) |
1360 |
m_status[QSAMPLER_STATUS_SESSION]->setText(tr("MOD")); |
m_statusItem[QSAMPLER_STATUS_SESSION]->setText(tr("MOD")); |
1361 |
else |
else |
1362 |
m_status[QSAMPLER_STATUS_SESSION]->clear(); |
m_statusItem[QSAMPLER_STATUS_SESSION]->clear(); |
1363 |
|
|
1364 |
// Recent files menu. |
// Recent files menu. |
1365 |
m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0); |
m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0); |
1371 |
|
|
1372 |
|
|
1373 |
// Channel change receiver slot. |
// Channel change receiver slot. |
1374 |
void qsamplerMainForm::channelChanged( qsamplerChannelStrip * ) |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip ) |
1375 |
{ |
{ |
1376 |
|
// Add this strip to the changed list... |
1377 |
|
if (m_changedStrips.containsRef(pChannelStrip) == 0) |
1378 |
|
m_changedStrips.append(pChannelStrip); |
1379 |
|
|
1380 |
// Just mark the dirty form. |
// Just mark the dirty form. |
1381 |
m_iDirtyCount++; |
m_iDirtyCount++; |
1382 |
// and update the form status... |
// and update the form status... |
1384 |
} |
} |
1385 |
|
|
1386 |
|
|
1387 |
|
// Grab and restore current sampler channels session. |
1388 |
|
void qsamplerMainForm::updateSession (void) |
1389 |
|
{ |
1390 |
|
// Retrieve the current channel list. |
1391 |
|
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
1392 |
|
if (piChannelIDs == NULL) { |
1393 |
|
if (::lscp_client_get_errno(m_pClient)) { |
1394 |
|
appendMessagesClient("lscp_list_channels"); |
1395 |
|
appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); |
1396 |
|
} |
1397 |
|
return; |
1398 |
|
} |
1399 |
|
|
1400 |
|
// Try to (re)create each channel. |
1401 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1402 |
|
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
1403 |
|
// Check if theres already a channel strip for this one... |
1404 |
|
if (!channelStrip(piChannelIDs[iChannel])) |
1405 |
|
createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel])); |
1406 |
|
// Make it visibly responsive... |
1407 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1408 |
|
} |
1409 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1410 |
|
|
1411 |
|
// Remember to refresh devices |
1412 |
|
if (m_pDeviceForm) |
1413 |
|
m_pDeviceForm->refreshDevices(); |
1414 |
|
} |
1415 |
|
|
1416 |
|
|
1417 |
// Update the recent files list and menu. |
// Update the recent files list and menu. |
1418 |
void qsamplerMainForm::updateRecentFiles ( const QString& sFilename ) |
void qsamplerMainForm::updateRecentFiles ( const QString& sFilename ) |
1419 |
{ |
{ |
1458 |
} |
} |
1459 |
|
|
1460 |
|
|
1461 |
|
// Force update of the channels instrument names mode. |
1462 |
|
void qsamplerMainForm::updateInstrumentNames (void) |
1463 |
|
{ |
1464 |
|
// Full channel list update... |
1465 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1466 |
|
if (wlist.isEmpty()) |
1467 |
|
return; |
1468 |
|
|
1469 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1470 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1471 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1472 |
|
if (pChannelStrip) |
1473 |
|
pChannelStrip->updateInstrumentName(true); |
1474 |
|
} |
1475 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1476 |
|
} |
1477 |
|
|
1478 |
|
|
1479 |
// Force update of the channels display font. |
// Force update of the channels display font. |
1480 |
void qsamplerMainForm::updateDisplayFont (void) |
void qsamplerMainForm::updateDisplayFont (void) |
1481 |
{ |
{ |
1497 |
|
|
1498 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
1499 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1500 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1501 |
pChannel->setDisplayFont(font); |
if (pChannelStrip) |
1502 |
|
pChannelStrip->setDisplayFont(font); |
1503 |
|
} |
1504 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1505 |
|
} |
1506 |
|
|
1507 |
|
|
1508 |
|
// Update channel strips background effect. |
1509 |
|
void qsamplerMainForm::updateDisplayEffect (void) |
1510 |
|
{ |
1511 |
|
QPixmap pm; |
1512 |
|
if (m_pOptions->bDisplayEffect) |
1513 |
|
pm = QPixmap::fromMimeSource("displaybg1.png"); |
1514 |
|
|
1515 |
|
// Full channel list update... |
1516 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1517 |
|
if (wlist.isEmpty()) |
1518 |
|
return; |
1519 |
|
|
1520 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1521 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1522 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1523 |
|
if (pChannelStrip) |
1524 |
|
pChannelStrip->setDisplayBackground(pm); |
1525 |
} |
} |
1526 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1527 |
} |
} |
1540 |
|
|
1541 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
1542 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1543 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1544 |
pChannel->setMaxVolume(m_pOptions->iMaxVolume); |
if (pChannelStrip) |
1545 |
|
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
1546 |
} |
} |
1547 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1548 |
} |
} |
1641 |
// qsamplerMainForm -- MDI channel strip management. |
// qsamplerMainForm -- MDI channel strip management. |
1642 |
|
|
1643 |
// The channel strip creation executive. |
// The channel strip creation executive. |
1644 |
void qsamplerMainForm::createChannel ( int iChannelID, bool bPrompt ) |
qsamplerChannelStrip *qsamplerMainForm::createChannelStrip ( qsamplerChannel *pChannel ) |
1645 |
{ |
{ |
1646 |
if (m_pClient == NULL) |
if (m_pClient == NULL || pChannel == NULL) |
1647 |
return; |
return NULL; |
1648 |
|
|
1649 |
// Prepare for auto-arrange? |
// Prepare for auto-arrange? |
1650 |
qsamplerChannelStrip *pChannel = NULL; |
qsamplerChannelStrip *pChannelStrip = NULL; |
1651 |
int y = 0; |
int y = 0; |
1652 |
if (m_pOptions && m_pOptions->bAutoArrange) { |
if (m_pOptions && m_pOptions->bAutoArrange) { |
1653 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1654 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1655 |
pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1656 |
// y += pChannel->height() + pChannel->parentWidget()->baseSize().height(); |
if (pChannelStrip) { |
1657 |
y += pChannel->parentWidget()->frameGeometry().height(); |
// y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
1658 |
|
y += pChannelStrip->parentWidget()->frameGeometry().height(); |
1659 |
|
} |
1660 |
} |
} |
1661 |
} |
} |
1662 |
|
|
1663 |
// Add a new channel itema... |
// Add a new channel itema... |
1664 |
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; |
1665 |
pChannel = new qsamplerChannelStrip(m_pWorkspace, 0, wflags); |
pChannelStrip = new qsamplerChannelStrip(m_pWorkspace, 0, wflags); |
1666 |
pChannel->setMaxVolume(m_pOptions->iMaxVolume); |
if (pChannelStrip == NULL) |
1667 |
pChannel->setup(this, iChannelID); |
return NULL; |
1668 |
// We'll need a display font. |
|
1669 |
QFont font; |
// Actual channel strip setup... |
1670 |
if (m_pOptions && font.fromString(m_pOptions->sDisplayFont)) |
pChannelStrip->setup(pChannel); |
1671 |
pChannel->setDisplayFont(font); |
QObject::connect(pChannelStrip, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelStripChanged(qsamplerChannelStrip *))); |
1672 |
// Track channel setup changes. |
// Set some initial aesthetic options... |
1673 |
QObject::connect(pChannel, SIGNAL(channelChanged(qsamplerChannelStrip *)), this, SLOT(channelChanged(qsamplerChannelStrip *))); |
if (m_pOptions) { |
1674 |
// Before we show it up, may be we'll |
// Background display effect... |
1675 |
// better ask for some initial values? |
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
1676 |
if (bPrompt) |
// We'll need a display font. |
1677 |
pChannel->channelSetup(); |
QFont font; |
1678 |
|
if (font.fromString(m_pOptions->sDisplayFont)) |
1679 |
|
pChannelStrip->setDisplayFont(font); |
1680 |
|
// Maximum allowed volume setting. |
1681 |
|
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
1682 |
|
} |
1683 |
|
|
1684 |
// Now we show up us to the world. |
// Now we show up us to the world. |
1685 |
pChannel->show(); |
pChannelStrip->show(); |
1686 |
// Only then, we'll auto-arrange... |
// Only then, we'll auto-arrange... |
1687 |
if (m_pOptions && m_pOptions->bAutoArrange) { |
if (m_pOptions && m_pOptions->bAutoArrange) { |
1688 |
int iWidth = m_pWorkspace->width(); |
int iWidth = m_pWorkspace->width(); |
1689 |
// int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height(); |
// int iHeight = pChannel->height() + pChannel->parentWidget()->baseSize().height(); |
1690 |
int iHeight = pChannel->parentWidget()->frameGeometry().height(); |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
1691 |
pChannel->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
1692 |
} |
} |
1693 |
|
|
1694 |
|
// This is pretty new, so we'll watch for it closely. |
1695 |
|
channelStripChanged(pChannelStrip); |
1696 |
|
|
1697 |
|
// Return our successful reference... |
1698 |
|
return pChannelStrip; |
1699 |
} |
} |
1700 |
|
|
1701 |
|
|
1702 |
// Retrieve the active channel strip. |
// Retrieve the active channel strip. |
1703 |
qsamplerChannelStrip *qsamplerMainForm::activeChannel (void) |
qsamplerChannelStrip *qsamplerMainForm::activeChannelStrip (void) |
1704 |
{ |
{ |
1705 |
return (qsamplerChannelStrip *) m_pWorkspace->activeWindow(); |
return (qsamplerChannelStrip *) m_pWorkspace->activeWindow(); |
1706 |
} |
} |
1707 |
|
|
1708 |
|
|
1709 |
// Retrieve a channel strip by index. |
// Retrieve a channel strip by index. |
1710 |
qsamplerChannelStrip *qsamplerMainForm::channelAt ( int iChannel ) |
qsamplerChannelStrip *qsamplerMainForm::channelStripAt ( int iChannel ) |
1711 |
{ |
{ |
1712 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1713 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
1714 |
return 0; |
return NULL; |
1715 |
|
|
1716 |
return (qsamplerChannelStrip *) wlist.at(iChannel); |
return (qsamplerChannelStrip *) wlist.at(iChannel); |
1717 |
} |
} |
1718 |
|
|
1719 |
|
|
1720 |
|
// Retrieve a channel strip by sampler channel id. |
1721 |
|
qsamplerChannelStrip *qsamplerMainForm::channelStrip ( int iChannelID ) |
1722 |
|
{ |
1723 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1724 |
|
if (wlist.isEmpty()) |
1725 |
|
return NULL; |
1726 |
|
|
1727 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1728 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1729 |
|
if (pChannelStrip) { |
1730 |
|
qsamplerChannel *pChannel = pChannelStrip->channel(); |
1731 |
|
if (pChannel && pChannel->channelID() == iChannelID) |
1732 |
|
return pChannelStrip; |
1733 |
|
} |
1734 |
|
} |
1735 |
|
|
1736 |
|
// Not found. |
1737 |
|
return NULL; |
1738 |
|
} |
1739 |
|
|
1740 |
|
|
1741 |
// Construct the windows menu. |
// Construct the windows menu. |
1742 |
void qsamplerMainForm::channelsMenuAboutToShow (void) |
void qsamplerMainForm::channelsMenuAboutToShow (void) |
1743 |
{ |
{ |
1749 |
if (!wlist.isEmpty()) { |
if (!wlist.isEmpty()) { |
1750 |
channelsMenu->insertSeparator(); |
channelsMenu->insertSeparator(); |
1751 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1752 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1753 |
int iItemID = channelsMenu->insertItem(pChannel->caption(), this, SLOT(channelsMenuActivated(int))); |
if (pChannelStrip) { |
1754 |
channelsMenu->setItemParameter(iItemID, iChannel); |
int iItemID = channelsMenu->insertItem(pChannelStrip->caption(), this, SLOT(channelsMenuActivated(int))); |
1755 |
channelsMenu->setItemChecked(iItemID, activeChannel() == pChannel); |
channelsMenu->setItemParameter(iItemID, iChannel); |
1756 |
|
channelsMenu->setItemChecked(iItemID, activeChannelStrip() == pChannelStrip); |
1757 |
|
} |
1758 |
} |
} |
1759 |
} |
} |
1760 |
} |
} |
1763 |
// Windows menu activation slot |
// Windows menu activation slot |
1764 |
void qsamplerMainForm::channelsMenuActivated ( int iChannel ) |
void qsamplerMainForm::channelsMenuActivated ( int iChannel ) |
1765 |
{ |
{ |
1766 |
qsamplerChannelStrip *pChannel = channelAt(iChannel); |
qsamplerChannelStrip *pChannelStrip = channelStripAt(iChannel); |
1767 |
if (pChannel) |
if (pChannelStrip) |
1768 |
pChannel->showNormal(); |
pChannelStrip->showNormal(); |
1769 |
pChannel->setFocus(); |
pChannelStrip->setFocus(); |
1770 |
} |
} |
1771 |
|
|
1772 |
|
|
1806 |
} |
} |
1807 |
|
|
1808 |
// Refresh each channel usage, on each period... |
// Refresh each channel usage, on each period... |
1809 |
if (m_pClient && m_pOptions->bAutoRefresh && m_pWorkspace->isUpdatesEnabled()) { |
if (m_pClient && (m_changedStrips.count() > 0 || m_pOptions->bAutoRefresh)) { |
1810 |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
1811 |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime) { |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled()) { |
1812 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
1813 |
|
// Update the channel information for each pending strip... |
1814 |
|
for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first(); |
1815 |
|
pChannelStrip; |
1816 |
|
pChannelStrip = m_changedStrips.next()) { |
1817 |
|
// If successfull, remove from pending list... |
1818 |
|
if (pChannelStrip->updateChannelInfo()) |
1819 |
|
m_changedStrips.remove(pChannelStrip); |
1820 |
|
} |
1821 |
|
// Update the channel stream usage for each strip... |
1822 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1823 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1824 |
qsamplerChannelStrip *pChannel = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1825 |
if (pChannel->isVisible()) |
if (pChannelStrip && pChannelStrip->isVisible()) |
1826 |
pChannel->updateChannelUsage(); |
pChannelStrip->updateChannelUsage(); |
1827 |
} |
} |
1828 |
} |
} |
1829 |
} |
} |
1909 |
// And try to stop server. |
// And try to stop server. |
1910 |
if (m_pServer) { |
if (m_pServer) { |
1911 |
appendMessages(tr("Server is stopping...")); |
appendMessages(tr("Server is stopping...")); |
1912 |
if (m_pServer->isRunning()) { |
if (m_pServer->isRunning()) |
1913 |
m_pServer->tryTerminate(); |
m_pServer->tryTerminate(); |
|
return; |
|
|
} |
|
1914 |
} |
} |
1915 |
|
|
1916 |
|
// Give it some time to terminate gracefully and stabilize... |
1917 |
|
QTime t; |
1918 |
|
t.start(); |
1919 |
|
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
1920 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1921 |
|
|
1922 |
// Do final processing anyway. |
// Do final processing anyway. |
1923 |
processServerExit(); |
processServerExit(); |
1924 |
} |
} |
1960 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
1961 |
// qsamplerMainForm -- Client stuff. |
// qsamplerMainForm -- Client stuff. |
1962 |
|
|
|
|
|
1963 |
// The LSCP client callback procedure. |
// The LSCP client callback procedure. |
1964 |
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 ) |
1965 |
{ |
{ |
1966 |
qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData; |
qsamplerMainForm *pMainForm = (qsamplerMainForm *) pvData; |
1967 |
if (pMainForm == NULL) |
if (pMainForm == NULL) |
1968 |
return LSCP_FAILED; |
return LSCP_FAILED; |
1969 |
|
|
1970 |
char *pszBuffer = (char *) malloc(cchBuffer + 1); |
// ATTN: DO NOT EVER call any GUI code here, |
1971 |
if (pszBuffer == NULL) |
// as this is run under some other thread context. |
1972 |
return LSCP_FAILED; |
// A custom event must be posted here... |
1973 |
|
QApplication::postEvent(pMainForm, new qsamplerCustomEvent(event, pchData, cchData)); |
|
memcpy(pszBuffer, pchBuffer, cchBuffer); |
|
|
pszBuffer[cchBuffer] = (char) 0; |
|
|
pMainForm->appendMessagesColor(pszBuffer, "#996699"); |
|
|
free(pszBuffer); |
|
1974 |
|
|
1975 |
return LSCP_OK; |
return LSCP_OK; |
1976 |
} |
} |
2016 |
// Log success here. |
// Log success here. |
2017 |
appendMessages(tr("Client connected.")); |
appendMessages(tr("Client connected.")); |
2018 |
|
|
2019 |
|
// Hard-notify device configuration form, |
2020 |
|
// if visible, that we're ready... |
2021 |
|
if (m_pDeviceForm && m_pDeviceForm->isVisible()) |
2022 |
|
m_pDeviceForm->setClient(m_pClient); |
2023 |
|
|
2024 |
// Is any session pending to be loaded? |
// Is any session pending to be loaded? |
2025 |
if (!m_pOptions->sSessionFile.isEmpty()) { |
if (!m_pOptions->sSessionFile.isEmpty()) { |
2026 |
// Just load the prabably startup session... |
// Just load the prabably startup session... |
2041 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
2042 |
return; |
return; |
2043 |
|
|
2044 |
|
// Hard-notify device configuration form, |
2045 |
|
// if visible, that we're running out... |
2046 |
|
if (m_pDeviceForm && m_pDeviceForm->isVisible()) |
2047 |
|
m_pDeviceForm->setClient(NULL); |
2048 |
|
|
2049 |
// Log prepare here. |
// Log prepare here. |
2050 |
appendMessages(tr("Client disconnecting...")); |
appendMessages(tr("Client disconnecting...")); |
2051 |
|
|