--- qsampler/trunk/src/qsamplerChannelStrip.cpp 2014/05/21 16:56:18 2570 +++ qsampler/trunk/src/qsamplerChannelStrip.cpp 2019/08/13 10:19:32 3555 @@ -1,7 +1,7 @@ // qsamplerChannelStrip.cpp // /**************************************************************************** - Copyright (C) 2004-2014, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2004-2019, rncbc aka Rui Nuno Capela. All rights reserved. Copyright (C) 2007, 2008, 2014 Christian Schoenebeck This program is free software; you can redistribute it and/or @@ -34,7 +34,7 @@ #include #include -#if QT_VERSION >= 0x050000 +#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include #endif @@ -63,11 +63,11 @@ // MIDI activity pixmap common resources. int ChannelStrip::g_iMidiActivityRefCount = 0; -QPixmap *ChannelStrip::g_pMidiActivityLedOn = NULL; -QPixmap *ChannelStrip::g_pMidiActivityLedOff = NULL; +QPixmap *ChannelStrip::g_pMidiActivityLedOn = nullptr; +QPixmap *ChannelStrip::g_pMidiActivityLedOff = nullptr; // Channel strip activation/selection. -ChannelStrip *ChannelStrip::g_pSelectedStrip = NULL; +ChannelStrip *ChannelStrip::g_pSelectedStrip = nullptr; ChannelStrip::ChannelStrip ( QWidget* pParent, Qt::WindowFlags wflags ) : QWidget(pParent, wflags) @@ -75,10 +75,10 @@ m_ui.setupUi(this); // Initialize locals. - m_pChannel = NULL; + m_pChannel = nullptr; m_iDirtyChange = 0; m_iErrorCount = 0; - m_instrumentListPopupMenu = NULL; + m_instrumentListPopupMenu = nullptr; if (++g_iMidiActivityRefCount == 1) { g_pMidiActivityLedOn = new QPixmap(":/images/ledon1.png"); @@ -111,16 +111,16 @@ QObject::connect(m_ui.ChannelSoloPushButton, SIGNAL(toggled(bool)), SLOT(channelSolo(bool))); - QObject::connect(m_ui.VolumeSlider, + QObject::connect(m_ui.ChannelVolumeSlider, SIGNAL(valueChanged(int)), SLOT(volumeChanged(int))); - QObject::connect(m_ui.VolumeSpinBox, + QObject::connect(m_ui.ChannelVolumeSpinBox, SIGNAL(valueChanged(int)), SLOT(volumeChanged(int))); QObject::connect(m_ui.ChannelEditPushButton, SIGNAL(clicked()), SLOT(channelEdit())); - QObject::connect(m_ui.FxPushButton, + QObject::connect(m_ui.ChannelFxPushButton, SIGNAL(clicked()), SLOT(channelFxEdit())); @@ -135,15 +135,15 @@ // Destroy existing channel descriptor. if (m_pChannel) delete m_pChannel; - m_pChannel = NULL; + m_pChannel = nullptr; if (--g_iMidiActivityRefCount == 0) { if (g_pMidiActivityLedOn) delete g_pMidiActivityLedOn; - g_pMidiActivityLedOn = NULL; + g_pMidiActivityLedOn = nullptr; if (g_pMidiActivityLedOff) delete g_pMidiActivityLedOff; - g_pMidiActivityLedOff = NULL; + g_pMidiActivityLedOff = nullptr; } } @@ -151,12 +151,12 @@ // Window drag-n-drop event handlers. void ChannelStrip::dragEnterEvent ( QDragEnterEvent* pDragEnterEvent ) { - if (m_pChannel == NULL) + if (m_pChannel == nullptr) return; bool bAccept = false; - if (pDragEnterEvent->source() == NULL) { + if (pDragEnterEvent->source() == nullptr) { const QMimeData *pMimeData = pDragEnterEvent->mimeData(); if (pMimeData && pMimeData->hasUrls()) { QListIterator iter(pMimeData->urls()); @@ -180,7 +180,7 @@ void ChannelStrip::dropEvent ( QDropEvent* pDropEvent ) { - if (m_pChannel == NULL) + if (m_pChannel == nullptr) return; if (pDropEvent->source()) @@ -237,6 +237,7 @@ return m_ui.EngineNameTextLabel->font(); } + void ChannelStrip::setDisplayFont ( const QFont & font ) { m_ui.EngineNameTextLabel->setFont(font); @@ -272,8 +273,8 @@ void ChannelStrip::setMaxVolume ( int iMaxVolume ) { m_iDirtyChange++; - m_ui.VolumeSlider->setRange(0, iMaxVolume); - m_ui.VolumeSpinBox->setRange(0, iMaxVolume); + m_ui.ChannelVolumeSlider->setRange(0, iMaxVolume); + m_ui.ChannelVolumeSpinBox->setRange(0, iMaxVolume); m_iDirtyChange--; } @@ -281,11 +282,11 @@ // Channel setup dialog slot. bool ChannelStrip::channelSetup (void) { - if (m_pChannel == NULL) + if (m_pChannel == nullptr) return false; // Invoke the channel setup dialog. - bool bResult = m_pChannel->channelSetup(this); + const bool bResult = m_pChannel->channelSetup(this); // Notify that this channel has changed. if (bResult) emit channelChanged(this); @@ -297,11 +298,11 @@ // Channel mute slot. bool ChannelStrip::channelMute ( bool bMute ) { - if (m_pChannel == NULL) + if (m_pChannel == nullptr) return false; // Invoke the channel mute method. - bool bResult = m_pChannel->setChannelMute(bMute); + const bool bResult = m_pChannel->setChannelMute(bMute); // Notify that this channel has changed. if (bResult) emit channelChanged(this); @@ -313,11 +314,11 @@ // Channel solo slot. bool ChannelStrip::channelSolo ( bool bSolo ) { - if (m_pChannel == NULL) + if (m_pChannel == nullptr) return false; // Invoke the channel solo method. - bool bResult = m_pChannel->setChannelSolo(bSolo); + const bool bResult = m_pChannel->setChannelSolo(bSolo); // Notify that this channel has changed. if (bResult) emit channelChanged(this); @@ -329,7 +330,7 @@ // Channel edit slot. void ChannelStrip::channelEdit (void) { - if (m_pChannel == NULL) + if (m_pChannel == nullptr) return; m_pChannel->editChannel(); @@ -363,14 +364,15 @@ return bResult; } + // Channel reset slot. bool ChannelStrip::channelReset (void) { - if (m_pChannel == NULL) + if (m_pChannel == nullptr) return false; // Invoke the channel reset method. - bool bResult = m_pChannel->channelReset(); + const bool bResult = m_pChannel->channelReset(); // Notify that this channel has changed. if (bResult) emit channelChanged(this); @@ -382,7 +384,7 @@ // Update the channel instrument name. bool ChannelStrip::updateInstrumentName ( bool bForce ) { - if (m_pChannel == NULL) + if (m_pChannel == nullptr) return false; // Do we refresh the actual name? @@ -437,12 +439,13 @@ if (!bShowInstrumentPopup && m_instrumentListPopupMenu) { delete m_instrumentListPopupMenu; - m_instrumentListPopupMenu = NULL; + m_instrumentListPopupMenu = nullptr; } return true; } + void ChannelStrip::instrumentListPopupItemClicked ( QAction *action ) { if (!action) return; @@ -454,10 +457,11 @@ } } + // Do the dirty volume change. bool ChannelStrip::updateChannelVolume (void) { - if (m_pChannel == NULL) + if (m_pChannel == nullptr) return false; // Convert... @@ -468,8 +472,8 @@ // Flag it here, to avoid infinite recursion. m_iDirtyChange++; - m_ui.VolumeSlider->setValue(iVolume); - m_ui.VolumeSpinBox->setValue(iVolume); + m_ui.ChannelVolumeSlider->setValue(iVolume); + m_ui.ChannelVolumeSpinBox->setValue(iVolume); m_iDirtyChange--; return true; @@ -479,7 +483,7 @@ // Update whole channel info state. bool ChannelStrip::updateChannelInfo (void) { - if (m_pChannel == NULL) + if (m_pChannel == nullptr) return false; // Check for error limit/recycle... @@ -487,13 +491,13 @@ return true; // Update strip caption. - QString sText = m_pChannel->channelName(); + const QString& sText = m_pChannel->channelName(); setWindowTitle(sText); m_ui.ChannelSetupPushButton->setText('&' + sText); // Check if we're up and connected. - MainForm* pMainForm = MainForm::getInstance(); - if (pMainForm->client() == NULL) + MainForm *pMainForm = MainForm::getInstance(); + if (pMainForm->client() == nullptr) return false; // Read actual channel information. @@ -544,7 +548,7 @@ #ifdef CONFIG_MUTE_SOLO // Mute/Solo button state coloring... - bool bMute = m_pChannel->channelMute(); + const bool bMute = m_pChannel->channelMute(); const QColor& rgbButton = pal.color(QPalette::Button); const QColor& rgbButtonText = pal.color(QPalette::ButtonText); pal.setColor(QPalette::Foreground, rgbFore); @@ -552,7 +556,7 @@ pal.setColor(QPalette::ButtonText, bMute ? Qt::darkYellow : rgbButtonText); m_ui.ChannelMutePushButton->setPalette(pal); m_ui.ChannelMutePushButton->setDown(bMute); - bool bSolo = m_pChannel->channelSolo(); + const bool bSolo = m_pChannel->channelSolo(); pal.setColor(QPalette::Button, bSolo ? Qt::cyan : rgbButton); pal.setColor(QPalette::ButtonText, bSolo ? Qt::darkCyan : rgbButtonText); m_ui.ChannelSoloPushButton->setPalette(pal); @@ -571,11 +575,11 @@ // Update whole channel usage state. bool ChannelStrip::updateChannelUsage (void) { - if (m_pChannel == NULL) + if (m_pChannel == nullptr) return false; MainForm *pMainForm = MainForm::getInstance(); - if (pMainForm->client() == NULL) + if (pMainForm->client() == nullptr) return false; // This only makes sense on fully loaded channels... @@ -583,16 +587,16 @@ return false; // Get current channel voice count. - int iVoiceCount = ::lscp_get_channel_voice_count( + const int iVoiceCount = ::lscp_get_channel_voice_count( pMainForm->client(), m_pChannel->channelID()); -// Get current stream count. - int iStreamCount = ::lscp_get_channel_stream_count( + // Get current stream count. + const int iStreamCount = ::lscp_get_channel_stream_count( pMainForm->client(), m_pChannel->channelID()); // Get current channel buffer fill usage. // As benno has suggested this is the percentage usage // of the least filled buffer stream... - int iStreamUsage = ::lscp_get_channel_stream_usage( - pMainForm->client(), m_pChannel->channelID());; + const int iStreamUsage = ::lscp_get_channel_stream_usage( + pMainForm->client(), m_pChannel->channelID()); // Update the GUI elements... m_ui.StreamUsageProgressBar->setValue(iStreamUsage); @@ -607,7 +611,7 @@ // Volume change slot. void ChannelStrip::volumeChanged ( int iVolume ) { - if (m_pChannel == NULL) + if (m_pChannel == nullptr) return; // Avoid recursion. @@ -630,7 +634,7 @@ // Context menu event handler. void ChannelStrip::contextMenuEvent( QContextMenuEvent *pEvent ) { - if (m_pChannel == NULL) + if (m_pChannel == nullptr) return; // We'll just show up the main form's edit menu (thru qsamplerChannel). @@ -669,16 +673,19 @@ g_pSelectedStrip = this; } else { if (g_pSelectedStrip == this) - g_pSelectedStrip = NULL; + g_pSelectedStrip = nullptr; } QPalette pal; if (bSelected) { const QColor& color = pal.midlight().color(); - pal.setColor(QPalette::Background, color.dark(150)); - pal.setColor(QPalette::Foreground, color.light(150)); + pal.setColor(QPalette::Background, color.darker(150)); + pal.setColor(QPalette::Foreground, color.lighter(150)); } - QWidget::setPalette(pal); + + QWidget *pParentWidget = QWidget::parentWidget(); + if (pParentWidget) + pParentWidget->setPalette(pal); }