--- qsampler/trunk/src/qsamplerChannelStrip.cpp 2014/05/20 20:04:19 2569 +++ qsampler/trunk/src/qsamplerChannelStrip.cpp 2016/08/16 15:34:45 2979 @@ -1,7 +1,7 @@ // qsamplerChannelStrip.cpp // /**************************************************************************** - Copyright (C) 2004-2014, rncbc aka Rui Nuno Capela. All rights reserved. + Copyright (C) 2004-2016, 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 @@ -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())); @@ -237,12 +237,12 @@ return m_ui.EngineNameTextLabel->font(); } + void ChannelStrip::setDisplayFont ( const QFont & font ) { m_ui.EngineNameTextLabel->setFont(font); m_ui.MidiPortChannelTextLabel->setFont(font); m_ui.InstrumentNamePushButton->setFont(font); - m_ui.InstrumentNamePushButton->setFont(font); m_ui.InstrumentStatusTextLabel->setFont(font); } @@ -256,6 +256,7 @@ m_ui.EngineNameTextLabel->setPalette(pal); m_ui.MidiPortChannelTextLabel->setPalette(pal); pal.setColor(QPalette::Foreground, Qt::green); + pal.setColor(QPalette::ButtonText, Qt::green); if (bDisplayEffect) { QPixmap pm(":/images/displaybg1.png"); pal.setBrush(QPalette::Background, QBrush(pm)); @@ -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--; } @@ -285,7 +286,7 @@ 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); @@ -301,7 +302,7 @@ 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); @@ -317,7 +318,7 @@ 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); @@ -363,6 +364,7 @@ return bResult; } + // Channel reset slot. bool ChannelStrip::channelReset (void) { @@ -370,7 +372,7 @@ 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); @@ -407,30 +409,30 @@ // Instrument list popup (for fast switching among sounds of the same file) if (!m_pChannel->instrumentFile().isEmpty()) { - QStringList instruments = Channel::getInstrumentList( - m_pChannel->instrumentFile(), true - ); + const QStringList instruments + = Channel::getInstrumentList(m_pChannel->instrumentFile(), true); if (!instruments.isEmpty()) { bShowInstrumentPopup = true; if (!m_instrumentListPopupMenu) { - m_instrumentListPopupMenu = new QMenu(m_ui.InstrumentNamePushButton); + m_instrumentListPopupMenu + = new QMenu(m_ui.InstrumentNamePushButton); m_instrumentListPopupMenu->setTitle(tr("Instruments")); - m_instrumentListPopupMenu->setMinimumWidth(118); // for cosmetical reasons, should have at least the width of the instrument name label + // for cosmetical reasons, should have at least + // the width of the instrument name label... + m_instrumentListPopupMenu->setMinimumWidth(120); m_ui.InstrumentNamePushButton->setMenu(m_instrumentListPopupMenu); - QObject::connect( - m_instrumentListPopupMenu, SIGNAL(triggered(QAction*)), - this, SLOT(instrumentListPopupItemClicked(QAction*)) - ); - } else m_instrumentListPopupMenu->clear(); - + QObject::connect(m_instrumentListPopupMenu, + SIGNAL(triggered(QAction*)), + SLOT(instrumentListPopupItemClicked(QAction *))); + } else { + m_instrumentListPopupMenu->clear(); + } + QAction *action; for (int i = 0; i < instruments.size(); ++i) { - QAction* action = - m_instrumentListPopupMenu->addAction(instruments.at(i)); + action = m_instrumentListPopupMenu->addAction(instruments.at(i)); action->setData(i); - if (i == m_pChannel->instrumentNr()) { - action->setCheckable(true); - action->setChecked(true); - } + action->setCheckable(true); + action->setChecked(i == m_pChannel->instrumentNr()); } } } @@ -443,7 +445,8 @@ return true; } -void ChannelStrip::instrumentListPopupItemClicked (QAction* action) + +void ChannelStrip::instrumentListPopupItemClicked ( QAction *action ) { if (!action) return; @@ -454,6 +457,7 @@ } } + // Do the dirty volume change. bool ChannelStrip::updateChannelVolume (void) { @@ -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; @@ -487,12 +491,12 @@ 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(); + MainForm *pMainForm = MainForm::getInstance(); if (pMainForm->client() == NULL) return false; @@ -524,7 +528,7 @@ const QColor& rgbFore = pal.color(QPalette::Foreground); // Instrument status... - int iInstrumentStatus = m_pChannel->instrumentStatus(); + const int iInstrumentStatus = m_pChannel->instrumentStatus(); if (iInstrumentStatus < 0) { pal.setColor(QPalette::Foreground, Qt::red); m_ui.InstrumentStatusTextLabel->setPalette(pal); @@ -533,6 +537,7 @@ m_iErrorCount++; return false; } + // All seems normal... pal.setColor(QPalette::Foreground, iInstrumentStatus < 100 ? Qt::yellow : Qt::green); @@ -543,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); @@ -551,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); @@ -582,15 +587,15 @@ 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( + const int iStreamUsage = ::lscp_get_channel_stream_usage( pMainForm->client(), m_pChannel->channelID());; // Update the GUI elements... @@ -677,7 +682,10 @@ pal.setColor(QPalette::Background, color.dark(150)); pal.setColor(QPalette::Foreground, color.light(150)); } - QWidget::setPalette(pal); + + QWidget *pParentWidget = QWidget::parentWidget(); + if (pParentWidget) + pParentWidget->setPalette(pal); }