1 |
// qsamplerMainForm.cpp |
// qsamplerMainForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2013, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2015, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, 2008 Christian Schoenebeck |
Copyright (C) 2007,2008,2015 Christian Schoenebeck |
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 |
65 |
#if QT_VERSION < 0x040500 |
#if QT_VERSION < 0x040500 |
66 |
namespace Qt { |
namespace Qt { |
67 |
const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000); |
const WindowFlags WindowCloseButtonHint = WindowFlags(0x08000000); |
|
#if QT_VERSION < 0x040200 |
|
|
const WindowFlags CustomizeWindowHint = WindowFlags(0x02000000); |
|
|
#endif |
|
68 |
} |
} |
69 |
#endif |
#endif |
70 |
|
|
254 |
QObject::connect(m_pVolumeSlider, |
QObject::connect(m_pVolumeSlider, |
255 |
SIGNAL(valueChanged(int)), |
SIGNAL(valueChanged(int)), |
256 |
SLOT(volumeChanged(int))); |
SLOT(volumeChanged(int))); |
|
//m_ui.channelsToolbar->setHorizontallyStretchable(true); |
|
|
//m_ui.channelsToolbar->setStretchableWidget(m_pVolumeSlider); |
|
257 |
m_ui.channelsToolbar->addWidget(m_pVolumeSlider); |
m_ui.channelsToolbar->addWidget(m_pVolumeSlider); |
258 |
// Volume spin-box |
// Volume spin-box |
259 |
m_ui.channelsToolbar->addSeparator(); |
m_ui.channelsToolbar->addSeparator(); |
260 |
m_pVolumeSpinBox = new QSpinBox(m_ui.channelsToolbar); |
m_pVolumeSpinBox = new QSpinBox(m_ui.channelsToolbar); |
|
m_pVolumeSpinBox->setMaximumHeight(24); |
|
261 |
m_pVolumeSpinBox->setSuffix(" %"); |
m_pVolumeSpinBox->setSuffix(" %"); |
262 |
m_pVolumeSpinBox->setMinimum(0); |
m_pVolumeSpinBox->setMinimum(0); |
263 |
m_pVolumeSpinBox->setMaximum(100); |
m_pVolumeSpinBox->setMaximum(100); |
392 |
QObject::connect(m_ui.channelsMenu, |
QObject::connect(m_ui.channelsMenu, |
393 |
SIGNAL(aboutToShow()), |
SIGNAL(aboutToShow()), |
394 |
SLOT(channelsMenuAboutToShow())); |
SLOT(channelsMenuAboutToShow())); |
395 |
|
#ifdef CONFIG_VOLUME |
396 |
|
QObject::connect(m_ui.channelsToolbar, |
397 |
|
SIGNAL(orientationChanged(Qt::Orientation)), |
398 |
|
SLOT(channelsToolbarOrientation(Qt::Orientation))); |
399 |
|
#endif |
400 |
} |
} |
401 |
|
|
402 |
// Destructor. |
// Destructor. |
1405 |
return; |
return; |
1406 |
|
|
1407 |
// Ask user whether he/she want's an internal sampler reset... |
// Ask user whether he/she want's an internal sampler reset... |
1408 |
if (QMessageBox::warning(this, |
if (m_pOptions && m_pOptions->bConfirmReset) { |
1409 |
QSAMPLER_TITLE ": " + tr("Warning"), |
const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning"); |
1410 |
tr("Resetting the sampler instance will close\n" |
const QString& sText = tr( |
1411 |
"all device and channel configurations.\n\n" |
"Resetting the sampler instance will close\n" |
1412 |
"Please note that this operation may cause\n" |
"all device and channel configurations.\n\n" |
1413 |
"temporary MIDI and Audio disruption.\n\n" |
"Please note that this operation may cause\n" |
1414 |
"Do you want to reset the sampler engine now?"), |
"temporary MIDI and Audio disruption.\n\n" |
1415 |
QMessageBox::Ok | QMessageBox::Cancel) |
"Do you want to reset the sampler engine now?"); |
1416 |
== QMessageBox::Cancel) |
#if 0 |
1417 |
return; |
if (QMessageBox::warning(this, sTitle, sText, |
1418 |
|
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) |
1419 |
|
return; |
1420 |
|
#else |
1421 |
|
QMessageBox mbox(this); |
1422 |
|
mbox.setIcon(QMessageBox::Warning); |
1423 |
|
mbox.setWindowTitle(sTitle); |
1424 |
|
mbox.setText(sText); |
1425 |
|
mbox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); |
1426 |
|
QCheckBox cbox(tr("Don't ask this again")); |
1427 |
|
cbox.setChecked(false); |
1428 |
|
cbox.blockSignals(true); |
1429 |
|
mbox.addButton(&cbox, QMessageBox::ActionRole); |
1430 |
|
if (mbox.exec() == QMessageBox::Cancel) |
1431 |
|
return; |
1432 |
|
if (cbox.isChecked()) |
1433 |
|
m_pOptions->bConfirmReset = false; |
1434 |
|
#endif |
1435 |
|
} |
1436 |
|
|
1437 |
// Trye closing the current session, first... |
// Trye closing the current session, first... |
1438 |
if (!closeSession(true)) |
if (!closeSession(true)) |
1464 |
|
|
1465 |
// Ask user whether he/she want's a complete restart... |
// Ask user whether he/she want's a complete restart... |
1466 |
// (if we're currently up and running) |
// (if we're currently up and running) |
1467 |
if (bRestart && m_pClient) { |
if (m_pOptions && m_pOptions->bConfirmRestart) { |
1468 |
bRestart = (QMessageBox::warning(this, |
const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning"); |
1469 |
QSAMPLER_TITLE ": " + tr("Warning"), |
const QString& sText = tr( |
1470 |
tr("New settings will be effective after\n" |
"New settings will be effective after\n" |
1471 |
"restarting the client/server connection.\n\n" |
"restarting the client/server connection.\n\n" |
1472 |
"Please note that this operation may cause\n" |
"Please note that this operation may cause\n" |
1473 |
"temporary MIDI and Audio disruption.\n\n" |
"temporary MIDI and Audio disruption.\n\n" |
1474 |
"Do you want to restart the connection now?"), |
"Do you want to restart the connection now?"); |
1475 |
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok); |
#if 0 |
1476 |
|
if (QMessageBox::warning(this, sTitle, sText, |
1477 |
|
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) |
1478 |
|
bRestart = false; |
1479 |
|
#else |
1480 |
|
QMessageBox mbox(this); |
1481 |
|
mbox.setIcon(QMessageBox::Warning); |
1482 |
|
mbox.setWindowTitle(sTitle); |
1483 |
|
mbox.setText(sText); |
1484 |
|
mbox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); |
1485 |
|
QCheckBox cbox(tr("Don't ask this again")); |
1486 |
|
cbox.setChecked(false); |
1487 |
|
cbox.blockSignals(true); |
1488 |
|
mbox.addButton(&cbox, QMessageBox::ActionRole); |
1489 |
|
if (mbox.exec() == QMessageBox::Cancel) |
1490 |
|
bRestart = false; |
1491 |
|
else |
1492 |
|
if (cbox.isChecked()) |
1493 |
|
m_pOptions->bConfirmRestart = false; |
1494 |
|
#endif |
1495 |
} |
} |
1496 |
|
|
1497 |
// Are we still for it? |
// Are we still for it? |
1566 |
|
|
1567 |
// Prompt user if he/she's sure about this... |
// Prompt user if he/she's sure about this... |
1568 |
if (m_pOptions && m_pOptions->bConfirmRemove) { |
if (m_pOptions && m_pOptions->bConfirmRemove) { |
1569 |
if (QMessageBox::warning(this, |
const QString& sTitle = QSAMPLER_TITLE ": " + tr("Warning"); |
1570 |
QSAMPLER_TITLE ": " + tr("Warning"), |
const QString& sText = tr( |
1571 |
tr("About to remove channel:\n\n" |
"About to remove channel:\n\n" |
1572 |
"%1\n\n" |
"%1\n\n" |
1573 |
"Are you sure?") |
"Are you sure?") |
1574 |
.arg(pChannelStrip->windowTitle()), |
.arg(pChannelStrip->windowTitle()); |
1575 |
QMessageBox::Ok | QMessageBox::Cancel) |
#if 0 |
1576 |
== QMessageBox::Cancel) |
if (QMessageBox::warning(this, sTitle, sText, |
1577 |
|
QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Cancel) |
1578 |
|
return; |
1579 |
|
#else |
1580 |
|
QMessageBox mbox(this); |
1581 |
|
mbox.setIcon(QMessageBox::Warning); |
1582 |
|
mbox.setWindowTitle(sTitle); |
1583 |
|
mbox.setText(sText); |
1584 |
|
mbox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel); |
1585 |
|
QCheckBox cbox(tr("Don't ask this again")); |
1586 |
|
cbox.setChecked(false); |
1587 |
|
cbox.blockSignals(true); |
1588 |
|
mbox.addButton(&cbox, QMessageBox::ActionRole); |
1589 |
|
if (mbox.exec() == QMessageBox::Cancel) |
1590 |
return; |
return; |
1591 |
|
if (cbox.isChecked()) |
1592 |
|
m_pOptions->bConfirmRemove = false; |
1593 |
|
#endif |
1594 |
} |
} |
1595 |
|
|
1596 |
// Remove the existing sampler channel. |
// Remove the existing sampler channel. |
2401 |
m_pMessages->appendMessagesText(s); |
m_pMessages->appendMessagesText(s); |
2402 |
} |
} |
2403 |
|
|
2404 |
void MainForm::appendMessagesError( const QString& s ) |
void MainForm::appendMessagesError( const QString& sText ) |
2405 |
{ |
{ |
2406 |
if (m_pMessages) |
if (m_pMessages) |
2407 |
m_pMessages->show(); |
m_pMessages->show(); |
2408 |
|
|
2409 |
appendMessagesColor(s.simplified(), "#ff0000"); |
appendMessagesColor(sText.simplified(), "#ff0000"); |
2410 |
|
|
2411 |
// Make it look responsive...:) |
// Make it look responsive...:) |
2412 |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents); |
2413 |
|
|
2414 |
QMessageBox::critical(this, |
if (m_pOptions && m_pOptions->bConfirmError) { |
2415 |
QSAMPLER_TITLE ": " + tr("Error"), s, QMessageBox::Cancel); |
const QString& sTitle = QSAMPLER_TITLE ": " + tr("Error"); |
2416 |
|
#if 0 |
2417 |
|
QMessageBox::critical(this, sTitle, sText, QMessageBox::Cancel); |
2418 |
|
#else |
2419 |
|
QMessageBox mbox(this); |
2420 |
|
mbox.setIcon(QMessageBox::Critical); |
2421 |
|
mbox.setWindowTitle(sTitle); |
2422 |
|
mbox.setText(sText); |
2423 |
|
mbox.setStandardButtons(QMessageBox::Cancel); |
2424 |
|
QCheckBox cbox(tr("Don't show this again")); |
2425 |
|
cbox.setChecked(false); |
2426 |
|
cbox.blockSignals(true); |
2427 |
|
mbox.addButton(&cbox, QMessageBox::ActionRole); |
2428 |
|
if (mbox.exec() && cbox.isChecked()) |
2429 |
|
m_pOptions->bConfirmError = false; |
2430 |
|
#endif |
2431 |
|
} |
2432 |
} |
} |
2433 |
|
|
2434 |
|
|
2763 |
|
|
2764 |
// Setup stdout/stderr capture... |
// Setup stdout/stderr capture... |
2765 |
// if (m_pOptions->bStdoutCapture) { |
// if (m_pOptions->bStdoutCapture) { |
|
#if QT_VERSION >= 0x040200 |
|
2766 |
m_pServer->setProcessChannelMode(QProcess::ForwardedChannels); |
m_pServer->setProcessChannelMode(QProcess::ForwardedChannels); |
|
#endif |
|
2767 |
QObject::connect(m_pServer, |
QObject::connect(m_pServer, |
2768 |
SIGNAL(readyReadStandardOutput()), |
SIGNAL(readyReadStandardOutput()), |
2769 |
SLOT(readServerStdout())); |
SLOT(readServerStdout())); |
2818 |
"according to your current sampler session and you could alter the\n" |
"according to your current sampler session and you could alter the\n" |
2819 |
"sampler session at any time by relaunching QSampler.\n\n" |
"sampler session at any time by relaunching QSampler.\n\n" |
2820 |
"Do you want LinuxSampler to stop?"), |
"Do you want LinuxSampler to stop?"), |
2821 |
QMessageBox::Yes | QMessageBox::No) == QMessageBox::No) |
QMessageBox::Yes | QMessageBox::No, |
2822 |
|
QMessageBox::Yes) == QMessageBox::No) |
2823 |
{ |
{ |
2824 |
bForceServerStop = false; |
bForceServerStop = false; |
2825 |
} |
} |
3076 |
} |
} |
3077 |
|
|
3078 |
|
|
3079 |
|
// Channel toolbar orientation change. |
3080 |
|
void MainForm::channelsToolbarOrientation ( Qt::Orientation orientation ) |
3081 |
|
{ |
3082 |
|
#ifdef CONFIG_VOLUME |
3083 |
|
m_pVolumeSlider->setOrientation(orientation); |
3084 |
|
if (orientation == Qt::Horizontal) { |
3085 |
|
m_pVolumeSlider->setMinimumHeight(24); |
3086 |
|
m_pVolumeSlider->setMaximumHeight(32); |
3087 |
|
m_pVolumeSlider->setMinimumWidth(120); |
3088 |
|
m_pVolumeSlider->setMaximumWidth(640); |
3089 |
|
m_pVolumeSpinBox->setMaximumWidth(64); |
3090 |
|
m_pVolumeSpinBox->setButtonSymbols(QSpinBox::UpDownArrows); |
3091 |
|
} else { |
3092 |
|
m_pVolumeSlider->setMinimumHeight(120); |
3093 |
|
m_pVolumeSlider->setMaximumHeight(480); |
3094 |
|
m_pVolumeSlider->setMinimumWidth(24); |
3095 |
|
m_pVolumeSlider->setMaximumWidth(32); |
3096 |
|
m_pVolumeSpinBox->setMaximumWidth(32); |
3097 |
|
m_pVolumeSpinBox->setButtonSymbols(QSpinBox::NoButtons); |
3098 |
|
} |
3099 |
|
#endif |
3100 |
|
} |
3101 |
|
|
3102 |
|
|
3103 |
} // namespace QSampler |
} // namespace QSampler |
3104 |
|
|
3105 |
|
|