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> |
295 |
} |
} |
296 |
|
|
297 |
|
|
298 |
// Window drag-n-drop event handlers. |
// Drag'n'drop file handler. |
299 |
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
bool qsamplerMainForm::decodeDragFiles ( const QMimeSource *pEvent, QStringList& files ) |
300 |
{ |
{ |
301 |
bool bAccept = false; |
bool bDecode = false; |
302 |
|
|
303 |
if (QTextDrag::canDecode(pDragEnterEvent)) { |
if (QTextDrag::canDecode(pEvent)) { |
304 |
QString sUrl; |
QString sText; |
305 |
if (QTextDrag::decode(pDragEnterEvent, sUrl) && m_pClient) |
bDecode = QTextDrag::decode(pEvent, sText); |
306 |
bAccept = QFileInfo(QUrl(sUrl).path()).exists(); |
if (bDecode) { |
307 |
|
files = QStringList::split('\n', sText); |
308 |
|
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) |
309 |
|
*iter = (*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null); |
310 |
|
} |
311 |
} |
} |
312 |
|
|
313 |
pDragEnterEvent->accept(bAccept); |
return bDecode; |
314 |
|
} |
315 |
|
|
316 |
|
|
317 |
|
// Window drag-n-drop event handlers. |
318 |
|
void qsamplerMainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
319 |
|
{ |
320 |
|
QStringList files; |
321 |
|
|
322 |
|
pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files)); |
323 |
} |
} |
324 |
|
|
325 |
|
|
326 |
void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent ) |
void qsamplerMainForm::dropEvent ( QDropEvent* pDropEvent ) |
327 |
{ |
{ |
328 |
if (QTextDrag::canDecode(pDropEvent)) { |
QStringList files; |
329 |
QString sUrl; |
|
330 |
if (QTextDrag::decode(pDropEvent, sUrl) && closeSession(true)) |
if (!decodeDragFiles(pDropEvent, files)) |
331 |
loadSessionFile(QUrl(sUrl).path()); |
return; |
332 |
} |
|
333 |
|
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) { |
334 |
|
const QString& sPath = QUrl(*iter).path(); |
335 |
|
if (qsamplerChannel::isInstrumentFile(sPath)) { |
336 |
|
// Try to create a new channel from instrument file... |
337 |
|
qsamplerChannel *pChannel = new qsamplerChannel(this); |
338 |
|
if (pChannel == NULL) |
339 |
|
return; |
340 |
|
// Start setting the instrument filename... |
341 |
|
pChannel->setInstrument(sPath, 0); |
342 |
|
// Before we show it up, may be we'll |
343 |
|
// better ask for some initial values? |
344 |
|
if (!pChannel->channelSetup(this)) { |
345 |
|
delete pChannel; |
346 |
|
return; |
347 |
|
} |
348 |
|
// Finally, give it to a new channel strip... |
349 |
|
if (!createChannelStrip(pChannel)) { |
350 |
|
delete pChannel; |
351 |
|
return; |
352 |
|
} |
353 |
|
// Make that an overall update. |
354 |
|
m_iDirtyCount++; |
355 |
|
m_iChangeCount++; |
356 |
|
stabilizeForm(); |
357 |
|
} // Otherwise, load an usual session file (LSCP script)... |
358 |
|
else if (closeSession(true)) |
359 |
|
loadSessionFile(sPath); |
360 |
|
// Make it look responsive...:) |
361 |
|
QApplication::eventLoop()->processEvents(QEventLoop::ExcludeUserInput); |
362 |
|
} |
363 |
} |
} |
364 |
|
|
365 |
|
|
582 |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
583 |
appendMessagesClient("lscp_client_query"); |
appendMessagesClient("lscp_client_query"); |
584 |
iErrors++; |
iErrors++; |
585 |
|
break; |
586 |
} |
} |
587 |
} |
} |
588 |
// Try to make it snappy :) |
// Try to make it snappy :) |
594 |
|
|
595 |
// Have we any errors? |
// Have we any errors? |
596 |
if (iErrors > 0) |
if (iErrors > 0) |
597 |
appendMessagesError(tr("Some setttings could not be loaded\nfrom \"%1\" session file.\n\nSorry.").arg(sFilename)); |
appendMessagesError(tr("Session could not be loaded\nfrom \"%1\".\n\nSorry.").arg(sFilename)); |
598 |
|
|
599 |
// Now we'll try to create the whole GUI session. |
// Now we'll try to create the whole GUI session. |
600 |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
1004 |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
int bOldMessagesLimit = m_pOptions->bMessagesLimit; |
1005 |
int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
int iOldMessagesLimitLines = m_pOptions->iMessagesLimitLines; |
1006 |
bool bOldCompletePath = m_pOptions->bCompletePath; |
bool bOldCompletePath = m_pOptions->bCompletePath; |
1007 |
|
bool bOldInstrumentNames = m_pOptions->bInstrumentNames; |
1008 |
int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
int iOldMaxRecentFiles = m_pOptions->iMaxRecentFiles; |
1009 |
// Load the current setup settings. |
// Load the current setup settings. |
1010 |
pOptionsForm->setup(m_pOptions); |
pOptionsForm->setup(m_pOptions); |
1023 |
(!bOldCompletePath && m_pOptions->bCompletePath) || |
(!bOldCompletePath && m_pOptions->bCompletePath) || |
1024 |
(iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles)) |
(iOldMaxRecentFiles != m_pOptions->iMaxRecentFiles)) |
1025 |
updateRecentFilesMenu(); |
updateRecentFilesMenu(); |
1026 |
|
if (( bOldInstrumentNames && !m_pOptions->bInstrumentNames) || |
1027 |
|
(!bOldInstrumentNames && m_pOptions->bInstrumentNames)) |
1028 |
|
updateInstrumentNames(); |
1029 |
if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) || |
if (( bOldDisplayEffect && !m_pOptions->bDisplayEffect) || |
1030 |
(!bOldDisplayEffect && m_pOptions->bDisplayEffect)) |
(!bOldDisplayEffect && m_pOptions->bDisplayEffect)) |
1031 |
updateDisplayEffect(); |
updateDisplayEffect(); |
1136 |
sText += tr("GIG (libgig) file support disabled."); |
sText += tr("GIG (libgig) file support disabled."); |
1137 |
sText += "</font></small><br />"; |
sText += "</font></small><br />"; |
1138 |
#endif |
#endif |
1139 |
|
#ifndef CONFIG_INSTRUMENT_NAME |
1140 |
|
sText += "<small><font color=\"red\">"; |
1141 |
|
sText += tr("LSCP (liblscp) instrument_name support disabled."); |
1142 |
|
sText += "</font></small><br />"; |
1143 |
|
#endif |
1144 |
sText += "<br />\n"; |
sText += "<br />\n"; |
1145 |
sText += tr("Using") + ": "; |
sText += tr("Using") + ": "; |
1146 |
sText += ::lscp_client_package(); |
sText += ::lscp_client_package(); |
1274 |
} |
} |
1275 |
|
|
1276 |
|
|
1277 |
|
// Force update of the channels instrument names mode. |
1278 |
|
void qsamplerMainForm::updateInstrumentNames (void) |
1279 |
|
{ |
1280 |
|
// Full channel list update... |
1281 |
|
QWidgetList wlist = m_pWorkspace->windowList(); |
1282 |
|
if (wlist.isEmpty()) |
1283 |
|
return; |
1284 |
|
|
1285 |
|
m_pWorkspace->setUpdatesEnabled(false); |
1286 |
|
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
1287 |
|
qsamplerChannelStrip *pChannelStrip = (qsamplerChannelStrip *) wlist.at(iChannel); |
1288 |
|
if (pChannelStrip) |
1289 |
|
pChannelStrip->updateInstrumentName(true); |
1290 |
|
} |
1291 |
|
m_pWorkspace->setUpdatesEnabled(true); |
1292 |
|
} |
1293 |
|
|
1294 |
|
|
1295 |
// Force update of the channels display font. |
// Force update of the channels display font. |
1296 |
void qsamplerMainForm::updateDisplayFont (void) |
void qsamplerMainForm::updateDisplayFont (void) |
1297 |
{ |
{ |