1 |
// qsamplerMainForm.cpp |
// qsamplerMainForm.cpp |
2 |
// |
// |
3 |
/**************************************************************************** |
/**************************************************************************** |
4 |
Copyright (C) 2004-2010, rncbc aka Rui Nuno Capela. All rights reserved. |
Copyright (C) 2004-2013, rncbc aka Rui Nuno Capela. All rights reserved. |
5 |
Copyright (C) 2007, 2008 Christian Schoenebeck |
Copyright (C) 2007, 2008 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 |
35 |
#include "qsamplerOptionsForm.h" |
#include "qsamplerOptionsForm.h" |
36 |
#include "qsamplerDeviceStatusForm.h" |
#include "qsamplerDeviceStatusForm.h" |
37 |
|
|
38 |
|
#include <QMdiArea> |
39 |
|
#include <QMdiSubWindow> |
40 |
|
|
41 |
#include <QApplication> |
#include <QApplication> |
|
#include <QWorkspace> |
|
42 |
#include <QProcess> |
#include <QProcess> |
43 |
#include <QMessageBox> |
#include <QMessageBox> |
44 |
|
|
58 |
#include <QTimer> |
#include <QTimer> |
59 |
#include <QDateTime> |
#include <QDateTime> |
60 |
|
|
61 |
|
#if QT_VERSION >= 0x050000 |
62 |
|
#include <QMimeData> |
63 |
|
#endif |
64 |
|
|
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); |
102 |
//------------------------------------------------------------------------- |
//------------------------------------------------------------------------- |
103 |
// LADISH Level 1 support stuff. |
// LADISH Level 1 support stuff. |
104 |
|
|
105 |
#ifdef HAVE_SIGNAL_H |
#if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H) |
106 |
|
|
107 |
#include <QSocketNotifier> |
#include <QSocketNotifier> |
108 |
|
|
208 |
|
|
209 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
210 |
|
|
211 |
#ifdef HAVE_SIGNAL_H |
#if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H) |
212 |
|
|
213 |
// Set to ignore any fatal "Broken pipe" signals. |
// Set to ignore any fatal "Broken pipe" signals. |
214 |
::signal(SIGPIPE, SIG_IGN); |
::signal(SIGPIPE, SIG_IGN); |
227 |
// Install SIGUSR1 signal handler. |
// Install SIGUSR1 signal handler. |
228 |
struct sigaction usr1; |
struct sigaction usr1; |
229 |
usr1.sa_handler = qsampler_sigusr1_handler; |
usr1.sa_handler = qsampler_sigusr1_handler; |
230 |
::sigemptyset(&usr1.sa_mask); |
sigemptyset(&usr1.sa_mask); |
231 |
usr1.sa_flags = 0; |
usr1.sa_flags = 0; |
232 |
usr1.sa_flags |= SA_RESTART; |
usr1.sa_flags |= SA_RESTART; |
233 |
::sigaction(SIGUSR1, &usr1, NULL); |
::sigaction(SIGUSR1, &usr1, NULL); |
234 |
|
|
235 |
#else // HAVE_SIGNAL_H |
#else // HAVE_SIGNAL_H |
236 |
|
|
237 |
m_pSocketNotifier = NULL; |
m_pUsr1Notifier = NULL; |
238 |
|
|
239 |
#endif // !HAVE_SIGNAL_H |
#endif // !HAVE_SIGNAL_H |
240 |
|
|
275 |
#endif |
#endif |
276 |
|
|
277 |
// Make it an MDI workspace. |
// Make it an MDI workspace. |
278 |
m_pWorkspace = new QWorkspace(this); |
m_pWorkspace = new QMdiArea(this); |
|
m_pWorkspace->setScrollBarsEnabled(true); |
|
279 |
// Set the activation connection. |
// Set the activation connection. |
280 |
QObject::connect(m_pWorkspace, |
QObject::connect(m_pWorkspace, |
281 |
SIGNAL(windowActivated(QWidget *)), |
SIGNAL(subWindowActivated(QMdiSubWindow *)), |
282 |
SLOT(activateStrip(QWidget *))); |
SLOT(activateStrip(QMdiSubWindow *))); |
283 |
// Make it shine :-) |
// Make it shine :-) |
284 |
setCentralWidget(m_pWorkspace); |
setCentralWidget(m_pWorkspace); |
285 |
|
|
408 |
WSACleanup(); |
WSACleanup(); |
409 |
#endif |
#endif |
410 |
|
|
411 |
#ifdef HAVE_SIGNAL_H |
#if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H) |
412 |
if (m_pUsr1Notifier) |
if (m_pUsr1Notifier) |
413 |
delete m_pUsr1Notifier; |
delete m_pUsr1Notifier; |
414 |
#endif |
#endif |
696 |
// LADISH Level 1 -- SIGUSR1 signal handler. |
// LADISH Level 1 -- SIGUSR1 signal handler. |
697 |
void MainForm::handle_sigusr1 (void) |
void MainForm::handle_sigusr1 (void) |
698 |
{ |
{ |
699 |
|
#if defined(HAVE_SIGNAL_H) && defined(HAVE_SYS_SOCKET_H) |
700 |
|
|
701 |
char c; |
char c; |
702 |
|
|
703 |
if (::read(g_fdUsr1[1], &c, sizeof(c)) > 0) |
if (::read(g_fdUsr1[1], &c, sizeof(c)) > 0) |
704 |
saveSession(false); |
saveSession(false); |
705 |
|
|
706 |
|
#endif |
707 |
} |
} |
708 |
|
|
709 |
|
|
895 |
if (bClose) { |
if (bClose) { |
896 |
// Remove all channel strips from sight... |
// Remove all channel strips from sight... |
897 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
898 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList(); |
899 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) { |
900 |
ChannelStrip *pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
ChannelStrip *pChannelStrip = NULL; |
901 |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel); |
902 |
|
if (pMdiSubWindow) |
903 |
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
904 |
if (pChannelStrip) { |
if (pChannelStrip) { |
905 |
Channel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
906 |
if (bForce && pChannel) |
if (bForce && pChannel) |
1197 |
#endif // CONFIG_MIDI_INSTRUMENT |
#endif // CONFIG_MIDI_INSTRUMENT |
1198 |
|
|
1199 |
// Sampler channel mapping. |
// Sampler channel mapping. |
1200 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList(); |
1201 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) { |
1202 |
ChannelStrip* pChannelStrip |
ChannelStrip *pChannelStrip = NULL; |
1203 |
= static_cast<ChannelStrip *> (wlist.at(iChannel)); |
QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel); |
1204 |
|
if (pMdiSubWindow) |
1205 |
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
1206 |
if (pChannelStrip) { |
if (pChannelStrip) { |
1207 |
Channel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
1208 |
if (pChannel) { |
if (pChannel) { |
1516 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
1517 |
return; |
return; |
1518 |
|
|
1519 |
ChannelStrip* pChannelStrip = activeChannelStrip(); |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
1520 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
1521 |
return; |
return; |
1522 |
|
|
1560 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
1561 |
return; |
return; |
1562 |
|
|
1563 |
ChannelStrip* pChannelStrip = activeChannelStrip(); |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
1564 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
1565 |
return; |
return; |
1566 |
|
|
1575 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
1576 |
return; |
return; |
1577 |
|
|
1578 |
ChannelStrip* pChannelStrip = activeChannelStrip(); |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
1579 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
1580 |
return; |
return; |
1581 |
|
|
1590 |
if (m_pClient == NULL) |
if (m_pClient == NULL) |
1591 |
return; |
return; |
1592 |
|
|
1593 |
ChannelStrip* pChannelStrip = activeChannelStrip(); |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
1594 |
if (pChannelStrip == NULL) |
if (pChannelStrip == NULL) |
1595 |
return; |
return; |
1596 |
|
|
1608 |
// Invoque the channel strip procedure, |
// Invoque the channel strip procedure, |
1609 |
// for all channels out there... |
// for all channels out there... |
1610 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
1611 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList(); |
1612 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) { |
1613 |
ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
ChannelStrip *pChannelStrip = NULL; |
1614 |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel); |
1615 |
|
if (pMdiSubWindow) |
1616 |
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
1617 |
if (pChannelStrip) |
if (pChannelStrip) |
1618 |
pChannelStrip->channelReset(); |
pChannelStrip->channelReset(); |
1619 |
} |
} |
1716 |
OptionsForm* pOptionsForm = new OptionsForm(this); |
OptionsForm* pOptionsForm = new OptionsForm(this); |
1717 |
if (pOptionsForm) { |
if (pOptionsForm) { |
1718 |
// Check out some initial nullities(tm)... |
// Check out some initial nullities(tm)... |
1719 |
ChannelStrip* pChannelStrip = activeChannelStrip(); |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
1720 |
if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip) |
if (m_pOptions->sDisplayFont.isEmpty() && pChannelStrip) |
1721 |
m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString(); |
m_pOptions->sDisplayFont = pChannelStrip->displayFont().toString(); |
1722 |
if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages) |
if (m_pOptions->sMessagesFont.isEmpty() && m_pMessages) |
1809 |
void MainForm::channelsArrange (void) |
void MainForm::channelsArrange (void) |
1810 |
{ |
{ |
1811 |
// Full width vertical tiling |
// Full width vertical tiling |
1812 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList(); |
1813 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
1814 |
return; |
return; |
1815 |
|
|
1816 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
1817 |
int y = 0; |
int y = 0; |
1818 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) { |
1819 |
ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
ChannelStrip *pChannelStrip = NULL; |
1820 |
/* if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) { |
QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel); |
1821 |
// Prevent flicker... |
if (pMdiSubWindow) |
1822 |
pChannelStrip->hide(); |
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
1823 |
pChannelStrip->showNormal(); |
if (pChannelStrip) { |
1824 |
} */ |
/* if (pChannelStrip->testWState(WState_Maximized | WState_Minimized)) { |
1825 |
pChannelStrip->adjustSize(); |
// Prevent flicker... |
1826 |
int iWidth = m_pWorkspace->width(); |
pChannelStrip->hide(); |
1827 |
if (iWidth < pChannelStrip->width()) |
pChannelStrip->showNormal(); |
1828 |
iWidth = pChannelStrip->width(); |
} */ |
1829 |
// int iHeight = pChannelStrip->height() |
pChannelStrip->adjustSize(); |
1830 |
// + pChannelStrip->parentWidget()->baseSize().height(); |
int iWidth = m_pWorkspace->width(); |
1831 |
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
if (iWidth < pChannelStrip->width()) |
1832 |
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
iWidth = pChannelStrip->width(); |
1833 |
y += iHeight; |
// int iHeight = pChannelStrip->height() |
1834 |
|
// + pChannelStrip->parentWidget()->baseSize().height(); |
1835 |
|
int iHeight = pChannelStrip->parentWidget()->frameGeometry().height(); |
1836 |
|
pChannelStrip->parentWidget()->setGeometry(0, y, iWidth, iHeight); |
1837 |
|
y += iHeight; |
1838 |
|
} |
1839 |
} |
} |
1840 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
1841 |
|
|
1980 |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
ChannelStrip *pChannelStrip = activeChannelStrip(); |
1981 |
bool bHasClient = (m_pOptions != NULL && m_pClient != NULL); |
bool bHasClient = (m_pOptions != NULL && m_pClient != NULL); |
1982 |
bool bHasChannel = (bHasClient && pChannelStrip != NULL); |
bool bHasChannel = (bHasClient && pChannelStrip != NULL); |
1983 |
bool bHasChannels = (bHasClient && m_pWorkspace->windowList().count() > 0); |
bool bHasChannels = (bHasClient && m_pWorkspace->subWindowList().count() > 0); |
1984 |
m_ui.fileNewAction->setEnabled(bHasClient); |
m_ui.fileNewAction->setEnabled(bHasClient); |
1985 |
m_ui.fileOpenAction->setEnabled(bHasClient); |
m_ui.fileOpenAction->setEnabled(bHasClient); |
1986 |
m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0); |
m_ui.fileSaveAction->setEnabled(bHasClient && m_iDirtyCount > 0); |
2076 |
|
|
2077 |
|
|
2078 |
// Channel change receiver slot. |
// Channel change receiver slot. |
2079 |
void MainForm::channelStripChanged(ChannelStrip* pChannelStrip) |
void MainForm::channelStripChanged ( ChannelStrip *pChannelStrip ) |
2080 |
{ |
{ |
2081 |
// Add this strip to the changed list... |
// Add this strip to the changed list... |
2082 |
if (!m_changedStrips.contains(pChannelStrip)) { |
if (!m_changedStrips.contains(pChannelStrip)) { |
2127 |
m_pDeviceForm->refreshDevices(); |
m_pDeviceForm->refreshDevices(); |
2128 |
} |
} |
2129 |
|
|
2130 |
void MainForm::updateAllChannelStrips(bool bRemoveDeadStrips) { |
|
2131 |
|
void MainForm::updateAllChannelStrips ( bool bRemoveDeadStrips ) |
2132 |
|
{ |
2133 |
// Retrieve the current channel list. |
// Retrieve the current channel list. |
2134 |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
int *piChannelIDs = ::lscp_list_channels(m_pClient); |
2135 |
if (piChannelIDs == NULL) { |
if (piChannelIDs == NULL) { |
2141 |
} else { |
} else { |
2142 |
// Try to (re)create each channel. |
// Try to (re)create each channel. |
2143 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2144 |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; iChannel++) { |
for (int iChannel = 0; piChannelIDs[iChannel] >= 0; ++iChannel) { |
2145 |
// Check if theres already a channel strip for this one... |
// Check if theres already a channel strip for this one... |
2146 |
if (!channelStrip(piChannelIDs[iChannel])) |
if (!channelStrip(piChannelIDs[iChannel])) |
2147 |
createChannelStrip(new Channel(piChannelIDs[iChannel])); |
createChannelStrip(new Channel(piChannelIDs[iChannel])); |
2148 |
} |
} |
|
|
|
2149 |
// Do we auto-arrange? |
// Do we auto-arrange? |
2150 |
if (m_pOptions && m_pOptions->bAutoArrange) |
if (m_pOptions && m_pOptions->bAutoArrange) |
2151 |
channelsArrange(); |
channelsArrange(); |
|
|
|
|
stabilizeForm(); |
|
|
|
|
2152 |
// remove dead channel strips |
// remove dead channel strips |
2153 |
if (bRemoveDeadStrips) { |
if (bRemoveDeadStrips) { |
2154 |
for (int i = 0; channelStripAt(i); ++i) { |
QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList(); |
2155 |
ChannelStrip* pChannelStrip = channelStripAt(i); |
for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) { |
2156 |
bool bExists = false; |
ChannelStrip *pChannelStrip = NULL; |
2157 |
for (int j = 0; piChannelIDs[j] >= 0; ++j) { |
QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel); |
2158 |
if (!pChannelStrip->channel()) break; |
if (pMdiSubWindow) |
2159 |
if (piChannelIDs[j] == pChannelStrip->channel()->channelID()) { |
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
2160 |
// strip exists, don't touch it |
if (pChannelStrip) { |
2161 |
bExists = true; |
bool bExists = false; |
2162 |
break; |
for (int j = 0; piChannelIDs[j] >= 0; ++j) { |
2163 |
|
if (!pChannelStrip->channel()) |
2164 |
|
break; |
2165 |
|
if (piChannelIDs[j] == pChannelStrip->channel()->channelID()) { |
2166 |
|
// strip exists, don't touch it |
2167 |
|
bExists = true; |
2168 |
|
break; |
2169 |
|
} |
2170 |
} |
} |
2171 |
|
if (!bExists) |
2172 |
|
destroyChannelStrip(pChannelStrip); |
2173 |
} |
} |
|
if (!bExists) destroyChannelStrip(pChannelStrip); |
|
2174 |
} |
} |
2175 |
} |
} |
2176 |
m_pWorkspace->setUpdatesEnabled(true); |
m_pWorkspace->setUpdatesEnabled(true); |
2177 |
} |
} |
2178 |
|
|
2179 |
|
stabilizeForm(); |
2180 |
} |
} |
2181 |
|
|
2182 |
|
|
2183 |
// Update the recent files list and menu. |
// Update the recent files list and menu. |
2184 |
void MainForm::updateRecentFiles ( const QString& sFilename ) |
void MainForm::updateRecentFiles ( const QString& sFilename ) |
2185 |
{ |
{ |
2226 |
void MainForm::updateInstrumentNames (void) |
void MainForm::updateInstrumentNames (void) |
2227 |
{ |
{ |
2228 |
// Full channel list update... |
// Full channel list update... |
2229 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList(); |
2230 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
2231 |
return; |
return; |
2232 |
|
|
2233 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2234 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) { |
2235 |
ChannelStrip *pChannelStrip = (ChannelStrip *) wlist.at(iChannel); |
ChannelStrip *pChannelStrip = (ChannelStrip *) wlist.at(iChannel); |
2236 |
if (pChannelStrip) |
if (pChannelStrip) |
2237 |
pChannelStrip->updateInstrumentName(true); |
pChannelStrip->updateInstrumentName(true); |
2255 |
return; |
return; |
2256 |
|
|
2257 |
// Full channel list update... |
// Full channel list update... |
2258 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList(); |
2259 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
2260 |
return; |
return; |
2261 |
|
|
2262 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2263 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) { |
2264 |
ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
ChannelStrip *pChannelStrip = NULL; |
2265 |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel); |
2266 |
|
if (pMdiSubWindow) |
2267 |
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
2268 |
if (pChannelStrip) |
if (pChannelStrip) |
2269 |
pChannelStrip->setDisplayFont(font); |
pChannelStrip->setDisplayFont(font); |
2270 |
} |
} |
2276 |
void MainForm::updateDisplayEffect (void) |
void MainForm::updateDisplayEffect (void) |
2277 |
{ |
{ |
2278 |
// Full channel list update... |
// Full channel list update... |
2279 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList(); |
2280 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
2281 |
return; |
return; |
2282 |
|
|
2283 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2284 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) { |
2285 |
ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
ChannelStrip *pChannelStrip = NULL; |
2286 |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel); |
2287 |
|
if (pMdiSubWindow) |
2288 |
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
2289 |
if (pChannelStrip) |
if (pChannelStrip) |
2290 |
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
pChannelStrip->setDisplayEffect(m_pOptions->bDisplayEffect); |
2291 |
} |
} |
2307 |
#endif |
#endif |
2308 |
|
|
2309 |
// Full channel list update... |
// Full channel list update... |
2310 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList(); |
2311 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
2312 |
return; |
return; |
2313 |
|
|
2314 |
m_pWorkspace->setUpdatesEnabled(false); |
m_pWorkspace->setUpdatesEnabled(false); |
2315 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) { |
2316 |
ChannelStrip* pChannelStrip = (ChannelStrip*) wlist.at(iChannel); |
ChannelStrip *pChannelStrip = NULL; |
2317 |
|
QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel); |
2318 |
|
if (pMdiSubWindow) |
2319 |
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
2320 |
if (pChannelStrip) |
if (pChannelStrip) |
2321 |
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
pChannelStrip->setMaxVolume(m_pOptions->iMaxVolume); |
2322 |
} |
} |
2424 |
// qsamplerMainForm -- MDI channel strip management. |
// qsamplerMainForm -- MDI channel strip management. |
2425 |
|
|
2426 |
// The channel strip creation executive. |
// The channel strip creation executive. |
2427 |
ChannelStrip* MainForm::createChannelStrip ( Channel *pChannel ) |
ChannelStrip *MainForm::createChannelStrip ( Channel *pChannel ) |
2428 |
{ |
{ |
2429 |
if (m_pClient == NULL || pChannel == NULL) |
if (m_pClient == NULL || pChannel == NULL) |
2430 |
return NULL; |
return NULL; |
2447 |
} |
} |
2448 |
|
|
2449 |
// Add it to workspace... |
// Add it to workspace... |
2450 |
m_pWorkspace->addWindow(pChannelStrip, Qt::FramelessWindowHint); |
m_pWorkspace->addSubWindow(pChannelStrip, Qt::FramelessWindowHint); |
2451 |
|
|
2452 |
// Actual channel strip setup... |
// Actual channel strip setup... |
2453 |
pChannelStrip->setup(pChannel); |
pChannelStrip->setup(pChannel); |
2454 |
|
|
2455 |
QObject::connect(pChannelStrip, |
QObject::connect(pChannelStrip, |
2456 |
SIGNAL(channelChanged(ChannelStrip*)), |
SIGNAL(channelChanged(ChannelStrip *)), |
2457 |
SLOT(channelStripChanged(ChannelStrip*))); |
SLOT(channelStripChanged(ChannelStrip *))); |
2458 |
|
|
2459 |
// Now we show up us to the world. |
// Now we show up us to the world. |
2460 |
pChannelStrip->show(); |
pChannelStrip->show(); |
2466 |
return pChannelStrip; |
return pChannelStrip; |
2467 |
} |
} |
2468 |
|
|
2469 |
void MainForm::destroyChannelStrip(ChannelStrip* pChannelStrip) { |
|
2470 |
|
void MainForm::destroyChannelStrip ( ChannelStrip *pChannelStrip ) |
2471 |
|
{ |
2472 |
// Just delete the channel strip. |
// Just delete the channel strip. |
2473 |
delete pChannelStrip; |
delete pChannelStrip; |
2474 |
|
|
2479 |
stabilizeForm(); |
stabilizeForm(); |
2480 |
} |
} |
2481 |
|
|
2482 |
|
|
2483 |
// Retrieve the active channel strip. |
// Retrieve the active channel strip. |
2484 |
ChannelStrip* MainForm::activeChannelStrip (void) |
ChannelStrip *MainForm::activeChannelStrip (void) |
2485 |
{ |
{ |
2486 |
return static_cast<ChannelStrip *> (m_pWorkspace->activeWindow()); |
QMdiSubWindow *pMdiSubWindow = m_pWorkspace->activeSubWindow(); |
2487 |
|
if (pMdiSubWindow) |
2488 |
|
return static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
2489 |
|
else |
2490 |
|
return NULL; |
2491 |
} |
} |
2492 |
|
|
2493 |
|
|
2494 |
// Retrieve a channel strip by index. |
// Retrieve a channel strip by index. |
2495 |
ChannelStrip* MainForm::channelStripAt ( int iChannel ) |
ChannelStrip *MainForm::channelStripAt ( int iChannel ) |
2496 |
{ |
{ |
2497 |
if (!m_pWorkspace) return NULL; |
if (!m_pWorkspace) return NULL; |
2498 |
|
|
2499 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList(); |
2500 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
2501 |
return NULL; |
return NULL; |
2502 |
|
|
2503 |
if (iChannel < 0 || iChannel >= wlist.size()) |
if (iChannel < 0 || iChannel >= wlist.size()) |
2504 |
return NULL; |
return NULL; |
2505 |
|
|
2506 |
return dynamic_cast<ChannelStrip *> (wlist.at(iChannel)); |
QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel); |
2507 |
|
if (pMdiSubWindow) |
2508 |
|
return static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
2509 |
|
else |
2510 |
|
return NULL; |
2511 |
} |
} |
2512 |
|
|
2513 |
|
|
2514 |
// Retrieve a channel strip by sampler channel id. |
// Retrieve a channel strip by sampler channel id. |
2515 |
ChannelStrip* MainForm::channelStrip ( int iChannelID ) |
ChannelStrip *MainForm::channelStrip ( int iChannelID ) |
2516 |
{ |
{ |
2517 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList(); |
2518 |
if (wlist.isEmpty()) |
if (wlist.isEmpty()) |
2519 |
return NULL; |
return NULL; |
2520 |
|
|
2521 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) { |
2522 |
ChannelStrip* pChannelStrip |
ChannelStrip *pChannelStrip = NULL; |
2523 |
= static_cast<ChannelStrip*> (wlist.at(iChannel)); |
QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel); |
2524 |
|
if (pMdiSubWindow) |
2525 |
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
2526 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2527 |
Channel *pChannel = pChannelStrip->channel(); |
Channel *pChannel = pChannelStrip->channel(); |
2528 |
if (pChannel && pChannel->channelID() == iChannelID) |
if (pChannel && pChannel->channelID() == iChannelID) |
2542 |
m_ui.channelsMenu->addAction(m_ui.channelsArrangeAction); |
m_ui.channelsMenu->addAction(m_ui.channelsArrangeAction); |
2543 |
m_ui.channelsMenu->addAction(m_ui.channelsAutoArrangeAction); |
m_ui.channelsMenu->addAction(m_ui.channelsAutoArrangeAction); |
2544 |
|
|
2545 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList(); |
2546 |
if (!wlist.isEmpty()) { |
if (!wlist.isEmpty()) { |
2547 |
m_ui.channelsMenu->addSeparator(); |
m_ui.channelsMenu->addSeparator(); |
2548 |
for (int iChannel = 0; iChannel < (int) wlist.count(); iChannel++) { |
for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) { |
2549 |
ChannelStrip* pChannelStrip |
ChannelStrip *pChannelStrip = NULL; |
2550 |
= static_cast<ChannelStrip*> (wlist.at(iChannel)); |
QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel); |
2551 |
|
if (pMdiSubWindow) |
2552 |
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
2553 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2554 |
QAction *pAction = m_ui.channelsMenu->addAction( |
QAction *pAction = m_ui.channelsMenu->addAction( |
2555 |
pChannelStrip->windowTitle(), |
pChannelStrip->windowTitle(), |
2571 |
if (pAction == NULL) |
if (pAction == NULL) |
2572 |
return; |
return; |
2573 |
|
|
2574 |
ChannelStrip* pChannelStrip = channelStripAt(pAction->data().toInt()); |
ChannelStrip *pChannelStrip = channelStripAt(pAction->data().toInt()); |
2575 |
if (pChannelStrip) { |
if (pChannelStrip) { |
2576 |
pChannelStrip->showNormal(); |
pChannelStrip->showNormal(); |
2577 |
pChannelStrip->setFocus(); |
pChannelStrip->setFocus(); |
2632 |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime) { |
if (m_iTimerSlot >= m_pOptions->iAutoRefreshTime) { |
2633 |
m_iTimerSlot = 0; |
m_iTimerSlot = 0; |
2634 |
// Update the channel stream usage for each strip... |
// Update the channel stream usage for each strip... |
2635 |
QWidgetList wlist = m_pWorkspace->windowList(); |
QList<QMdiSubWindow *> wlist = m_pWorkspace->subWindowList(); |
2636 |
for (int iChannel = 0; |
for (int iChannel = 0; iChannel < (int) wlist.count(); ++iChannel) { |
2637 |
iChannel < (int) wlist.count(); iChannel++) { |
ChannelStrip *pChannelStrip = NULL; |
2638 |
ChannelStrip* pChannelStrip |
QMdiSubWindow *pMdiSubWindow = wlist.at(iChannel); |
2639 |
= (ChannelStrip*) wlist.at(iChannel); |
if (pMdiSubWindow) |
2640 |
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
2641 |
if (pChannelStrip && pChannelStrip->isVisible()) |
if (pChannelStrip && pChannelStrip->isVisible()) |
2642 |
pChannelStrip->updateChannelUsage(); |
pChannelStrip->updateChannelUsage(); |
2643 |
} |
} |
2991 |
|
|
2992 |
|
|
2993 |
// Channel strip activation/selection. |
// Channel strip activation/selection. |
2994 |
void MainForm::activateStrip ( QWidget *pWidget ) |
void MainForm::activateStrip ( QMdiSubWindow *pMdiSubWindow ) |
2995 |
{ |
{ |
2996 |
ChannelStrip *pChannelStrip |
ChannelStrip *pChannelStrip = NULL; |
2997 |
= static_cast<ChannelStrip *> (pWidget); |
if (pMdiSubWindow) |
2998 |
|
pChannelStrip = static_cast<ChannelStrip *> (pMdiSubWindow->widget()); |
2999 |
if (pChannelStrip) |
if (pChannelStrip) |
3000 |
pChannelStrip->setSelected(true); |
pChannelStrip->setSelected(true); |
3001 |
|
|