22 |
|
|
23 |
#include "qsamplerMainForm.h" |
#include "qsamplerMainForm.h" |
24 |
|
|
|
#include <qapplication.h> |
|
|
#include <qeventloop.h> |
|
|
#include <qworkspace.h> |
|
|
#include <qprocess.h> |
|
|
#include <qmessagebox.h> |
|
|
//#include <qdragobject.h> |
|
|
#include <qregexp.h> |
|
|
#include <qfiledialog.h> |
|
|
#include <qfileinfo.h> |
|
|
#include <qfile.h> |
|
|
#include <qtextstream.h> |
|
|
#include <qstatusbar.h> |
|
|
#include <qslider.h> |
|
|
#include <qspinbox.h> |
|
|
#include <qlabel.h> |
|
|
#include <qtimer.h> |
|
|
#include <qtooltip.h> |
|
|
|
|
25 |
#include "qsamplerAbout.h" |
#include "qsamplerAbout.h" |
26 |
#include "qsamplerOptions.h" |
#include "qsamplerOptions.h" |
27 |
#include "qsamplerChannel.h" |
#include "qsamplerChannel.h" |
34 |
#include "qsamplerDeviceForm.h" |
#include "qsamplerDeviceForm.h" |
35 |
#include "qsamplerOptionsForm.h" |
#include "qsamplerOptionsForm.h" |
36 |
|
|
37 |
|
#include <QApplication> |
38 |
|
#include <QWorkspace> |
39 |
|
#include <QProcess> |
40 |
|
#include <QMessageBox> |
41 |
|
|
42 |
|
#include <QRegExp> |
43 |
|
#include <QTextStream> |
44 |
|
#include <QFileDialog> |
45 |
|
#include <QFileInfo> |
46 |
|
#include <QFile> |
47 |
|
#include <QUrl> |
48 |
|
|
49 |
|
#include <QDragEnterEvent> |
50 |
|
|
51 |
|
#include <QStatusBar> |
52 |
|
#include <QSpinBox> |
53 |
|
#include <QSlider> |
54 |
|
#include <QLabel> |
55 |
|
#include <QTimer> |
56 |
|
#include <QDateTime> |
57 |
|
|
58 |
|
|
59 |
#ifdef HAVE_SIGNAL_H |
#ifdef HAVE_SIGNAL_H |
60 |
#include <signal.h> |
#include <signal.h> |
61 |
#endif |
#endif |
107 |
: QEvent(QSAMPLER_CUSTOM_EVENT) |
: QEvent(QSAMPLER_CUSTOM_EVENT) |
108 |
{ |
{ |
109 |
m_event = event; |
m_event = event; |
110 |
m_data.setLatin1(pchData, cchData); |
m_data = QString::fromUtf8(pchData, cchData); |
111 |
} |
} |
112 |
|
|
113 |
// Accessors. |
// Accessors. |
169 |
// Volume slider... |
// Volume slider... |
170 |
ui.channelsToolbar->addSeparator(); |
ui.channelsToolbar->addSeparator(); |
171 |
m_pVolumeSlider = new QSlider(Qt::Horizontal, ui.channelsToolbar); |
m_pVolumeSlider = new QSlider(Qt::Horizontal, ui.channelsToolbar); |
172 |
m_pVolumeSlider->setTickmarks(QSlider::Below); |
m_pVolumeSlider->setTickPosition(QSlider::TicksBelow); |
173 |
m_pVolumeSlider->setTickInterval(10); |
m_pVolumeSlider->setTickInterval(10); |
174 |
m_pVolumeSlider->setPageStep(10); |
m_pVolumeSlider->setPageStep(10); |
175 |
m_pVolumeSlider->setRange(0, 100); |
m_pVolumeSlider->setSingleStep(10); |
176 |
|
m_pVolumeSlider->setMinimum(0); |
177 |
|
m_pVolumeSlider->setMaximum(100); |
178 |
m_pVolumeSlider->setMaximumHeight(26); |
m_pVolumeSlider->setMaximumHeight(26); |
179 |
m_pVolumeSlider->setMinimumWidth(160); |
m_pVolumeSlider->setMinimumWidth(160); |
180 |
QToolTip::add(m_pVolumeSlider, sVolumeText); |
m_pVolumeSlider->setToolTip(sVolumeText); |
181 |
QObject::connect(m_pVolumeSlider, |
QObject::connect(m_pVolumeSlider, |
182 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
183 |
SLOT(volumeChanged(int))); |
SLOT(volumeChanged(int))); |
188 |
ui.channelsToolbar->addSeparator(); |
ui.channelsToolbar->addSeparator(); |
189 |
m_pVolumeSpinBox = new QSpinBox(ui.channelsToolbar); |
m_pVolumeSpinBox = new QSpinBox(ui.channelsToolbar); |
190 |
m_pVolumeSpinBox->setSuffix(" %"); |
m_pVolumeSpinBox->setSuffix(" %"); |
191 |
m_pVolumeSpinBox->setRange(0, 100); |
m_pVolumeSpinBox->setMinimum(0); |
192 |
QToolTip::add(m_pVolumeSpinBox, sVolumeText); |
m_pVolumeSpinBox->setMaximum(100); |
193 |
|
m_pVolumeSpinBox->setToolTip(sVolumeText); |
194 |
QObject::connect(m_pVolumeSpinBox, |
QObject::connect(m_pVolumeSpinBox, |
195 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
196 |
SLOT(volumeChanged(int))); |
SLOT(volumeChanged(int))); |
232 |
m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel; |
m_statusItem[QSAMPLER_STATUS_SESSION] = pLabel; |
233 |
statusBar()->addWidget(pLabel); |
statusBar()->addWidget(pLabel); |
234 |
|
|
|
// Create the recent files sub-menu. |
|
|
m_pRecentFilesMenu = new Q3PopupMenu(this); |
|
|
ui.fileMenu->insertSeparator(4); |
|
|
ui.fileMenu->insertItem(tr("Recent &Files"), m_pRecentFilesMenu, 0, 5); |
|
|
|
|
235 |
#if defined(WIN32) |
#if defined(WIN32) |
236 |
WSAStartup(MAKEWORD(1, 1), &_wsaData); |
WSAStartup(MAKEWORD(1, 1), &_wsaData); |
237 |
#endif |
#endif |
238 |
|
|
239 |
QObject::connect(ui.fileNewAction, |
QObject::connect(ui.fileNewAction, |
240 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
241 |
SLOT(fileNew())); |
SLOT(fileNew())); |
242 |
QObject::connect(ui.fileOpenAction, |
QObject::connect(ui.fileOpenAction, |
243 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
244 |
SLOT(fileOpen())); |
SLOT(fileOpen())); |
245 |
QObject::connect(ui.fileSaveAction, |
QObject::connect(ui.fileSaveAction, |
246 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
247 |
SLOT(fileSave())); |
SLOT(fileSave())); |
248 |
QObject::connect(ui.fileSaveAsAction, |
QObject::connect(ui.fileSaveAsAction, |
249 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
250 |
SLOT(fileSaveAs())); |
SLOT(fileSaveAs())); |
251 |
QObject::connect(ui.fileResetAction, |
QObject::connect(ui.fileResetAction, |
252 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
253 |
SLOT(fileReset())); |
SLOT(fileReset())); |
254 |
QObject::connect(ui.fileRestartAction, |
QObject::connect(ui.fileRestartAction, |
255 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
256 |
SLOT(fileRestart())); |
SLOT(fileRestart())); |
257 |
QObject::connect(ui.fileExitAction, |
QObject::connect(ui.fileExitAction, |
258 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
259 |
SLOT(fileExit())); |
SLOT(fileExit())); |
260 |
QObject::connect(ui.editAddChannelAction, |
QObject::connect(ui.editAddChannelAction, |
261 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
262 |
SLOT(editAddChannel())); |
SLOT(editAddChannel())); |
263 |
QObject::connect(ui.editRemoveChannelAction, |
QObject::connect(ui.editRemoveChannelAction, |
264 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
265 |
SLOT(editRemoveChannel())); |
SLOT(editRemoveChannel())); |
266 |
QObject::connect(ui.editSetupChannelAction, |
QObject::connect(ui.editSetupChannelAction, |
267 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
268 |
SLOT(editSetupChannel())); |
SLOT(editSetupChannel())); |
269 |
QObject::connect(ui.editEditChannelAction, |
QObject::connect(ui.editEditChannelAction, |
270 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
271 |
SLOT(editEditChannel())); |
SLOT(editEditChannel())); |
272 |
QObject::connect(ui.editResetChannelAction, |
QObject::connect(ui.editResetChannelAction, |
273 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
274 |
SLOT(editResetChannel())); |
SLOT(editResetChannel())); |
275 |
QObject::connect(ui.editResetAllChannelsAction, |
QObject::connect(ui.editResetAllChannelsAction, |
276 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
277 |
SLOT(editResetAllChannels())); |
SLOT(editResetAllChannels())); |
278 |
QObject::connect(ui.viewMenubarAction, |
QObject::connect(ui.viewMenubarAction, |
279 |
SIGNAL(toggled(bool)), |
SIGNAL(toggled(bool)), |
288 |
SIGNAL(toggled(bool)), |
SIGNAL(toggled(bool)), |
289 |
SLOT(viewMessages(bool))); |
SLOT(viewMessages(bool))); |
290 |
QObject::connect(ui.viewInstrumentsAction, |
QObject::connect(ui.viewInstrumentsAction, |
291 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
292 |
SLOT(viewInstruments())); |
SLOT(viewInstruments())); |
293 |
QObject::connect(ui.viewDevicesAction, |
QObject::connect(ui.viewDevicesAction, |
294 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
295 |
SLOT(viewDevices())); |
SLOT(viewDevices())); |
296 |
QObject::connect(ui.viewOptionsAction, |
QObject::connect(ui.viewOptionsAction, |
297 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
298 |
SLOT(viewOptions())); |
SLOT(viewOptions())); |
299 |
QObject::connect(ui.channelsArrangeAction, |
QObject::connect(ui.channelsArrangeAction, |
300 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
301 |
SLOT(channelsArrange())); |
SLOT(channelsArrange())); |
302 |
QObject::connect(ui.channelsAutoArrangeAction, |
QObject::connect(ui.channelsAutoArrangeAction, |
303 |
SIGNAL(toggled(bool)), |
SIGNAL(toggled(bool)), |
304 |
SLOT(channelsAutoArrange(bool))); |
SLOT(channelsAutoArrange(bool))); |
305 |
QObject::connect(ui.helpAboutAction, |
QObject::connect(ui.helpAboutAction, |
306 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
307 |
SLOT(helpAbout())); |
SLOT(helpAbout())); |
308 |
QObject::connect(ui.helpAboutQtAction, |
QObject::connect(ui.helpAboutQtAction, |
309 |
SIGNAL(activated()), |
SIGNAL(triggered()), |
310 |
SLOT(helpAboutQt())); |
SLOT(helpAboutQt())); |
311 |
|
|
312 |
|
QObject::connect(ui.fileMenu, |
313 |
|
SIGNAL(aboutToShow()), |
314 |
|
SLOT(updateRecentFilesMenu())); |
315 |
} |
} |
316 |
|
|
317 |
// Destructor. |
// Destructor. |
349 |
delete m_pVolumeSlider; |
delete m_pVolumeSlider; |
350 |
#endif |
#endif |
351 |
|
|
|
// Delete recentfiles menu. |
|
|
if (m_pRecentFilesMenu) |
|
|
delete m_pRecentFilesMenu; |
|
|
|
|
352 |
// Pseudo-singleton reference shut-down. |
// Pseudo-singleton reference shut-down. |
353 |
g_pMainForm = NULL; |
g_pMainForm = NULL; |
354 |
} |
} |
361 |
m_pOptions = pOptions; |
m_pOptions = pOptions; |
362 |
|
|
363 |
// What style do we create these forms? |
// What style do we create these forms? |
364 |
Qt::WFlags wflags = Qt::WStyle_Customize |
Qt::WindowFlags wflags = Qt::Window |
365 |
| Qt::WStyle_NormalBorder |
#if QT_VERSION >= 0x040200 |
366 |
| Qt::WStyle_Title |
| Qt::CustomizeWindowHint |
367 |
| Qt::WStyle_SysMenu |
#endif |
368 |
| Qt::WStyle_MinMax |
| Qt::WindowTitleHint |
369 |
| Qt::WType_TopLevel; |
| Qt::WindowSystemMenuHint |
370 |
if (m_pOptions->bKeepOnTop) |
| Qt::WindowMinMaxButtonsHint; |
371 |
wflags |= Qt::WStyle_Tool; |
if (m_pOptions->bKeepOnTop) |
372 |
|
wflags |= Qt::Tool; |
373 |
// Some child forms are to be created right now. |
// Some child forms are to be created right now. |
374 |
m_pMessages = new qsamplerMessages(this); |
m_pMessages = new qsamplerMessages(this); |
375 |
m_pDeviceForm = new DeviceForm(this, wflags); |
m_pDeviceForm = new DeviceForm(this, wflags); |
391 |
SLOT(stabilizeForm())); |
SLOT(stabilizeForm())); |
392 |
|
|
393 |
// Initial decorations toggle state. |
// Initial decorations toggle state. |
394 |
ui.viewMenubarAction->setOn(m_pOptions->bMenubar); |
ui.viewMenubarAction->setChecked(m_pOptions->bMenubar); |
395 |
ui.viewToolbarAction->setOn(m_pOptions->bToolbar); |
ui.viewToolbarAction->setChecked(m_pOptions->bToolbar); |
396 |
ui.viewStatusbarAction->setOn(m_pOptions->bStatusbar); |
ui.viewStatusbarAction->setChecked(m_pOptions->bStatusbar); |
397 |
ui.channelsAutoArrangeAction->setOn(m_pOptions->bAutoArrange); |
ui.channelsAutoArrangeAction->setChecked(m_pOptions->bAutoArrange); |
398 |
|
|
399 |
// Initial decorations visibility state. |
// Initial decorations visibility state. |
400 |
viewMenubar(m_pOptions->bMenubar); |
viewMenubar(m_pOptions->bMenubar); |
403 |
|
|
404 |
addDockWidget(Qt::BottomDockWidgetArea, m_pMessages); |
addDockWidget(Qt::BottomDockWidgetArea, m_pMessages); |
405 |
|
|
406 |
// Restore whole toolbar & dock windows states. |
// Restore whole dock windows state. |
407 |
QString sDockables = m_pOptions->settings().readEntry("/Layout/DockWindowsBase64" , QString::null); |
QByteArray aDockables = m_pOptions->settings().value( |
408 |
if (!sDockables.isEmpty()) { |
"/Layout/DockWindows").toByteArray(); |
409 |
restoreState(QByteArray::fromBase64(sDockables.toAscii())); |
if (!aDockables.isEmpty()) { |
410 |
} |
restoreState(aDockables); |
411 |
|
} |
412 |
|
|
413 |
// Try to restore old window positioning and initial visibility. |
// Try to restore old window positioning and initial visibility. |
414 |
m_pOptions->loadWidgetGeometry(this); |
m_pOptions->loadWidgetGeometry(this); |
415 |
m_pOptions->loadWidgetGeometry(m_pInstrumentListForm); |
m_pOptions->loadWidgetGeometry(m_pInstrumentListForm); |
421 |
stabilizeForm(); |
stabilizeForm(); |
422 |
|
|
423 |
// Make it ready :-) |
// Make it ready :-) |
424 |
statusBar()->message(tr("Ready"), 3000); |
statusBar()->showMessage(tr("Ready"), 3000); |
425 |
|
|
426 |
// We'll try to start immediately... |
// We'll try to start immediately... |
427 |
startSchedule(0); |
startSchedule(0); |
449 |
m_pOptions->bStatusbar = statusBar()->isVisible(); |
m_pOptions->bStatusbar = statusBar()->isVisible(); |
450 |
// Save the dock windows state. |
// Save the dock windows state. |
451 |
const QString sDockables = saveState().toBase64().data(); |
const QString sDockables = saveState().toBase64().data(); |
452 |
m_pOptions->settings().writeEntry("/Layout/DockWindowsBase64", sDockables); |
m_pOptions->settings().setValue("/Layout/DockWindows", saveState()); |
453 |
// And the children, and the main windows state,. |
// And the children, and the main windows state,. |
454 |
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
m_pOptions->saveWidgetGeometry(m_pDeviceForm); |
455 |
m_pOptions->saveWidgetGeometry(m_pInstrumentListForm); |
m_pOptions->saveWidgetGeometry(m_pInstrumentListForm); |
477 |
} |
} |
478 |
|
|
479 |
|
|
|
// Drag'n'drop file handler. |
|
|
bool MainForm::decodeDragFiles ( const QMimeSource *pEvent, QStringList& files ) |
|
|
{ |
|
|
bool bDecode = false; |
|
|
|
|
|
if (Q3TextDrag::canDecode(pEvent)) { |
|
|
QString sText; |
|
|
bDecode = Q3TextDrag::decode(pEvent, sText); |
|
|
if (bDecode) { |
|
|
files = QStringList::split('\n', sText); |
|
|
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) |
|
|
*iter = QUrl((*iter).stripWhiteSpace().replace(QRegExp("^file:"), QString::null)).path(); |
|
|
} |
|
|
} |
|
|
|
|
|
return bDecode; |
|
|
} |
|
|
|
|
|
|
|
480 |
// Window drag-n-drop event handlers. |
// Window drag-n-drop event handlers. |
481 |
void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
void MainForm::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) |
482 |
{ |
{ |
483 |
QStringList files; |
// Accept external drags only... |
484 |
pDragEnterEvent->accept(decodeDragFiles(pDragEnterEvent, files)); |
if (pDragEnterEvent->source() == NULL |
485 |
|
&& pDragEnterEvent->mimeData()->hasUrls()) { |
486 |
|
pDragEnterEvent->accept(); |
487 |
|
} else { |
488 |
|
pDragEnterEvent->ignore(); |
489 |
|
} |
490 |
} |
} |
491 |
|
|
492 |
|
|
493 |
void MainForm::dropEvent ( QDropEvent* pDropEvent ) |
void MainForm::dropEvent ( QDropEvent* pDropEvent ) |
494 |
{ |
{ |
495 |
QStringList files; |
// Accept externally originated drops only... |
496 |
|
if (pDropEvent->source()) |
497 |
if (!decodeDragFiles(pDropEvent, files)) |
return; |
|
return; |
|
498 |
|
|
499 |
for (QStringList::Iterator iter = files.begin(); iter != files.end(); iter++) { |
const QMimeData *pMimeData = pDropEvent->mimeData(); |
500 |
const QString& sPath = *iter; |
if (pMimeData->hasUrls()) { |
501 |
if (qsamplerChannel::isInstrumentFile(sPath)) { |
QListIterator<QUrl> iter(pMimeData->urls()); |
502 |
// Try to create a new channel from instrument file... |
while (iter.hasNext()) { |
503 |
qsamplerChannel *pChannel = new qsamplerChannel(); |
const QString& sPath = iter.next().toLocalFile(); |
504 |
if (pChannel == NULL) |
if (qsamplerChannel::isInstrumentFile(sPath)) { |
505 |
return; |
// Try to create a new channel from instrument file... |
506 |
// Start setting the instrument filename... |
qsamplerChannel *pChannel = new qsamplerChannel(); |
507 |
pChannel->setInstrument(sPath, 0); |
if (pChannel == NULL) |
508 |
// Before we show it up, may be we'll |
return; |
509 |
// better ask for some initial values? |
// Start setting the instrument filename... |
510 |
if (!pChannel->channelSetup(this)) { |
pChannel->setInstrument(sPath, 0); |
511 |
delete pChannel; |
// Before we show it up, may be we'll |
512 |
return; |
// better ask for some initial values? |
513 |
} |
if (!pChannel->channelSetup(this)) { |
514 |
// Finally, give it to a new channel strip... |
delete pChannel; |
515 |
if (!createChannelStrip(pChannel)) { |
return; |
516 |
delete pChannel; |
} |
517 |
return; |
// Finally, give it to a new channel strip... |
518 |
|
if (!createChannelStrip(pChannel)) { |
519 |
|
delete pChannel; |
520 |
|
return; |
521 |
|
} |
522 |
|
// Make that an overall update. |
523 |
|
m_iDirtyCount++; |
524 |
|
stabilizeForm(); |
525 |
|
} // Otherwise, load an usual session file (LSCP script)... |
526 |
|
else if (closeSession(true)) { |
527 |
|
loadSessionFile(sPath); |
528 |
|
break; |
529 |
} |
} |
|
// Make that an overall update. |
|
|
m_iDirtyCount++; |
|
|
stabilizeForm(); |
|
|
} // Otherwise, load an usual session file (LSCP script)... |
|
|
else if (closeSession(true)) { |
|
|
loadSessionFile(sPath); |
|
|
break; |
|
530 |
} |
} |
531 |
// Make it look responsive...:) |
// Make it look responsive...:) |
532 |
QApplication::processEvents(QEventLoop::ExcludeUserInput); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
533 |
} |
} |
534 |
} |
} |
535 |
|
|
536 |
|
|
537 |
// Custome event handler. |
// Custome event handler. |
538 |
void MainForm::customEvent(QEvent* pCustomEvent) |
void MainForm::customEvent(QEvent* pCustomEvent) |
539 |
{ |
{ |
632 |
return false; |
return false; |
633 |
|
|
634 |
// Ask for the filename to open... |
// Ask for the filename to open... |
635 |
QString sFilename = QFileDialog::getOpenFileName( |
QString sFilename = QFileDialog::getOpenFileName(this, |
636 |
m_pOptions->sSessionDir, // Start here. |
QSAMPLER_TITLE ": " + tr("Open Session"), // Caption. |
637 |
tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files) |
m_pOptions->sSessionDir, // Start here. |
638 |
this, 0, // Parent and name (none) |
tr("LSCP Session files") + " (*.lscp)" // Filter (LSCP files) |
639 |
QSAMPLER_TITLE ": " + tr("Open Session") // Caption. |
); |
|
); |
|
640 |
|
|
641 |
// Have we cancelled? |
// Have we cancelled? |
642 |
if (sFilename.isEmpty()) |
if (sFilename.isEmpty()) |
665 |
if (sFilename.isEmpty()) |
if (sFilename.isEmpty()) |
666 |
sFilename = m_pOptions->sSessionDir; |
sFilename = m_pOptions->sSessionDir; |
667 |
// Prompt the guy... |
// Prompt the guy... |
668 |
sFilename = QFileDialog::getSaveFileName( |
sFilename = QFileDialog::getSaveFileName(this, |
669 |
sFilename, // Start here. |
QSAMPLER_TITLE ": " + tr("Save Session"), // Caption. |
670 |
tr("LSCP Session files") + " (*.lscp)", // Filter (LSCP files) |
sFilename, // Start here. |
671 |
this, 0, // Parent and name (none) |
tr("LSCP Session files") + " (*.lscp)" // Filter (LSCP files) |
672 |
QSAMPLER_TITLE ": " + tr("Save Session") // Caption. |
); |
|
); |
|
673 |
// Have we cancelled it? |
// Have we cancelled it? |
674 |
if (sFilename.isEmpty()) |
if (sFilename.isEmpty()) |
675 |
return false; |
return false; |
676 |
// Enforce .lscp extension... |
// Enforce .lscp extension... |
677 |
if (QFileInfo(sFilename).extension().isEmpty()) |
if (QFileInfo(sFilename).suffix().isEmpty()) |
678 |
sFilename += ".lscp"; |
sFilename += ".lscp"; |
679 |
// Check if already exists... |
// Check if already exists... |
680 |
if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) { |
if (sFilename != m_sFilename && QFileInfo(sFilename).exists()) { |
750 |
|
|
751 |
// Open and read from real file. |
// Open and read from real file. |
752 |
QFile file(sFilename); |
QFile file(sFilename); |
753 |
if (!file.open(IO_ReadOnly)) { |
if (!file.open(QIODevice::ReadOnly)) { |
754 |
appendMessagesError(tr("Could not open \"%1\" session file.\n\nSorry.").arg(sFilename)); |
appendMessagesError(tr("Could not open \"%1\" session file.\n\nSorry.").arg(sFilename)); |
755 |
return false; |
return false; |
756 |
} |
} |
764 |
QTextStream ts(&file); |
QTextStream ts(&file); |
765 |
while (!ts.atEnd()) { |
while (!ts.atEnd()) { |
766 |
// Read the line. |
// Read the line. |
767 |
QString sCommand = ts.readLine().stripWhiteSpace(); |
QString sCommand = ts.readLine().trimmed(); |
768 |
iLine++; |
iLine++; |
769 |
// If not empty, nor a comment, call the server... |
// If not empty, nor a comment, call the server... |
770 |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
if (!sCommand.isEmpty() && sCommand[0] != '#') { |
771 |
// Remember that, no matter what, |
// Remember that, no matter what, |
772 |
// all LSCP commands are CR/LF terminated. |
// all LSCP commands are CR/LF terminated. |
773 |
sCommand += "\r\n"; |
sCommand += "\r\n"; |
774 |
if (::lscp_client_query(m_pClient, sCommand.latin1()) != LSCP_OK) { |
if (::lscp_client_query(m_pClient, sCommand.toUtf8().constData()) |
775 |
|
!= LSCP_OK) { |
776 |
appendMessagesColor(QString("%1(%2): %3") |
appendMessagesColor(QString("%1(%2): %3") |
777 |
.arg(QFileInfo(sFilename).fileName()).arg(iLine) |
.arg(QFileInfo(sFilename).fileName()).arg(iLine) |
778 |
.arg(sCommand.simplifyWhiteSpace()), "#996633"); |
.arg(sCommand.simplified()), "#996633"); |
779 |
appendMessagesClient("lscp_client_query"); |
appendMessagesClient("lscp_client_query"); |
780 |
iErrors++; |
iErrors++; |
781 |
} |
} |
782 |
} |
} |
783 |
// Try to make it snappy :) |
// Try to make it snappy :) |
784 |
QApplication::processEvents(QEventLoop::ExcludeUserInput); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
785 |
} |
} |
786 |
|
|
787 |
// Ok. we've read it. |
// Ok. we've read it. |
799 |
|
|
800 |
// Save as default session directory. |
// Save as default session directory. |
801 |
if (m_pOptions) |
if (m_pOptions) |
802 |
m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true); |
m_pOptions->sSessionDir = QFileInfo(sFilename).dir().absolutePath(); |
803 |
// We're not dirty anymore, if loaded without errors, |
// We're not dirty anymore, if loaded without errors, |
804 |
m_iDirtyCount = iErrors; |
m_iDirtyCount = iErrors; |
805 |
// Stabilize form... |
// Stabilize form... |
827 |
|
|
828 |
// Open and write into real file. |
// Open and write into real file. |
829 |
QFile file(sFilename); |
QFile file(sFilename); |
830 |
if (!file.open(IO_WriteOnly | IO_Truncate)) { |
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) { |
831 |
appendMessagesError(tr("Could not open \"%1\" session file.\n\nSorry.").arg(sFilename)); |
appendMessagesError(tr("Could not open \"%1\" session file.\n\nSorry.").arg(sFilename)); |
832 |
return false; |
return false; |
833 |
} |
} |
872 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
873 |
deviceParam != device.params().end(); |
deviceParam != device.params().end(); |
874 |
++deviceParam) { |
++deviceParam) { |
875 |
const qsamplerDeviceParam& param = deviceParam.data(); |
const qsamplerDeviceParam& param = deviceParam.value(); |
876 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
877 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
878 |
} |
} |
879 |
ts << endl; |
ts << endl; |
880 |
// Audio channel parameters... |
// Audio channel parameters... |
881 |
int iPort = 0; |
int iPort = 0; |
882 |
for (qsamplerDevicePort *pPort = device.ports().first(); |
QListIterator<qsamplerDevicePort *> iter(device.ports()); |
883 |
pPort; |
while (iter.hasNext()) { |
884 |
pPort = device.ports().next(), ++iPort) { |
qsamplerDevicePort *pPort = iter.next(); |
885 |
qsamplerDeviceParamMap::ConstIterator portParam; |
qsamplerDeviceParamMap::ConstIterator portParam; |
886 |
for (portParam = pPort->params().begin(); |
for (portParam = pPort->params().begin(); |
887 |
portParam != pPort->params().end(); |
portParam != pPort->params().end(); |
888 |
++portParam) { |
++portParam) { |
889 |
const qsamplerDeviceParam& param = portParam.data(); |
const qsamplerDeviceParam& param = portParam.value(); |
890 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
891 |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
ts << "SET AUDIO_OUTPUT_CHANNEL_PARAMETER " << iDevice |
892 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
893 |
<< "='" << param.value << "'" << endl; |
<< "='" << param.value << "'" << endl; |
894 |
} |
} |
895 |
|
iPort++; |
896 |
} |
} |
897 |
// Audio device index/id mapping. |
// Audio device index/id mapping. |
898 |
audioDeviceMap[device.deviceID()] = iDevice; |
audioDeviceMap[device.deviceID()] = iDevice; |
899 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
900 |
QApplication::processEvents(QEventLoop::ExcludeUserInput); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
901 |
} |
} |
902 |
|
|
903 |
// MIDI device mapping. |
// MIDI device mapping. |
914 |
for (deviceParam = device.params().begin(); |
for (deviceParam = device.params().begin(); |
915 |
deviceParam != device.params().end(); |
deviceParam != device.params().end(); |
916 |
++deviceParam) { |
++deviceParam) { |
917 |
const qsamplerDeviceParam& param = deviceParam.data(); |
const qsamplerDeviceParam& param = deviceParam.value(); |
918 |
if (param.value.isEmpty()) ts << "# "; |
if (param.value.isEmpty()) ts << "# "; |
919 |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
ts << " " << deviceParam.key() << "='" << param.value << "'"; |
920 |
} |
} |
921 |
ts << endl; |
ts << endl; |
922 |
// MIDI port parameters... |
// MIDI port parameters... |
923 |
int iPort = 0; |
int iPort = 0; |
924 |
for (qsamplerDevicePort *pPort = device.ports().first(); |
QListIterator<qsamplerDevicePort *> iter(device.ports()); |
925 |
pPort; |
while (iter.hasNext()) { |
926 |
pPort = device.ports().next(), ++iPort) { |
qsamplerDevicePort *pPort = iter.next(); |
927 |
qsamplerDeviceParamMap::ConstIterator portParam; |
qsamplerDeviceParamMap::ConstIterator portParam; |
928 |
for (portParam = pPort->params().begin(); |
for (portParam = pPort->params().begin(); |
929 |
portParam != pPort->params().end(); |
portParam != pPort->params().end(); |
930 |
++portParam) { |
++portParam) { |
931 |
const qsamplerDeviceParam& param = portParam.data(); |
const qsamplerDeviceParam& param = portParam.value(); |
932 |
if (param.fix || param.value.isEmpty()) ts << "# "; |
if (param.fix || param.value.isEmpty()) ts << "# "; |
933 |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
ts << "SET MIDI_INPUT_PORT_PARAMETER " << iDevice |
934 |
<< " " << iPort << " " << portParam.key() |
<< " " << iPort << " " << portParam.key() |
935 |
<< "='" << param.value << "'" << endl; |
<< "='" << param.value << "'" << endl; |
936 |
} |
} |
937 |
|
iPort++; |
938 |
} |
} |
939 |
// MIDI device index/id mapping. |
// MIDI device index/id mapping. |
940 |
midiDeviceMap[device.deviceID()] = iDevice; |
midiDeviceMap[device.deviceID()] = iDevice; |
941 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
942 |
QApplication::processEvents(QEventLoop::ExcludeUserInput); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
943 |
} |
} |
944 |
ts << endl; |
ts << endl; |
945 |
|
|
996 |
iErrors++; |
iErrors++; |
997 |
} |
} |
998 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
999 |
QApplication::processEvents(QEventLoop::ExcludeUserInput); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
1000 |
} |
} |
1001 |
ts << endl; |
ts << endl; |
1002 |
// Check for errors... |
// Check for errors... |
1056 |
++audioRoute) { |
++audioRoute) { |
1057 |
ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannel |
ts << "SET CHANNEL AUDIO_OUTPUT_CHANNEL " << iChannel |
1058 |
<< " " << audioRoute.key() |
<< " " << audioRoute.key() |
1059 |
<< " " << audioRoute.data() << endl; |
<< " " << audioRoute.value() << endl; |
1060 |
} |
} |
1061 |
ts << "SET CHANNEL VOLUME " << iChannel |
ts << "SET CHANNEL VOLUME " << iChannel |
1062 |
<< " " << pChannel->volume() << endl; |
<< " " << pChannel->volume() << endl; |
1110 |
} |
} |
1111 |
} |
} |
1112 |
// Try to keep it snappy :) |
// Try to keep it snappy :) |
1113 |
QApplication::processEvents(QEventLoop::ExcludeUserInput); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
1114 |
} |
} |
1115 |
|
|
1116 |
#ifdef CONFIG_VOLUME |
#ifdef CONFIG_VOLUME |
1131 |
|
|
1132 |
// Save as default session directory. |
// Save as default session directory. |
1133 |
if (m_pOptions) |
if (m_pOptions) |
1134 |
m_pOptions->sSessionDir = QFileInfo(sFilename).dirPath(true); |
m_pOptions->sSessionDir = QFileInfo(sFilename).dir().absolutePath(); |
1135 |
// We're not dirty anymore. |
// We're not dirty anymore. |
1136 |
m_iDirtyCount = 0; |
m_iDirtyCount = 0; |
1137 |
// Stabilize form... |
// Stabilize form... |
1173 |
|
|
1174 |
|
|
1175 |
// Open a recent file session. |
// Open a recent file session. |
1176 |
void MainForm::fileOpenRecent ( int iIndex ) |
void MainForm::fileOpenRecent (void) |
1177 |
{ |
{ |
1178 |
// Check if we can safely close the current session... |
// Retrive filename index from action data... |
1179 |
if (m_pOptions && closeSession(true)) { |
QAction *pAction = qobject_cast<QAction *> (sender()); |
1180 |
QString sFilename = m_pOptions->recentFiles[iIndex]; |
if (pAction && m_pOptions) { |
1181 |
loadSessionFile(sFilename); |
int iIndex = pAction->data().toInt(); |
1182 |
} |
if (iIndex >= 0 && iIndex < m_pOptions->recentFiles.count()) { |
1183 |
|
QString sFilename = m_pOptions->recentFiles[iIndex]; |
1184 |
|
// Check if we can safely close the current session... |
1185 |
|
if (!sFilename.isEmpty() && closeSession(true)) |
1186 |
|
loadSessionFile(sFilename); |
1187 |
|
} |
1188 |
|
} |
1189 |
} |
} |
1190 |
|
|
1191 |
|
|
1335 |
tr("About to remove channel:\n\n" |
tr("About to remove channel:\n\n" |
1336 |
"%1\n\n" |
"%1\n\n" |
1337 |
"Are you sure?") |
"Are you sure?") |
1338 |
.arg(pChannelStrip->caption()), |
.arg(pChannelStrip->windowTitle()), |
1339 |
tr("OK"), tr("Cancel")) > 0) |
tr("OK"), tr("Cancel")) > 0) |
1340 |
return; |
return; |
1341 |
} |
} |
1482 |
} else { |
} else { |
1483 |
m_pInstrumentListForm->show(); |
m_pInstrumentListForm->show(); |
1484 |
m_pInstrumentListForm->raise(); |
m_pInstrumentListForm->raise(); |
1485 |
m_pInstrumentListForm->setActiveWindow(); |
m_pInstrumentListForm->activateWindow(); |
1486 |
} |
} |
1487 |
} |
} |
1488 |
} |
} |
1501 |
} else { |
} else { |
1502 |
m_pDeviceForm->show(); |
m_pDeviceForm->show(); |
1503 |
m_pDeviceForm->raise(); |
m_pDeviceForm->raise(); |
1504 |
m_pDeviceForm->setActiveWindow(); |
m_pDeviceForm->activateWindow(); |
1505 |
} |
} |
1506 |
} |
} |
1507 |
} |
} |
1743 |
QString sSessionName = sessionName(m_sFilename); |
QString sSessionName = sessionName(m_sFilename); |
1744 |
if (m_iDirtyCount > 0) |
if (m_iDirtyCount > 0) |
1745 |
sSessionName += " *"; |
sSessionName += " *"; |
1746 |
setCaption(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName)); |
setWindowTitle(tr(QSAMPLER_TITLE " - [%1]").arg(sSessionName)); |
1747 |
|
|
1748 |
// Update the main menu state... |
// Update the main menu state... |
1749 |
ChannelStrip* pChannelStrip = activeChannelStrip(); |
ChannelStrip* pChannelStrip = activeChannelStrip(); |
1765 |
#endif |
#endif |
1766 |
ui.editResetChannelAction->setEnabled(bHasChannel); |
ui.editResetChannelAction->setEnabled(bHasChannel); |
1767 |
ui.editResetAllChannelsAction->setEnabled(bHasChannel); |
ui.editResetAllChannelsAction->setEnabled(bHasChannel); |
1768 |
ui.viewMessagesAction->setOn(m_pMessages && m_pMessages->isVisible()); |
ui.viewMessagesAction->setChecked(m_pMessages && m_pMessages->isVisible()); |
1769 |
#ifdef CONFIG_MIDI_INSTRUMENT |
#ifdef CONFIG_MIDI_INSTRUMENT |
1770 |
ui.viewInstrumentsAction->setOn(m_pInstrumentListForm |
ui.viewInstrumentsAction->setChecked(m_pInstrumentListForm |
1771 |
&& m_pInstrumentListForm->isVisible()); |
&& m_pInstrumentListForm->isVisible()); |
1772 |
ui.viewInstrumentsAction->setEnabled(bHasClient); |
ui.viewInstrumentsAction->setEnabled(bHasClient); |
1773 |
#else |
#else |
1774 |
ui.viewInstrumentsAction->setEnabled(false); |
ui.viewInstrumentsAction->setEnabled(false); |
1775 |
#endif |
#endif |
1776 |
ui.viewDevicesAction->setOn(m_pDeviceForm |
ui.viewDevicesAction->setChecked(m_pDeviceForm |
1777 |
&& m_pDeviceForm->isVisible()); |
&& m_pDeviceForm->isVisible()); |
1778 |
ui.viewDevicesAction->setEnabled(bHasClient); |
ui.viewDevicesAction->setEnabled(bHasClient); |
1779 |
ui.channelsArrangeAction->setEnabled(bHasChannel); |
ui.channelsArrangeAction->setEnabled(bHasChannel); |
1794 |
} |
} |
1795 |
// Channel status... |
// Channel status... |
1796 |
if (bHasChannel) |
if (bHasChannel) |
1797 |
m_statusItem[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->caption()); |
m_statusItem[QSAMPLER_STATUS_CHANNEL]->setText(pChannelStrip->windowTitle()); |
1798 |
else |
else |
1799 |
m_statusItem[QSAMPLER_STATUS_CHANNEL]->clear(); |
m_statusItem[QSAMPLER_STATUS_CHANNEL]->clear(); |
1800 |
// Session status... |
// Session status... |
1804 |
m_statusItem[QSAMPLER_STATUS_SESSION]->clear(); |
m_statusItem[QSAMPLER_STATUS_SESSION]->clear(); |
1805 |
|
|
1806 |
// Recent files menu. |
// Recent files menu. |
1807 |
m_pRecentFilesMenu->setEnabled(bHasClient && m_pOptions->recentFiles.count() > 0); |
ui.fileOpenRecentMenu->setEnabled(m_pOptions->recentFiles.count() > 0); |
1808 |
} |
} |
1809 |
|
|
1810 |
|
|
1844 |
void MainForm::channelStripChanged(ChannelStrip* pChannelStrip) |
void MainForm::channelStripChanged(ChannelStrip* pChannelStrip) |
1845 |
{ |
{ |
1846 |
// Add this strip to the changed list... |
// Add this strip to the changed list... |
1847 |
if (m_changedStrips.containsRef(pChannelStrip) == 0) { |
if (!m_changedStrips.contains(pChannelStrip)) { |
1848 |
m_changedStrips.append(pChannelStrip); |
m_changedStrips.append(pChannelStrip); |
1849 |
pChannelStrip->resetErrorCount(); |
pChannelStrip->resetErrorCount(); |
1850 |
} |
} |
1872 |
if (iMaps < 0) |
if (iMaps < 0) |
1873 |
appendMessagesClient("lscp_get_midi_instrument_maps"); |
appendMessagesClient("lscp_get_midi_instrument_maps"); |
1874 |
else if (iMaps < 1) { |
else if (iMaps < 1) { |
1875 |
::lscp_add_midi_instrument_map(m_pClient, tr("Chromatic").latin1()); |
::lscp_add_midi_instrument_map(m_pClient, |
1876 |
::lscp_add_midi_instrument_map(m_pClient, tr("Drum Kits").latin1()); |
tr("Chromatic").toUtf8().constData()); |
1877 |
|
::lscp_add_midi_instrument_map(m_pClient, |
1878 |
|
tr("Drum Kits").toUtf8().constData()); |
1879 |
} |
} |
1880 |
#endif |
#endif |
1881 |
|
|
1916 |
return; |
return; |
1917 |
|
|
1918 |
// Remove from list if already there (avoid duplicates) |
// Remove from list if already there (avoid duplicates) |
1919 |
QStringList::Iterator iter = m_pOptions->recentFiles.find(sFilename); |
int iIndex = m_pOptions->recentFiles.indexOf(sFilename); |
1920 |
if (iter != m_pOptions->recentFiles.end()) |
if (iIndex >= 0) |
1921 |
m_pOptions->recentFiles.remove(iter); |
m_pOptions->recentFiles.removeAt(iIndex); |
1922 |
// Put it to front... |
// Put it to front... |
1923 |
m_pOptions->recentFiles.push_front(sFilename); |
m_pOptions->recentFiles.push_front(sFilename); |
|
|
|
|
// May update the menu. |
|
|
updateRecentFilesMenu(); |
|
1924 |
} |
} |
1925 |
|
|
1926 |
|
|
1927 |
// Update the recent files list and menu. |
// Update the recent files list and menu. |
1928 |
void MainForm::updateRecentFilesMenu (void) |
void MainForm::updateRecentFilesMenu (void) |
1929 |
{ |
{ |
1930 |
if (m_pOptions == NULL) |
if (m_pOptions == NULL) |
1931 |
return; |
return; |
1932 |
|
|
1933 |
// Time to keep the list under limits. |
// Time to keep the list under limits. |
1934 |
int iRecentFiles = m_pOptions->recentFiles.count(); |
int iRecentFiles = m_pOptions->recentFiles.count(); |
1935 |
while (iRecentFiles > m_pOptions->iMaxRecentFiles) { |
while (iRecentFiles > m_pOptions->iMaxRecentFiles) { |
1936 |
m_pOptions->recentFiles.pop_back(); |
m_pOptions->recentFiles.pop_back(); |
1937 |
iRecentFiles--; |
iRecentFiles--; |
1938 |
} |
} |
1939 |
|
|
1940 |
// rebuild the recent files menu... |
// Rebuild the recent files menu... |
1941 |
m_pRecentFilesMenu->clear(); |
ui.fileOpenRecentMenu->clear(); |
1942 |
for (int i = 0; i < iRecentFiles; i++) { |
for (int i = 0; i < iRecentFiles; i++) { |
1943 |
const QString& sFilename = m_pOptions->recentFiles[i]; |
const QString& sFilename = m_pOptions->recentFiles[i]; |
1944 |
if (QFileInfo(sFilename).exists()) { |
if (QFileInfo(sFilename).exists()) { |
1945 |
m_pRecentFilesMenu->insertItem(QString("&%1 %2") |
QAction *pAction = ui.fileOpenRecentMenu->addAction( |
1946 |
.arg(i + 1).arg(sessionName(sFilename)), |
QString("&%1 %2").arg(i + 1).arg(sessionName(sFilename)), |
1947 |
this, SLOT(fileOpenRecent(int)), 0, i); |
this, SLOT(fileOpenRecent())); |
1948 |
} |
pAction->setData(i); |
1949 |
} |
} |
1950 |
|
} |
1951 |
} |
} |
1952 |
|
|
1953 |
|
|
2001 |
// Update channel strips background effect. |
// Update channel strips background effect. |
2002 |
void MainForm::updateDisplayEffect (void) |
void MainForm::updateDisplayEffect (void) |
2003 |
{ |
{ |
|
QPixmap pm; |
|
|
if (m_pOptions->bDisplayEffect) |
|
|
pm = QPixmap(":/qsampler/pixmaps/displaybg1.png"); |
|
|
|
|
2004 |
// Full channel list update... |
// Full channel list update... |
2005 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
2006 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
2009 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2010 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
2011 |
ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
2012 |
if (pChannelStrip) |
if (pChannelStrip) |
2013 |
pChannelStrip->setDisplayBackground(pm); |
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
2014 |
} |
} |
2015 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
2016 |
} |
} |
2024 |
|
|
2025 |
#ifdef CONFIG_VOLUME |
#ifdef CONFIG_VOLUME |
2026 |
m_iVolumeChanging++; |
m_iVolumeChanging++; |
2027 |
m_pVolumeSlider->setMaxValue(m_pOptions->iMaxVolume); |
m_pVolumeSlider->setMaximum(m_pOptions->iMaxVolume); |
2028 |
m_pVolumeSpinBox->setMaxValue(m_pOptions->iMaxVolume); |
m_pVolumeSpinBox->setMaximum(m_pOptions->iMaxVolume); |
2029 |
m_iVolumeChanging--; |
m_iVolumeChanging--; |
2030 |
#endif |
#endif |
2031 |
|
|
2053 |
if (m_pMessages) |
if (m_pMessages) |
2054 |
m_pMessages->appendMessages(s); |
m_pMessages->appendMessages(s); |
2055 |
|
|
2056 |
statusBar()->message(s, 3000); |
statusBar()->showMessage(s, 3000); |
2057 |
} |
} |
2058 |
|
|
2059 |
void MainForm::appendMessagesColor( const QString& s, const QString& c ) |
void MainForm::appendMessagesColor( const QString& s, const QString& c ) |
2061 |
if (m_pMessages) |
if (m_pMessages) |
2062 |
m_pMessages->appendMessagesColor(s, c); |
m_pMessages->appendMessagesColor(s, c); |
2063 |
|
|
2064 |
statusBar()->message(s, 3000); |
statusBar()->showMessage(s, 3000); |
2065 |
} |
} |
2066 |
|
|
2067 |
void MainForm::appendMessagesText( const QString& s ) |
void MainForm::appendMessagesText( const QString& s ) |
2078 |
appendMessagesColor(s.simplified(), "#ff0000"); |
appendMessagesColor(s.simplified(), "#ff0000"); |
2079 |
|
|
2080 |
// Make it look responsive...:) |
// Make it look responsive...:) |
2081 |
QApplication::processEvents(QEventLoop::ExcludeUserInput); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
2082 |
|
|
2083 |
QMessageBox::critical(this, |
QMessageBox::critical(this, |
2084 |
QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel")); |
QSAMPLER_TITLE ": " + tr("Error"), s, tr("Cancel")); |
2096 |
.arg(::lscp_client_get_errno(m_pClient)), "#996666"); |
.arg(::lscp_client_get_errno(m_pClient)), "#996666"); |
2097 |
|
|
2098 |
// Make it look responsive...:) |
// Make it look responsive...:) |
2099 |
QApplication::processEvents(QEventLoop::ExcludeUserInput); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
2100 |
} |
} |
2101 |
|
|
2102 |
|
|
2155 |
if (m_pOptions && m_pOptions->bAutoArrange) { |
if (m_pOptions && m_pOptions->bAutoArrange) { |
2156 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
2157 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
2158 |
pChannelStrip = (ChannelStrip *) wlist.at(iChannel); |
pChannelStrip = static_cast<ChannelStrip *> (wlist.at(iChannel)); |
2159 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2160 |
// y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
// y += pChannelStrip->height() + pChannelStrip->parentWidget()->baseSize().height(); |
2161 |
y += pChannelStrip->parentWidget()->frameGeometry().height(); |
y += pChannelStrip->parentWidget()->frameGeometry().height(); |
2207 |
// Retrieve the active channel strip. |
// Retrieve the active channel strip. |
2208 |
ChannelStrip* MainForm::activeChannelStrip (void) |
ChannelStrip* MainForm::activeChannelStrip (void) |
2209 |
{ |
{ |
2210 |
return (ChannelStrip*) m_pWorkspace->activeWindow(); |
return static_cast<ChannelStrip *> (m_pWorkspace->activeWindow()); |
2211 |
} |
} |
2212 |
|
|
2213 |
|
|
2218 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
2219 |
return NULL; |
return NULL; |
2220 |
|
|
2221 |
return (ChannelStrip*) wlist.at(iChannel); |
return static_cast<ChannelStrip *> (wlist.at(iChannel)); |
2222 |
} |
} |
2223 |
|
|
2224 |
|
|
2230 |
return NULL; |
return NULL; |
2231 |
|
|
2232 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
2233 |
ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
ChannelStrip* pChannelStrip |
2234 |
|
= static_cast<ChannelStrip*> (wlist.at(iChannel)); |
2235 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2236 |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
qsamplerChannel *pChannel = pChannelStrip->channel(); |
2237 |
if (pChannel && pChannel->channelID() == iChannelID) |
if (pChannel && pChannel->channelID() == iChannelID) |
2248 |
void MainForm::channelsMenuAboutToShow (void) |
void MainForm::channelsMenuAboutToShow (void) |
2249 |
{ |
{ |
2250 |
ui.channelsMenu->clear(); |
ui.channelsMenu->clear(); |
2251 |
ui.channelsArrangeAction->addTo(ui.channelsMenu); |
ui.channelsMenu->addAction(ui.channelsArrangeAction); |
2252 |
ui.channelsAutoArrangeAction->addTo(ui.channelsMenu); |
ui.channelsMenu->addAction(ui.channelsAutoArrangeAction); |
2253 |
|
|
2254 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QWidgetList wlist = m_pWorkspace->windowList(); |
2255 |
if (!wlist.isEmpty()) { |
if (!wlist.isEmpty()) { |
2256 |
ui.channelsMenu->insertSeparator(); |
ui.channelsMenu->addSeparator(); |
2257 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
2258 |
ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
ChannelStrip* pChannelStrip |
2259 |
if (pChannelStrip) { |
= static_cast<ChannelStrip*> (wlist.at(iChannel)); |
2260 |
int iItemID = ui.channelsMenu->insertItem(pChannelStrip->caption(), this, SLOT(channelsMenuActivated(int))); |
if (pChannelStrip) { |
2261 |
ui.channelsMenu->setItemParameter(iItemID, iChannel); |
QAction *pAction = ui.channelsMenu->addAction( |
2262 |
ui.channelsMenu->setItemChecked(iItemID, activeChannelStrip() == pChannelStrip); |
pChannelStrip->windowTitle(), this, SLOT(channelsMenuActivated())); |
2263 |
} |
pAction->setData(iChannel); |
2264 |
|
pAction->setChecked(activeChannelStrip() == pChannelStrip); |
2265 |
|
} |
2266 |
} |
} |
2267 |
} |
} |
2268 |
} |
} |
2269 |
|
|
2270 |
|
|
2271 |
// Windows menu activation slot |
// Windows menu activation slot |
2272 |
void MainForm::channelsMenuActivated ( int iChannel ) |
void MainForm::channelsMenuActivated (void) |
2273 |
{ |
{ |
2274 |
ChannelStrip* pChannelStrip = channelStripAt(iChannel); |
// Retrive channel index from action data... |
2275 |
if (pChannelStrip) |
QAction *pAction = qobject_cast<QAction *> (sender()); |
2276 |
pChannelStrip->showNormal(); |
if (pAction == NULL) |
2277 |
pChannelStrip->setFocus(); |
return; |
2278 |
|
|
2279 |
|
ChannelStrip* pChannelStrip = channelStripAt(pAction->data().toInt()); |
2280 |
|
if (pChannelStrip) { |
2281 |
|
pChannelStrip->showNormal(); |
2282 |
|
pChannelStrip->setFocus(); |
2283 |
|
} |
2284 |
} |
} |
2285 |
|
|
2286 |
|
|
2321 |
|
|
2322 |
if (m_pClient) { |
if (m_pClient) { |
2323 |
// Update the channel information for each pending strip... |
// Update the channel information for each pending strip... |
2324 |
if (m_changedStrips.count() > 0) { |
QListIterator<ChannelStrip *> iter(m_changedStrips); |
2325 |
for (ChannelStrip* pChannelStrip = m_changedStrips.first(); |
while (iter.hasNext()) { |
2326 |
pChannelStrip; pChannelStrip = m_changedStrips.next()) { |
ChannelStrip *pChannelStrip = iter.next(); |
2327 |
// If successfull, remove from pending list... |
// If successfull, remove from pending list... |
2328 |
if (pChannelStrip->updateChannelInfo()) |
if (pChannelStrip->updateChannelInfo()) { |
2329 |
m_changedStrips.remove(pChannelStrip); |
int iChannelStrip = m_changedStrips.indexOf(pChannelStrip); |
2330 |
|
if (iChannelStrip >= 0) |
2331 |
|
m_changedStrips.removeAt(iChannelStrip); |
2332 |
} |
} |
2333 |
} |
} |
2334 |
// Refresh each channel usage, on each period... |
// Refresh each channel usage, on each period... |
2407 |
SLOT(processServerExit())); |
SLOT(processServerExit())); |
2408 |
|
|
2409 |
// Build process arguments... |
// Build process arguments... |
2410 |
QStringList serverCmdLine = QStringList::split(' ', m_pOptions->sServerCmdLine); |
QStringList serverCmdLine = m_pOptions->sServerCmdLine.split(' '); |
2411 |
|
|
2412 |
appendMessages(tr("Server is starting...")); |
appendMessages(tr("Server is starting...")); |
2413 |
appendMessagesColor(m_pOptions->sServerCmdLine, "#990099"); |
appendMessagesColor(m_pOptions->sServerCmdLine, "#990099"); |
2452 |
QTime t; |
QTime t; |
2453 |
t.start(); |
t.start(); |
2454 |
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
while (t.elapsed() < QSAMPLER_TIMER_MSECS) |
2455 |
QApplication::processEvents(QEventLoop::ExcludeUserInput); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
2456 |
|
|
2457 |
// Do final processing anyway. |
// Do final processing anyway. |
2458 |
processServerExit(); |
processServerExit(); |
2527 |
appendMessages(tr("Client connecting...")); |
appendMessages(tr("Client connecting...")); |
2528 |
|
|
2529 |
// Create the client handle... |
// Create the client handle... |
2530 |
m_pClient = ::lscp_client_create(m_pOptions->sServerHost.latin1(), m_pOptions->iServerPort, qsampler_client_callback, this); |
m_pClient = ::lscp_client_create( |
2531 |
|
m_pOptions->sServerHost.toUtf8().constData(), |
2532 |
|
m_pOptions->iServerPort, qsampler_client_callback, this); |
2533 |
if (m_pClient == NULL) { |
if (m_pClient == NULL) { |
2534 |
// Is this the first try? |
// Is this the first try? |
2535 |
// maybe we need to start a local server... |
// maybe we need to start a local server... |