108 |
m_pMessages = NULL; |
m_pMessages = NULL; |
109 |
|
|
110 |
// We'll start clean. |
// We'll start clean. |
111 |
m_iUntitled = 0; |
m_iUntitled = 0; |
112 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
|
m_iChangeCount = 0; |
|
113 |
|
|
114 |
m_pServer = NULL; |
m_pServer = NULL; |
115 |
m_pClient = NULL; |
m_pClient = NULL; |
316 |
// Window drag-n-drop event handlers. |
// Window drag-n-drop event handlers. |
317 |
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
318 |
{ |
{ |
319 |
QStringList files; |
QStringList files; |
320 |
|
pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files)); |
|
pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files)); |
|
321 |
} |
} |
322 |
|
|
323 |
|
|
324 |
void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent ) |
void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent ) |
325 |
{ |
{ |
326 |
QStringList files; |
QStringList files; |
327 |
if (decodeDragFiles(pDropEvent, files)) { |
|
328 |
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) { |
if (!decodeDragFiles(pDropEvent, files)) |
329 |
const QString& sPath = QUrl(*iter).path(); |
return; |
330 |
if (qsamplerChannel::isInstrumentFile(sPath)) { |
|
331 |
// Try to create a new channel from instrument file... |
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) { |
332 |
qsamplerChannel *pChannel = new qsamplerChannel(this); |
const QString& sPath = QUrl(*iter).path(); |
333 |
if (pChannel == NULL) |
if (qsamplerChannel::isInstrumentFile(sPath)) { |
334 |
return; |
// Try to create a new channel from instrument file... |
335 |
// Start setting the instrument filename... |
qsamplerChannel *pChannel = new qsamplerChannel(this); |
336 |
pChannel->setInstrument(sPath, 0); |
if (pChannel == NULL) |
337 |
// Before we show it up, may be we'll |
return; |
338 |
// better ask for some initial values? |
// Start setting the instrument filename... |
339 |
if (!pChannel->channelSetup(this)) { |
pChannel->setInstrument(sPath, 0); |
340 |
delete pChannel; |
// Before we show it up, may be we'll |
341 |
return; |
// better ask for some initial values? |
342 |
} |
if (!pChannel->channelSetup(this)) { |
343 |
// Make that an overall update. |
delete pChannel; |
344 |
m_iDirtyCount++; |
return; |
345 |
m_iChangeCount++; |
} |
346 |
stabilizeForm(); |
// Finally, give it to a new channel strip... |
347 |
} // Otherwise, load an usual session file (LSCP script)... |
if (!createChannelStrip(pChannel)) { |
348 |
else if (closeSession(true)) |
delete pChannel; |
349 |
loadSessionFile(sPath); |
return; |
350 |
} |
} |
351 |
} |
// Make that an overall update. |
352 |
|
m_iDirtyCount++; |
353 |
|
stabilizeForm(); |
354 |
|
} // Otherwise, load an usual session file (LSCP script)... |
355 |
|
else if (closeSession(true)) |
356 |
|
loadSessionFile(sPath); |
357 |
|
// Make it look responsive...:) |
358 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
359 |
|
} |
360 |
} |
} |
361 |
|
|
362 |
|
|
421 |
if (!closeSession(true)) |
if (!closeSession(true)) |
422 |
return false; |
return false; |
423 |
|
|
424 |
|
// Give us what the server has, right now... |
425 |
|
updateSession(); |
426 |
|
|
427 |
// Ok increment untitled count. |
// Ok increment untitled count. |
428 |
m_iUntitled++; |
m_iUntitled++; |
429 |
|
|
596 |
if (iErrors > 0) |
if (iErrors > 0) |
597 |
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)); |
598 |
|
|
599 |
// Now we'll try to create the whole GUI session. |
// Now we'll try to create (update) the whole GUI session. |
600 |
int *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); |
|
|
} |
|
601 |
|
|
602 |
// Save as default session directory. |
// Save as default session directory. |
603 |
if (m_pOptions) |
if (m_pOptions) |
610 |
appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename))); |
appendMessages(tr("Open session: \"%1\".").arg(sessionName(m_sFilename))); |
611 |
|
|
612 |
// Make that an overall update. |
// Make that an overall update. |
|
m_iChangeCount++; |
|
613 |
stabilizeForm(); |
stabilizeForm(); |
614 |
return true; |
return true; |
615 |
} |
} |
761 |
|
|
762 |
// Log this. |
// Log this. |
763 |
appendMessages(tr("Sampler reset.")); |
appendMessages(tr("Sampler reset.")); |
764 |
|
|
765 |
|
// Make it a new session... |
766 |
|
newSession(); |
767 |
} |
} |
768 |
|
|
769 |
|
|
834 |
|
|
835 |
// Make that an overall update. |
// Make that an overall update. |
836 |
m_iDirtyCount++; |
m_iDirtyCount++; |
|
m_iChangeCount++; |
|
837 |
stabilizeForm(); |
stabilizeForm(); |
838 |
} |
} |
839 |
|
|
905 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
906 |
return; |
return; |
907 |
|
|
908 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
// Just invoque the channel strip procedure. |
909 |
if (pChannel == NULL) |
pChannelStrip->channelReset(); |
|
return; |
|
|
|
|
|
// Reset the existing sampler channel. |
|
|
pChannel->resetChannel(); |
|
|
|
|
|
// And force a deferred update. |
|
|
m_iChangeCount++; |
|
910 |
} |
} |
911 |
|
|
912 |
|
|
1201 |
|
|
1202 |
|
|
1203 |
// Channel change receiver slot. |
// Channel change receiver slot. |
1204 |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip * ) |
void qsamplerMainForm::channelStripChanged( qsamplerChannelStrip *pChannelStrip ) |
1205 |
{ |
{ |
1206 |
// Flag that we're update those channel strips. |
// Add this strip to the changed list... |
1207 |
m_iChangeCount++; |
if (m_changedStrips.containsRef(pChannelStrip) == 0) |
1208 |
|
m_changedStrips.append(pChannelStrip); |
1209 |
|
|
1210 |
// Just mark the dirty form. |
// Just mark the dirty form. |
1211 |
m_iDirtyCount++; |
m_iDirtyCount++; |
1212 |
// and update the form status... |
// and update the form status... |
1214 |
} |
} |
1215 |
|
|
1216 |
|
|
1217 |
|
// Grab and restore current sampler channels session. |
1218 |
|
void qsamplerMainForm::updateSession (void) |
1219 |
|
{ |
1220 |
|
// Retrieve the current channel list. |
1221 |
|
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
1222 |
|
if (piChannelIDs == NULL) { |
1223 |
|
if (::lscp_client_get_errno(m_pClient)) { |
1224 |
|
appendMessagesClient("lscp_list_channels"); |
1225 |
|
appendMessagesError(tr("Could not get current list of channels.\n\nSorry.")); |
1226 |
|
} |
1227 |
|
return; |
1228 |
|
} |
1229 |
|
|
1230 |
|
// Try to (re)create each channel. |
1231 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1232 |
|
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
1233 |
|
// Check if theres already a channel strip for this one... |
1234 |
|
if (!channelStrip(piChannelIDs[iChannel])) |
1235 |
|
createChannelStrip(new qsamplerChannel(this, piChannelIDs[iChannel])); |
1236 |
|
// Make it visibly responsive... |
1237 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
1238 |
|
} |
1239 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1240 |
|
} |
1241 |
|
|
1242 |
|
|
1243 |
// Update the recent files list and menu. |
// Update the recent files list and menu. |
1244 |
void qsamplerMainForm::updateRecentFiles ( const QString& sFilename ) |
void qsamplerMainForm::updateRecentFiles ( const QString& sFilename ) |
1245 |
{ |
{ |
1479 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1480 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1481 |
pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1482 |
// y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
if (pChannelStrip) { |
1483 |
y += pChannelStrip->parentWidget()->frameGeometry().height(); |
// y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
1484 |
|
y += pChannelStrip->parentWidget()->frameGeometry().height(); |
1485 |
|
} |
1486 |
} |
} |
1487 |
} |
} |
1488 |
|
|
1516 |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
1517 |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
1518 |
} |
} |
1519 |
|
|
1520 |
|
// This is pretty new, so we'll watch for it closely. |
1521 |
|
channelStripChanged(pChannelStrip); |
1522 |
|
|
1523 |
// Return our successful reference... |
// Return our successful reference... |
1524 |
return pChannelStrip; |
return pChannelStrip; |
1525 |
} |
} |
1537 |
{ |
{ |
1538 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1539 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
1540 |
return 0; |
return NULL; |
1541 |
|
|
1542 |
return (qsamplerChannelStrip *) wlist.at(iChannel); |
return (qsamplerChannelStrip *) wlist.at(iChannel); |
1543 |
} |
} |
1544 |
|
|
1545 |
|
|
1546 |
|
// Retrieve a channel strip by sampler channel id. |
1547 |
|
qsamplerChannelStrip *qsamplerMainForm::channelStrip ( int iChannelID ) |
1548 |
|
{ |
1549 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1550 |
|
if (wlist.isEmpty()) |
1551 |
|
return NULL; |
1552 |
|
|
1553 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1554 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1555 |
|
if (pChannelStrip) { |
1556 |
|
qsamplerChannel *pChannel = pChannelStrip->channel(); |
1557 |
|
if (pChannel && pChannel->channelID() == iChannelID) |
1558 |
|
return pChannelStrip; |
1559 |
|
} |
1560 |
|
} |
1561 |
|
|
1562 |
|
// Not found. |
1563 |
|
return NULL; |
1564 |
|
} |
1565 |
|
|
1566 |
|
|
1567 |
// Construct the windows menu. |
// Construct the windows menu. |
1568 |
void qsamplerMainForm::channelsMenuAboutToShow (void) |
void qsamplerMainForm::channelsMenuAboutToShow (void) |
1569 |
{ |
{ |
1632 |
} |
} |
1633 |
|
|
1634 |
// Refresh each channel usage, on each period... |
// Refresh each channel usage, on each period... |
1635 |
if (m_pClient && (m_iChangeCount > 0 || m_pOptions->bAutoRefresh)) { |
if (m_pClient && (m_changedStrips.count() > 0 || m_pOptions->bAutoRefresh)) { |
1636 |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
m_iTimerSlot += QSAMPLER_TIMER_MSECS; |
1637 |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled()) { |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime && m_pWorkspace->isUpdatesEnabled()) { |
1638 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
1639 |
m_iChangeCount = 0; |
// Update the channel information for each pending strip... |
1640 |
|
for (qsamplerChannelStrip *pChannelStrip = m_changedStrips.first(); |
1641 |
|
pChannelStrip; |
1642 |
|
pChannelStrip = m_changedStrips.next()) { |
1643 |
|
// If successfull, remove from pending list... |
1644 |
|
if (pChannelStrip->updateChannelInfo()) |
1645 |
|
m_changedStrips.remove(pChannelStrip); |
1646 |
|
} |
1647 |
|
// Update the channel stream usage for each strip... |
1648 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
1649 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1650 |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1651 |
if (pChannelStrip && pChannelStrip->isVisible()) { |
if (pChannelStrip && pChannelStrip->isVisible()) |
1652 |
// If we can't make it clean, try next time. |
pChannelStrip->updateChannelUsage(); |
|
if (!pChannelStrip->updateChannelUsage()) |
|
|
m_iChangeCount++; |
|
|
} |
|
1653 |
} |
} |
1654 |
} |
} |
1655 |
} |
} |