From cabb9f349e28b90eedcabfa8501a18c726ae18cc Mon Sep 17 00:00:00 2001 From: sakertooth Date: Wed, 20 Sep 2023 18:58:06 -0400 Subject: [PATCH 01/35] Replace knobFModel with std::vector --- plugins/VstEffect/VstEffectControls.cpp | 17 ++++++----------- plugins/VstEffect/VstEffectControls.h | 2 +- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/plugins/VstEffect/VstEffectControls.cpp b/plugins/VstEffect/VstEffectControls.cpp index cf0c831a6b8..200ed7a18c7 100644 --- a/plugins/VstEffect/VstEffectControls.cpp +++ b/plugins/VstEffect/VstEffectControls.cpp @@ -50,7 +50,6 @@ VstEffectControls::VstEffectControls( VstEffect * _eff ) : EffectControls( _eff ), m_effect( _eff ), m_subWindow( nullptr ), - knobFModel( nullptr ), ctrHandle( nullptr ), lastPosInMenu (0), m_vstGuiVisible ( true ) @@ -84,7 +83,7 @@ void VstEffectControls::loadSettings( const QDomElement & _this ) const QMap & dump = m_effect->m_plugin->parameterDump(); paramCount = dump.size(); auto paramStr = std::array{}; - knobFModel = new FloatModel *[ paramCount ]; + knobFModel.resize(paramCount); QStringList s_dumpValues; for( int i = 0; i < paramCount; i++ ) { @@ -131,7 +130,7 @@ void VstEffectControls::saveSettings( QDomDocument & _doc, QDomElement & _this ) if( m_effect->m_plugin != nullptr ) { m_effect->m_plugin->saveSettings( _doc, _this ); - if (knobFModel != nullptr) { + if (!knobFModel.empty()) { const QMap & dump = m_effect->m_plugin->parameterDump(); paramCount = dump.size(); auto paramStr = std::array{}; @@ -376,8 +375,9 @@ ManageVSTEffectView::ManageVSTEffectView( VstEffect * _eff, VstEffectControls * vstKnobs = new CustomTextKnob *[ m_vi->paramCount ]; bool hasKnobModel = true; - if (m_vi->knobFModel == nullptr) { - m_vi->knobFModel = new FloatModel *[ m_vi->paramCount ]; + if (m_vi->knobFModel.empty()) + { + m_vi->knobFModel.resize(m_vi->paramCount); hasKnobModel = false; } @@ -543,7 +543,7 @@ void ManageVSTEffectView::syncParameterText() ManageVSTEffectView::~ManageVSTEffectView() { - if( m_vi2->knobFModel != nullptr ) + if (!m_vi2->knobFModel.empty()) { for( int i = 0; i < m_vi2->paramCount; i++ ) { @@ -558,11 +558,6 @@ ManageVSTEffectView::~ManageVSTEffectView() vstKnobs = nullptr; } - if( m_vi2->knobFModel != nullptr ) - { - delete [] m_vi2->knobFModel; - m_vi2->knobFModel = nullptr; - } if( m_vi2->m_scrollArea != nullptr ) { diff --git a/plugins/VstEffect/VstEffectControls.h b/plugins/VstEffect/VstEffectControls.h index 42178b5b645..e2bea36e88c 100644 --- a/plugins/VstEffect/VstEffectControls.h +++ b/plugins/VstEffect/VstEffectControls.h @@ -89,7 +89,7 @@ protected slots: QMdiSubWindow * m_subWindow; QScrollArea * m_scrollArea; - FloatModel ** knobFModel; + std::vector knobFModel; int paramCount; QObject * ctrHandle; From cb4429586e17c21f5a824b7560d84e48d2f0527d Mon Sep 17 00:00:00 2001 From: sakertooth Date: Wed, 20 Sep 2023 19:02:53 -0400 Subject: [PATCH 02/35] Create QPixmap's on the stack --- plugins/Eq/EqControlsDialog.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/Eq/EqControlsDialog.cpp b/plugins/Eq/EqControlsDialog.cpp index a26fa0db918..4485348faac 100644 --- a/plugins/Eq/EqControlsDialog.cpp +++ b/plugins/Eq/EqControlsDialog.cpp @@ -72,17 +72,17 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) : setBand( 6, &controls->m_highShelfActiveModel, &controls->m_highShelfFreqModel, &controls->m_highShelfResModel, &controls->m_highShelfGainModel, QColor(255 ,255, 255), tr( "High-shelf" ), &controls->m_highShelfPeakL, &controls->m_highShelfPeakR,0,0,0,0,0,0 ); setBand( 7, &controls->m_lpActiveModel, &controls->m_lpFreqModel, &controls->m_lpResModel, 0, QColor(255 ,255, 255), tr( "LP" ) ,0,0,0,0,0, &controls->m_lp12Model, &controls->m_lp24Model, &controls->m_lp48Model); - auto faderBg = new QPixmap(PLUGIN_NAME::getIconPixmap("faderback")); - auto faderLeds = new QPixmap(PLUGIN_NAME::getIconPixmap("faderleds")); - auto faderKnob = new QPixmap(PLUGIN_NAME::getIconPixmap("faderknob")); + auto faderBg = QPixmap(PLUGIN_NAME::getIconPixmap("faderback")); + auto faderLeds = QPixmap(PLUGIN_NAME::getIconPixmap("faderleds")); + auto faderKnob = QPixmap(PLUGIN_NAME::getIconPixmap("faderknob")); - auto GainFaderIn = new EqFader(&controls->m_inGainModel, tr("Input gain"), this, faderBg, faderLeds, faderKnob, + auto GainFaderIn = new EqFader(&controls->m_inGainModel, tr("Input gain"), this, &faderBg, &faderLeds, &faderKnob, &controls->m_inPeakL, &controls->m_inPeakR); GainFaderIn->move( 23, 295 ); GainFaderIn->setDisplayConversion( false ); GainFaderIn->setHintText( tr( "Gain" ), "dBv"); - auto GainFaderOut = new EqFader(&controls->m_outGainModel, tr("Output gain"), this, faderBg, faderLeds, faderKnob, + auto GainFaderOut = new EqFader(&controls->m_outGainModel, tr("Output gain"), this, &faderBg, &faderLeds, &faderKnob, &controls->m_outPeakL, &controls->m_outPeakR); GainFaderOut->move( 453, 295); GainFaderOut->setDisplayConversion( false ); @@ -92,8 +92,8 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) : int distance = 126; for( int i = 1; i < m_parameterWidget->bandCount() - 1; i++ ) { - auto gainFader = new EqFader(m_parameterWidget->getBandModels(i)->gain, tr(""), this, faderBg, faderLeds, - faderKnob, m_parameterWidget->getBandModels(i)->peakL, m_parameterWidget->getBandModels(i)->peakR); + auto gainFader = new EqFader(m_parameterWidget->getBandModels(i)->gain, tr(""), this, &faderBg, &faderLeds, + &faderKnob, m_parameterWidget->getBandModels(i)->peakL, m_parameterWidget->getBandModels(i)->peakR); gainFader->move( distance, 295 ); distance += 44; gainFader->setMinimumHeight(80); From 35b728bfd964f01cfa1c7912eb023f2738749652 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Wed, 20 Sep 2023 20:06:30 -0400 Subject: [PATCH 03/35] Assign parent for QGraphicsScene A call to QGraphicsView::setScene does not make the view take ownership of the scene. --- plugins/Eq/EqParameterWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/Eq/EqParameterWidget.cpp b/plugins/Eq/EqParameterWidget.cpp index b48f0f31760..c56247a6782 100644 --- a/plugins/Eq/EqParameterWidget.cpp +++ b/plugins/Eq/EqParameterWidget.cpp @@ -56,7 +56,7 @@ EqParameterWidget::EqParameterWidget( QWidget *parent, EqControls * controls ) : m_pixelsPerOctave = EqHandle::freqToXPixel( 10000, m_displayWidth ) - EqHandle::freqToXPixel( 5000, m_displayWidth ); //GraphicsScene and GraphicsView stuff - auto scene = new QGraphicsScene(); + auto scene = new QGraphicsScene(this); scene->setSceneRect( 0, 0, m_displayWidth, m_displayHeigth ); auto view = new QGraphicsView(this); view->setStyleSheet( "border-style: none; background: transparent;" ); From c52553bb070c40567616345c81c8331b8d5d0201 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Wed, 20 Sep 2023 20:17:44 -0400 Subject: [PATCH 04/35] Do not allocate QList on the heap --- plugins/Eq/EqParameterWidget.cpp | 87 ++++++++++++++------------------ plugins/Eq/EqParameterWidget.h | 2 +- 2 files changed, 39 insertions(+), 50 deletions(-) diff --git a/plugins/Eq/EqParameterWidget.cpp b/plugins/Eq/EqParameterWidget.cpp index c56247a6782..ceccb669f6b 100644 --- a/plugins/Eq/EqParameterWidget.cpp +++ b/plugins/Eq/EqParameterWidget.cpp @@ -65,22 +65,22 @@ EqParameterWidget::EqParameterWidget( QWidget *parent, EqControls * controls ) : view->setScene( scene ); //adds the handles - m_handleList = new QList; + m_handleList.reserve(bandCount()); for ( int i = 0; i < bandCount(); i++ ) { m_handle = new EqHandle ( i, m_displayWidth, m_displayHeigth ); - m_handleList->append( m_handle ); + m_handleList.append(m_handle); m_handle->setZValue( 1 ); scene->addItem( m_handle ); } //adds the curve widget - m_eqcurve = new EqCurve( m_handleList, m_displayWidth, m_displayHeigth ); + m_eqcurve = new EqCurve(&m_handleList, m_displayWidth, m_displayHeigth); scene->addItem( m_eqcurve ); for ( int i = 0; i < bandCount(); i++ ) { // if the data of handle position has changed update the models - QObject::connect( m_handleList->at( i ) ,SIGNAL( positionChanged() ), this ,SLOT( updateModels() ) ); + QObject::connect(m_handleList.at(i), SIGNAL(positionChanged()), this, SLOT(updateModels())); } } @@ -112,16 +112,13 @@ void EqParameterWidget::updateHandle() m_eqcurve->setModelChanged( true ); for( int i = 0 ; i < bandCount(); i++ ) { - if ( !m_handleList->at( i )->mousePressed() ) //prevents a short circuit between handle and data model + if (!m_handleList.at(i)->mousePressed()) // prevents a short circuit between handle and data model { //sets the band on active if a fader or a knob is moved bool hover = false; // prevents an action if handle is moved for ( int j = 0; j < bandCount(); j++ ) { - if ( m_handleList->at(j)->isMouseHover() ) - { - hover = true; - } + if (m_handleList.at(j)->isMouseHover()) { hover = true; } } if ( !hover ) { @@ -131,17 +128,14 @@ void EqParameterWidget::updateHandle() } changeHandle( i ); } - else - { - m_handleList->at( i )->setHandleActive( m_bands[i].active->value() ); - } + else { m_handleList.at(i)->setHandleActive(m_bands[i].active->value()); } } - if ( m_bands[0].hp12->value() ) m_handleList->at( 0 )->sethp12(); - if ( m_bands[0].hp24->value() ) m_handleList->at( 0 )->sethp24(); - if ( m_bands[0].hp48->value() ) m_handleList->at( 0 )->sethp48(); - if ( m_bands[7].lp12->value() ) m_handleList->at( 7 )->setlp12(); - if ( m_bands[7].lp24->value() ) m_handleList->at( 7 )->setlp24(); - if ( m_bands[7].lp48->value() ) m_handleList->at( 7 )->setlp48(); + if (m_bands[0].hp12->value()) m_handleList.at(0)->sethp12(); + if (m_bands[0].hp24->value()) m_handleList.at(0)->sethp24(); + if (m_bands[0].hp48->value()) m_handleList.at(0)->sethp48(); + if (m_bands[7].lp12->value()) m_handleList.at(7)->setlp12(); + if (m_bands[7].lp24->value()) m_handleList.at(7)->setlp24(); + if (m_bands[7].lp48->value()) m_handleList.at(7)->setlp48(); } @@ -151,7 +145,7 @@ void EqParameterWidget::changeHandle( int i ) { //fill x, y, and bw with data from model float x = EqHandle::freqToXPixel( m_bands[i].freq->value(), m_displayWidth ); - float y = m_handleList->at( i )->y(); + float y = m_handleList.at(i)->y(); //for pass filters there is no gain model if( m_bands[i].gain ) { @@ -164,48 +158,45 @@ void EqParameterWidget::changeHandle( int i ) switch ( i ) { case 0 : - m_handleList->at( i )->setType( EqHandleType::HighPass ); - m_handleList->at( i )->setPos( x, m_displayHeigth / 2 ); + m_handleList.at(i)->setType(EqHandleType::HighPass); + m_handleList.at(i)->setPos(x, m_displayHeigth / 2); break; case 1: - m_handleList->at( i )->setType( EqHandleType::LowShelf ); - m_handleList->at( i )->setPos( x, y ); + m_handleList.at(i)->setType(EqHandleType::LowShelf); + m_handleList.at(i)->setPos(x, y); break; case 2: - m_handleList->at( i )->setType( EqHandleType::Para ); - m_handleList->at( i )->setPos( x, y ); + m_handleList.at(i)->setType(EqHandleType::Para); + m_handleList.at(i)->setPos(x, y); break; case 3: - m_handleList->at( i )->setType( EqHandleType::Para ); - m_handleList->at( i )->setPos( x, y ); + m_handleList.at(i)->setType(EqHandleType::Para); + m_handleList.at(i)->setPos(x, y); break; case 4: - m_handleList->at( i )->setType( EqHandleType::Para ); - m_handleList->at( i )->setPos( x, y ); + m_handleList.at(i)->setType(EqHandleType::Para); + m_handleList.at(i)->setPos(x, y); break; case 5: - m_handleList->at( i )->setType( EqHandleType::Para ); - m_handleList->at( i )->setPos( x, y ); + m_handleList.at(i)->setType(EqHandleType::Para); + m_handleList.at(i)->setPos(x, y); break; case 6: - m_handleList->at( i )->setType( EqHandleType::HighShelf ); - m_handleList->at( i )->setPos( x, y ); + m_handleList.at(i)->setType(EqHandleType::HighShelf); + m_handleList.at(i)->setPos(x, y); break; case 7: - m_handleList->at( i )->setType( EqHandleType::LowPass ); - m_handleList->at( i )->setPos( QPointF( x, m_displayHeigth / 2 ) ); + m_handleList.at(i)->setType(EqHandleType::LowPass); + m_handleList.at(i)->setPos(QPointF(x, m_displayHeigth / 2)); break; } // set resonance/bandwidth for each handle - if ( m_handleList->at( i )->getResonance() != bw ) - { - m_handleList->at( i )->setResonance( bw ); - } + if (m_handleList.at(i)->getResonance() != bw) { m_handleList.at(i)->setResonance(bw); } // and the active status - m_handleList->at( i )->setHandleActive( m_bands[i].active->value() ); - m_handleList->at( i )->update(); + m_handleList.at(i)->setHandleActive(m_bands[i].active->value()); + m_handleList.at(i)->update(); m_eqcurve->update(); } @@ -216,19 +207,17 @@ void EqParameterWidget::updateModels() { for ( int i=0 ; i < bandCount(); i++ ) { - m_bands[i].freq->setValue( EqHandle::xPixelToFreq( m_handleList->at( i )->x(), m_displayWidth ) ); + m_bands[i].freq->setValue(EqHandle::xPixelToFreq(m_handleList.at(i)->x(), m_displayWidth)); if( m_bands[i].gain ) { - m_bands[i].gain->setValue( EqHandle::yPixelToGain( m_handleList->at(i)->y(), m_displayHeigth, m_pixelsPerUnitHeight ) ); + m_bands[i].gain->setValue( + EqHandle::yPixelToGain(m_handleList.at(i)->y(), m_displayHeigth, m_pixelsPerUnitHeight)); } - m_bands[i].res->setValue( m_handleList->at( i )->getResonance() ); + m_bands[i].res->setValue(m_handleList.at(i)->getResonance()); //identifies the handle which is moved and set the band active - if ( sender() == m_handleList->at( i ) ) - { - m_bands[i].active->setValue( true ); - } + if (sender() == m_handleList.at(i)) { m_bands[i].active->setValue(true); } } m_eqcurve->update(); } diff --git a/plugins/Eq/EqParameterWidget.h b/plugins/Eq/EqParameterWidget.h index f80499395c7..c3444873bdd 100644 --- a/plugins/Eq/EqParameterWidget.h +++ b/plugins/Eq/EqParameterWidget.h @@ -75,7 +75,7 @@ class EqParameterWidget : public QWidget public: explicit EqParameterWidget( QWidget *parent = 0, EqControls * controls = 0 ); ~EqParameterWidget() override; - QList *m_handleList; + QList m_handleList; const int bandCount() { From 96745ef62dc589143f429101e015b2c4f994b187 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Thu, 21 Sep 2023 17:57:23 -0400 Subject: [PATCH 05/35] Use static QPixmap's The QPixmap's need to be created within the constructor, and not outside where they are defined, since it can't find them otherwise. I'm not too sure why. --- plugins/Eq/EqControlsDialog.cpp | 19 +++++++++++-------- plugins/Eq/EqControlsDialog.h | 3 +++ 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/plugins/Eq/EqControlsDialog.cpp b/plugins/Eq/EqControlsDialog.cpp index 4485348faac..df6fc6c5b4e 100644 --- a/plugins/Eq/EqControlsDialog.cpp +++ b/plugins/Eq/EqControlsDialog.cpp @@ -40,6 +40,9 @@ namespace lmms::gui { +QPixmap EqControlsDialog::s_faderBg; +QPixmap EqControlsDialog::s_faderLeds; +QPixmap EqControlsDialog::s_faderKnob; EqControlsDialog::EqControlsDialog( EqControls *controls ) : @@ -72,17 +75,17 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) : setBand( 6, &controls->m_highShelfActiveModel, &controls->m_highShelfFreqModel, &controls->m_highShelfResModel, &controls->m_highShelfGainModel, QColor(255 ,255, 255), tr( "High-shelf" ), &controls->m_highShelfPeakL, &controls->m_highShelfPeakR,0,0,0,0,0,0 ); setBand( 7, &controls->m_lpActiveModel, &controls->m_lpFreqModel, &controls->m_lpResModel, 0, QColor(255 ,255, 255), tr( "LP" ) ,0,0,0,0,0, &controls->m_lp12Model, &controls->m_lp24Model, &controls->m_lp48Model); - auto faderBg = QPixmap(PLUGIN_NAME::getIconPixmap("faderback")); - auto faderLeds = QPixmap(PLUGIN_NAME::getIconPixmap("faderleds")); - auto faderKnob = QPixmap(PLUGIN_NAME::getIconPixmap("faderknob")); + if (s_faderBg.isNull()) { s_faderBg = QPixmap(PLUGIN_NAME::getIconPixmap("faderback")); } + if (s_faderLeds.isNull()) { s_faderLeds = QPixmap(PLUGIN_NAME::getIconPixmap("faderleds")); } + if (s_faderKnob.isNull()) { s_faderKnob = QPixmap(PLUGIN_NAME::getIconPixmap("faderknob")); } - auto GainFaderIn = new EqFader(&controls->m_inGainModel, tr("Input gain"), this, &faderBg, &faderLeds, &faderKnob, - &controls->m_inPeakL, &controls->m_inPeakR); + auto GainFaderIn = new EqFader(&controls->m_inGainModel, tr("Input gain"), this, &s_faderBg, &s_faderLeds, + &s_faderKnob, &controls->m_inPeakL, &controls->m_inPeakR); GainFaderIn->move( 23, 295 ); GainFaderIn->setDisplayConversion( false ); GainFaderIn->setHintText( tr( "Gain" ), "dBv"); - auto GainFaderOut = new EqFader(&controls->m_outGainModel, tr("Output gain"), this, &faderBg, &faderLeds, &faderKnob, + auto GainFaderOut = new EqFader(&controls->m_outGainModel, tr("Output gain"), this, &s_faderBg, &s_faderLeds, &s_faderKnob, &controls->m_outPeakL, &controls->m_outPeakR); GainFaderOut->move( 453, 295); GainFaderOut->setDisplayConversion( false ); @@ -92,8 +95,8 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) : int distance = 126; for( int i = 1; i < m_parameterWidget->bandCount() - 1; i++ ) { - auto gainFader = new EqFader(m_parameterWidget->getBandModels(i)->gain, tr(""), this, &faderBg, &faderLeds, - &faderKnob, m_parameterWidget->getBandModels(i)->peakL, m_parameterWidget->getBandModels(i)->peakR); + auto gainFader = new EqFader(m_parameterWidget->getBandModels(i)->gain, tr(""), this, &s_faderBg, &s_faderLeds, + &s_faderKnob, m_parameterWidget->getBandModels(i)->peakL, m_parameterWidget->getBandModels(i)->peakR); gainFader->move( distance, 295 ); distance += 44; gainFader->setMinimumHeight(80); diff --git a/plugins/Eq/EqControlsDialog.h b/plugins/Eq/EqControlsDialog.h index 52bb2ae197b..cdf85afbf47 100644 --- a/plugins/Eq/EqControlsDialog.h +++ b/plugins/Eq/EqControlsDialog.h @@ -60,6 +60,9 @@ class EqControlsDialog : public EffectControlDialog EqBand *setBand( int index, BoolModel *active, FloatModel *freq, FloatModel *res, FloatModel *gain, QColor color, QString name, float *peakL, float *peakR, BoolModel *hp12, BoolModel *hp24, BoolModel *hp48, BoolModel *lp12, BoolModel *lp24, BoolModel *lp48 ); int m_originalHeight; + static QPixmap s_faderBg; + static QPixmap s_faderLeds; + static QPixmap s_faderKnob; }; From df8d261ccd307e1192520099bd8a6abaf9cf6156 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Thu, 21 Sep 2023 18:01:25 -0400 Subject: [PATCH 06/35] Clear m_vi2->knobFModel in destructor --- plugins/VstEffect/VstEffectControls.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/VstEffect/VstEffectControls.cpp b/plugins/VstEffect/VstEffectControls.cpp index 200ed7a18c7..af90e46464e 100644 --- a/plugins/VstEffect/VstEffectControls.cpp +++ b/plugins/VstEffect/VstEffectControls.cpp @@ -558,6 +558,7 @@ ManageVSTEffectView::~ManageVSTEffectView() vstKnobs = nullptr; } + m_vi2->knobFModel.clear(); if( m_vi2->m_scrollArea != nullptr ) { From ab1c7f4554a3e59fe93ec734f2899e150cd12212 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 13:12:18 -0400 Subject: [PATCH 07/35] Use local static QPixmap's --- plugins/Eq/EqControlsDialog.cpp | 13 +++++-------- plugins/Eq/EqControlsDialog.h | 3 --- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/plugins/Eq/EqControlsDialog.cpp b/plugins/Eq/EqControlsDialog.cpp index df6fc6c5b4e..6130b6bd75c 100644 --- a/plugins/Eq/EqControlsDialog.cpp +++ b/plugins/Eq/EqControlsDialog.cpp @@ -40,9 +40,6 @@ namespace lmms::gui { -QPixmap EqControlsDialog::s_faderBg; -QPixmap EqControlsDialog::s_faderLeds; -QPixmap EqControlsDialog::s_faderKnob; EqControlsDialog::EqControlsDialog( EqControls *controls ) : @@ -75,12 +72,12 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) : setBand( 6, &controls->m_highShelfActiveModel, &controls->m_highShelfFreqModel, &controls->m_highShelfResModel, &controls->m_highShelfGainModel, QColor(255 ,255, 255), tr( "High-shelf" ), &controls->m_highShelfPeakL, &controls->m_highShelfPeakR,0,0,0,0,0,0 ); setBand( 7, &controls->m_lpActiveModel, &controls->m_lpFreqModel, &controls->m_lpResModel, 0, QColor(255 ,255, 255), tr( "LP" ) ,0,0,0,0,0, &controls->m_lp12Model, &controls->m_lp24Model, &controls->m_lp48Model); - if (s_faderBg.isNull()) { s_faderBg = QPixmap(PLUGIN_NAME::getIconPixmap("faderback")); } - if (s_faderLeds.isNull()) { s_faderLeds = QPixmap(PLUGIN_NAME::getIconPixmap("faderleds")); } - if (s_faderKnob.isNull()) { s_faderKnob = QPixmap(PLUGIN_NAME::getIconPixmap("faderknob")); } + static auto s_faderBg = QPixmap(PLUGIN_NAME::getIconPixmap("faderback")); + static auto s_faderLeds = QPixmap(PLUGIN_NAME::getIconPixmap("faderleds")); + static auto s_faderKnob = QPixmap(PLUGIN_NAME::getIconPixmap("faderknob")); - auto GainFaderIn = new EqFader(&controls->m_inGainModel, tr("Input gain"), this, &s_faderBg, &s_faderLeds, - &s_faderKnob, &controls->m_inPeakL, &controls->m_inPeakR); + auto GainFaderIn = new EqFader(&controls->m_inGainModel, tr("Input gain"), this, &s_faderBg, &s_faderLeds, &s_faderKnob, + &controls->m_inPeakL, &controls->m_inPeakR); GainFaderIn->move( 23, 295 ); GainFaderIn->setDisplayConversion( false ); GainFaderIn->setHintText( tr( "Gain" ), "dBv"); diff --git a/plugins/Eq/EqControlsDialog.h b/plugins/Eq/EqControlsDialog.h index cdf85afbf47..52bb2ae197b 100644 --- a/plugins/Eq/EqControlsDialog.h +++ b/plugins/Eq/EqControlsDialog.h @@ -60,9 +60,6 @@ class EqControlsDialog : public EffectControlDialog EqBand *setBand( int index, BoolModel *active, FloatModel *freq, FloatModel *res, FloatModel *gain, QColor color, QString name, float *peakL, float *peakR, BoolModel *hp12, BoolModel *hp24, BoolModel *hp48, BoolModel *lp12, BoolModel *lp24, BoolModel *lp48 ); int m_originalHeight; - static QPixmap s_faderBg; - static QPixmap s_faderLeds; - static QPixmap s_faderKnob; }; From 7ea957d33abacedf3c7c4028f950d97aca3572f2 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 13:26:45 -0400 Subject: [PATCH 08/35] Do not allocate QPixmap with new in AudioFileProcessor --- plugins/AudioFileProcessor/AudioFileProcessor.cpp | 10 ++-------- plugins/AudioFileProcessor/AudioFileProcessor.h | 1 - 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/plugins/AudioFileProcessor/AudioFileProcessor.cpp b/plugins/AudioFileProcessor/AudioFileProcessor.cpp index a941e773f25..b1520849b4a 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessor.cpp +++ b/plugins/AudioFileProcessor/AudioFileProcessor.cpp @@ -439,19 +439,12 @@ namespace gui { -QPixmap * AudioFileProcessorView::s_artwork = nullptr; AudioFileProcessorView::AudioFileProcessorView( Instrument * _instrument, QWidget * _parent ) : InstrumentViewFixedSize( _instrument, _parent ) { - if( s_artwork == nullptr ) - { - s_artwork = new QPixmap( PLUGIN_NAME::getIconPixmap( - "artwork" ) ); - } - m_openAudioFileButton = new PixmapButton( this ); m_openAudioFileButton->setCursor( QCursor( Qt::PointingHandCursor ) ); m_openAudioFileButton->move( 227, 72 ); @@ -637,7 +630,8 @@ void AudioFileProcessorView::paintEvent( QPaintEvent * ) { QPainter p( this ); - p.drawPixmap( 0, 0, *s_artwork ); + static auto s_artwork = QPixmap{PLUGIN_NAME::getIconPixmap("artwork")}; + p.drawPixmap(0, 0, s_artwork); auto a = castModel(); diff --git a/plugins/AudioFileProcessor/AudioFileProcessor.h b/plugins/AudioFileProcessor/AudioFileProcessor.h index 5fed10862ff..62b7876a477 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessor.h +++ b/plugins/AudioFileProcessor/AudioFileProcessor.h @@ -145,7 +145,6 @@ protected slots: private: virtual void modelChanged(); - static QPixmap * s_artwork; AudioFileProcessorWaveView * m_waveView; Knob * m_ampKnob; From 4ac9170b58e69b0c80905f94fcf9f4d5026c8731 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 13:27:49 -0400 Subject: [PATCH 09/35] Do not allocate QPixmap with new in Nes --- plugins/Nes/Nes.cpp | 9 ++------- plugins/Nes/Nes.h | 1 - 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/plugins/Nes/Nes.cpp b/plugins/Nes/Nes.cpp index a530ac19b3b..af9419c211c 100644 --- a/plugins/Nes/Nes.cpp +++ b/plugins/Nes/Nes.cpp @@ -721,7 +721,6 @@ namespace gui { -QPixmap * NesInstrumentView::s_artwork = nullptr; NesInstrumentView::NesInstrumentView( Instrument * instrument, QWidget * parent ) : @@ -730,12 +729,8 @@ NesInstrumentView::NesInstrumentView( Instrument * instrument, QWidget * parent setAutoFillBackground( true ); QPalette pal; - if( s_artwork == nullptr ) - { - s_artwork = new QPixmap( PLUGIN_NAME::getIconPixmap( "artwork" ) ); - } - - pal.setBrush( backgroundRole(), *s_artwork ); + static auto s_artwork = QPixmap{PLUGIN_NAME::getIconPixmap("artwork")}; + pal.setBrush(backgroundRole(), s_artwork); setPalette( pal ); const int KNOB_Y1 = 24; diff --git a/plugins/Nes/Nes.h b/plugins/Nes/Nes.h index 3ddf0fc9a0d..b4102f31d10 100644 --- a/plugins/Nes/Nes.h +++ b/plugins/Nes/Nes.h @@ -372,7 +372,6 @@ class NesInstrumentView : public InstrumentViewFixedSize Knob * m_masterVolKnob; Knob * m_vibratoKnob; - static QPixmap * s_artwork; }; From 95f35667581cb598885b5713e87cd9f47d5e5593 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 13:38:22 -0400 Subject: [PATCH 10/35] Do not allocate QPixmap with new in Organic --- plugins/Organic/Organic.cpp | 11 ++--------- plugins/Organic/Organic.h | 1 - 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/plugins/Organic/Organic.cpp b/plugins/Organic/Organic.cpp index f8a2b0d135c..eb1bc6bda49 100644 --- a/plugins/Organic/Organic.cpp +++ b/plugins/Organic/Organic.cpp @@ -60,7 +60,6 @@ Plugin::Descriptor PLUGIN_EXPORT organic_plugin_descriptor = } -QPixmap * gui::OrganicInstrumentView::s_artwork = nullptr; float * OrganicInstrument::s_harmonics = nullptr; /*********************************************************************** @@ -422,8 +421,8 @@ OrganicInstrumentView::OrganicInstrumentView( Instrument * _instrument, setAutoFillBackground( true ); QPalette pal; - pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( - "artwork" ) ); + static auto s_artwork = QPixmap{PLUGIN_NAME::getIconPixmap("artwork")}; + pal.setBrush(backgroundRole(), s_artwork); setPalette( pal ); // setup knob for FX1 @@ -453,12 +452,6 @@ OrganicInstrumentView::OrganicInstrumentView( Instrument * _instrument, oi, SLOT( randomiseSettings() ) ); - if( s_artwork == nullptr ) - { - s_artwork = new QPixmap( PLUGIN_NAME::getIconPixmap( - "artwork" ) ); - } - } diff --git a/plugins/Organic/Organic.h b/plugins/Organic/Organic.h index 6c53e84ec06..a46b7882ffa 100644 --- a/plugins/Organic/Organic.h +++ b/plugins/Organic/Organic.h @@ -227,7 +227,6 @@ class OrganicInstrumentView : public InstrumentViewFixedSize int m_numOscillators; - static QPixmap * s_artwork; protected slots: void updateKnobHint(); From 3c6b8c0e4b27831a5a54caee92a3f1472786fc54 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 13:49:29 -0400 Subject: [PATCH 11/35] Do not allocate QPixmap with new in SaControlsDialog --- plugins/SpectrumAnalyzer/SaControlsDialog.cpp | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp index eb09c793a9f..2e2d1a8d923 100644 --- a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp +++ b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp @@ -89,28 +89,28 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // pause and freeze buttons auto pauseButton = new PixmapButton(this, tr("Pause")); pauseButton->setToolTip(tr("Pause data acquisition")); - auto pauseOnPixmap = new QPixmap( + static auto s_pauseOnPixmap = QPixmap( PLUGIN_NAME::getIconPixmap("play").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - auto pauseOffPixmap = new QPixmap( + static auto s_pauseOffPixmap = QPixmap( PLUGIN_NAME::getIconPixmap("pause").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - pauseOnPixmap->setDevicePixelRatio(devicePixelRatio()); - pauseOffPixmap->setDevicePixelRatio(devicePixelRatio()); - pauseButton->setActiveGraphic(*pauseOnPixmap); - pauseButton->setInactiveGraphic(*pauseOffPixmap); + s_pauseOnPixmap.setDevicePixelRatio(devicePixelRatio()); + s_pauseOffPixmap.setDevicePixelRatio(devicePixelRatio()); + pauseButton->setActiveGraphic(s_pauseOnPixmap); + pauseButton->setInactiveGraphic(s_pauseOffPixmap); pauseButton->setCheckable(true); pauseButton->setModel(&controls->m_pauseModel); config_layout->addWidget(pauseButton, 0, 0, 2, 1, Qt::AlignHCenter); auto refFreezeButton = new PixmapButton(this, tr("Reference freeze")); refFreezeButton->setToolTip(tr("Freeze current input as a reference / disable falloff in peak-hold mode.")); - auto freezeOnPixmap = new QPixmap( + static auto s_freezeOnPixmap = QPixmap( PLUGIN_NAME::getIconPixmap("freeze").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - auto freezeOffPixmap = new QPixmap( + static auto s_freezeOffPixmap = QPixmap( PLUGIN_NAME::getIconPixmap("freeze_off").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - freezeOnPixmap->setDevicePixelRatio(devicePixelRatio()); - freezeOffPixmap->setDevicePixelRatio(devicePixelRatio()); - refFreezeButton->setActiveGraphic(*freezeOnPixmap); - refFreezeButton->setInactiveGraphic(*freezeOffPixmap); + s_freezeOnPixmap.setDevicePixelRatio(devicePixelRatio()); + s_freezeOffPixmap.setDevicePixelRatio(devicePixelRatio()); + refFreezeButton->setActiveGraphic(s_freezeOnPixmap); + refFreezeButton->setInactiveGraphic(s_freezeOffPixmap); refFreezeButton->setCheckable(true); refFreezeButton->setModel(&controls->m_refFreezeModel); config_layout->addWidget(refFreezeButton, 2, 0, 2, 1, Qt::AlignHCenter); @@ -147,14 +147,14 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // frequency: linear / log. switch and range selector auto logXButton = new PixmapButton(this, tr("Logarithmic frequency")); logXButton->setToolTip(tr("Switch between logarithmic and linear frequency scale")); - auto logXOnPixmap = new QPixmap( + static auto s_logXOnPixmap = QPixmap( PLUGIN_NAME::getIconPixmap("x_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - auto logXOffPixmap = new QPixmap( + static auto s_logXOffPixmap = QPixmap( PLUGIN_NAME::getIconPixmap("x_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - logXOnPixmap->setDevicePixelRatio(devicePixelRatio()); - logXOffPixmap->setDevicePixelRatio(devicePixelRatio()); - logXButton->setActiveGraphic(*logXOnPixmap); - logXButton->setInactiveGraphic(*logXOffPixmap); + s_logXOnPixmap.setDevicePixelRatio(devicePixelRatio()); + s_logXOffPixmap.setDevicePixelRatio(devicePixelRatio()); + logXButton->setActiveGraphic(s_logXOnPixmap); + logXButton->setInactiveGraphic(s_logXOffPixmap); logXButton->setCheckable(true); logXButton->setModel(&controls->m_logXModel); config_layout->addWidget(logXButton, 0, 2, 2, 1, Qt::AlignRight); @@ -169,14 +169,14 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // amplitude: linear / log switch and range selector auto logYButton = new PixmapButton(this, tr("Logarithmic amplitude")); logYButton->setToolTip(tr("Switch between logarithmic and linear amplitude scale")); - auto logYOnPixmap = new QPixmap( + static auto s_logYOnPixmap = QPixmap( PLUGIN_NAME::getIconPixmap("y_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - auto logYOffPixmap = new QPixmap( + static auto s_logYOffPixmap = QPixmap( PLUGIN_NAME::getIconPixmap("y_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - logYOnPixmap->setDevicePixelRatio(devicePixelRatio()); - logYOffPixmap->setDevicePixelRatio(devicePixelRatio()); - logYButton->setActiveGraphic(*logYOnPixmap); - logYButton->setInactiveGraphic(*logYOffPixmap); + s_logYOnPixmap.setDevicePixelRatio(devicePixelRatio()); + s_logYOffPixmap.setDevicePixelRatio(devicePixelRatio()); + logYButton->setActiveGraphic(s_logYOnPixmap); + logYButton->setInactiveGraphic(s_logYOffPixmap); logYButton->setCheckable(true); logYButton->setModel(&controls->m_logYModel); config_layout->addWidget(logYButton, 2, 2, 2, 1, Qt::AlignRight); @@ -190,9 +190,9 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // FFT: block size: icon and selector auto blockSizeLabel = new QLabel("", this); - auto blockSizeIcon = new QPixmap(PLUGIN_NAME::getIconPixmap("block_size")); - blockSizeIcon->setDevicePixelRatio(devicePixelRatio()); - blockSizeLabel->setPixmap(blockSizeIcon->scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + static auto s_blockSizeIcon = QPixmap(PLUGIN_NAME::getIconPixmap("block_size")); + s_blockSizeIcon.setDevicePixelRatio(devicePixelRatio()); + blockSizeLabel->setPixmap(s_blockSizeIcon.scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); config_layout->addWidget(blockSizeLabel, 0, 4, 2, 1, Qt::AlignRight); auto blockSizeCombo = new ComboBox(this, tr("FFT block size")); @@ -206,9 +206,9 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // FFT: window type: icon and selector auto windowLabel = new QLabel("", this); - auto windowIcon = new QPixmap(PLUGIN_NAME::getIconPixmap("window")); - windowIcon->setDevicePixelRatio(devicePixelRatio()); - windowLabel->setPixmap(windowIcon->scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + static auto s_windowIcon = QPixmap(PLUGIN_NAME::getIconPixmap("window")); + s_windowIcon.setDevicePixelRatio(devicePixelRatio()); + windowLabel->setPixmap(s_windowIcon.scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); config_layout->addWidget(windowLabel, 2, 4, 2, 1, Qt::AlignRight); auto windowCombo = new ComboBox(this, tr("FFT window type")); @@ -307,14 +307,14 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // Advanced settings button auto advancedButton = new PixmapButton(this, tr("Advanced settings")); advancedButton->setToolTip(tr("Access advanced settings")); - auto advancedOnPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("advanced_on") + static auto s_advancedOnPixmap = QPixmap(PLUGIN_NAME::getIconPixmap("advanced_on") .scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - auto advancedOffPixmap = new QPixmap(PLUGIN_NAME::getIconPixmap("advanced_off") + static auto s_advancedOffPixmap = QPixmap(PLUGIN_NAME::getIconPixmap("advanced_off") .scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - advancedOnPixmap->setDevicePixelRatio(devicePixelRatio()); - advancedOffPixmap->setDevicePixelRatio(devicePixelRatio()); - advancedButton->setActiveGraphic(*advancedOnPixmap); - advancedButton->setInactiveGraphic(*advancedOffPixmap); + s_advancedOnPixmap.setDevicePixelRatio(devicePixelRatio()); + s_advancedOffPixmap.setDevicePixelRatio(devicePixelRatio()); + advancedButton->setActiveGraphic(s_advancedOnPixmap); + advancedButton->setInactiveGraphic(s_advancedOffPixmap); advancedButton->setCheckable(true); controls_layout->addStretch(0); controls_layout->addWidget(advancedButton); From 9e830c3306587f2941bfa0866011321125f9f6e4 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 13:53:14 -0400 Subject: [PATCH 12/35] Do not allocate QPixmap with new in Vestige --- plugins/Vestige/Vestige.cpp | 13 ++----------- plugins/Vestige/Vestige.h | 3 --- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/plugins/Vestige/Vestige.cpp b/plugins/Vestige/Vestige.cpp index dd8e9cbef3b..7f1fb993a5c 100644 --- a/plugins/Vestige/Vestige.cpp +++ b/plugins/Vestige/Vestige.cpp @@ -489,21 +489,11 @@ gui::PluginView * VestigeInstrument::instantiateView( QWidget * _parent ) namespace gui { -QPixmap * VestigeInstrumentView::s_artwork = nullptr; -QPixmap * ManageVestigeInstrumentView::s_artwork = nullptr; - - VestigeInstrumentView::VestigeInstrumentView( Instrument * _instrument, QWidget * _parent ) : InstrumentViewFixedSize( _instrument, _parent ), lastPosInMenu (0) { - if( s_artwork == nullptr ) - { - s_artwork = new QPixmap( PLUGIN_NAME::getIconPixmap( - "artwork" ) ); - } - m_openPluginButton = new PixmapButton( this, "" ); m_openPluginButton->setCheckable( false ); m_openPluginButton->setCursor( Qt::PointingHandCursor ); @@ -885,7 +875,8 @@ void VestigeInstrumentView::paintEvent( QPaintEvent * ) { QPainter p( this ); - p.drawPixmap( 0, 0, *s_artwork ); + static auto s_artwork = QPixmap{PLUGIN_NAME::getIconPixmap("artwork")}; + p.drawPixmap(0, 0, s_artwork); QString plugin_name = ( m_vi->m_plugin != nullptr ) ? m_vi->m_plugin->name()/* + QString::number( diff --git a/plugins/Vestige/Vestige.h b/plugins/Vestige/Vestige.h index f740913ead5..9ac66f74da6 100644 --- a/plugins/Vestige/Vestige.h +++ b/plugins/Vestige/Vestige.h @@ -131,8 +131,6 @@ protected slots: private: - static QPixmap * s_artwork; - VestigeInstrument * m_vi; QWidget *widget; @@ -175,7 +173,6 @@ protected slots: private: virtual void modelChanged(); - static QPixmap * s_artwork; VestigeInstrument * m_vi; From 50e5707e6225541d2864b1aa190006e2114e32b8 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 14:35:22 -0400 Subject: [PATCH 13/35] Do not allocate QPixmap with new for FileBrowser --- include/FileBrowser.h | 8 +-- src/gui/FileBrowser.cpp | 121 ++++++++-------------------------------- 2 files changed, 27 insertions(+), 102 deletions(-) diff --git a/include/FileBrowser.h b/include/FileBrowser.h index eafb827dac5..1f64409edfe 100644 --- a/include/FileBrowser.h +++ b/include/FileBrowser.h @@ -197,14 +197,12 @@ class Directory : public QTreeWidgetItem private: - void initPixmaps(); - bool addItems( const QString & path ); - static QPixmap * s_folderPixmap; - static QPixmap * s_folderOpenedPixmap; - static QPixmap * s_folderLockedPixmap; + QPixmap* folderPixmap; + QPixmap* folderOpenedPixmap; + QPixmap* folderLockedPixmap; //! Directories that lead here //! Initially, this is just set to the current path of a directory diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index 181e67cd749..6cba7159b02 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -958,16 +958,6 @@ void FileBrowserTreeWidget::updateDirectory(QTreeWidgetItem * item ) } } - - - - - -QPixmap * Directory::s_folderPixmap = nullptr; -QPixmap * Directory::s_folderOpenedPixmap = nullptr; -QPixmap * Directory::s_folderLockedPixmap = nullptr; - - Directory::Directory(const QString & filename, const QString & path, const QString & filter ) : QTreeWidgetItem( QStringList( filename ), TypeDirectoryItem ), @@ -975,56 +965,27 @@ Directory::Directory(const QString & filename, const QString & path, m_filter( filter ), m_dirCount( 0 ) { - initPixmaps(); - - setChildIndicatorPolicy( QTreeWidgetItem::ShowIndicator ); - - if( !QDir( fullName() ).isReadable() ) - { - setIcon( 0, *s_folderLockedPixmap ); - } - else - { - setIcon( 0, *s_folderPixmap ); - } -} - - - - -void Directory::initPixmaps() -{ - if( s_folderPixmap == nullptr ) - { - s_folderPixmap = new QPixmap( - embed::getIconPixmap( "folder" ) ); - } + static auto s_folderPixmap = QPixmap{embed::getIconPixmap("folder")}; + static auto s_folderOpenedPixmap = QPixmap{embed::getIconPixmap("folder_opened")}; + static auto s_folderLockedPixmap = QPixmap{embed::getIconPixmap("folder_locked")}; - if( s_folderOpenedPixmap == nullptr ) - { - s_folderOpenedPixmap = new QPixmap( - embed::getIconPixmap( "folder_opened" ) ); - } + folderPixmap = &s_folderPixmap; + folderOpenedPixmap = &s_folderOpenedPixmap; + folderLockedPixmap = &s_folderLockedPixmap; - if( s_folderLockedPixmap == nullptr ) - { - s_folderLockedPixmap = new QPixmap( - embed::getIconPixmap( "folder_locked" ) ); - } + setIcon(0, !QDir{fullName()}.isReadable() ? s_folderLockedPixmap : s_folderPixmap); + setChildIndicatorPolicy( QTreeWidgetItem::ShowIndicator ); } - - - void Directory::update() { if( !isExpanded() ) { - setIcon( 0, *s_folderPixmap ); + setIcon(0, *folderPixmap); return; } - setIcon( 0, *s_folderOpenedPixmap ); + setIcon(0, *folderOpenedPixmap); if( !childCount() ) { m_dirCount = 0; @@ -1123,72 +1084,38 @@ FileItem::FileItem(const QString & name, const QString & path ) : void FileItem::initPixmaps() { - if( s_projectFilePixmap == nullptr ) - { - s_projectFilePixmap = new QPixmap( embed::getIconPixmap( - "project_file", 16, 16 ) ); - } - - if( s_presetFilePixmap == nullptr ) - { - s_presetFilePixmap = new QPixmap( embed::getIconPixmap( - "preset_file", 16, 16 ) ); - } - - if( s_sampleFilePixmap == nullptr ) - { - s_sampleFilePixmap = new QPixmap( embed::getIconPixmap( - "sample_file", 16, 16 ) ); - } - - if ( s_soundfontFilePixmap == nullptr ) - { - s_soundfontFilePixmap = new QPixmap( embed::getIconPixmap( - "soundfont_file", 16, 16 ) ); - } - - if ( s_vstPluginFilePixmap == nullptr ) - { - s_vstPluginFilePixmap = new QPixmap( embed::getIconPixmap( - "vst_plugin_file", 16, 16 ) ); - } - - if( s_midiFilePixmap == nullptr ) - { - s_midiFilePixmap = new QPixmap( embed::getIconPixmap( - "midi_file", 16, 16 ) ); - } - - if( s_unknownFilePixmap == nullptr ) - { - s_unknownFilePixmap = new QPixmap( embed::getIconPixmap( - "unknown_file" ) ); - } + static auto s_projectFilePixmap = QPixmap{embed::getIconPixmap("project_file", 16, 16)}; + static auto s_presetFilePixmap = QPixmap{embed::getIconPixmap("preset_file", 16, 16)}; + static auto s_sampleFilePixmap = QPixmap{embed::getIconPixmap("sample_file", 16, 16)}; + static auto s_soundfontFilePixmap = QPixmap{embed::getIconPixmap("soundfont_file", 16, 16)}; + static auto s_vstPluginFilePixmap = QPixmap{embed::getIconPixmap("vst_plugin_file", 16, 16)}; + static auto s_midiFilePixmap = QPixmap{embed::getIconPixmap("midi_file", 16, 16)}; + static auto s_unknownFilePixmap = QPixmap{embed::getIconPixmap("unknown_file")}; switch( m_type ) { case FileType::Project: - setIcon( 0, *s_projectFilePixmap ); + setIcon(0, s_projectFilePixmap); break; case FileType::Preset: - setIcon( 0, *s_presetFilePixmap ); + setIcon(0, s_presetFilePixmap); break; case FileType::SoundFont: - setIcon( 0, *s_soundfontFilePixmap ); + setIcon(0, s_soundfontFilePixmap); break; case FileType::VstPlugin: - setIcon( 0, *s_vstPluginFilePixmap ); + setIcon(0, s_vstPluginFilePixmap); break; case FileType::Sample: case FileType::Patch: // TODO - setIcon( 0, *s_sampleFilePixmap ); + setIcon(0, s_sampleFilePixmap); break; case FileType::Midi: - setIcon( 0, *s_midiFilePixmap ); + setIcon(0, s_midiFilePixmap); break; case FileType::Unknown: default: - setIcon( 0, *s_unknownFilePixmap ); + setIcon(0, s_unknownFilePixmap); break; } } From fb055c27ce90ef6ce351fb8ec436f91a3ebeb8be Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 14:39:54 -0400 Subject: [PATCH 14/35] Do not allocate QPixmap with new in MixerLine --- include/MixerLine.h | 2 -- src/gui/MixerLine.cpp | 23 ++++------------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/include/MixerLine.h b/include/MixerLine.h index 68a61728c46..655b30ec371 100644 --- a/include/MixerLine.h +++ b/include/MixerLine.h @@ -94,8 +94,6 @@ class MixerLine : public QWidget QColor m_strokeOuterInactive; QColor m_strokeInnerActive; QColor m_strokeInnerInactive; - static QPixmap * s_sendBgArrow; - static QPixmap * s_receiveBgArrow; bool m_inRename; QLineEdit * m_renameLineEdit; QGraphicsView * m_view; diff --git a/src/gui/MixerLine.cpp b/src/gui/MixerLine.cpp index a90f13f833e..53617c12992 100644 --- a/src/gui/MixerLine.cpp +++ b/src/gui/MixerLine.cpp @@ -68,8 +68,6 @@ bool MixerLine::eventFilter( QObject *dist, QEvent *event ) } const int MixerLine::MixerLineHeight = 287; -QPixmap * MixerLine::s_sendBgArrow = nullptr; -QPixmap * MixerLine::s_receiveBgArrow = nullptr; MixerLine::MixerLine( QWidget * _parent, MixerView * _mv, int _channelIndex ) : QWidget( _parent ), @@ -82,15 +80,6 @@ MixerLine::MixerLine( QWidget * _parent, MixerView * _mv, int _channelIndex ) : m_strokeInnerInactive( 0, 0, 0 ), m_inRename( false ) { - if( !s_sendBgArrow ) - { - s_sendBgArrow = new QPixmap( embed::getIconPixmap( "send_bg_arrow", 29, 56 ) ); - } - if( !s_receiveBgArrow ) - { - s_receiveBgArrow = new QPixmap( embed::getIconPixmap( "receive_bg_arrow", 29, 56 ) ); - } - setFixedSize( 33, MixerLineHeight ); setAttribute( Qt::WA_OpaquePaintEvent, true ); setCursor( QCursor( embed::getIconPixmap( "hand" ), 3, 3 ) ); @@ -193,14 +182,10 @@ void MixerLine::drawMixerLine( QPainter* p, const MixerLine *mixerLine, bool isA p->drawRect( 0, 0, width-1, height-1 ); // draw the mixer send background - if( sendToThis ) - { - p->drawPixmap( 2, 0, 29, 56, *s_sendBgArrow ); - } - else if( receiveFromThis ) - { - p->drawPixmap( 2, 0, 29, 56, *s_receiveBgArrow ); - } + + static auto s_sendBgArrow = QPixmap{embed::getIconPixmap("send_bg_arrow", 29, 56)}; + static auto s_receiveBgArrow = QPixmap{embed::getIconPixmap("receive_bg_arrow", 29, 56)}; + p->drawPixmap(2, 0, 29, 56, sendToThis ? s_sendBgArrow : s_receiveBgArrow); } From f539b6afe09744c394927c028eba012523b14b10 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 14:48:09 -0400 Subject: [PATCH 15/35] Do not allocate QPixmap with new in SendButtonIndicator --- include/SendButtonIndicator.h | 4 ++-- src/gui/SendButtonIndicator.cpp | 23 +++++++---------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/include/SendButtonIndicator.h b/include/SendButtonIndicator.h index f1ee2dbca56..d2b65930241 100644 --- a/include/SendButtonIndicator.h +++ b/include/SendButtonIndicator.h @@ -53,8 +53,8 @@ class SendButtonIndicator : public QLabel MixerLine * m_parent; MixerView * m_mv; - static QPixmap * s_qpmOn; - static QPixmap * s_qpmOff; + QPixmap* qpmOn; + QPixmap* qpmOff; FloatModel * getSendModel(); }; diff --git a/src/gui/SendButtonIndicator.cpp b/src/gui/SendButtonIndicator.cpp index cd1996c4564..cf867dc0d10 100644 --- a/src/gui/SendButtonIndicator.cpp +++ b/src/gui/SendButtonIndicator.cpp @@ -8,30 +8,21 @@ namespace lmms::gui { - -QPixmap * SendButtonIndicator::s_qpmOff = nullptr; -QPixmap * SendButtonIndicator::s_qpmOn = nullptr; - SendButtonIndicator:: SendButtonIndicator( QWidget * _parent, MixerLine * _owner, MixerView * _mv) : QLabel( _parent ), m_parent( _owner ), m_mv( _mv ) { - if( ! s_qpmOff ) - { - s_qpmOff = new QPixmap( embed::getIconPixmap( "mixer_send_off", 29, 20 ) ); - } - - if( ! s_qpmOn ) - { - s_qpmOn = new QPixmap( embed::getIconPixmap( "mixer_send_on", 29, 20 ) ); - } - + static auto s_qpmOff = QPixmap{embed::getIconPixmap("mixer_send_off", 29, 20)}; + static auto s_qpmOn = QPixmap{embed::getIconPixmap("mixer_send_on", 29, 20)}; + qpmOff = &s_qpmOff; + qpmOn = &s_qpmOn; + // don't do any initializing yet, because the MixerView and MixerLine // that were passed to this constructor are not done with their constructors // yet. - setPixmap( *s_qpmOff ); + setPixmap(s_qpmOff); } void SendButtonIndicator::mousePressEvent( QMouseEvent * e ) @@ -64,7 +55,7 @@ FloatModel * SendButtonIndicator::getSendModel() void SendButtonIndicator::updateLightStatus() { - setPixmap( getSendModel() == nullptr ? *s_qpmOff : *s_qpmOn ); + setPixmap(!getSendModel() ? *qpmOff : *qpmOn); } From d11ad5d5181144fdae7c29ecce995cf9e251d1fb Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 14:50:22 -0400 Subject: [PATCH 16/35] Do not allocate QPixmap with new in AutomationClipView --- include/AutomationClipView.h | 3 --- src/gui/clips/AutomationClipView.cpp | 9 ++------- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/include/AutomationClipView.h b/include/AutomationClipView.h index a20e2ce2822..bdd2f056872 100644 --- a/include/AutomationClipView.h +++ b/include/AutomationClipView.h @@ -74,9 +74,6 @@ protected slots: QPixmap m_paintPixmap; QStaticText m_staticTextName; - - static QPixmap * s_clip_rec; - void scaleTimemapToFit( float oldMin, float oldMax ); } ; diff --git a/src/gui/clips/AutomationClipView.cpp b/src/gui/clips/AutomationClipView.cpp index 3e0e12b75d0..b39538e5077 100644 --- a/src/gui/clips/AutomationClipView.cpp +++ b/src/gui/clips/AutomationClipView.cpp @@ -44,8 +44,6 @@ namespace lmms::gui { -QPixmap * AutomationClipView::s_clip_rec = nullptr; - AutomationClipView::AutomationClipView( AutomationClip * _clip, TrackView * _parent ) : ClipView( _clip, _parent ), @@ -61,10 +59,6 @@ AutomationClipView::AutomationClipView( AutomationClip * _clip, setToolTip(m_clip->name()); setStyle( QApplication::style() ); - - if( s_clip_rec == nullptr ) { s_clip_rec = new QPixmap( embed::getIconPixmap( - "clip_rec" ) ); } - update(); } @@ -379,7 +373,8 @@ void AutomationClipView::paintEvent( QPaintEvent * ) // recording icon for when recording automation if( m_clip->isRecording() ) { - p.drawPixmap( 1, rect().bottom() - s_clip_rec->height(), *s_clip_rec ); + static auto s_clipRec = QPixmap(embed::getIconPixmap("clip_rec")); + p.drawPixmap(1, rect().bottom() - s_clipRec.height(), s_clipRec); } // clip name From 155757f54cb3a3573784bfdeee661c0122b07381 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 14:55:49 -0400 Subject: [PATCH 17/35] Do not allocate QPixmap with new in MidiClipView --- src/gui/clips/MidiClipView.cpp | 56 +++++++++------------------------- 1 file changed, 14 insertions(+), 42 deletions(-) diff --git a/src/gui/clips/MidiClipView.cpp b/src/gui/clips/MidiClipView.cpp index 79c4cd73d68..ee067e137b2 100644 --- a/src/gui/clips/MidiClipView.cpp +++ b/src/gui/clips/MidiClipView.cpp @@ -56,31 +56,6 @@ MidiClipView::MidiClipView( MidiClip* clip, TrackView* parent ) : { connect( getGUI()->pianoRoll(), SIGNAL(currentMidiClipChanged()), this, SLOT(update())); - - if( s_stepBtnOn0 == nullptr ) - { - s_stepBtnOn0 = new QPixmap( embed::getIconPixmap( - "step_btn_on_0" ) ); - } - - if( s_stepBtnOn200 == nullptr ) - { - s_stepBtnOn200 = new QPixmap( embed::getIconPixmap( - "step_btn_on_200" ) ); - } - - if( s_stepBtnOff == nullptr ) - { - s_stepBtnOff = new QPixmap( embed::getIconPixmap( - "step_btn_off" ) ); - } - - if( s_stepBtnOffLight == nullptr ) - { - s_stepBtnOffLight = new QPixmap( embed::getIconPixmap( - "step_btn_off_light" ) ); - } - update(); setStyle( QApplication::style() ); @@ -584,23 +559,20 @@ void MidiClipView::paintEvent( QPaintEvent * ) m_clip->m_steps ); const int w = width() - 2 * BORDER_WIDTH; + static auto s_stepBtnOn0 = QPixmap{embed::getIconPixmap("step_btn_on_0")}; + static auto s_stepBtnOn200 = QPixmap(embed::getIconPixmap("step_btn_on_200")); + static auto s_stepBtnOff = QPixmap(embed::getIconPixmap("step_btn_off")); + static auto s_stepBtnOffLight = QPixmap{embed::getIconPixmap("step_btn_off_light")}; + // scale step graphics to fit the beat clip length - stepon0 = s_stepBtnOn0->scaled( w / steps, - s_stepBtnOn0->height(), - Qt::IgnoreAspectRatio, - Qt::SmoothTransformation ); - stepon200 = s_stepBtnOn200->scaled( w / steps, - s_stepBtnOn200->height(), - Qt::IgnoreAspectRatio, - Qt::SmoothTransformation ); - stepoff = s_stepBtnOff->scaled( w / steps, - s_stepBtnOff->height(), - Qt::IgnoreAspectRatio, - Qt::SmoothTransformation ); - stepoffl = s_stepBtnOffLight->scaled( w / steps, - s_stepBtnOffLight->height(), - Qt::IgnoreAspectRatio, - Qt::SmoothTransformation ); + stepon0 + = s_stepBtnOn0.scaled(w / steps, s_stepBtnOn0.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + stepon200 = s_stepBtnOn200.scaled( + w / steps, s_stepBtnOn200.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + stepoff + = s_stepBtnOff.scaled(w / steps, s_stepBtnOff.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + stepoffl = s_stepBtnOffLight.scaled( + w / steps, s_stepBtnOffLight.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); for( int it = 0; it < steps; it++ ) // go through all the steps in the beat clip { @@ -608,7 +580,7 @@ void MidiClipView::paintEvent( QPaintEvent * ) // figure out x and y coordinates for step graphic const int x = BORDER_WIDTH + static_cast( it * w / steps ); - const int y = height() - s_stepBtnOff->height() - 1; + const int y = height() - s_stepBtnOff.height() - 1; if( n ) { From 65689f5803d0bfad2798611c97b9ef8cff6cec68 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 15:02:42 -0400 Subject: [PATCH 18/35] Do not allocate QPixmap with new in AutomationEditor --- include/AutomationEditor.h | 12 +++--- src/gui/editors/AutomationEditor.cpp | 61 +++++++++------------------- 2 files changed, 26 insertions(+), 47 deletions(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index ecefa8b26f1..6a1d4e1c7fd 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -170,12 +170,12 @@ protected slots: AutomationEditor( const AutomationEditor & ); ~AutomationEditor() override; - static QPixmap * s_toolDraw; - static QPixmap * s_toolErase; - static QPixmap * s_toolDrawOut; - static QPixmap * s_toolMove; - static QPixmap * s_toolYFlip; - static QPixmap * s_toolXFlip; + QPixmap* toolDraw; + QPixmap* toolErase; + QPixmap* toolDrawOut; + QPixmap* toolMove; + QPixmap* toolYFlip; + QPixmap* toolXFlip; ComboBoxModel m_zoomingXModel; ComboBoxModel m_zoomingYModel; diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index f98066bbaa2..db8c8013a06 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -64,14 +64,6 @@ namespace lmms::gui { - -QPixmap * AutomationEditor::s_toolDraw = nullptr; -QPixmap * AutomationEditor::s_toolErase = nullptr; -QPixmap * AutomationEditor::s_toolDrawOut = nullptr; -QPixmap * AutomationEditor::s_toolMove = nullptr; -QPixmap * AutomationEditor::s_toolYFlip = nullptr; -QPixmap * AutomationEditor::s_toolXFlip = nullptr; - const std::array AutomationEditor::m_zoomXLevels = { 0.125f, 0.25f, 0.5f, 1.0f, 2.0f, 4.0f, 8.0f }; @@ -133,16 +125,10 @@ AutomationEditor::AutomationEditor() : this, SLOT(setQuantization())); m_quantizeModel.setValue( m_quantizeModel.findText( "1/8" ) ); - if (s_toolYFlip == nullptr) - { - s_toolYFlip = new QPixmap( embed::getIconPixmap( - "flip_y" ) ); - } - if (s_toolXFlip == nullptr) - { - s_toolXFlip = new QPixmap( embed::getIconPixmap( - "flip_x" ) ); - } + static auto s_toolYFlip = QPixmap{embed::getIconPixmap("flip_y")}; + static auto s_toolXFlip = QPixmap{embed::getIconPixmap("flip_x")}; + toolYFlip = &s_toolYFlip; + toolXFlip = &s_toolXFlip; // add time-line m_timeLine = new TimeLineWidget( VALUES_WIDTH, 0, m_ppb, @@ -168,22 +154,15 @@ AutomationEditor::AutomationEditor() : SLOT(verScrolled(int))); // init pixmaps - if (s_toolDraw == nullptr) - { - s_toolDraw = new QPixmap(embed::getIconPixmap("edit_draw")); - } - if (s_toolErase == nullptr) - { - s_toolErase= new QPixmap(embed::getIconPixmap("edit_erase")); - } - if (s_toolDrawOut == nullptr) - { - s_toolDrawOut = new QPixmap(embed::getIconPixmap("edit_draw_outvalue")); - } - if (s_toolMove == nullptr) - { - s_toolMove = new QPixmap(embed::getIconPixmap("edit_move")); - } + static auto s_toolDraw = QPixmap{embed::getIconPixmap("edit_draw")}; + static auto s_toolErase = QPixmap{embed::getIconPixmap("edit_erase")}; + static auto s_toolDrawOut = QPixmap{embed::getIconPixmap("edit_draw_outvalue")}; + static auto s_toolMove = QPixmap{embed::getIconPixmap("edit_move")}; + + toolDraw = &s_toolDraw; + toolErase = &s_toolErase; + toolDrawOut = &s_toolDrawOut; + toolMove = &s_toolMove; setCurrentClip(nullptr); @@ -1250,21 +1229,21 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) { case EditMode::Draw: { - if (m_action == Action::EraseValues) { cursor = s_toolErase; } - else if (m_action == Action::MoveValue) { cursor = s_toolMove; } - else { cursor = s_toolDraw; } + if (m_action == Action::EraseValues) { cursor = toolErase; } + else if (m_action == Action::MoveValue) { cursor = toolMove; } + else { cursor = toolDraw; } break; } case EditMode::Erase: { - cursor = s_toolErase; + cursor = toolErase; break; } case EditMode::DrawOutValues: { - if (m_action == Action::ResetOutValues) { cursor = s_toolErase; } - else if (m_action == Action::MoveOutValue) { cursor = s_toolMove; } - else { cursor = s_toolDrawOut; } + if (m_action == Action::ResetOutValues) { cursor = toolErase; } + else if (m_action == Action::MoveOutValue) { cursor = toolMove; } + else { cursor = toolDrawOut; } break; } } From 8382629cae4c2f730e008eaacc1b59311c910ef1 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 15:20:17 -0400 Subject: [PATCH 19/35] Do not allocate QPixmap with new in PianoRoll --- include/PianoRoll.h | 12 +++---- src/gui/editors/PianoRoll.cpp | 68 +++++++++++++++-------------------- 2 files changed, 34 insertions(+), 46 deletions(-) diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 38788180f8f..0e2ebaafc43 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -339,12 +339,12 @@ protected slots: static const int cm_scrollAmtHoriz = 10; static const int cm_scrollAmtVert = 1; - static QPixmap * s_toolDraw; - static QPixmap * s_toolErase; - static QPixmap * s_toolSelect; - static QPixmap * s_toolMove; - static QPixmap * s_toolOpen; - static QPixmap* s_toolKnife; + QPixmap* toolDraw; + QPixmap* toolErase; + QPixmap* toolSelect; + QPixmap* toolMove; + QPixmap* toolOpen; + QPixmap* toolKnife; static std::array prKeyOrder; diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index b3833599583..5f7cae83599 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -119,15 +119,6 @@ const int INITIAL_START_KEY = Octave::Octave_4 + Key::C; const int NUM_EVEN_LENGTHS = 6; const int NUM_TRIPLET_LENGTHS = 5; - - -QPixmap * PianoRoll::s_toolDraw = nullptr; -QPixmap * PianoRoll::s_toolErase = nullptr; -QPixmap * PianoRoll::s_toolSelect = nullptr; -QPixmap * PianoRoll::s_toolMove = nullptr; -QPixmap * PianoRoll::s_toolOpen = nullptr; -QPixmap* PianoRoll::s_toolKnife = nullptr; - SimpleTextFloat * PianoRoll::s_textFloat = nullptr; static std::array s_noteStrings {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"}; @@ -262,30 +253,19 @@ PianoRoll::PianoRoll() : m_semiToneMarkerMenu->addAction( copyAllNotesAction ); // init pixmaps - if( s_toolDraw == nullptr ) - { - s_toolDraw = new QPixmap( embed::getIconPixmap( "edit_draw" ) ); - } - if( s_toolErase == nullptr ) - { - s_toolErase= new QPixmap( embed::getIconPixmap( "edit_erase" ) ); - } - if( s_toolSelect == nullptr ) - { - s_toolSelect = new QPixmap( embed::getIconPixmap( "edit_select" ) ); - } - if( s_toolMove == nullptr ) - { - s_toolMove = new QPixmap( embed::getIconPixmap( "edit_move" ) ); - } - if( s_toolOpen == nullptr ) - { - s_toolOpen = new QPixmap( embed::getIconPixmap( "automation" ) ); - } - if (s_toolKnife == nullptr) - { - s_toolKnife = new QPixmap(embed::getIconPixmap("edit_knife")); - } + static auto s_toolDraw = QPixmap{embed::getIconPixmap("edit_draw")}; + static auto s_toolErase = QPixmap{embed::getIconPixmap("edit_erase")}; + static auto s_toolSelect = QPixmap{embed::getIconPixmap("edit_select")}; + static auto s_toolMove = QPixmap{embed::getIconPixmap("edit_move")}; + static auto s_toolOpen = QPixmap{embed::getIconPixmap("automation")}; + static auto s_toolKnife = QPixmap{embed::getIconPixmap("edit_knife")}; + + toolDraw = &s_toolDraw; + toolErase = &s_toolErase; + toolSelect = &s_toolSelect; + toolMove = &s_toolMove; + toolOpen = &s_toolOpen; + toolOpen = &s_toolKnife; // init text-float if( s_textFloat == nullptr ) @@ -3696,21 +3676,29 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) case EditMode::Draw: if( m_mouseDownRight ) { - cursor = s_toolErase; + cursor = toolErase; } else if( m_action == Action::MoveNote ) { - cursor = s_toolMove; + cursor = toolMove; } else { - cursor = s_toolDraw; + cursor = toolDraw; } break; - case EditMode::Erase: cursor = s_toolErase; break; - case EditMode::Select: cursor = s_toolSelect; break; - case EditMode::Detuning: cursor = s_toolOpen; break; - case EditMode::Knife: cursor = s_toolKnife; break; + case EditMode::Erase: + cursor = toolErase; + break; + case EditMode::Select: + cursor = toolSelect; + break; + case EditMode::Detuning: + cursor = toolOpen; + break; + case EditMode::Knife: + cursor = toolKnife; + break; } QPoint mousePosition = mapFromGlobal( QCursor::pos() ); if( cursor != nullptr && mousePosition.y() > keyAreaTop() && mousePosition.x() > noteEditLeft()) From 55bc30e4d67863801ec9c211c24a287638ae1bf7 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 15:24:28 -0400 Subject: [PATCH 20/35] Do not allocate QPixmap with new in TimeLineWidget --- include/TimeLineWidget.h | 2 +- src/gui/editors/TimeLineWidget.cpp | 28 +++++++++++----------------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/include/TimeLineWidget.h b/include/TimeLineWidget.h index 2e4ba6a97a4..c2a9dbd4564 100644 --- a/include/TimeLineWidget.h +++ b/include/TimeLineWidget.h @@ -205,7 +205,7 @@ public slots: private: - static QPixmap * s_posMarkerPixmap; + QPixmap* posMarkerPixmap; QColor m_inactiveLoopColor; QBrush m_inactiveLoopBrush; diff --git a/src/gui/editors/TimeLineWidget.cpp b/src/gui/editors/TimeLineWidget.cpp index 423485a2589..f75c3ef9021 100644 --- a/src/gui/editors/TimeLineWidget.cpp +++ b/src/gui/editors/TimeLineWidget.cpp @@ -45,9 +45,6 @@ namespace constexpr int MIN_BAR_LABEL_DISTANCE = 35; } - -QPixmap * TimeLineWidget::s_posMarkerPixmap = nullptr; - TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppb, Song::PlayPos & pos, const TimePos & begin, Song::PlayMode mode, QWidget * parent ) : @@ -80,16 +77,13 @@ TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppb, m_loopPos[0] = 0; m_loopPos[1] = DefaultTicksPerBar; - if( s_posMarkerPixmap == nullptr ) - { - s_posMarkerPixmap = new QPixmap( embed::getIconPixmap( - "playpos_marker" ) ); - } + static auto s_posMarkerPixmap = QPixmap{embed::getIconPixmap("playpos_marker")}; + posMarkerPixmap = &s_posMarkerPixmap; setAttribute( Qt::WA_OpaquePaintEvent, true ); move( 0, yoff ); - m_xOffset -= s_posMarkerPixmap->width() / 2; + m_xOffset -= s_posMarkerPixmap.width() / 2; setMouseTracking(true); m_pos.m_timeLine = this; @@ -119,7 +113,7 @@ TimeLineWidget::~TimeLineWidget() void TimeLineWidget::setXOffset(const int x) { m_xOffset = x; - if (s_posMarkerPixmap != nullptr) { m_xOffset -= s_posMarkerPixmap->width() / 2; } + m_xOffset -= posMarkerPixmap->width() / 2; } @@ -245,7 +239,7 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) p.fillRect( 0, 0, width(), height(), p.background() ); // Clip so that we only draw everything starting from the offset - const int leftMargin = m_xOffset + s_posMarkerPixmap->width() / 2; + const int leftMargin = m_xOffset + posMarkerPixmap->width() / 2; p.setClipRect(leftMargin, 0, width() - leftMargin, height() ); // Draw the loop rectangle @@ -273,7 +267,7 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) QColor const & barNumberColor = getBarNumberColor(); bar_t barNumber = m_begin.getBar(); - int const x = m_xOffset + s_posMarkerPixmap->width() / 2 - + int const x = m_xOffset + posMarkerPixmap->width() / 2 - ( ( static_cast( m_begin * m_ppb ) / TimePos::ticksPerBar() ) % static_cast( m_ppb ) ); // Double the interval between bar numbers until they are far enough appart @@ -307,12 +301,12 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) p.drawRect( innerRectangle ); // Only draw the position marker if the position line is in view - if (m_posMarkerX >= m_xOffset && m_posMarkerX < width() - s_posMarkerPixmap->width() / 2) + if (m_posMarkerX >= m_xOffset && m_posMarkerX < width() - posMarkerPixmap->width() / 2) { // Let the position marker extrude to the left p.setClipping(false); p.setOpacity(0.6); - p.drawPixmap(m_posMarkerX, height() - s_posMarkerPixmap->height(), *s_posMarkerPixmap); + p.drawPixmap(m_posMarkerX, height() - posMarkerPixmap->height(), *posMarkerPixmap); } } @@ -328,13 +322,13 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event ) if( event->button() == Qt::LeftButton && !(event->modifiers() & Qt::ShiftModifier) ) { m_action = Action::MovePositionMarker; - if( event->x() - m_xOffset < s_posMarkerPixmap->width() ) + if( event->x() - m_xOffset < posMarkerPixmap->width() ) { m_moveXOff = event->x() - m_xOffset; } else { - m_moveXOff = s_posMarkerPixmap->width() / 2; + m_moveXOff = posMarkerPixmap->width() / 2; } } else if( event->button() == Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier) ) @@ -344,7 +338,7 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event ) } else if( event->button() == Qt::RightButton ) { - m_moveXOff = s_posMarkerPixmap->width() / 2; + m_moveXOff = posMarkerPixmap->width() / 2; const TimePos t = m_begin + static_cast( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * TimePos::ticksPerBar() / m_ppb ); const TimePos loopMid = ( m_loopPos[0] + m_loopPos[1] ) / 2; From 405bec7518fb57e1ad3500394da85f197c0cc997 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 15:28:09 -0400 Subject: [PATCH 21/35] Do not allocate QPixmap with new in EnvelopeAndLfoView --- include/EnvelopeAndLfoView.h | 4 +- src/gui/instrument/EnvelopeAndLfoView.cpp | 45 +++++++---------------- 2 files changed, 16 insertions(+), 33 deletions(-) diff --git a/include/EnvelopeAndLfoView.h b/include/EnvelopeAndLfoView.h index b5c7a67d46c..7515f72e40f 100644 --- a/include/EnvelopeAndLfoView.h +++ b/include/EnvelopeAndLfoView.h @@ -71,8 +71,8 @@ protected slots: private: - static QPixmap * s_envGraph; - static QPixmap * s_lfoGraph; + QPixmap* envGraph; + QPixmap* lfoGraph; EnvelopeAndLfoParameters * m_params; diff --git a/src/gui/instrument/EnvelopeAndLfoView.cpp b/src/gui/instrument/EnvelopeAndLfoView.cpp index edb6c99c797..05c1b831393 100644 --- a/src/gui/instrument/EnvelopeAndLfoView.cpp +++ b/src/gui/instrument/EnvelopeAndLfoView.cpp @@ -79,25 +79,15 @@ const int LFO_AMOUNT_KNOB_X = LFO_SPEED_KNOB_X+KNOB_X_SPACING; const int LFO_SHAPES_X = LFO_GRAPH_X;//PREDELAY_KNOB_X; const int LFO_SHAPES_Y = LFO_GRAPH_Y + 50; - -QPixmap * EnvelopeAndLfoView::s_envGraph = nullptr; -QPixmap * EnvelopeAndLfoView::s_lfoGraph = nullptr; - - - EnvelopeAndLfoView::EnvelopeAndLfoView( QWidget * _parent ) : QWidget( _parent ), ModelView( nullptr, this ), m_params( nullptr ) { - if( s_envGraph == nullptr ) - { - s_envGraph = new QPixmap( embed::getIconPixmap( "envelope_graph" ) ); - } - if( s_lfoGraph == nullptr ) - { - s_lfoGraph = new QPixmap( embed::getIconPixmap( "lfo_graph" ) ); - } + static auto s_envGraph = QPixmap{embed::getIconPixmap("envelope_graph")}; + static auto s_lfoGraph = QPixmap{embed::getIconPixmap("lfo_graph")}; + envGraph = &s_envGraph; + lfoGraph = &s_lfoGraph; m_predelayKnob = new Knob( KnobType::Bright26, this ); m_predelayKnob->setLabel( tr( "DEL" ) ); @@ -277,8 +267,7 @@ void EnvelopeAndLfoView::mousePressEvent( QMouseEvent * _me ) return; } - if( QRect( ENV_GRAPH_X, ENV_GRAPH_Y, s_envGraph->width(), - s_envGraph->height() ).contains( _me->pos() ) == true ) + if (QRect(ENV_GRAPH_X, ENV_GRAPH_Y, envGraph->width(), envGraph->height()).contains(_me->pos())) { if( m_params->m_amountModel.value() < 1.0f ) { @@ -289,8 +278,7 @@ void EnvelopeAndLfoView::mousePressEvent( QMouseEvent * _me ) m_params->m_amountModel.setValue( 0.0f ); } } - else if( QRect( LFO_GRAPH_X, LFO_GRAPH_Y, s_lfoGraph->width(), - s_lfoGraph->height() ).contains( _me->pos() ) == true ) + else if (QRect(LFO_GRAPH_X, LFO_GRAPH_Y, lfoGraph->width(), lfoGraph->height()).contains(_me->pos())) { if( m_params->m_lfoAmountModel.value() < 1.0f ) { @@ -351,10 +339,9 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) p.setRenderHint( QPainter::Antialiasing ); // draw envelope-graph - p.drawPixmap( ENV_GRAPH_X, ENV_GRAPH_Y, *s_envGraph ); + p.drawPixmap(ENV_GRAPH_X, ENV_GRAPH_Y, *envGraph); // draw LFO-graph - p.drawPixmap( LFO_GRAPH_X, LFO_GRAPH_Y, *s_lfoGraph ); - + p.drawPixmap(LFO_GRAPH_X, LFO_GRAPH_Y, *lfoGraph); p.setFont( pointSize<8>( p.font() ) ); @@ -368,8 +355,8 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) const QColor end_points_color( 0x99, 0xAF, 0xFF ); const QColor end_points_bg_color( 0, 0, 2 ); - const int y_base = ENV_GRAPH_Y + s_envGraph->height() - 3; - const int avail_height = s_envGraph->height() - 6; + const int y_base = ENV_GRAPH_Y + envGraph->height() - 3; + const int avail_height = envGraph->height() - 6; int x1 = static_cast( m_predelayKnob->value() * TIME_UNIT_WIDTH ); int x2 = x1 + static_cast( m_attackKnob->value() * TIME_UNIT_WIDTH ); @@ -422,9 +409,8 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) p.fillRect( x5 - 1, y_base - 2, 4, 4, end_points_bg_color ); p.fillRect( x5, y_base - 1, 2, 2, end_points_color ); - - int LFO_GRAPH_W = s_lfoGraph->width() - 3; // subtract border - int LFO_GRAPH_H = s_lfoGraph->height() - 6; // subtract border + int LFO_GRAPH_W = lfoGraph->width() - 3; // subtract border + int LFO_GRAPH_H = lfoGraph->height() - 6; // subtract border int graph_x_base = LFO_GRAPH_X + 2; int graph_y_base = LFO_GRAPH_Y + 3 + LFO_GRAPH_H / 2; @@ -505,11 +491,8 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) int ms_per_osc = static_cast( SECS_PER_LFO_OSCILLATION * m_lfoSpeedKnob->value() * 1000.0f ); - p.drawText( LFO_GRAPH_X + 4, LFO_GRAPH_Y + s_lfoGraph->height() - 6, - tr( "ms/LFO:" ) ); - p.drawText( LFO_GRAPH_X + 52, LFO_GRAPH_Y + s_lfoGraph->height() - 6, - QString::number( ms_per_osc ) ); - + p.drawText(LFO_GRAPH_X + 4, LFO_GRAPH_Y + lfoGraph->height() - 6, tr("ms/LFO:")); + p.drawText(LFO_GRAPH_X + 52, LFO_GRAPH_Y + lfoGraph->height() - 6, QString::number(ms_per_osc)); } From 1ee56a648f339fa8ef17f54c0acf62b8534d2f37 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 15:33:50 -0400 Subject: [PATCH 22/35] Do not allocate QPixmap with new in PianoView --- include/PianoView.h | 12 +++--- src/gui/instrument/PianoView.cpp | 65 +++++++++++--------------------- 2 files changed, 29 insertions(+), 48 deletions(-) diff --git a/include/PianoView.h b/include/PianoView.h index 6421ff4381c..b024f814ee5 100644 --- a/include/PianoView.h +++ b/include/PianoView.h @@ -73,12 +73,12 @@ class PianoView : public QWidget, public ModelView int getKeyHeight(int key_num) const; IntModel *getNearestMarker(int key, QString* title = nullptr); - static QPixmap * s_whiteKeyPm; - static QPixmap * s_blackKeyPm; - static QPixmap * s_whiteKeyPressedPm; - static QPixmap * s_blackKeyPressedPm; - static QPixmap * s_whiteKeyDisabledPm; - static QPixmap * s_blackKeyDisabledPm; + QPixmap* whiteKeyPm; + QPixmap* blackKeyPm; + QPixmap* whiteKeyPressedPm; + QPixmap* blackKeyPressedPm; + QPixmap* whiteKeyDisabledPm; + QPixmap* blackKeyDisabledPm; Piano * m_piano; diff --git a/src/gui/instrument/PianoView.cpp b/src/gui/instrument/PianoView.cpp index d20cbcac52e..04be49b36fe 100644 --- a/src/gui/instrument/PianoView.cpp +++ b/src/gui/instrument/PianoView.cpp @@ -67,15 +67,6 @@ auto WhiteKeys = std::array Key::C, Key::D, Key::E, Key::F, Key::G, Key::A, Key::H } ; - -QPixmap * PianoView::s_whiteKeyPm = nullptr; /*!< A white key released */ -QPixmap * PianoView::s_blackKeyPm = nullptr; /*!< A black key released */ -QPixmap * PianoView::s_whiteKeyPressedPm = nullptr; /*!< A white key pressed */ -QPixmap * PianoView::s_blackKeyPressedPm = nullptr; /*!< A black key pressed */ -QPixmap * PianoView::s_whiteKeyDisabledPm = nullptr; /*!< A white key disabled */ -QPixmap * PianoView::s_blackKeyDisabledPm = nullptr; /*!< A black key disabled */ - - const int PIANO_BASE = 11; /*!< The height of the root note display */ const int PW_WHITE_KEY_WIDTH = 10; /*!< The width of a white key */ const int PW_BLACK_KEY_WIDTH = 8; /*!< The width of a black key */ @@ -99,30 +90,20 @@ PianoView::PianoView(QWidget *parent) : m_lastKey(-1), /*!< The last key displayed? */ m_movedNoteModel(nullptr) /*!< Key marker which is being moved */ { - if (s_whiteKeyPm == nullptr) - { - s_whiteKeyPm = new QPixmap(embed::getIconPixmap("white_key")); - } - if (s_blackKeyPm == nullptr) - { - s_blackKeyPm = new QPixmap(embed::getIconPixmap("black_key")); - } - if (s_whiteKeyPressedPm == nullptr) - { - s_whiteKeyPressedPm = new QPixmap(embed::getIconPixmap("white_key_pressed")); - } - if (s_blackKeyPressedPm == nullptr) - { - s_blackKeyPressedPm = new QPixmap(embed::getIconPixmap("black_key_pressed")); - } - if (s_whiteKeyDisabledPm == nullptr) - { - s_whiteKeyDisabledPm = new QPixmap(embed::getIconPixmap("white_key_disabled")); - } - if (s_blackKeyDisabledPm == nullptr) - { - s_blackKeyDisabledPm = new QPixmap(embed::getIconPixmap("black_key_disabled")); - } + + static auto s_whiteKeyPm = QPixmap{embed::getIconPixmap("white_key")}; + static auto s_blackKeyPm = QPixmap{embed::getIconPixmap("black_key")}; + static auto s_whiteKeyPressedPm = QPixmap{embed::getIconPixmap("white_key_pressed")}; + static auto s_blackKeyPressedPm = QPixmap{embed::getIconPixmap("black_key_pressed")}; + static auto s_whiteKeyDisabledPm = QPixmap{embed::getIconPixmap("white_key_disabled")}; + static auto s_blackKeyDisabledPm = QPixmap{embed::getIconPixmap("black_key_disabled")}; + + whiteKeyPm = &s_whiteKeyPm; + blackKeyPm = &s_blackKeyPm; + whiteKeyPressedPm = &s_whiteKeyPressedPm; + blackKeyPressedPm = &s_blackKeyPressedPm; + whiteKeyDisabledPm = &s_whiteKeyDisabledPm; + blackKeyDisabledPm = &s_blackKeyDisabledPm; setAttribute(Qt::WA_OpaquePaintEvent, true); setFocusPolicy(Qt::StrongFocus); @@ -894,16 +875,16 @@ void PianoView::paintEvent( QPaintEvent * ) { if (m_piano && m_piano->isKeyPressed(cur_key)) { - p.drawPixmap(x, PIANO_BASE, *s_whiteKeyPressedPm); + p.drawPixmap(x, PIANO_BASE, *whiteKeyPressedPm); } else { - p.drawPixmap(x, PIANO_BASE, *s_whiteKeyPm); + p.drawPixmap(x, PIANO_BASE, *whiteKeyPm); } } else { - p.drawPixmap(x, PIANO_BASE, *s_whiteKeyDisabledPm); + p.drawPixmap(x, PIANO_BASE, *whiteKeyDisabledPm); } x += PW_WHITE_KEY_WIDTH; @@ -928,16 +909,16 @@ void PianoView::paintEvent( QPaintEvent * ) { if (m_piano && m_piano->isKeyPressed(startKey)) { - p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyPressedPm); + p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *blackKeyPressedPm); } else { - p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyPm); + p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *blackKeyPm); } } else { - p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyDisabledPm); + p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *blackKeyDisabledPm); } } @@ -951,16 +932,16 @@ void PianoView::paintEvent( QPaintEvent * ) { if (m_piano && m_piano->isKeyPressed(cur_key)) { - p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyPressedPm); + p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *blackKeyPressedPm); } else { - p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyPm); + p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *blackKeyPm); } } else { - p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *s_blackKeyDisabledPm); + p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *blackKeyDisabledPm); } x += PW_WHITE_KEY_WIDTH; white_cnt = 0; From 54b7867c21bfcd067df2881f0a0411250129129d Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 15:40:06 -0400 Subject: [PATCH 23/35] Do not allocate QPixmap with new in ComboBox --- include/ComboBox.h | 6 +++--- src/gui/widgets/ComboBox.cpp | 31 +++++++++---------------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/include/ComboBox.h b/include/ComboBox.h index 8153451e863..22e157ba27f 100644 --- a/include/ComboBox.h +++ b/include/ComboBox.h @@ -66,9 +66,9 @@ public slots: private: - static QPixmap* s_background; - static QPixmap* s_arrow; - static QPixmap* s_arrowSelected; + QPixmap* background; + QPixmap* arrow; + QPixmap* arrowSelected; QMenu m_menu; diff --git a/src/gui/widgets/ComboBox.cpp b/src/gui/widgets/ComboBox.cpp index bdf78ccce36..3166fe5b9c8 100644 --- a/src/gui/widgets/ComboBox.cpp +++ b/src/gui/widgets/ComboBox.cpp @@ -38,11 +38,6 @@ namespace lmms::gui { - -QPixmap * ComboBox::s_background = nullptr; -QPixmap * ComboBox::s_arrow = nullptr; -QPixmap * ComboBox::s_arrowSelected = nullptr; - const int CB_ARROW_BTN_WIDTH = 18; @@ -54,20 +49,12 @@ ComboBox::ComboBox( QWidget * _parent, const QString & _name ) : { setFixedHeight( ComboBox::DEFAULT_HEIGHT ); - if( s_background == nullptr ) - { - s_background = new QPixmap( embed::getIconPixmap( "combobox_bg" ) ); - } - - if( s_arrow == nullptr ) - { - s_arrow = new QPixmap( embed::getIconPixmap( "combobox_arrow" ) ); - } - - if( s_arrowSelected == nullptr ) - { - s_arrowSelected = new QPixmap( embed::getIconPixmap( "combobox_arrow_selected" ) ); - } + static auto s_background = QPixmap{embed::getIconPixmap("combobox_bg")}; + static auto s_arrow = QPixmap{embed::getIconPixmap("combobox_arrow")}; + static auto s_arrowSelected = QPixmap{embed::getIconPixmap("combobox_arrow_selected")}; + background = &s_background; + arrow = &s_arrow; + arrowSelected = &s_arrowSelected; setFont( pointSize<9>( font() ) ); m_menu.setFont( pointSize<8>( m_menu.font() ) ); @@ -173,7 +160,7 @@ void ComboBox::paintEvent( QPaintEvent * _pe ) { QPainter p( this ); - p.fillRect( 2, 2, width()-2, height()-4, *s_background ); + p.fillRect(2, 2, width() - 2, height() - 4, *background); QColor shadow = palette().shadow().color(); QColor highlight = palette().highlight().color(); @@ -195,9 +182,9 @@ void ComboBox::paintEvent( QPaintEvent * _pe ) style()->drawPrimitive( QStyle::PE_Frame, &opt, &p, this ); - QPixmap * arrow = m_pressed ? s_arrowSelected : s_arrow; + auto arrowPixmap = m_pressed ? arrowSelected : arrow; - p.drawPixmap( width() - CB_ARROW_BTN_WIDTH + 3, 4, *arrow ); + p.drawPixmap(width() - CB_ARROW_BTN_WIDTH + 3, 4, *arrowPixmap); if( model() && model()->size() > 0 ) { From bec3f7a375324dd2eaa8aa0a74f54e447e58a423 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 15:41:49 -0400 Subject: [PATCH 24/35] Do not allocate QPixmap with new in Fader --- include/Fader.h | 4 ---- src/gui/widgets/Fader.cpp | 26 +++++++------------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/include/Fader.h b/include/Fader.h index b46bed11b47..3445f37e9cf 100644 --- a/include/Fader.h +++ b/include/Fader.h @@ -151,10 +151,6 @@ class LMMS_EXPORT Fader : public QWidget, public FloatModelView QElapsedTimer m_lastPeakTimer_L; QElapsedTimer m_lastPeakTimer_R; - static QPixmap * s_back; - static QPixmap * s_leds; - static QPixmap * s_knob; - QPixmap * m_back; QPixmap * m_leds; QPixmap * m_knob; diff --git a/src/gui/widgets/Fader.cpp b/src/gui/widgets/Fader.cpp index dcf648c37e3..a806e472d33 100644 --- a/src/gui/widgets/Fader.cpp +++ b/src/gui/widgets/Fader.cpp @@ -59,11 +59,7 @@ namespace lmms::gui { - SimpleTextFloat * Fader::s_textFloat = nullptr; -QPixmap * Fader::s_back = nullptr; -QPixmap * Fader::s_leds = nullptr; -QPixmap * Fader::s_knob = nullptr; Fader::Fader( FloatModel * _model, const QString & _name, QWidget * _parent ) : QWidget( _parent ), @@ -85,22 +81,14 @@ Fader::Fader( FloatModel * _model, const QString & _name, QWidget * _parent ) : { s_textFloat = new SimpleTextFloat; } - if( ! s_back ) - { - s_back = new QPixmap( embed::getIconPixmap( "fader_background" ) ); - } - if( ! s_leds ) - { - s_leds = new QPixmap( embed::getIconPixmap( "fader_leds" ) ); - } - if( ! s_knob ) - { - s_knob = new QPixmap( embed::getIconPixmap( "fader_knob" ) ); - } - m_back = s_back; - m_leds = s_leds; - m_knob = s_knob; + static auto s_back = QPixmap{embed::getIconPixmap("fader_background")}; + static auto s_leds = QPixmap{embed::getIconPixmap("fader_leds")}; + static auto s_knob = QPixmap{embed::getIconPixmap("fader_knob")}; + + m_back = &s_back; + m_leds = &s_leds; + m_knob = &s_knob; init(_model, _name); From 710005106f1b2ca99507bcf02dd8120eac7a863a Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 15:47:58 -0400 Subject: [PATCH 25/35] Do not allocate QPixmap with new for LcdWidget --- src/gui/widgets/LcdWidget.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/LcdWidget.cpp b/src/gui/widgets/LcdWidget.cpp index 0f5e1346658..529fda1d5a2 100644 --- a/src/gui/widgets/LcdWidget.cpp +++ b/src/gui/widgets/LcdWidget.cpp @@ -278,9 +278,11 @@ void LcdWidget::initUi(const QString& name , const QString& style) setWindowTitle( name ); // We should make a factory for these or something. - //m_lcdPixmap = new QPixmap( embed::getIconPixmap( QString( "lcd_" + style ).toUtf8().constData() ) ); - //m_lcdPixmap = new QPixmap( embed::getIconPixmap( "lcd_19green" ) ); // TODO!! - m_lcdPixmap = new QPixmap( embed::getIconPixmap( QString( "lcd_" + style ).toUtf8().constData() ) ); + //m_lcdPixmap = QPixmap{embed::getIconPixmap(QString("lcd_" + style).toUtf8().constData())}; + //m_lcdPixmap = QPixmap{embed::getIconPixmap("lcd_19green")}; // TODO!! + + static auto s_lcdPixmap = QPixmap{embed::getIconPixmap(QString("lcd_" + style).toUtf8().constData())}; + m_lcdPixmap = &s_lcdPixmap; m_cellWidth = m_lcdPixmap->size().width() / LcdWidget::charsPerPixmap; m_cellHeight = m_lcdPixmap->size().height() / 2; From 27ada30960f25a084152a57a63bb475d17ec83a0 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 15:48:16 -0400 Subject: [PATCH 26/35] Do not allocate QPixmap with new for LedCheckbox --- include/LedCheckBox.h | 4 ++-- src/gui/widgets/LedCheckBox.cpp | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/include/LedCheckBox.h b/include/LedCheckBox.h index e3629e143e7..e5d4242213e 100644 --- a/include/LedCheckBox.h +++ b/include/LedCheckBox.h @@ -69,8 +69,8 @@ class LMMS_EXPORT LedCheckBox : public AutomatableButton private: - QPixmap * m_ledOnPixmap; - QPixmap * m_ledOffPixmap; + QPixmap* m_ledOnPixmap; + QPixmap* m_ledOffPixmap; QString m_text; diff --git a/src/gui/widgets/LedCheckBox.cpp b/src/gui/widgets/LedCheckBox.cpp index 0c16bf391ae..ab0b1e2bebc 100644 --- a/src/gui/widgets/LedCheckBox.cpp +++ b/src/gui/widgets/LedCheckBox.cpp @@ -107,9 +107,11 @@ void LedCheckBox::initUi( LedColor _color ) { setCheckable( true ); - m_ledOnPixmap = new QPixmap( embed::getIconPixmap( - names[static_cast(_color)].toUtf8().constData() ) ); - m_ledOffPixmap = new QPixmap( embed::getIconPixmap( "led_off" ) ); + static auto s_ledOnPixmap + = QPixmap{embed::getIconPixmap(names[static_cast(_color)].toUtf8().constData())}; + static auto s_ledOffPixmap = QPixmap{embed::getIconPixmap("led_off")}; + m_ledOnPixmap = &s_ledOffPixmap; + m_ledOffPixmap = &s_ledOnPixmap; setFont( pointSize<7>( font() ) ); setText( m_text ); From 4be08f2d671153b4668fb546b9c7be102d8b45d3 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 16:03:35 -0400 Subject: [PATCH 27/35] Use m_ as prefix for members --- include/AutomationEditor.h | 12 ++++----- include/ComboBox.h | 6 ++--- include/EnvelopeAndLfoView.h | 4 +-- include/FileBrowser.h | 6 ++--- include/PianoRoll.h | 12 ++++----- include/PianoView.h | 12 ++++----- include/SendButtonIndicator.h | 4 +-- include/TimeLineWidget.h | 2 +- src/gui/FileBrowser.cpp | 10 ++++---- src/gui/SendButtonIndicator.cpp | 6 ++--- src/gui/editors/AutomationEditor.cpp | 26 ++++++++++---------- src/gui/editors/PianoRoll.cpp | 26 ++++++++++---------- src/gui/editors/TimeLineWidget.cpp | 18 +++++++------- src/gui/instrument/EnvelopeAndLfoView.cpp | 24 +++++++++--------- src/gui/instrument/PianoView.cpp | 30 +++++++++++------------ src/gui/widgets/ComboBox.cpp | 12 ++++----- 16 files changed, 105 insertions(+), 105 deletions(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index 6a1d4e1c7fd..6229bfe1f19 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -170,12 +170,12 @@ protected slots: AutomationEditor( const AutomationEditor & ); ~AutomationEditor() override; - QPixmap* toolDraw; - QPixmap* toolErase; - QPixmap* toolDrawOut; - QPixmap* toolMove; - QPixmap* toolYFlip; - QPixmap* toolXFlip; + QPixmap* m_toolDraw; + QPixmap* m_toolErase; + QPixmap* m_toolDrawOut; + QPixmap* m_toolMove; + QPixmap* m_toolYFlip; + QPixmap* m_toolXFlip; ComboBoxModel m_zoomingXModel; ComboBoxModel m_zoomingYModel; diff --git a/include/ComboBox.h b/include/ComboBox.h index 22e157ba27f..d361b3fa4ba 100644 --- a/include/ComboBox.h +++ b/include/ComboBox.h @@ -66,9 +66,9 @@ public slots: private: - QPixmap* background; - QPixmap* arrow; - QPixmap* arrowSelected; + QPixmap* m_background; + QPixmap* m_arrow; + QPixmap* m_arrowSelected; QMenu m_menu; diff --git a/include/EnvelopeAndLfoView.h b/include/EnvelopeAndLfoView.h index 7515f72e40f..b798594a141 100644 --- a/include/EnvelopeAndLfoView.h +++ b/include/EnvelopeAndLfoView.h @@ -71,8 +71,8 @@ protected slots: private: - QPixmap* envGraph; - QPixmap* lfoGraph; + QPixmap* m_envGraph; + QPixmap* m_lfoGraph; EnvelopeAndLfoParameters * m_params; diff --git a/include/FileBrowser.h b/include/FileBrowser.h index 1f64409edfe..3bdf43700fe 100644 --- a/include/FileBrowser.h +++ b/include/FileBrowser.h @@ -200,9 +200,9 @@ class Directory : public QTreeWidgetItem bool addItems( const QString & path ); - QPixmap* folderPixmap; - QPixmap* folderOpenedPixmap; - QPixmap* folderLockedPixmap; + QPixmap* m_folderPixmap; + QPixmap* m_folderOpenedPixmap; + QPixmap* m_folderLockedPixmap; //! Directories that lead here //! Initially, this is just set to the current path of a directory diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 0e2ebaafc43..9de2d3182ed 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -339,12 +339,12 @@ protected slots: static const int cm_scrollAmtHoriz = 10; static const int cm_scrollAmtVert = 1; - QPixmap* toolDraw; - QPixmap* toolErase; - QPixmap* toolSelect; - QPixmap* toolMove; - QPixmap* toolOpen; - QPixmap* toolKnife; + QPixmap* m_toolDraw; + QPixmap* m_toolErase; + QPixmap* m_toolSelect; + QPixmap* m_toolMove; + QPixmap* m_toolOpen; + QPixmap* m_toolKnife; static std::array prKeyOrder; diff --git a/include/PianoView.h b/include/PianoView.h index b024f814ee5..68a4b732857 100644 --- a/include/PianoView.h +++ b/include/PianoView.h @@ -73,12 +73,12 @@ class PianoView : public QWidget, public ModelView int getKeyHeight(int key_num) const; IntModel *getNearestMarker(int key, QString* title = nullptr); - QPixmap* whiteKeyPm; - QPixmap* blackKeyPm; - QPixmap* whiteKeyPressedPm; - QPixmap* blackKeyPressedPm; - QPixmap* whiteKeyDisabledPm; - QPixmap* blackKeyDisabledPm; + QPixmap* m_whiteKeyPm; + QPixmap* m_blackKeyPm; + QPixmap* m_whiteKeyPressedPm; + QPixmap* m_blackKeyPressedPm; + QPixmap* m_whiteKeyDisabledPm; + QPixmap* m_blackKeyDisabledPm; Piano * m_piano; diff --git a/include/SendButtonIndicator.h b/include/SendButtonIndicator.h index d2b65930241..bdab27a9f29 100644 --- a/include/SendButtonIndicator.h +++ b/include/SendButtonIndicator.h @@ -53,8 +53,8 @@ class SendButtonIndicator : public QLabel MixerLine * m_parent; MixerView * m_mv; - QPixmap* qpmOn; - QPixmap* qpmOff; + QPixmap* m_qpmOn; + QPixmap* m_qpmOff; FloatModel * getSendModel(); }; diff --git a/include/TimeLineWidget.h b/include/TimeLineWidget.h index c2a9dbd4564..487740bacf2 100644 --- a/include/TimeLineWidget.h +++ b/include/TimeLineWidget.h @@ -205,7 +205,7 @@ public slots: private: - QPixmap* posMarkerPixmap; + QPixmap* m_posMarkerPixmap; QColor m_inactiveLoopColor; QBrush m_inactiveLoopBrush; diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index 6cba7159b02..30f1e36eeba 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -969,9 +969,9 @@ Directory::Directory(const QString & filename, const QString & path, static auto s_folderOpenedPixmap = QPixmap{embed::getIconPixmap("folder_opened")}; static auto s_folderLockedPixmap = QPixmap{embed::getIconPixmap("folder_locked")}; - folderPixmap = &s_folderPixmap; - folderOpenedPixmap = &s_folderOpenedPixmap; - folderLockedPixmap = &s_folderLockedPixmap; + m_folderPixmap = &s_folderPixmap; + m_folderOpenedPixmap = &s_folderOpenedPixmap; + m_folderLockedPixmap = &s_folderLockedPixmap; setIcon(0, !QDir{fullName()}.isReadable() ? s_folderLockedPixmap : s_folderPixmap); setChildIndicatorPolicy( QTreeWidgetItem::ShowIndicator ); @@ -981,11 +981,11 @@ void Directory::update() { if( !isExpanded() ) { - setIcon(0, *folderPixmap); + setIcon(0, *m_folderPixmap); return; } - setIcon(0, *folderOpenedPixmap); + setIcon(0, *m_folderOpenedPixmap); if( !childCount() ) { m_dirCount = 0; diff --git a/src/gui/SendButtonIndicator.cpp b/src/gui/SendButtonIndicator.cpp index cf867dc0d10..d7023f7e649 100644 --- a/src/gui/SendButtonIndicator.cpp +++ b/src/gui/SendButtonIndicator.cpp @@ -16,8 +16,8 @@ SendButtonIndicator:: SendButtonIndicator( QWidget * _parent, MixerLine * _owner { static auto s_qpmOff = QPixmap{embed::getIconPixmap("mixer_send_off", 29, 20)}; static auto s_qpmOn = QPixmap{embed::getIconPixmap("mixer_send_on", 29, 20)}; - qpmOff = &s_qpmOff; - qpmOn = &s_qpmOn; + m_qpmOff = &s_qpmOff; + m_qpmOn = &s_qpmOn; // don't do any initializing yet, because the MixerView and MixerLine // that were passed to this constructor are not done with their constructors @@ -55,7 +55,7 @@ FloatModel * SendButtonIndicator::getSendModel() void SendButtonIndicator::updateLightStatus() { - setPixmap(!getSendModel() ? *qpmOff : *qpmOn); + setPixmap(!getSendModel() ? *m_qpmOff : *m_qpmOn); } diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index db8c8013a06..b4c00369e6d 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -127,8 +127,8 @@ AutomationEditor::AutomationEditor() : static auto s_toolYFlip = QPixmap{embed::getIconPixmap("flip_y")}; static auto s_toolXFlip = QPixmap{embed::getIconPixmap("flip_x")}; - toolYFlip = &s_toolYFlip; - toolXFlip = &s_toolXFlip; + m_toolYFlip = &s_toolYFlip; + m_toolXFlip = &s_toolXFlip; // add time-line m_timeLine = new TimeLineWidget( VALUES_WIDTH, 0, m_ppb, @@ -159,10 +159,10 @@ AutomationEditor::AutomationEditor() : static auto s_toolDrawOut = QPixmap{embed::getIconPixmap("edit_draw_outvalue")}; static auto s_toolMove = QPixmap{embed::getIconPixmap("edit_move")}; - toolDraw = &s_toolDraw; - toolErase = &s_toolErase; - toolDrawOut = &s_toolDrawOut; - toolMove = &s_toolMove; + m_toolDraw = &s_toolDraw; + m_toolErase = &s_toolErase; + m_toolDrawOut = &s_toolDrawOut; + m_toolMove = &s_toolMove; setCurrentClip(nullptr); @@ -1229,21 +1229,21 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) { case EditMode::Draw: { - if (m_action == Action::EraseValues) { cursor = toolErase; } - else if (m_action == Action::MoveValue) { cursor = toolMove; } - else { cursor = toolDraw; } + if (m_action == Action::EraseValues) { cursor = m_toolErase; } + else if (m_action == Action::MoveValue) { cursor = m_toolMove; } + else { cursor = m_toolDraw; } break; } case EditMode::Erase: { - cursor = toolErase; + cursor = m_toolErase; break; } case EditMode::DrawOutValues: { - if (m_action == Action::ResetOutValues) { cursor = toolErase; } - else if (m_action == Action::MoveOutValue) { cursor = toolMove; } - else { cursor = toolDrawOut; } + if (m_action == Action::ResetOutValues) { cursor = m_toolErase; } + else if (m_action == Action::MoveOutValue) { cursor = m_toolMove; } + else { cursor = m_toolDrawOut; } break; } } diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 5f7cae83599..94a687d8d39 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -260,12 +260,12 @@ PianoRoll::PianoRoll() : static auto s_toolOpen = QPixmap{embed::getIconPixmap("automation")}; static auto s_toolKnife = QPixmap{embed::getIconPixmap("edit_knife")}; - toolDraw = &s_toolDraw; - toolErase = &s_toolErase; - toolSelect = &s_toolSelect; - toolMove = &s_toolMove; - toolOpen = &s_toolOpen; - toolOpen = &s_toolKnife; + m_toolDraw = &s_toolDraw; + m_toolErase = &s_toolErase; + m_toolSelect = &s_toolSelect; + m_toolMove = &s_toolMove; + m_toolOpen = &s_toolOpen; + m_toolOpen = &s_toolKnife; // init text-float if( s_textFloat == nullptr ) @@ -3676,28 +3676,28 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) case EditMode::Draw: if( m_mouseDownRight ) { - cursor = toolErase; + cursor = m_toolErase; } else if( m_action == Action::MoveNote ) { - cursor = toolMove; + cursor = m_toolMove; } else { - cursor = toolDraw; + cursor = m_toolDraw; } break; case EditMode::Erase: - cursor = toolErase; + cursor = m_toolErase; break; case EditMode::Select: - cursor = toolSelect; + cursor = m_toolSelect; break; case EditMode::Detuning: - cursor = toolOpen; + cursor = m_toolOpen; break; case EditMode::Knife: - cursor = toolKnife; + cursor = m_toolKnife; break; } QPoint mousePosition = mapFromGlobal( QCursor::pos() ); diff --git a/src/gui/editors/TimeLineWidget.cpp b/src/gui/editors/TimeLineWidget.cpp index f75c3ef9021..80d32098aeb 100644 --- a/src/gui/editors/TimeLineWidget.cpp +++ b/src/gui/editors/TimeLineWidget.cpp @@ -78,7 +78,7 @@ TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppb, m_loopPos[1] = DefaultTicksPerBar; static auto s_posMarkerPixmap = QPixmap{embed::getIconPixmap("playpos_marker")}; - posMarkerPixmap = &s_posMarkerPixmap; + m_posMarkerPixmap = &s_posMarkerPixmap; setAttribute( Qt::WA_OpaquePaintEvent, true ); move( 0, yoff ); @@ -113,7 +113,7 @@ TimeLineWidget::~TimeLineWidget() void TimeLineWidget::setXOffset(const int x) { m_xOffset = x; - m_xOffset -= posMarkerPixmap->width() / 2; + m_xOffset -= m_posMarkerPixmap->width() / 2; } @@ -239,7 +239,7 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) p.fillRect( 0, 0, width(), height(), p.background() ); // Clip so that we only draw everything starting from the offset - const int leftMargin = m_xOffset + posMarkerPixmap->width() / 2; + const int leftMargin = m_xOffset + m_posMarkerPixmap->width() / 2; p.setClipRect(leftMargin, 0, width() - leftMargin, height() ); // Draw the loop rectangle @@ -267,7 +267,7 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) QColor const & barNumberColor = getBarNumberColor(); bar_t barNumber = m_begin.getBar(); - int const x = m_xOffset + posMarkerPixmap->width() / 2 - + int const x = m_xOffset + m_posMarkerPixmap->width() / 2 - ( ( static_cast( m_begin * m_ppb ) / TimePos::ticksPerBar() ) % static_cast( m_ppb ) ); // Double the interval between bar numbers until they are far enough appart @@ -301,12 +301,12 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) p.drawRect( innerRectangle ); // Only draw the position marker if the position line is in view - if (m_posMarkerX >= m_xOffset && m_posMarkerX < width() - posMarkerPixmap->width() / 2) + if (m_posMarkerX >= m_xOffset && m_posMarkerX < width() - m_posMarkerPixmap->width() / 2) { // Let the position marker extrude to the left p.setClipping(false); p.setOpacity(0.6); - p.drawPixmap(m_posMarkerX, height() - posMarkerPixmap->height(), *posMarkerPixmap); + p.drawPixmap(m_posMarkerX, height() - m_posMarkerPixmap->height(), *m_posMarkerPixmap); } } @@ -322,13 +322,13 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event ) if( event->button() == Qt::LeftButton && !(event->modifiers() & Qt::ShiftModifier) ) { m_action = Action::MovePositionMarker; - if( event->x() - m_xOffset < posMarkerPixmap->width() ) + if( event->x() - m_xOffset < m_posMarkerPixmap->width() ) { m_moveXOff = event->x() - m_xOffset; } else { - m_moveXOff = posMarkerPixmap->width() / 2; + m_moveXOff = m_posMarkerPixmap->width() / 2; } } else if( event->button() == Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier) ) @@ -338,7 +338,7 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event ) } else if( event->button() == Qt::RightButton ) { - m_moveXOff = posMarkerPixmap->width() / 2; + m_moveXOff = m_posMarkerPixmap->width() / 2; const TimePos t = m_begin + static_cast( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * TimePos::ticksPerBar() / m_ppb ); const TimePos loopMid = ( m_loopPos[0] + m_loopPos[1] ) / 2; diff --git a/src/gui/instrument/EnvelopeAndLfoView.cpp b/src/gui/instrument/EnvelopeAndLfoView.cpp index 05c1b831393..77599bbe154 100644 --- a/src/gui/instrument/EnvelopeAndLfoView.cpp +++ b/src/gui/instrument/EnvelopeAndLfoView.cpp @@ -86,8 +86,8 @@ EnvelopeAndLfoView::EnvelopeAndLfoView( QWidget * _parent ) : { static auto s_envGraph = QPixmap{embed::getIconPixmap("envelope_graph")}; static auto s_lfoGraph = QPixmap{embed::getIconPixmap("lfo_graph")}; - envGraph = &s_envGraph; - lfoGraph = &s_lfoGraph; + m_envGraph = &s_envGraph; + m_lfoGraph = &s_lfoGraph; m_predelayKnob = new Knob( KnobType::Bright26, this ); m_predelayKnob->setLabel( tr( "DEL" ) ); @@ -267,7 +267,7 @@ void EnvelopeAndLfoView::mousePressEvent( QMouseEvent * _me ) return; } - if (QRect(ENV_GRAPH_X, ENV_GRAPH_Y, envGraph->width(), envGraph->height()).contains(_me->pos())) + if (QRect(ENV_GRAPH_X, ENV_GRAPH_Y, m_envGraph->width(), m_envGraph->height()).contains(_me->pos())) { if( m_params->m_amountModel.value() < 1.0f ) { @@ -278,7 +278,7 @@ void EnvelopeAndLfoView::mousePressEvent( QMouseEvent * _me ) m_params->m_amountModel.setValue( 0.0f ); } } - else if (QRect(LFO_GRAPH_X, LFO_GRAPH_Y, lfoGraph->width(), lfoGraph->height()).contains(_me->pos())) + else if (QRect(LFO_GRAPH_X, LFO_GRAPH_Y, m_lfoGraph->width(), m_lfoGraph->height()).contains(_me->pos())) { if( m_params->m_lfoAmountModel.value() < 1.0f ) { @@ -339,9 +339,9 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) p.setRenderHint( QPainter::Antialiasing ); // draw envelope-graph - p.drawPixmap(ENV_GRAPH_X, ENV_GRAPH_Y, *envGraph); + p.drawPixmap(ENV_GRAPH_X, ENV_GRAPH_Y, *m_envGraph); // draw LFO-graph - p.drawPixmap(LFO_GRAPH_X, LFO_GRAPH_Y, *lfoGraph); + p.drawPixmap(LFO_GRAPH_X, LFO_GRAPH_Y, *m_lfoGraph); p.setFont( pointSize<8>( p.font() ) ); @@ -355,8 +355,8 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) const QColor end_points_color( 0x99, 0xAF, 0xFF ); const QColor end_points_bg_color( 0, 0, 2 ); - const int y_base = ENV_GRAPH_Y + envGraph->height() - 3; - const int avail_height = envGraph->height() - 6; + const int y_base = ENV_GRAPH_Y + m_envGraph->height() - 3; + const int avail_height = m_envGraph->height() - 6; int x1 = static_cast( m_predelayKnob->value() * TIME_UNIT_WIDTH ); int x2 = x1 + static_cast( m_attackKnob->value() * TIME_UNIT_WIDTH ); @@ -409,8 +409,8 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) p.fillRect( x5 - 1, y_base - 2, 4, 4, end_points_bg_color ); p.fillRect( x5, y_base - 1, 2, 2, end_points_color ); - int LFO_GRAPH_W = lfoGraph->width() - 3; // subtract border - int LFO_GRAPH_H = lfoGraph->height() - 6; // subtract border + int LFO_GRAPH_W = m_lfoGraph->width() - 3; // subtract border + int LFO_GRAPH_H = m_lfoGraph->height() - 6; // subtract border int graph_x_base = LFO_GRAPH_X + 2; int graph_y_base = LFO_GRAPH_Y + 3 + LFO_GRAPH_H / 2; @@ -491,8 +491,8 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) int ms_per_osc = static_cast( SECS_PER_LFO_OSCILLATION * m_lfoSpeedKnob->value() * 1000.0f ); - p.drawText(LFO_GRAPH_X + 4, LFO_GRAPH_Y + lfoGraph->height() - 6, tr("ms/LFO:")); - p.drawText(LFO_GRAPH_X + 52, LFO_GRAPH_Y + lfoGraph->height() - 6, QString::number(ms_per_osc)); + p.drawText(LFO_GRAPH_X + 4, LFO_GRAPH_Y + m_lfoGraph->height() - 6, tr("ms/LFO:")); + p.drawText(LFO_GRAPH_X + 52, LFO_GRAPH_Y + m_lfoGraph->height() - 6, QString::number(ms_per_osc)); } diff --git a/src/gui/instrument/PianoView.cpp b/src/gui/instrument/PianoView.cpp index 04be49b36fe..4306a8b3aca 100644 --- a/src/gui/instrument/PianoView.cpp +++ b/src/gui/instrument/PianoView.cpp @@ -98,12 +98,12 @@ PianoView::PianoView(QWidget *parent) : static auto s_whiteKeyDisabledPm = QPixmap{embed::getIconPixmap("white_key_disabled")}; static auto s_blackKeyDisabledPm = QPixmap{embed::getIconPixmap("black_key_disabled")}; - whiteKeyPm = &s_whiteKeyPm; - blackKeyPm = &s_blackKeyPm; - whiteKeyPressedPm = &s_whiteKeyPressedPm; - blackKeyPressedPm = &s_blackKeyPressedPm; - whiteKeyDisabledPm = &s_whiteKeyDisabledPm; - blackKeyDisabledPm = &s_blackKeyDisabledPm; + m_whiteKeyPm = &s_whiteKeyPm; + m_blackKeyPm = &s_blackKeyPm; + m_whiteKeyPressedPm = &s_whiteKeyPressedPm; + m_blackKeyPressedPm = &s_blackKeyPressedPm; + m_whiteKeyDisabledPm = &s_whiteKeyDisabledPm; + m_whiteKeyDisabledPm = &s_blackKeyDisabledPm; setAttribute(Qt::WA_OpaquePaintEvent, true); setFocusPolicy(Qt::StrongFocus); @@ -875,16 +875,16 @@ void PianoView::paintEvent( QPaintEvent * ) { if (m_piano && m_piano->isKeyPressed(cur_key)) { - p.drawPixmap(x, PIANO_BASE, *whiteKeyPressedPm); + p.drawPixmap(x, PIANO_BASE, *m_whiteKeyPressedPm); } else { - p.drawPixmap(x, PIANO_BASE, *whiteKeyPm); + p.drawPixmap(x, PIANO_BASE, *m_whiteKeyPm); } } else { - p.drawPixmap(x, PIANO_BASE, *whiteKeyDisabledPm); + p.drawPixmap(x, PIANO_BASE, *m_whiteKeyDisabledPm); } x += PW_WHITE_KEY_WIDTH; @@ -909,16 +909,16 @@ void PianoView::paintEvent( QPaintEvent * ) { if (m_piano && m_piano->isKeyPressed(startKey)) { - p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *blackKeyPressedPm); + p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *m_blackKeyPressedPm); } else { - p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *blackKeyPm); + p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *m_blackKeyPm); } } else { - p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *blackKeyDisabledPm); + p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *m_whiteKeyDisabledPm); } } @@ -932,16 +932,16 @@ void PianoView::paintEvent( QPaintEvent * ) { if (m_piano && m_piano->isKeyPressed(cur_key)) { - p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *blackKeyPressedPm); + p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *m_blackKeyPressedPm); } else { - p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *blackKeyPm); + p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *m_blackKeyPm); } } else { - p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *blackKeyDisabledPm); + p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *m_whiteKeyDisabledPm); } x += PW_WHITE_KEY_WIDTH; white_cnt = 0; diff --git a/src/gui/widgets/ComboBox.cpp b/src/gui/widgets/ComboBox.cpp index 3166fe5b9c8..5d21ada8ed5 100644 --- a/src/gui/widgets/ComboBox.cpp +++ b/src/gui/widgets/ComboBox.cpp @@ -52,9 +52,9 @@ ComboBox::ComboBox( QWidget * _parent, const QString & _name ) : static auto s_background = QPixmap{embed::getIconPixmap("combobox_bg")}; static auto s_arrow = QPixmap{embed::getIconPixmap("combobox_arrow")}; static auto s_arrowSelected = QPixmap{embed::getIconPixmap("combobox_arrow_selected")}; - background = &s_background; - arrow = &s_arrow; - arrowSelected = &s_arrowSelected; + m_background = &s_background; + m_arrow = &s_arrow; + m_arrowSelected = &s_arrowSelected; setFont( pointSize<9>( font() ) ); m_menu.setFont( pointSize<8>( m_menu.font() ) ); @@ -160,7 +160,7 @@ void ComboBox::paintEvent( QPaintEvent * _pe ) { QPainter p( this ); - p.fillRect(2, 2, width() - 2, height() - 4, *background); + p.fillRect(2, 2, width() - 2, height() - 4, *m_background); QColor shadow = palette().shadow().color(); QColor highlight = palette().highlight().color(); @@ -182,9 +182,9 @@ void ComboBox::paintEvent( QPaintEvent * _pe ) style()->drawPrimitive( QStyle::PE_Frame, &opt, &p, this ); - auto arrowPixmap = m_pressed ? arrowSelected : arrow; + auto arrow = m_pressed ? m_arrowSelected : m_arrow; - p.drawPixmap(width() - CB_ARROW_BTN_WIDTH + 3, 4, *arrowPixmap); + p.drawPixmap(width() - CB_ARROW_BTN_WIDTH + 3, 4, *arrow); if( model() && model()->size() > 0 ) { From 2e4f96f07ed82515a07e205492c086930c895c36 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 22 Sep 2023 16:15:59 -0400 Subject: [PATCH 28/35] Use uniform initialization I already started using uniform initialization for the QPixmap changes for some reason, so I'm finishing that up. --- src/gui/clips/AutomationClipView.cpp | 2 +- src/gui/clips/MidiClipView.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/clips/AutomationClipView.cpp b/src/gui/clips/AutomationClipView.cpp index b39538e5077..261b3a50006 100644 --- a/src/gui/clips/AutomationClipView.cpp +++ b/src/gui/clips/AutomationClipView.cpp @@ -373,7 +373,7 @@ void AutomationClipView::paintEvent( QPaintEvent * ) // recording icon for when recording automation if( m_clip->isRecording() ) { - static auto s_clipRec = QPixmap(embed::getIconPixmap("clip_rec")); + static auto s_clipRec = QPixmap{embed::getIconPixmap("clip_rec")}; p.drawPixmap(1, rect().bottom() - s_clipRec.height(), s_clipRec); } diff --git a/src/gui/clips/MidiClipView.cpp b/src/gui/clips/MidiClipView.cpp index ee067e137b2..2e5749c7d39 100644 --- a/src/gui/clips/MidiClipView.cpp +++ b/src/gui/clips/MidiClipView.cpp @@ -560,8 +560,8 @@ void MidiClipView::paintEvent( QPaintEvent * ) const int w = width() - 2 * BORDER_WIDTH; static auto s_stepBtnOn0 = QPixmap{embed::getIconPixmap("step_btn_on_0")}; - static auto s_stepBtnOn200 = QPixmap(embed::getIconPixmap("step_btn_on_200")); - static auto s_stepBtnOff = QPixmap(embed::getIconPixmap("step_btn_off")); + static auto s_stepBtnOn200 = QPixmap{embed::getIconPixmap("step_btn_on_200")}; + static auto s_stepBtnOff = QPixmap{embed::getIconPixmap("step_btn_off")}; static auto s_stepBtnOffLight = QPixmap{embed::getIconPixmap("step_btn_off_light")}; // scale step graphics to fit the beat clip length From e7de39932d8c2c0294de5a41b30378b8f5452c1d Mon Sep 17 00:00:00 2001 From: sakertooth Date: Sat, 21 Oct 2023 11:06:11 -0400 Subject: [PATCH 29/35] Uniform initiaization --- src/gui/editors/AutomationEditor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 14312f1fc2e..d2427d004d4 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -158,7 +158,7 @@ AutomationEditor::AutomationEditor() : static auto s_toolDraw = QPixmap{embed::getIconPixmap("edit_draw")}; static auto s_toolErase = QPixmap{embed::getIconPixmap("edit_erase")}; static auto s_toolDrawOut = QPixmap{embed::getIconPixmap("edit_draw_outvalue")}; - static auto s_toolEditTangents = QPixmap(embed::getIconPixmap("edit_tangent")); + static auto s_toolEditTangents = QPixmap{embed::getIconPixmap("edit_tangent")}; static auto s_toolMove = QPixmap{embed::getIconPixmap("edit_move")}; m_toolDraw = &s_toolDraw; From b4a67fabe55fca68d302c857da495e390b46228e Mon Sep 17 00:00:00 2001 From: sakertooth Date: Sat, 21 Oct 2023 11:19:33 -0400 Subject: [PATCH 30/35] And then he realized he was making copies... --- .../AudioFileProcessor/AudioFileProcessor.cpp | 2 +- plugins/Nes/Nes.cpp | 2 +- plugins/Organic/Organic.cpp | 2 +- plugins/Vestige/Vestige.cpp | 2 +- src/gui/FileBrowser.cpp | 20 +++++++++---------- src/gui/MixerLine.cpp | 4 ++-- src/gui/SendButtonIndicator.cpp | 4 ++-- src/gui/clips/AutomationClipView.cpp | 2 +- src/gui/clips/MidiClipView.cpp | 8 ++++---- src/gui/editors/AutomationEditor.cpp | 14 ++++++------- src/gui/editors/PianoRoll.cpp | 12 +++++------ src/gui/editors/TimeLineWidget.cpp | 2 +- src/gui/instrument/EnvelopeAndLfoView.cpp | 6 +++--- src/gui/instrument/PianoView.cpp | 12 +++++------ src/gui/widgets/ComboBox.cpp | 6 +++--- src/gui/widgets/Fader.cpp | 6 +++--- src/gui/widgets/LcdWidget.cpp | 6 +++--- src/gui/widgets/LedCheckBox.cpp | 5 ++--- 18 files changed, 57 insertions(+), 58 deletions(-) diff --git a/plugins/AudioFileProcessor/AudioFileProcessor.cpp b/plugins/AudioFileProcessor/AudioFileProcessor.cpp index 6c0592bc975..c51915d85bf 100644 --- a/plugins/AudioFileProcessor/AudioFileProcessor.cpp +++ b/plugins/AudioFileProcessor/AudioFileProcessor.cpp @@ -638,7 +638,7 @@ void AudioFileProcessorView::paintEvent( QPaintEvent * ) { QPainter p( this ); - static auto s_artwork = QPixmap{PLUGIN_NAME::getIconPixmap("artwork")}; + static auto s_artwork = PLUGIN_NAME::getIconPixmap("artwork"); p.drawPixmap(0, 0, s_artwork); auto a = castModel(); diff --git a/plugins/Nes/Nes.cpp b/plugins/Nes/Nes.cpp index 382b42e5601..2c0907a197e 100644 --- a/plugins/Nes/Nes.cpp +++ b/plugins/Nes/Nes.cpp @@ -727,7 +727,7 @@ NesInstrumentView::NesInstrumentView( Instrument * instrument, QWidget * parent setAutoFillBackground( true ); QPalette pal; - static auto s_artwork = QPixmap{PLUGIN_NAME::getIconPixmap("artwork")}; + static auto s_artwork = PLUGIN_NAME::getIconPixmap("artwork"); pal.setBrush(backgroundRole(), s_artwork); setPalette( pal ); diff --git a/plugins/Organic/Organic.cpp b/plugins/Organic/Organic.cpp index 4c3c9428f3e..761010922a3 100644 --- a/plugins/Organic/Organic.cpp +++ b/plugins/Organic/Organic.cpp @@ -419,7 +419,7 @@ OrganicInstrumentView::OrganicInstrumentView( Instrument * _instrument, setAutoFillBackground( true ); QPalette pal; - static auto s_artwork = QPixmap{PLUGIN_NAME::getIconPixmap("artwork")}; + static auto s_artwork = PLUGIN_NAME::getIconPixmap("artwork"); pal.setBrush(backgroundRole(), s_artwork); setPalette( pal ); diff --git a/plugins/Vestige/Vestige.cpp b/plugins/Vestige/Vestige.cpp index f5a597bf599..583075c0cd3 100644 --- a/plugins/Vestige/Vestige.cpp +++ b/plugins/Vestige/Vestige.cpp @@ -871,7 +871,7 @@ void VestigeInstrumentView::paintEvent( QPaintEvent * ) { QPainter p( this ); - static auto s_artwork = QPixmap{PLUGIN_NAME::getIconPixmap("artwork")}; + static auto s_artwork = PLUGIN_NAME::getIconPixmap("artwork"); p.drawPixmap(0, 0, s_artwork); QString plugin_name = ( m_vi->m_plugin != nullptr ) ? diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index 30f1e36eeba..4db867274e8 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -965,9 +965,9 @@ Directory::Directory(const QString & filename, const QString & path, m_filter( filter ), m_dirCount( 0 ) { - static auto s_folderPixmap = QPixmap{embed::getIconPixmap("folder")}; - static auto s_folderOpenedPixmap = QPixmap{embed::getIconPixmap("folder_opened")}; - static auto s_folderLockedPixmap = QPixmap{embed::getIconPixmap("folder_locked")}; + static auto s_folderPixmap = embed::getIconPixmap("folder"); + static auto s_folderOpenedPixmap = embed::getIconPixmap("folder_opened"); + static auto s_folderLockedPixmap = embed::getIconPixmap("folder_locked"); m_folderPixmap = &s_folderPixmap; m_folderOpenedPixmap = &s_folderOpenedPixmap; @@ -1084,13 +1084,13 @@ FileItem::FileItem(const QString & name, const QString & path ) : void FileItem::initPixmaps() { - static auto s_projectFilePixmap = QPixmap{embed::getIconPixmap("project_file", 16, 16)}; - static auto s_presetFilePixmap = QPixmap{embed::getIconPixmap("preset_file", 16, 16)}; - static auto s_sampleFilePixmap = QPixmap{embed::getIconPixmap("sample_file", 16, 16)}; - static auto s_soundfontFilePixmap = QPixmap{embed::getIconPixmap("soundfont_file", 16, 16)}; - static auto s_vstPluginFilePixmap = QPixmap{embed::getIconPixmap("vst_plugin_file", 16, 16)}; - static auto s_midiFilePixmap = QPixmap{embed::getIconPixmap("midi_file", 16, 16)}; - static auto s_unknownFilePixmap = QPixmap{embed::getIconPixmap("unknown_file")}; + static auto s_projectFilePixmap = embed::getIconPixmap("project_file", 16, 16); + static auto s_presetFilePixmap = embed::getIconPixmap("preset_file", 16, 16); + static auto s_sampleFilePixmap = embed::getIconPixmap("sample_file", 16, 16); + static auto s_soundfontFilePixmap = embed::getIconPixmap("soundfont_file", 16, 16); + static auto s_vstPluginFilePixmap = embed::getIconPixmap("vst_plugin_file", 16, 16); + static auto s_midiFilePixmap = embed::getIconPixmap("midi_file", 16, 16); + static auto s_unknownFilePixmap = embed::getIconPixmap("unknown_file"); switch( m_type ) { diff --git a/src/gui/MixerLine.cpp b/src/gui/MixerLine.cpp index 53617c12992..5a6b5e3f47e 100644 --- a/src/gui/MixerLine.cpp +++ b/src/gui/MixerLine.cpp @@ -183,8 +183,8 @@ void MixerLine::drawMixerLine( QPainter* p, const MixerLine *mixerLine, bool isA // draw the mixer send background - static auto s_sendBgArrow = QPixmap{embed::getIconPixmap("send_bg_arrow", 29, 56)}; - static auto s_receiveBgArrow = QPixmap{embed::getIconPixmap("receive_bg_arrow", 29, 56)}; + static auto s_sendBgArrow = embed::getIconPixmap("send_bg_arrow", 29, 56); + static auto s_receiveBgArrow = embed::getIconPixmap("receive_bg_arrow", 29, 56); p->drawPixmap(2, 0, 29, 56, sendToThis ? s_sendBgArrow : s_receiveBgArrow); } diff --git a/src/gui/SendButtonIndicator.cpp b/src/gui/SendButtonIndicator.cpp index d7023f7e649..a47f0697104 100644 --- a/src/gui/SendButtonIndicator.cpp +++ b/src/gui/SendButtonIndicator.cpp @@ -14,8 +14,8 @@ SendButtonIndicator:: SendButtonIndicator( QWidget * _parent, MixerLine * _owner m_parent( _owner ), m_mv( _mv ) { - static auto s_qpmOff = QPixmap{embed::getIconPixmap("mixer_send_off", 29, 20)}; - static auto s_qpmOn = QPixmap{embed::getIconPixmap("mixer_send_on", 29, 20)}; + static auto s_qpmOff = embed::getIconPixmap("mixer_send_off", 29, 20); + static auto s_qpmOn = embed::getIconPixmap("mixer_send_on", 29, 20); m_qpmOff = &s_qpmOff; m_qpmOn = &s_qpmOn; diff --git a/src/gui/clips/AutomationClipView.cpp b/src/gui/clips/AutomationClipView.cpp index 261b3a50006..7ddb7015182 100644 --- a/src/gui/clips/AutomationClipView.cpp +++ b/src/gui/clips/AutomationClipView.cpp @@ -373,7 +373,7 @@ void AutomationClipView::paintEvent( QPaintEvent * ) // recording icon for when recording automation if( m_clip->isRecording() ) { - static auto s_clipRec = QPixmap{embed::getIconPixmap("clip_rec")}; + static auto s_clipRec = embed::getIconPixmap("clip_rec"); p.drawPixmap(1, rect().bottom() - s_clipRec.height(), s_clipRec); } diff --git a/src/gui/clips/MidiClipView.cpp b/src/gui/clips/MidiClipView.cpp index 33fbd53082d..0733b548daf 100644 --- a/src/gui/clips/MidiClipView.cpp +++ b/src/gui/clips/MidiClipView.cpp @@ -560,10 +560,10 @@ void MidiClipView::paintEvent( QPaintEvent * ) m_clip->m_steps ); const int w = width() - 2 * BORDER_WIDTH; - static auto s_stepBtnOn0 = QPixmap{embed::getIconPixmap("step_btn_on_0")}; - static auto s_stepBtnOn200 = QPixmap{embed::getIconPixmap("step_btn_on_200")}; - static auto s_stepBtnOff = QPixmap{embed::getIconPixmap("step_btn_off")}; - static auto s_stepBtnOffLight = QPixmap{embed::getIconPixmap("step_btn_off_light")}; + static auto s_stepBtnOn0 = embed::getIconPixmap("step_btn_on_0"); + static auto s_stepBtnOn200 = embed::getIconPixmap("step_btn_on_200"); + static auto s_stepBtnOff = embed::getIconPixmap("step_btn_off"); + static auto s_stepBtnOffLight = embed::getIconPixmap("step_btn_off_light"); // scale step graphics to fit the beat clip length stepon0 diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index d2427d004d4..718156ea5bd 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -126,8 +126,8 @@ AutomationEditor::AutomationEditor() : this, SLOT(setQuantization())); m_quantizeModel.setValue( m_quantizeModel.findText( "1/8" ) ); - static auto s_toolYFlip = QPixmap{embed::getIconPixmap("flip_y")}; - static auto s_toolXFlip = QPixmap{embed::getIconPixmap("flip_x")}; + static auto s_toolYFlip = embed::getIconPixmap("flip_y"); + static auto s_toolXFlip = embed::getIconPixmap("flip_x"); m_toolYFlip = &s_toolYFlip; m_toolXFlip = &s_toolXFlip; @@ -155,11 +155,11 @@ AutomationEditor::AutomationEditor() : SLOT(verScrolled(int))); // init pixmaps - static auto s_toolDraw = QPixmap{embed::getIconPixmap("edit_draw")}; - static auto s_toolErase = QPixmap{embed::getIconPixmap("edit_erase")}; - static auto s_toolDrawOut = QPixmap{embed::getIconPixmap("edit_draw_outvalue")}; - static auto s_toolEditTangents = QPixmap{embed::getIconPixmap("edit_tangent")}; - static auto s_toolMove = QPixmap{embed::getIconPixmap("edit_move")}; + static auto s_toolDraw = embed::getIconPixmap("edit_draw"); + static auto s_toolErase = embed::getIconPixmap("edit_erase"); + static auto s_toolDrawOut = embed::getIconPixmap("edit_draw_outvalue"); + static auto s_toolEditTangents = embed::getIconPixmap("edit_tangent"); + static auto s_toolMove = embed::getIconPixmap("edit_move"); m_toolDraw = &s_toolDraw; m_toolErase = &s_toolErase; diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 65b70ad39d4..444787b10b3 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -256,12 +256,12 @@ PianoRoll::PianoRoll() : m_semiToneMarkerMenu->addAction( copyAllNotesAction ); // init pixmaps - static auto s_toolDraw = QPixmap{embed::getIconPixmap("edit_draw")}; - static auto s_toolErase = QPixmap{embed::getIconPixmap("edit_erase")}; - static auto s_toolSelect = QPixmap{embed::getIconPixmap("edit_select")}; - static auto s_toolMove = QPixmap{embed::getIconPixmap("edit_move")}; - static auto s_toolOpen = QPixmap{embed::getIconPixmap("automation")}; - static auto s_toolKnife = QPixmap{embed::getIconPixmap("edit_knife")}; + static auto s_toolDraw = embed::getIconPixmap("edit_draw"); + static auto s_toolErase = embed::getIconPixmap("edit_erase"); + static auto s_toolSelect = embed::getIconPixmap("edit_select"); + static auto s_toolMove = embed::getIconPixmap("edit_move"); + static auto s_toolOpen = embed::getIconPixmap("automation"); + static auto s_toolKnife = embed::getIconPixmap("edit_knife"); m_toolDraw = &s_toolDraw; m_toolErase = &s_toolErase; diff --git a/src/gui/editors/TimeLineWidget.cpp b/src/gui/editors/TimeLineWidget.cpp index 80d32098aeb..172cc35bf12 100644 --- a/src/gui/editors/TimeLineWidget.cpp +++ b/src/gui/editors/TimeLineWidget.cpp @@ -77,7 +77,7 @@ TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppb, m_loopPos[0] = 0; m_loopPos[1] = DefaultTicksPerBar; - static auto s_posMarkerPixmap = QPixmap{embed::getIconPixmap("playpos_marker")}; + static auto s_posMarkerPixmap = embed::getIconPixmap("playpos_marker"); m_posMarkerPixmap = &s_posMarkerPixmap; setAttribute( Qt::WA_OpaquePaintEvent, true ); diff --git a/src/gui/instrument/EnvelopeAndLfoView.cpp b/src/gui/instrument/EnvelopeAndLfoView.cpp index 77599bbe154..fb8d2347a6b 100644 --- a/src/gui/instrument/EnvelopeAndLfoView.cpp +++ b/src/gui/instrument/EnvelopeAndLfoView.cpp @@ -84,8 +84,8 @@ EnvelopeAndLfoView::EnvelopeAndLfoView( QWidget * _parent ) : ModelView( nullptr, this ), m_params( nullptr ) { - static auto s_envGraph = QPixmap{embed::getIconPixmap("envelope_graph")}; - static auto s_lfoGraph = QPixmap{embed::getIconPixmap("lfo_graph")}; + static auto s_envGraph = embed::getIconPixmap("envelope_graph"); + static auto s_lfoGraph = embed::getIconPixmap("lfo_graph"); m_envGraph = &s_envGraph; m_lfoGraph = &s_lfoGraph; @@ -519,4 +519,4 @@ void EnvelopeAndLfoView::lfoUserWaveChanged() } // namespace gui -} // namespace lmms \ No newline at end of file +} // namespace lmms diff --git a/src/gui/instrument/PianoView.cpp b/src/gui/instrument/PianoView.cpp index 4306a8b3aca..2c5b466b334 100644 --- a/src/gui/instrument/PianoView.cpp +++ b/src/gui/instrument/PianoView.cpp @@ -91,12 +91,12 @@ PianoView::PianoView(QWidget *parent) : m_movedNoteModel(nullptr) /*!< Key marker which is being moved */ { - static auto s_whiteKeyPm = QPixmap{embed::getIconPixmap("white_key")}; - static auto s_blackKeyPm = QPixmap{embed::getIconPixmap("black_key")}; - static auto s_whiteKeyPressedPm = QPixmap{embed::getIconPixmap("white_key_pressed")}; - static auto s_blackKeyPressedPm = QPixmap{embed::getIconPixmap("black_key_pressed")}; - static auto s_whiteKeyDisabledPm = QPixmap{embed::getIconPixmap("white_key_disabled")}; - static auto s_blackKeyDisabledPm = QPixmap{embed::getIconPixmap("black_key_disabled")}; + static auto s_whiteKeyPm = embed::getIconPixmap("white_key"); + static auto s_blackKeyPm = embed::getIconPixmap("black_key"); + static auto s_whiteKeyPressedPm = embed::getIconPixmap("white_key_pressed"); + static auto s_blackKeyPressedPm = embed::getIconPixmap("black_key_pressed"); + static auto s_whiteKeyDisabledPm = embed::getIconPixmap("white_key_disabled"); + static auto s_blackKeyDisabledPm = embed::getIconPixmap("black_key_disabled"); m_whiteKeyPm = &s_whiteKeyPm; m_blackKeyPm = &s_blackKeyPm; diff --git a/src/gui/widgets/ComboBox.cpp b/src/gui/widgets/ComboBox.cpp index 23feb0901d5..c01ae766333 100644 --- a/src/gui/widgets/ComboBox.cpp +++ b/src/gui/widgets/ComboBox.cpp @@ -49,9 +49,9 @@ ComboBox::ComboBox( QWidget * _parent, const QString & _name ) : { setFixedHeight( ComboBox::DEFAULT_HEIGHT ); - static auto s_background = QPixmap{embed::getIconPixmap("combobox_bg")}; - static auto s_arrow = QPixmap{embed::getIconPixmap("combobox_arrow")}; - static auto s_arrowSelected = QPixmap{embed::getIconPixmap("combobox_arrow_selected")}; + static auto s_background = embed::getIconPixmap("combobox_bg"); + static auto s_arrow = embed::getIconPixmap("combobox_arrow"); + static auto s_arrowSelected = embed::getIconPixmap("combobox_arrow_selected"); m_background = &s_background; m_arrow = &s_arrow; m_arrowSelected = &s_arrowSelected; diff --git a/src/gui/widgets/Fader.cpp b/src/gui/widgets/Fader.cpp index a806e472d33..3b8decdaeb1 100644 --- a/src/gui/widgets/Fader.cpp +++ b/src/gui/widgets/Fader.cpp @@ -82,9 +82,9 @@ Fader::Fader( FloatModel * _model, const QString & _name, QWidget * _parent ) : s_textFloat = new SimpleTextFloat; } - static auto s_back = QPixmap{embed::getIconPixmap("fader_background")}; - static auto s_leds = QPixmap{embed::getIconPixmap("fader_leds")}; - static auto s_knob = QPixmap{embed::getIconPixmap("fader_knob")}; + static auto s_back = embed::getIconPixmap("fader_background"); + static auto s_leds = embed::getIconPixmap("fader_leds"); + static auto s_knob = embed::getIconPixmap("fader_knob"); m_back = &s_back; m_leds = &s_leds; diff --git a/src/gui/widgets/LcdWidget.cpp b/src/gui/widgets/LcdWidget.cpp index 701ea9fb6ab..434b29d03ea 100644 --- a/src/gui/widgets/LcdWidget.cpp +++ b/src/gui/widgets/LcdWidget.cpp @@ -294,10 +294,10 @@ void LcdWidget::initUi(const QString& name , const QString& style) setWindowTitle( name ); // We should make a factory for these or something. - //m_lcdPixmap = QPixmap{embed::getIconPixmap(QString("lcd_" + style).toUtf8().constData())}; - //m_lcdPixmap = QPixmap{embed::getIconPixmap("lcd_19green")}; // TODO!! + //m_lcdPixmap = embed::getIconPixmap(QString("lcd_" + style).toUtf8().constData()); + //m_lcdPixmap = embed::getIconPixmap("lcd_19green"); // TODO!! - static auto s_lcdPixmap = QPixmap{embed::getIconPixmap(QString("lcd_" + style).toUtf8().constData())}; + static auto s_lcdPixmap = embed::getIconPixmap(QString("lcd_" + style).toUtf8().constData()); m_lcdPixmap = &s_lcdPixmap; m_cellWidth = m_lcdPixmap->size().width() / LcdWidget::charsPerPixmap; diff --git a/src/gui/widgets/LedCheckBox.cpp b/src/gui/widgets/LedCheckBox.cpp index ab0b1e2bebc..7ee1acbca62 100644 --- a/src/gui/widgets/LedCheckBox.cpp +++ b/src/gui/widgets/LedCheckBox.cpp @@ -107,9 +107,8 @@ void LedCheckBox::initUi( LedColor _color ) { setCheckable( true ); - static auto s_ledOnPixmap - = QPixmap{embed::getIconPixmap(names[static_cast(_color)].toUtf8().constData())}; - static auto s_ledOffPixmap = QPixmap{embed::getIconPixmap("led_off")}; + static auto s_ledOnPixmap = embed::getIconPixmap(names[static_cast(_color)].toUtf8().constData()); + static auto s_ledOffPixmap = embed::getIconPixmap("led_off"); m_ledOnPixmap = &s_ledOffPixmap; m_ledOffPixmap = &s_ledOnPixmap; From 932ebe956fff99035b9b2fb175473996b06c808a Mon Sep 17 00:00:00 2001 From: sakertooth Date: Sat, 21 Oct 2023 11:35:16 -0400 Subject: [PATCH 31/35] Do not call QPixmap copy constructor --- plugins/Eq/EqControlsDialog.cpp | 8 ++++---- plugins/SpectrumAnalyzer/SaControlsDialog.cpp | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/Eq/EqControlsDialog.cpp b/plugins/Eq/EqControlsDialog.cpp index 6130b6bd75c..634bde846bc 100644 --- a/plugins/Eq/EqControlsDialog.cpp +++ b/plugins/Eq/EqControlsDialog.cpp @@ -72,9 +72,9 @@ EqControlsDialog::EqControlsDialog( EqControls *controls ) : setBand( 6, &controls->m_highShelfActiveModel, &controls->m_highShelfFreqModel, &controls->m_highShelfResModel, &controls->m_highShelfGainModel, QColor(255 ,255, 255), tr( "High-shelf" ), &controls->m_highShelfPeakL, &controls->m_highShelfPeakR,0,0,0,0,0,0 ); setBand( 7, &controls->m_lpActiveModel, &controls->m_lpFreqModel, &controls->m_lpResModel, 0, QColor(255 ,255, 255), tr( "LP" ) ,0,0,0,0,0, &controls->m_lp12Model, &controls->m_lp24Model, &controls->m_lp48Model); - static auto s_faderBg = QPixmap(PLUGIN_NAME::getIconPixmap("faderback")); - static auto s_faderLeds = QPixmap(PLUGIN_NAME::getIconPixmap("faderleds")); - static auto s_faderKnob = QPixmap(PLUGIN_NAME::getIconPixmap("faderknob")); + static auto s_faderBg = PLUGIN_NAME::getIconPixmap("faderback"); + static auto s_faderLeds = PLUGIN_NAME::getIconPixmap("faderleds"); + static auto s_faderKnob = PLUGIN_NAME::getIconPixmap("faderknob"); auto GainFaderIn = new EqFader(&controls->m_inGainModel, tr("Input gain"), this, &s_faderBg, &s_faderLeds, &s_faderKnob, &controls->m_inPeakL, &controls->m_inPeakR); @@ -242,4 +242,4 @@ EqBand* EqControlsDialog::setBand(int index, BoolModel* active, FloatModel* freq } -} // namespace lmms::gui \ No newline at end of file +} // namespace lmms::gui diff --git a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp index 2e2d1a8d923..0df72fe68c8 100644 --- a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp +++ b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp @@ -190,7 +190,7 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // FFT: block size: icon and selector auto blockSizeLabel = new QLabel("", this); - static auto s_blockSizeIcon = QPixmap(PLUGIN_NAME::getIconPixmap("block_size")); + static auto s_blockSizeIcon = PLUGIN_NAME::getIconPixmap("block_size"); s_blockSizeIcon.setDevicePixelRatio(devicePixelRatio()); blockSizeLabel->setPixmap(s_blockSizeIcon.scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); config_layout->addWidget(blockSizeLabel, 0, 4, 2, 1, Qt::AlignRight); @@ -206,7 +206,7 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // FFT: window type: icon and selector auto windowLabel = new QLabel("", this); - static auto s_windowIcon = QPixmap(PLUGIN_NAME::getIconPixmap("window")); + static auto s_windowIcon = PLUGIN_NAME::getIconPixmap("window"); s_windowIcon.setDevicePixelRatio(devicePixelRatio()); windowLabel->setPixmap(s_windowIcon.scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); config_layout->addWidget(windowLabel, 2, 4, 2, 1, Qt::AlignRight); @@ -307,10 +307,10 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // Advanced settings button auto advancedButton = new PixmapButton(this, tr("Advanced settings")); advancedButton->setToolTip(tr("Access advanced settings")); - static auto s_advancedOnPixmap = QPixmap(PLUGIN_NAME::getIconPixmap("advanced_on") - .scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - static auto s_advancedOffPixmap = QPixmap(PLUGIN_NAME::getIconPixmap("advanced_off") - .scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + static auto s_advancedOnPixmap = PLUGIN_NAME::getIconPixmap("advanced_on") + .scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + static auto s_advancedOffPixmap = PLUGIN_NAME::getIconPixmap("advanced_off") + .scaled(advButtonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); s_advancedOnPixmap.setDevicePixelRatio(devicePixelRatio()); s_advancedOffPixmap.setDevicePixelRatio(devicePixelRatio()); advancedButton->setActiveGraphic(s_advancedOnPixmap); From 905bb64625e9116ae5b499fe8db513963a757164 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Sat, 21 Oct 2023 11:40:13 -0400 Subject: [PATCH 32/35] Do not call QPixmap copy constructor in SaControlsDialog --- plugins/SpectrumAnalyzer/SaControlsDialog.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp index 0df72fe68c8..d36d8a3eeb2 100644 --- a/plugins/SpectrumAnalyzer/SaControlsDialog.cpp +++ b/plugins/SpectrumAnalyzer/SaControlsDialog.cpp @@ -89,10 +89,10 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // pause and freeze buttons auto pauseButton = new PixmapButton(this, tr("Pause")); pauseButton->setToolTip(tr("Pause data acquisition")); - static auto s_pauseOnPixmap = QPixmap( - PLUGIN_NAME::getIconPixmap("play").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - static auto s_pauseOffPixmap = QPixmap( - PLUGIN_NAME::getIconPixmap("pause").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + static auto s_pauseOnPixmap + = PLUGIN_NAME::getIconPixmap("play").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + static auto s_pauseOffPixmap + = PLUGIN_NAME::getIconPixmap("pause").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); s_pauseOnPixmap.setDevicePixelRatio(devicePixelRatio()); s_pauseOffPixmap.setDevicePixelRatio(devicePixelRatio()); pauseButton->setActiveGraphic(s_pauseOnPixmap); @@ -103,10 +103,10 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) auto refFreezeButton = new PixmapButton(this, tr("Reference freeze")); refFreezeButton->setToolTip(tr("Freeze current input as a reference / disable falloff in peak-hold mode.")); - static auto s_freezeOnPixmap = QPixmap( - PLUGIN_NAME::getIconPixmap("freeze").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - static auto s_freezeOffPixmap = QPixmap( - PLUGIN_NAME::getIconPixmap("freeze_off").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + static auto s_freezeOnPixmap + = PLUGIN_NAME::getIconPixmap("freeze").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + static auto s_freezeOffPixmap + = PLUGIN_NAME::getIconPixmap("freeze_off").scaled(buttonSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); s_freezeOnPixmap.setDevicePixelRatio(devicePixelRatio()); s_freezeOffPixmap.setDevicePixelRatio(devicePixelRatio()); refFreezeButton->setActiveGraphic(s_freezeOnPixmap); @@ -147,10 +147,10 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // frequency: linear / log. switch and range selector auto logXButton = new PixmapButton(this, tr("Logarithmic frequency")); logXButton->setToolTip(tr("Switch between logarithmic and linear frequency scale")); - static auto s_logXOnPixmap = QPixmap( - PLUGIN_NAME::getIconPixmap("x_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - static auto s_logXOffPixmap = QPixmap( - PLUGIN_NAME::getIconPixmap("x_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + static auto s_logXOnPixmap + = PLUGIN_NAME::getIconPixmap("x_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + static auto s_logXOffPixmap + = PLUGIN_NAME::getIconPixmap("x_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); s_logXOnPixmap.setDevicePixelRatio(devicePixelRatio()); s_logXOffPixmap.setDevicePixelRatio(devicePixelRatio()); logXButton->setActiveGraphic(s_logXOnPixmap); @@ -169,10 +169,10 @@ SaControlsDialog::SaControlsDialog(SaControls *controls, SaProcessor *processor) // amplitude: linear / log switch and range selector auto logYButton = new PixmapButton(this, tr("Logarithmic amplitude")); logYButton->setToolTip(tr("Switch between logarithmic and linear amplitude scale")); - static auto s_logYOnPixmap = QPixmap( - PLUGIN_NAME::getIconPixmap("y_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); - static auto s_logYOffPixmap = QPixmap( - PLUGIN_NAME::getIconPixmap("y_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation)); + static auto s_logYOnPixmap + = PLUGIN_NAME::getIconPixmap("y_log").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + static auto s_logYOffPixmap + = PLUGIN_NAME::getIconPixmap("y_linear").scaled(iconSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation); s_logYOnPixmap.setDevicePixelRatio(devicePixelRatio()); s_logYOffPixmap.setDevicePixelRatio(devicePixelRatio()); logYButton->setActiveGraphic(s_logYOnPixmap); From 685251246c705f49bf0638ee7966ae02851902bb Mon Sep 17 00:00:00 2001 From: sakertooth Date: Mon, 6 Nov 2023 06:59:13 -0500 Subject: [PATCH 33/35] Do not make pixmap's static for Lcd's and Led's --- include/LcdWidget.h | 4 +--- include/LedCheckBox.h | 7 ++---- src/gui/widgets/LcdWidget.cpp | 38 +++++++-------------------------- src/gui/widgets/LedCheckBox.cpp | 35 ++++++------------------------ 4 files changed, 17 insertions(+), 67 deletions(-) diff --git a/include/LcdWidget.h b/include/LcdWidget.h index cef121b3fce..f900fea1500 100644 --- a/include/LcdWidget.h +++ b/include/LcdWidget.h @@ -47,8 +47,6 @@ class LMMS_EXPORT LcdWidget : public QWidget LcdWidget(int numDigits, const QString& style, QWidget* parent, const QString& name = QString(), bool leadingZero = false); - ~LcdWidget() override; - void setValue(int value); void setValue(float value); void setLabel(const QString& label); @@ -98,7 +96,7 @@ public slots: QString m_display; QString m_label; - QPixmap* m_lcdPixmap; + QPixmap m_lcdPixmap; QColor m_textColor; QColor m_textShadowColor; diff --git a/include/LedCheckBox.h b/include/LedCheckBox.h index e5d4242213e..d3fe25abfa7 100644 --- a/include/LedCheckBox.h +++ b/include/LedCheckBox.h @@ -52,9 +52,6 @@ class LMMS_EXPORT LedCheckBox : public AutomatableButton const QString & _name = QString(), LedColor _color = LedColor::Yellow ); - ~LedCheckBox() override; - - inline const QString & text() { return( m_text ); @@ -69,8 +66,8 @@ class LMMS_EXPORT LedCheckBox : public AutomatableButton private: - QPixmap* m_ledOnPixmap; - QPixmap* m_ledOffPixmap; + QPixmap m_ledOnPixmap; + QPixmap m_ledOffPixmap; QString m_text; diff --git a/src/gui/widgets/LcdWidget.cpp b/src/gui/widgets/LcdWidget.cpp index 434b29d03ea..a409fee8bf6 100644 --- a/src/gui/widgets/LcdWidget.cpp +++ b/src/gui/widgets/LcdWidget.cpp @@ -66,17 +66,6 @@ LcdWidget::LcdWidget(int numDigits, const QString& style, QWidget* parent, const initUi( name, style ); } - - - -LcdWidget::~LcdWidget() -{ - delete m_lcdPixmap; -} - - - - void LcdWidget::setValue(int value) { QString s = m_textForValue[value]; @@ -162,11 +151,8 @@ void LcdWidget::paintEvent( QPaintEvent* ) { p.translate(margin, margin); // Left Margin - p.drawPixmap( - cellRect, - *m_lcdPixmap, - QRect(QPoint(charsPerPixmap * m_cellWidth, isEnabled() ? 0 : m_cellHeight), cellSize) - ); + p.drawPixmap(cellRect, m_lcdPixmap, + QRect(QPoint(charsPerPixmap * m_cellWidth, isEnabled() ? 0 : m_cellHeight), cellSize)); p.translate(m_marginWidth, 0); } @@ -174,8 +160,7 @@ void LcdWidget::paintEvent( QPaintEvent* ) // Padding for( int i=0; i < m_numDigits - m_display.length(); i++ ) { - p.drawPixmap( cellRect, *m_lcdPixmap, - QRect( QPoint( 10 * m_cellWidth, isEnabled()?0:m_cellHeight) , cellSize ) ); + p.drawPixmap(cellRect, m_lcdPixmap, QRect(QPoint(10 * m_cellWidth, isEnabled() ? 0 : m_cellHeight), cellSize)); p.translate( m_cellWidth, 0 ); } @@ -189,19 +174,14 @@ void LcdWidget::paintEvent( QPaintEvent* ) else val = 10; } - p.drawPixmap( cellRect, *m_lcdPixmap, - QRect( QPoint( val*m_cellWidth, - isEnabled()?0:m_cellHeight ), - cellSize ) ); + p.drawPixmap(cellRect, m_lcdPixmap, QRect(QPoint(val * m_cellWidth, isEnabled() ? 0 : m_cellHeight), cellSize)); p.translate( m_cellWidth, 0 ); } // Right Margin - p.drawPixmap(QRect(0, 0, m_seamlessRight ? 0 : m_marginWidth - 1, m_cellHeight), - *m_lcdPixmap, + p.drawPixmap(QRect(0, 0, m_seamlessRight ? 0 : m_marginWidth - 1, m_cellHeight), m_lcdPixmap, QRect(charsPerPixmap * m_cellWidth, isEnabled() ? 0 : m_cellHeight, m_cellWidth / 2, m_cellHeight)); - p.restore(); // Border @@ -297,11 +277,9 @@ void LcdWidget::initUi(const QString& name , const QString& style) //m_lcdPixmap = embed::getIconPixmap(QString("lcd_" + style).toUtf8().constData()); //m_lcdPixmap = embed::getIconPixmap("lcd_19green"); // TODO!! - static auto s_lcdPixmap = embed::getIconPixmap(QString("lcd_" + style).toUtf8().constData()); - m_lcdPixmap = &s_lcdPixmap; - - m_cellWidth = m_lcdPixmap->size().width() / LcdWidget::charsPerPixmap; - m_cellHeight = m_lcdPixmap->size().height() / 2; + m_lcdPixmap = embed::getIconPixmap(QString("lcd_" + style).toUtf8().constData()); + m_cellWidth = m_lcdPixmap.size().width() / LcdWidget::charsPerPixmap; + m_cellHeight = m_lcdPixmap.size().height() / 2; m_marginWidth = m_cellWidth / 2; diff --git a/src/gui/widgets/LedCheckBox.cpp b/src/gui/widgets/LedCheckBox.cpp index 7ee1acbca62..b39d7b39138 100644 --- a/src/gui/widgets/LedCheckBox.cpp +++ b/src/gui/widgets/LedCheckBox.cpp @@ -60,17 +60,6 @@ LedCheckBox::LedCheckBox( QWidget * _parent, { } - - -LedCheckBox::~LedCheckBox() -{ - delete m_ledOnPixmap; - delete m_ledOffPixmap; -} - - - - void LedCheckBox::setText( const QString &s ) { m_text = s; @@ -85,19 +74,11 @@ void LedCheckBox::paintEvent( QPaintEvent * ) QPainter p( this ); p.setFont( pointSize<7>( font() ) ); - if( model()->value() == true ) - { - p.drawPixmap( 0, 0, *m_ledOnPixmap ); - } - else - { - p.drawPixmap( 0, 0, *m_ledOffPixmap ); - } - + p.drawPixmap(0, 0, model()->value() ? m_ledOnPixmap : m_ledOffPixmap); p.setPen( QColor( 64, 64, 64 ) ); - p.drawText( m_ledOffPixmap->width() + 4, 11, text() ); + p.drawText(m_ledOffPixmap.width() + 4, 11, text()); p.setPen( QColor( 255, 255, 255 ) ); - p.drawText( m_ledOffPixmap->width() + 3, 10, text() ); + p.drawText(m_ledOffPixmap.width() + 3, 10, text()); } @@ -107,10 +88,8 @@ void LedCheckBox::initUi( LedColor _color ) { setCheckable( true ); - static auto s_ledOnPixmap = embed::getIconPixmap(names[static_cast(_color)].toUtf8().constData()); - static auto s_ledOffPixmap = embed::getIconPixmap("led_off"); - m_ledOnPixmap = &s_ledOffPixmap; - m_ledOffPixmap = &s_ledOnPixmap; + m_ledOnPixmap = embed::getIconPixmap(names[static_cast(_color)].toUtf8().constData()); + m_ledOffPixmap = embed::getIconPixmap("led_off"); setFont( pointSize<7>( font() ) ); setText( m_text ); @@ -121,9 +100,7 @@ void LedCheckBox::initUi( LedColor _color ) void LedCheckBox::onTextUpdated() { - setFixedSize(m_ledOffPixmap->width() + 5 + horizontalAdvance(QFontMetrics(font()), - text()), - m_ledOffPixmap->height()); + setFixedSize(m_ledOffPixmap.width() + 5 + horizontalAdvance(QFontMetrics(font()), text()), m_ledOffPixmap.height()); } From 138971611c2779d155b89e1ebefb14bb3e174ad7 Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 10 Nov 2023 04:07:06 -0500 Subject: [PATCH 34/35] Initialize pixmaps in-class --- include/AutomationEditor.h | 14 +++---- include/ComboBox.h | 6 +-- include/EnvelopeAndLfoView.h | 5 ++- include/Fader.h | 9 +++-- include/FileBrowser.h | 15 ++------ include/MidiClipView.h | 9 +++-- include/PianoRoll.h | 12 +++--- include/PianoView.h | 13 ++++--- include/SendButtonIndicator.h | 5 ++- include/TimeLineWidget.h | 3 +- src/gui/FileBrowser.cpp | 23 ++---------- src/gui/SendButtonIndicator.cpp | 8 +--- src/gui/clips/MidiClipView.cpp | 26 +++++-------- src/gui/editors/AutomationEditor.cpp | 34 ++++------------- src/gui/editors/PianoRoll.cpp | 29 ++++---------- src/gui/editors/TimeLineWidget.cpp | 23 +++++------- src/gui/instrument/EnvelopeAndLfoView.cpp | 24 +++++------- src/gui/instrument/PianoView.cpp | 33 +++++----------- src/gui/widgets/ComboBox.cpp | 11 +----- src/gui/widgets/Fader.cpp | 46 +++++++++-------------- src/tracks/MidiClip.cpp | 7 ---- 21 files changed, 123 insertions(+), 232 deletions(-) diff --git a/include/AutomationEditor.h b/include/AutomationEditor.h index abc450d6bf3..da6bdcaaf32 100644 --- a/include/AutomationEditor.h +++ b/include/AutomationEditor.h @@ -187,13 +187,13 @@ protected slots: AutomationEditor( const AutomationEditor & ); ~AutomationEditor() override; - QPixmap* m_toolDraw; - QPixmap* m_toolErase; - QPixmap* m_toolDrawOut; - QPixmap* m_toolEditTangents; - QPixmap* m_toolMove; - QPixmap* m_toolYFlip; - QPixmap* m_toolXFlip; + QPixmap m_toolDraw = embed::getIconPixmap("edit_draw"); + QPixmap m_toolErase = embed::getIconPixmap("edit_erase"); + QPixmap m_toolDrawOut = embed::getIconPixmap("edit_draw_outvalue"); + QPixmap m_toolEditTangents = embed::getIconPixmap("edit_tangent"); + QPixmap m_toolMove = embed::getIconPixmap("edit_move"); + QPixmap m_toolYFlip = embed::getIconPixmap("flip_y"); + QPixmap m_toolXFlip = embed::getIconPixmap("flip_x"); ComboBoxModel m_zoomingXModel; ComboBoxModel m_zoomingYModel; diff --git a/include/ComboBox.h b/include/ComboBox.h index d361b3fa4ba..cc4ad68dd88 100644 --- a/include/ComboBox.h +++ b/include/ComboBox.h @@ -66,9 +66,9 @@ public slots: private: - QPixmap* m_background; - QPixmap* m_arrow; - QPixmap* m_arrowSelected; + QPixmap m_background = embed::getIconPixmap("combobox_bg"); + QPixmap m_arrow = embed::getIconPixmap("combobox_arrow"); + QPixmap m_arrowSelected = embed::getIconPixmap("combobox_arrow_selected"); QMenu m_menu; diff --git a/include/EnvelopeAndLfoView.h b/include/EnvelopeAndLfoView.h index b798594a141..d545aaa0687 100644 --- a/include/EnvelopeAndLfoView.h +++ b/include/EnvelopeAndLfoView.h @@ -29,6 +29,7 @@ #include #include "ModelView.h" +#include "embed.h" class QPaintEvent; class QPixmap; @@ -71,8 +72,8 @@ protected slots: private: - QPixmap* m_envGraph; - QPixmap* m_lfoGraph; + QPixmap m_envGraph = embed::getIconPixmap("envelope_graph"); + QPixmap m_lfoGraph = embed::getIconPixmap("lfo_graph"); EnvelopeAndLfoParameters * m_params; diff --git a/include/Fader.h b/include/Fader.h index 3445f37e9cf..c44d976a712 100644 --- a/include/Fader.h +++ b/include/Fader.h @@ -53,6 +53,7 @@ #include "AutomatableModelView.h" +#include "embed.h" namespace lmms::gui @@ -131,7 +132,7 @@ class LMMS_EXPORT Fader : public QWidget, public FloatModelView float fRange = model()->maxValue() - model()->minValue(); float realVal = model()->value() - model()->minValue(); - return height() - ( ( height() - m_knob->height() ) * ( realVal / fRange ) ); + return height() - ((height() - m_knob.height()) * (realVal / fRange)); } void setPeak( float fPeak, float &targetPeak, float &persistentPeak, QElapsedTimer &lastPeakTimer ); @@ -151,9 +152,9 @@ class LMMS_EXPORT Fader : public QWidget, public FloatModelView QElapsedTimer m_lastPeakTimer_L; QElapsedTimer m_lastPeakTimer_R; - QPixmap * m_back; - QPixmap * m_leds; - QPixmap * m_knob; + QPixmap m_back = embed::getIconPixmap("fader_background"); + QPixmap m_leds = embed::getIconPixmap("fader_leds"); + QPixmap m_knob = embed::getIconPixmap("fader_knob"); bool m_levelsDisplayedInDBFS; diff --git a/include/FileBrowser.h b/include/FileBrowser.h index 3bdf43700fe..b5709043fab 100644 --- a/include/FileBrowser.h +++ b/include/FileBrowser.h @@ -28,6 +28,7 @@ #include #include #include +#include "embed.h" #if (QT_VERSION >= QT_VERSION_CHECK(5,14,0)) #include #endif @@ -200,9 +201,9 @@ class Directory : public QTreeWidgetItem bool addItems( const QString & path ); - QPixmap* m_folderPixmap; - QPixmap* m_folderOpenedPixmap; - QPixmap* m_folderLockedPixmap; + QPixmap m_folderPixmap = embed::getIconPixmap("folder"); + QPixmap m_folderOpenedPixmap = embed::getIconPixmap("folder_opened"); + QPixmap m_folderLockedPixmap = embed::getIconPixmap("folder_locked"); //! Directories that lead here //! Initially, this is just set to the current path of a directory @@ -278,14 +279,6 @@ class FileItem : public QTreeWidgetItem void initPixmaps(); void determineFileType(); - static QPixmap * s_projectFilePixmap; - static QPixmap * s_presetFilePixmap; - static QPixmap * s_sampleFilePixmap; - static QPixmap * s_soundfontFilePixmap; - static QPixmap * s_vstPluginFilePixmap; - static QPixmap * s_midiFilePixmap; - static QPixmap * s_unknownFilePixmap; - QString m_path; FileType m_type; FileHandling m_handling; diff --git a/include/MidiClipView.h b/include/MidiClipView.h index 6558688b49b..a32be956a2c 100644 --- a/include/MidiClipView.h +++ b/include/MidiClipView.h @@ -27,6 +27,7 @@ #include #include "ClipView.h" +#include "embed.h" namespace lmms { @@ -85,10 +86,10 @@ protected slots: private: - static QPixmap * s_stepBtnOn0; - static QPixmap * s_stepBtnOn200; - static QPixmap * s_stepBtnOff; - static QPixmap * s_stepBtnOffLight; + QPixmap m_stepBtnOn0 = embed::getIconPixmap("step_btn_on_0"); + QPixmap m_stepBtnOn200 = embed::getIconPixmap("step_btn_on_200"); + QPixmap m_stepBtnOff = embed::getIconPixmap("step_btn_off"); + QPixmap m_stepBtnOffLight = embed::getIconPixmap("step_btn_off_light"); MidiClip* m_clip; QPixmap m_paintPixmap; diff --git a/include/PianoRoll.h b/include/PianoRoll.h index 9de2d3182ed..806b16973d3 100644 --- a/include/PianoRoll.h +++ b/include/PianoRoll.h @@ -339,12 +339,12 @@ protected slots: static const int cm_scrollAmtHoriz = 10; static const int cm_scrollAmtVert = 1; - QPixmap* m_toolDraw; - QPixmap* m_toolErase; - QPixmap* m_toolSelect; - QPixmap* m_toolMove; - QPixmap* m_toolOpen; - QPixmap* m_toolKnife; + QPixmap m_toolDraw = embed::getIconPixmap("edit_draw"); + QPixmap m_toolErase = embed::getIconPixmap("edit_erase"); + QPixmap m_toolSelect = embed::getIconPixmap("edit_select"); + QPixmap m_toolMove = embed::getIconPixmap("edit_move"); + QPixmap m_toolOpen = embed::getIconPixmap("automation"); + QPixmap m_toolKnife = embed::getIconPixmap("edit_knife"); static std::array prKeyOrder; diff --git a/include/PianoView.h b/include/PianoView.h index 68a4b732857..3f8d8026f56 100644 --- a/include/PianoView.h +++ b/include/PianoView.h @@ -30,6 +30,7 @@ #include "AutomatableModel.h" #include "ModelView.h" +#include "embed.h" namespace lmms { @@ -73,12 +74,12 @@ class PianoView : public QWidget, public ModelView int getKeyHeight(int key_num) const; IntModel *getNearestMarker(int key, QString* title = nullptr); - QPixmap* m_whiteKeyPm; - QPixmap* m_blackKeyPm; - QPixmap* m_whiteKeyPressedPm; - QPixmap* m_blackKeyPressedPm; - QPixmap* m_whiteKeyDisabledPm; - QPixmap* m_blackKeyDisabledPm; + QPixmap m_whiteKeyPm = embed::getIconPixmap("white_key"); + QPixmap m_blackKeyPm = embed::getIconPixmap("black_key"); + QPixmap m_whiteKeyPressedPm = embed::getIconPixmap("white_key_pressed"); + QPixmap m_blackKeyPressedPm = embed::getIconPixmap("black_key_pressed"); + QPixmap m_whiteKeyDisabledPm = embed::getIconPixmap("white_key_disabled"); + QPixmap m_blackKeyDisabledPm = embed::getIconPixmap("black_key_disabled"); Piano * m_piano; diff --git a/include/SendButtonIndicator.h b/include/SendButtonIndicator.h index bdab27a9f29..86f38318feb 100644 --- a/include/SendButtonIndicator.h +++ b/include/SendButtonIndicator.h @@ -26,6 +26,7 @@ #define LMMS_GUI_SEND_BUTTON_INDICATOR_H #include +#include "embed.h" namespace lmms @@ -53,8 +54,8 @@ class SendButtonIndicator : public QLabel MixerLine * m_parent; MixerView * m_mv; - QPixmap* m_qpmOn; - QPixmap* m_qpmOff; + QPixmap m_qpmOff = embed::getIconPixmap("mixer_send_off", 29, 20); + QPixmap m_qpmOn = embed::getIconPixmap("mixer_send_on", 29, 20); FloatModel * getSendModel(); }; diff --git a/include/TimeLineWidget.h b/include/TimeLineWidget.h index 487740bacf2..2be73b77c49 100644 --- a/include/TimeLineWidget.h +++ b/include/TimeLineWidget.h @@ -28,6 +28,7 @@ #include #include "Song.h" +#include "embed.h" class QPixmap; @@ -205,7 +206,7 @@ public slots: private: - QPixmap* m_posMarkerPixmap; + QPixmap m_posMarkerPixmap = embed::getIconPixmap("playpos_marker"); QColor m_inactiveLoopColor; QBrush m_inactiveLoopBrush; diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index 4db867274e8..5f75712bcd7 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -965,15 +965,7 @@ Directory::Directory(const QString & filename, const QString & path, m_filter( filter ), m_dirCount( 0 ) { - static auto s_folderPixmap = embed::getIconPixmap("folder"); - static auto s_folderOpenedPixmap = embed::getIconPixmap("folder_opened"); - static auto s_folderLockedPixmap = embed::getIconPixmap("folder_locked"); - - m_folderPixmap = &s_folderPixmap; - m_folderOpenedPixmap = &s_folderOpenedPixmap; - m_folderLockedPixmap = &s_folderLockedPixmap; - - setIcon(0, !QDir{fullName()}.isReadable() ? s_folderLockedPixmap : s_folderPixmap); + setIcon(0, !QDir{fullName()}.isReadable() ? m_folderLockedPixmap : m_folderPixmap); setChildIndicatorPolicy( QTreeWidgetItem::ShowIndicator ); } @@ -981,11 +973,11 @@ void Directory::update() { if( !isExpanded() ) { - setIcon(0, *m_folderPixmap); + setIcon(0, m_folderPixmap); return; } - setIcon(0, *m_folderOpenedPixmap); + setIcon(0, m_folderOpenedPixmap); if( !childCount() ) { m_dirCount = 0; @@ -1050,15 +1042,6 @@ bool Directory::addItems(const QString& path) -QPixmap * FileItem::s_projectFilePixmap = nullptr; -QPixmap * FileItem::s_presetFilePixmap = nullptr; -QPixmap * FileItem::s_sampleFilePixmap = nullptr; -QPixmap * FileItem::s_soundfontFilePixmap = nullptr; -QPixmap * FileItem::s_vstPluginFilePixmap = nullptr; -QPixmap * FileItem::s_midiFilePixmap = nullptr; -QPixmap * FileItem::s_unknownFilePixmap = nullptr; - - FileItem::FileItem(QTreeWidget * parent, const QString & name, const QString & path ) : QTreeWidgetItem( parent, QStringList( name) , TypeFileItem ), diff --git a/src/gui/SendButtonIndicator.cpp b/src/gui/SendButtonIndicator.cpp index a47f0697104..d6f8a832778 100644 --- a/src/gui/SendButtonIndicator.cpp +++ b/src/gui/SendButtonIndicator.cpp @@ -14,15 +14,11 @@ SendButtonIndicator:: SendButtonIndicator( QWidget * _parent, MixerLine * _owner m_parent( _owner ), m_mv( _mv ) { - static auto s_qpmOff = embed::getIconPixmap("mixer_send_off", 29, 20); - static auto s_qpmOn = embed::getIconPixmap("mixer_send_on", 29, 20); - m_qpmOff = &s_qpmOff; - m_qpmOn = &s_qpmOn; // don't do any initializing yet, because the MixerView and MixerLine // that were passed to this constructor are not done with their constructors // yet. - setPixmap(s_qpmOff); + setPixmap(m_qpmOff); } void SendButtonIndicator::mousePressEvent( QMouseEvent * e ) @@ -55,7 +51,7 @@ FloatModel * SendButtonIndicator::getSendModel() void SendButtonIndicator::updateLightStatus() { - setPixmap(!getSendModel() ? *m_qpmOff : *m_qpmOn); + setPixmap(!getSendModel() ? m_qpmOff : m_qpmOn); } diff --git a/src/gui/clips/MidiClipView.cpp b/src/gui/clips/MidiClipView.cpp index 0733b548daf..36471522845 100644 --- a/src/gui/clips/MidiClipView.cpp +++ b/src/gui/clips/MidiClipView.cpp @@ -227,9 +227,8 @@ void MidiClipView::constructContextMenu( QMenu * _cm ) void MidiClipView::mousePressEvent( QMouseEvent * _me ) { bool displayPattern = fixedClips() || (pixelsPerBar() >= 96 && m_legacySEPattern); - if( _me->button() == Qt::LeftButton && - m_clip->m_clipType == MidiClip::Type::BeatClip && - displayPattern && _me->y() > height() - s_stepBtnOff->height() ) + if (_me->button() == Qt::LeftButton && m_clip->m_clipType == MidiClip::Type::BeatClip && displayPattern + && _me->y() > height() - m_stepBtnOff.height()) // when mouse button is pressed in pattern mode @@ -299,7 +298,7 @@ void MidiClipView::wheelEvent(QWheelEvent * we) { if(m_clip->m_clipType == MidiClip::Type::BeatClip && (fixedClips() || pixelsPerBar() >= 96) && - position(we).y() > height() - s_stepBtnOff->height()) + position(we).y() > height() - m_stepBtnOff.height()) { // get the step number that was wheeled on and // do calculations in floats to prevent rounding errors... @@ -560,20 +559,15 @@ void MidiClipView::paintEvent( QPaintEvent * ) m_clip->m_steps ); const int w = width() - 2 * BORDER_WIDTH; - static auto s_stepBtnOn0 = embed::getIconPixmap("step_btn_on_0"); - static auto s_stepBtnOn200 = embed::getIconPixmap("step_btn_on_200"); - static auto s_stepBtnOff = embed::getIconPixmap("step_btn_off"); - static auto s_stepBtnOffLight = embed::getIconPixmap("step_btn_off_light"); - // scale step graphics to fit the beat clip length stepon0 - = s_stepBtnOn0.scaled(w / steps, s_stepBtnOn0.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - stepon200 = s_stepBtnOn200.scaled( - w / steps, s_stepBtnOn200.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + = m_stepBtnOn0.scaled(w / steps, m_stepBtnOn0.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + stepon200 = m_stepBtnOn200.scaled( + w / steps, m_stepBtnOn200.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); stepoff - = s_stepBtnOff.scaled(w / steps, s_stepBtnOff.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); - stepoffl = s_stepBtnOffLight.scaled( - w / steps, s_stepBtnOffLight.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + = m_stepBtnOff.scaled(w / steps, m_stepBtnOff.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); + stepoffl = m_stepBtnOffLight.scaled( + w / steps, m_stepBtnOffLight.height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); for( int it = 0; it < steps; it++ ) // go through all the steps in the beat clip { @@ -581,7 +575,7 @@ void MidiClipView::paintEvent( QPaintEvent * ) // figure out x and y coordinates for step graphic const int x = BORDER_WIDTH + static_cast( it * w / steps ); - const int y = height() - s_stepBtnOff.height() - 1; + const int y = height() - m_stepBtnOff.height() - 1; if( n ) { diff --git a/src/gui/editors/AutomationEditor.cpp b/src/gui/editors/AutomationEditor.cpp index 718156ea5bd..bd9566a057d 100644 --- a/src/gui/editors/AutomationEditor.cpp +++ b/src/gui/editors/AutomationEditor.cpp @@ -126,11 +126,6 @@ AutomationEditor::AutomationEditor() : this, SLOT(setQuantization())); m_quantizeModel.setValue( m_quantizeModel.findText( "1/8" ) ); - static auto s_toolYFlip = embed::getIconPixmap("flip_y"); - static auto s_toolXFlip = embed::getIconPixmap("flip_x"); - m_toolYFlip = &s_toolYFlip; - m_toolXFlip = &s_toolXFlip; - // add time-line m_timeLine = new TimeLineWidget( VALUES_WIDTH, 0, m_ppb, Engine::getSong()->getPlayPos( @@ -154,19 +149,6 @@ AutomationEditor::AutomationEditor() : connect( m_topBottomScroll, SIGNAL(valueChanged(int)), this, SLOT(verScrolled(int))); - // init pixmaps - static auto s_toolDraw = embed::getIconPixmap("edit_draw"); - static auto s_toolErase = embed::getIconPixmap("edit_erase"); - static auto s_toolDrawOut = embed::getIconPixmap("edit_draw_outvalue"); - static auto s_toolEditTangents = embed::getIconPixmap("edit_tangent"); - static auto s_toolMove = embed::getIconPixmap("edit_move"); - - m_toolDraw = &s_toolDraw; - m_toolErase = &s_toolErase; - m_toolDrawOut = &s_toolDrawOut; - m_toolEditTangents = &s_toolEditTangents; - m_toolMove = &s_toolMove; - setCurrentClip(nullptr); setMouseTracking( true ); @@ -1376,26 +1358,26 @@ void AutomationEditor::paintEvent(QPaintEvent * pe ) { case EditMode::Draw: { - if (m_action == Action::EraseValues) { cursor = m_toolErase; } - else if (m_action == Action::MoveValue) { cursor = m_toolMove; } - else { cursor = m_toolDraw; } + if (m_action == Action::EraseValues) { cursor = &m_toolErase; } + else if (m_action == Action::MoveValue) { cursor = &m_toolMove; } + else { cursor = &m_toolDraw; } break; } case EditMode::Erase: { - cursor = m_toolErase; + cursor = &m_toolErase; break; } case EditMode::DrawOutValues: { - if (m_action == Action::ResetOutValues) { cursor = m_toolErase; } - else if (m_action == Action::MoveOutValue) { cursor = m_toolMove; } - else { cursor = m_toolDrawOut; } + if (m_action == Action::ResetOutValues) { cursor = &m_toolErase; } + else if (m_action == Action::MoveOutValue) { cursor = &m_toolMove; } + else { cursor = &m_toolDrawOut; } break; } case EditMode::EditTangents: { - cursor = m_action == Action::MoveTangent ? m_toolMove : m_toolEditTangents; + cursor = m_action == Action::MoveTangent ? &m_toolMove : &m_toolEditTangents; break; } } diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 444787b10b3..e5a93d28634 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -255,21 +255,6 @@ PianoRoll::PianoRoll() : m_semiToneMarkerMenu->addAction( unmarkAllAction ); m_semiToneMarkerMenu->addAction( copyAllNotesAction ); - // init pixmaps - static auto s_toolDraw = embed::getIconPixmap("edit_draw"); - static auto s_toolErase = embed::getIconPixmap("edit_erase"); - static auto s_toolSelect = embed::getIconPixmap("edit_select"); - static auto s_toolMove = embed::getIconPixmap("edit_move"); - static auto s_toolOpen = embed::getIconPixmap("automation"); - static auto s_toolKnife = embed::getIconPixmap("edit_knife"); - - m_toolDraw = &s_toolDraw; - m_toolErase = &s_toolErase; - m_toolSelect = &s_toolSelect; - m_toolMove = &s_toolMove; - m_toolOpen = &s_toolOpen; - m_toolOpen = &s_toolKnife; - // init text-float if( s_textFloat == nullptr ) { @@ -3679,28 +3664,28 @@ void PianoRoll::paintEvent(QPaintEvent * pe ) case EditMode::Draw: if( m_mouseDownRight ) { - cursor = m_toolErase; + cursor = &m_toolErase; } else if( m_action == Action::MoveNote ) { - cursor = m_toolMove; + cursor = &m_toolMove; } else { - cursor = m_toolDraw; + cursor = &m_toolDraw; } break; case EditMode::Erase: - cursor = m_toolErase; + cursor = &m_toolErase; break; case EditMode::Select: - cursor = m_toolSelect; + cursor = &m_toolSelect; break; case EditMode::Detuning: - cursor = m_toolOpen; + cursor = &m_toolOpen; break; case EditMode::Knife: - cursor = m_toolKnife; + cursor = &m_toolKnife; break; } QPoint mousePosition = mapFromGlobal( QCursor::pos() ); diff --git a/src/gui/editors/TimeLineWidget.cpp b/src/gui/editors/TimeLineWidget.cpp index 172cc35bf12..049a8623ffb 100644 --- a/src/gui/editors/TimeLineWidget.cpp +++ b/src/gui/editors/TimeLineWidget.cpp @@ -77,13 +77,10 @@ TimeLineWidget::TimeLineWidget( const int xoff, const int yoff, const float ppb, m_loopPos[0] = 0; m_loopPos[1] = DefaultTicksPerBar; - static auto s_posMarkerPixmap = embed::getIconPixmap("playpos_marker"); - m_posMarkerPixmap = &s_posMarkerPixmap; - setAttribute( Qt::WA_OpaquePaintEvent, true ); move( 0, yoff ); - m_xOffset -= s_posMarkerPixmap.width() / 2; + m_xOffset -= m_posMarkerPixmap.width() / 2; setMouseTracking(true); m_pos.m_timeLine = this; @@ -113,7 +110,7 @@ TimeLineWidget::~TimeLineWidget() void TimeLineWidget::setXOffset(const int x) { m_xOffset = x; - m_xOffset -= m_posMarkerPixmap->width() / 2; + m_xOffset -= m_posMarkerPixmap.width() / 2; } @@ -239,7 +236,7 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) p.fillRect( 0, 0, width(), height(), p.background() ); // Clip so that we only draw everything starting from the offset - const int leftMargin = m_xOffset + m_posMarkerPixmap->width() / 2; + const int leftMargin = m_xOffset + m_posMarkerPixmap.width() / 2; p.setClipRect(leftMargin, 0, width() - leftMargin, height() ); // Draw the loop rectangle @@ -267,8 +264,8 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) QColor const & barNumberColor = getBarNumberColor(); bar_t barNumber = m_begin.getBar(); - int const x = m_xOffset + m_posMarkerPixmap->width() / 2 - - ( ( static_cast( m_begin * m_ppb ) / TimePos::ticksPerBar() ) % static_cast( m_ppb ) ); + int const x = m_xOffset + m_posMarkerPixmap.width() / 2 + - ((static_cast(m_begin * m_ppb) / TimePos::ticksPerBar()) % static_cast(m_ppb)); // Double the interval between bar numbers until they are far enough appart int barLabelInterval = 1; @@ -301,12 +298,12 @@ void TimeLineWidget::paintEvent( QPaintEvent * ) p.drawRect( innerRectangle ); // Only draw the position marker if the position line is in view - if (m_posMarkerX >= m_xOffset && m_posMarkerX < width() - m_posMarkerPixmap->width() / 2) + if (m_posMarkerX >= m_xOffset && m_posMarkerX < width() - m_posMarkerPixmap.width() / 2) { // Let the position marker extrude to the left p.setClipping(false); p.setOpacity(0.6); - p.drawPixmap(m_posMarkerX, height() - m_posMarkerPixmap->height(), *m_posMarkerPixmap); + p.drawPixmap(m_posMarkerX, height() - m_posMarkerPixmap.height(), m_posMarkerPixmap); } } @@ -322,13 +319,13 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event ) if( event->button() == Qt::LeftButton && !(event->modifiers() & Qt::ShiftModifier) ) { m_action = Action::MovePositionMarker; - if( event->x() - m_xOffset < m_posMarkerPixmap->width() ) + if (event->x() - m_xOffset < m_posMarkerPixmap.width()) { m_moveXOff = event->x() - m_xOffset; } else { - m_moveXOff = m_posMarkerPixmap->width() / 2; + m_moveXOff = m_posMarkerPixmap.width() / 2; } } else if( event->button() == Qt::LeftButton && (event->modifiers() & Qt::ShiftModifier) ) @@ -338,7 +335,7 @@ void TimeLineWidget::mousePressEvent( QMouseEvent* event ) } else if( event->button() == Qt::RightButton ) { - m_moveXOff = m_posMarkerPixmap->width() / 2; + m_moveXOff = m_posMarkerPixmap.width() / 2; const TimePos t = m_begin + static_cast( qMax( event->x() - m_xOffset - m_moveXOff, 0 ) * TimePos::ticksPerBar() / m_ppb ); const TimePos loopMid = ( m_loopPos[0] + m_loopPos[1] ) / 2; diff --git a/src/gui/instrument/EnvelopeAndLfoView.cpp b/src/gui/instrument/EnvelopeAndLfoView.cpp index fb8d2347a6b..2a192832601 100644 --- a/src/gui/instrument/EnvelopeAndLfoView.cpp +++ b/src/gui/instrument/EnvelopeAndLfoView.cpp @@ -84,10 +84,6 @@ EnvelopeAndLfoView::EnvelopeAndLfoView( QWidget * _parent ) : ModelView( nullptr, this ), m_params( nullptr ) { - static auto s_envGraph = embed::getIconPixmap("envelope_graph"); - static auto s_lfoGraph = embed::getIconPixmap("lfo_graph"); - m_envGraph = &s_envGraph; - m_lfoGraph = &s_lfoGraph; m_predelayKnob = new Knob( KnobType::Bright26, this ); m_predelayKnob->setLabel( tr( "DEL" ) ); @@ -267,7 +263,7 @@ void EnvelopeAndLfoView::mousePressEvent( QMouseEvent * _me ) return; } - if (QRect(ENV_GRAPH_X, ENV_GRAPH_Y, m_envGraph->width(), m_envGraph->height()).contains(_me->pos())) + if (QRect(ENV_GRAPH_X, ENV_GRAPH_Y, m_envGraph.width(), m_envGraph.height()).contains(_me->pos())) { if( m_params->m_amountModel.value() < 1.0f ) { @@ -278,7 +274,7 @@ void EnvelopeAndLfoView::mousePressEvent( QMouseEvent * _me ) m_params->m_amountModel.setValue( 0.0f ); } } - else if (QRect(LFO_GRAPH_X, LFO_GRAPH_Y, m_lfoGraph->width(), m_lfoGraph->height()).contains(_me->pos())) + else if (QRect(LFO_GRAPH_X, LFO_GRAPH_Y, m_lfoGraph.width(), m_lfoGraph.height()).contains(_me->pos())) { if( m_params->m_lfoAmountModel.value() < 1.0f ) { @@ -339,9 +335,9 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) p.setRenderHint( QPainter::Antialiasing ); // draw envelope-graph - p.drawPixmap(ENV_GRAPH_X, ENV_GRAPH_Y, *m_envGraph); + p.drawPixmap(ENV_GRAPH_X, ENV_GRAPH_Y, m_envGraph); // draw LFO-graph - p.drawPixmap(LFO_GRAPH_X, LFO_GRAPH_Y, *m_lfoGraph); + p.drawPixmap(LFO_GRAPH_X, LFO_GRAPH_Y, m_lfoGraph); p.setFont( pointSize<8>( p.font() ) ); @@ -355,8 +351,8 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) const QColor end_points_color( 0x99, 0xAF, 0xFF ); const QColor end_points_bg_color( 0, 0, 2 ); - const int y_base = ENV_GRAPH_Y + m_envGraph->height() - 3; - const int avail_height = m_envGraph->height() - 6; + const int y_base = ENV_GRAPH_Y + m_envGraph.height() - 3; + const int avail_height = m_envGraph.height() - 6; int x1 = static_cast( m_predelayKnob->value() * TIME_UNIT_WIDTH ); int x2 = x1 + static_cast( m_attackKnob->value() * TIME_UNIT_WIDTH ); @@ -409,8 +405,8 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) p.fillRect( x5 - 1, y_base - 2, 4, 4, end_points_bg_color ); p.fillRect( x5, y_base - 1, 2, 2, end_points_color ); - int LFO_GRAPH_W = m_lfoGraph->width() - 3; // subtract border - int LFO_GRAPH_H = m_lfoGraph->height() - 6; // subtract border + int LFO_GRAPH_W = m_lfoGraph.width() - 3; // subtract border + int LFO_GRAPH_H = m_lfoGraph.height() - 6; // subtract border int graph_x_base = LFO_GRAPH_X + 2; int graph_y_base = LFO_GRAPH_Y + 3 + LFO_GRAPH_H / 2; @@ -491,8 +487,8 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) int ms_per_osc = static_cast( SECS_PER_LFO_OSCILLATION * m_lfoSpeedKnob->value() * 1000.0f ); - p.drawText(LFO_GRAPH_X + 4, LFO_GRAPH_Y + m_lfoGraph->height() - 6, tr("ms/LFO:")); - p.drawText(LFO_GRAPH_X + 52, LFO_GRAPH_Y + m_lfoGraph->height() - 6, QString::number(ms_per_osc)); + p.drawText(LFO_GRAPH_X + 4, LFO_GRAPH_Y + m_lfoGraph.height() - 6, tr("ms/LFO:")); + p.drawText(LFO_GRAPH_X + 52, LFO_GRAPH_Y + m_lfoGraph.height() - 6, QString::number(ms_per_osc)); } diff --git a/src/gui/instrument/PianoView.cpp b/src/gui/instrument/PianoView.cpp index 2c5b466b334..c70e7b6142a 100644 --- a/src/gui/instrument/PianoView.cpp +++ b/src/gui/instrument/PianoView.cpp @@ -90,21 +90,6 @@ PianoView::PianoView(QWidget *parent) : m_lastKey(-1), /*!< The last key displayed? */ m_movedNoteModel(nullptr) /*!< Key marker which is being moved */ { - - static auto s_whiteKeyPm = embed::getIconPixmap("white_key"); - static auto s_blackKeyPm = embed::getIconPixmap("black_key"); - static auto s_whiteKeyPressedPm = embed::getIconPixmap("white_key_pressed"); - static auto s_blackKeyPressedPm = embed::getIconPixmap("black_key_pressed"); - static auto s_whiteKeyDisabledPm = embed::getIconPixmap("white_key_disabled"); - static auto s_blackKeyDisabledPm = embed::getIconPixmap("black_key_disabled"); - - m_whiteKeyPm = &s_whiteKeyPm; - m_blackKeyPm = &s_blackKeyPm; - m_whiteKeyPressedPm = &s_whiteKeyPressedPm; - m_blackKeyPressedPm = &s_blackKeyPressedPm; - m_whiteKeyDisabledPm = &s_whiteKeyDisabledPm; - m_whiteKeyDisabledPm = &s_blackKeyDisabledPm; - setAttribute(Qt::WA_OpaquePaintEvent, true); setFocusPolicy(Qt::StrongFocus); @@ -875,16 +860,16 @@ void PianoView::paintEvent( QPaintEvent * ) { if (m_piano && m_piano->isKeyPressed(cur_key)) { - p.drawPixmap(x, PIANO_BASE, *m_whiteKeyPressedPm); + p.drawPixmap(x, PIANO_BASE, m_whiteKeyPressedPm); } else { - p.drawPixmap(x, PIANO_BASE, *m_whiteKeyPm); + p.drawPixmap(x, PIANO_BASE, m_whiteKeyPm); } } else { - p.drawPixmap(x, PIANO_BASE, *m_whiteKeyDisabledPm); + p.drawPixmap(x, PIANO_BASE, m_whiteKeyDisabledPm); } x += PW_WHITE_KEY_WIDTH; @@ -909,16 +894,16 @@ void PianoView::paintEvent( QPaintEvent * ) { if (m_piano && m_piano->isKeyPressed(startKey)) { - p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *m_blackKeyPressedPm); + p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_blackKeyPressedPm); } else { - p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *m_blackKeyPm); + p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_blackKeyPm); } } else { - p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *m_whiteKeyDisabledPm); + p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_whiteKeyDisabledPm); } } @@ -932,16 +917,16 @@ void PianoView::paintEvent( QPaintEvent * ) { if (m_piano && m_piano->isKeyPressed(cur_key)) { - p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *m_blackKeyPressedPm); + p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_blackKeyPressedPm); } else { - p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *m_blackKeyPm); + p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_blackKeyPm); } } else { - p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, *m_whiteKeyDisabledPm); + p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_whiteKeyDisabledPm); } x += PW_WHITE_KEY_WIDTH; white_cnt = 0; diff --git a/src/gui/widgets/ComboBox.cpp b/src/gui/widgets/ComboBox.cpp index c01ae766333..ccc0c675b0d 100644 --- a/src/gui/widgets/ComboBox.cpp +++ b/src/gui/widgets/ComboBox.cpp @@ -49,13 +49,6 @@ ComboBox::ComboBox( QWidget * _parent, const QString & _name ) : { setFixedHeight( ComboBox::DEFAULT_HEIGHT ); - static auto s_background = embed::getIconPixmap("combobox_bg"); - static auto s_arrow = embed::getIconPixmap("combobox_arrow"); - static auto s_arrowSelected = embed::getIconPixmap("combobox_arrow_selected"); - m_background = &s_background; - m_arrow = &s_arrow; - m_arrowSelected = &s_arrowSelected; - setFont( pointSize<9>( font() ) ); connect( &m_menu, SIGNAL(triggered(QAction*)), @@ -159,7 +152,7 @@ void ComboBox::paintEvent( QPaintEvent * _pe ) { QPainter p( this ); - p.fillRect(2, 2, width() - 2, height() - 4, *m_background); + p.fillRect(2, 2, width() - 2, height() - 4, m_background); QColor shadow = palette().shadow().color(); QColor highlight = palette().highlight().color(); @@ -183,7 +176,7 @@ void ComboBox::paintEvent( QPaintEvent * _pe ) auto arrow = m_pressed ? m_arrowSelected : m_arrow; - p.drawPixmap(width() - CB_ARROW_BTN_WIDTH + 3, 4, *arrow); + p.drawPixmap(width() - CB_ARROW_BTN_WIDTH + 3, 4, arrow); if( model() && model()->size() > 0 ) { diff --git a/src/gui/widgets/Fader.cpp b/src/gui/widgets/Fader.cpp index 3b8decdaeb1..9ddbc74e187 100644 --- a/src/gui/widgets/Fader.cpp +++ b/src/gui/widgets/Fader.cpp @@ -82,14 +82,6 @@ Fader::Fader( FloatModel * _model, const QString & _name, QWidget * _parent ) : s_textFloat = new SimpleTextFloat; } - static auto s_back = embed::getIconPixmap("fader_background"); - static auto s_leds = embed::getIconPixmap("fader_leds"); - static auto s_knob = embed::getIconPixmap("fader_knob"); - - m_back = &s_back; - m_leds = &s_leds; - m_knob = &s_knob; - init(_model, _name); m_conversionFactor = 100.0; @@ -116,10 +108,6 @@ Fader::Fader( FloatModel * model, const QString & name, QWidget * parent, QPixma s_textFloat = new SimpleTextFloat; } - m_back = back; - m_leds = leds; - m_knob = knob; - init(model, name); } @@ -127,7 +115,7 @@ void Fader::init(FloatModel * model, QString const & name) { setWindowTitle( name ); setAttribute( Qt::WA_OpaquePaintEvent, false ); - QSize backgroundSize = m_back->size(); + QSize backgroundSize = m_back.size(); setMinimumSize( backgroundSize ); setMaximumSize( backgroundSize ); resize( backgroundSize ); @@ -154,7 +142,7 @@ void Fader::mouseMoveEvent( QMouseEvent *mouseEvent ) { int dy = m_moveStartPoint - mouseEvent->globalY(); - float delta = dy * ( model()->maxValue() - model()->minValue() ) / (float) ( height() - ( *m_knob ).height() ); + float delta = dy * (model()->maxValue() - model()->minValue()) / (float)(height() - (m_knob).height()); const auto step = model()->step(); float newValue = static_cast( static_cast( ( m_startValue + delta ) / step + 0.5 ) ) * step; @@ -179,7 +167,7 @@ void Fader::mousePressEvent( QMouseEvent* mouseEvent ) thisModel->saveJournallingState( false ); } - if( mouseEvent->y() >= knobPosY() - ( *m_knob ).height() && mouseEvent->y() < knobPosY() ) + if (mouseEvent->y() >= knobPosY() - (m_knob).height() && mouseEvent->y() < knobPosY()) { updateTextFloat(); s_textFloat->show(); @@ -323,9 +311,9 @@ void Fader::updateTextFloat() inline int Fader::calculateDisplayPeak( float fPeak ) { - int peak = (int)( m_back->height() - ( fPeak / ( m_fMaxPeak - m_fMinPeak ) ) * m_back->height() ); + int peak = static_cast(m_back.height() - (fPeak / (m_fMaxPeak - m_fMinPeak)) * m_back.height()); - return qMin( peak, m_back->height() ); + return qMin(peak, m_back.height()); } @@ -334,7 +322,7 @@ void Fader::paintEvent( QPaintEvent * ev) QPainter painter(this); // Draw the background - painter.drawPixmap( ev->rect(), *m_back, ev->rect() ); + painter.drawPixmap(ev->rect(), m_back, ev->rect()); // Draw the levels with peaks if (getLevelsDisplayedInDBFS()) @@ -347,14 +335,14 @@ void Fader::paintEvent( QPaintEvent * ev) } // Draw the knob - painter.drawPixmap( 0, knobPosY() - m_knob->height(), *m_knob ); + painter.drawPixmap(0, knobPosY() - m_knob.height(), m_knob); } void Fader::paintDBFSLevels(QPaintEvent * ev, QPainter & painter) { - int height = m_back->height(); - int width = m_back->width() / 2; - int center = m_back->width() - width; + int height = m_back.height(); + int width = m_back.width() / 2; + int center = m_back.width() - width; float const maxDB(ampToDbfs(m_fMaxPeak)); float const minDB(ampToDbfs(m_fMinPeak)); @@ -368,7 +356,7 @@ void Fader::paintDBFSLevels(QPaintEvent * ev, QPainter & painter) float const leftSpan = ampToDbfs(qMax(0.0001, m_fPeakValue_L)) - minDB; int peak_L = height * leftSpan * fullSpanReciprocal; QRect drawRectL( 0, height - peak_L, width, peak_L ); // Source and target are identical - painter.drawPixmap( drawRectL, *m_leds, drawRectL ); + painter.drawPixmap(drawRectL, m_leds, drawRectL); float const persistentLeftPeakDBFS = ampToDbfs(qMax(0.0001, m_persistentPeak_L)); int persistentPeak_L = height * (1 - (persistentLeftPeakDBFS - minDB) * fullSpanReciprocal); @@ -390,7 +378,7 @@ void Fader::paintDBFSLevels(QPaintEvent * ev, QPainter & painter) float const rightSpan = ampToDbfs(qMax(0.0001, m_fPeakValue_R)) - minDB; int peak_R = height * rightSpan * fullSpanReciprocal; QRect const drawRectR( center, height - peak_R, width, peak_R ); // Source and target are identical - painter.drawPixmap( drawRectR, *m_leds, drawRectR ); + painter.drawPixmap(drawRectR, m_leds, drawRectR); float const persistentRightPeakDBFS = ampToDbfs(qMax(0.0001, m_persistentPeak_R)); int persistentPeak_R = height * (1 - (persistentRightPeakDBFS - minDB) * fullSpanReciprocal); @@ -413,13 +401,13 @@ void Fader::paintLinearLevels(QPaintEvent * ev, QPainter & painter) // peak leds //float fRange = abs( m_fMaxPeak ) + abs( m_fMinPeak ); - int height = m_back->height(); - int width = m_back->width() / 2; - int center = m_back->width() - width; + int height = m_back.height(); + int width = m_back.width() / 2; + int center = m_back.width() - width; int peak_L = calculateDisplayPeak( m_fPeakValue_L - m_fMinPeak ); int persistentPeak_L = qMax( 3, calculateDisplayPeak( m_persistentPeak_L - m_fMinPeak ) ); - painter.drawPixmap( QRect( 0, peak_L, width, height - peak_L ), *m_leds, QRect( 0, peak_L, width, height - peak_L ) ); + painter.drawPixmap(QRect(0, peak_L, width, height - peak_L), m_leds, QRect(0, peak_L, width, height - peak_L)); if( m_persistentPeak_L > 0.05 ) { @@ -430,7 +418,7 @@ void Fader::paintLinearLevels(QPaintEvent * ev, QPainter & painter) int peak_R = calculateDisplayPeak( m_fPeakValue_R - m_fMinPeak ); int persistentPeak_R = qMax( 3, calculateDisplayPeak( m_persistentPeak_R - m_fMinPeak ) ); - painter.drawPixmap( QRect( center, peak_R, width, height - peak_R ), *m_leds, QRect( center, peak_R, width, height - peak_R ) ); + painter.drawPixmap(QRect(center, peak_R, width, height - peak_R), m_leds, QRect(center, peak_R, width, height - peak_R)); if( m_persistentPeak_R > 0.05 ) { diff --git a/src/tracks/MidiClip.cpp b/src/tracks/MidiClip.cpp index 490f6e6d041..1054ee5c709 100644 --- a/src/tracks/MidiClip.cpp +++ b/src/tracks/MidiClip.cpp @@ -38,13 +38,6 @@ namespace lmms { -QPixmap * gui::MidiClipView::s_stepBtnOn0 = nullptr; -QPixmap * gui::MidiClipView::s_stepBtnOn200 = nullptr; -QPixmap * gui::MidiClipView::s_stepBtnOff = nullptr; -QPixmap * gui::MidiClipView::s_stepBtnOffLight = nullptr; - - - MidiClip::MidiClip( InstrumentTrack * _instrument_track ) : Clip( _instrument_track ), m_instrumentTrack( _instrument_track ), From d4b106a988e39f3a712c49d513846008e16056be Mon Sep 17 00:00:00 2001 From: sakertooth Date: Fri, 10 Nov 2023 04:54:48 -0500 Subject: [PATCH 35/35] Fix few mistakes and formatting --- src/gui/instrument/PianoView.cpp | 4 ++-- src/gui/widgets/LedCheckBox.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/gui/instrument/PianoView.cpp b/src/gui/instrument/PianoView.cpp index c70e7b6142a..c8882898bc2 100644 --- a/src/gui/instrument/PianoView.cpp +++ b/src/gui/instrument/PianoView.cpp @@ -903,7 +903,7 @@ void PianoView::paintEvent( QPaintEvent * ) } else { - p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_whiteKeyDisabledPm); + p.drawPixmap(0 - PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_blackKeyDisabledPm); } } @@ -926,7 +926,7 @@ void PianoView::paintEvent( QPaintEvent * ) } else { - p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_whiteKeyDisabledPm); + p.drawPixmap(x + PW_WHITE_KEY_WIDTH / 2, PIANO_BASE, m_blackKeyDisabledPm); } x += PW_WHITE_KEY_WIDTH; white_cnt = 0; diff --git a/src/gui/widgets/LedCheckBox.cpp b/src/gui/widgets/LedCheckBox.cpp index ba77b538e81..1dbf650ed6e 100644 --- a/src/gui/widgets/LedCheckBox.cpp +++ b/src/gui/widgets/LedCheckBox.cpp @@ -132,7 +132,7 @@ void LedCheckBox::paintNonLegacy(QPaintEvent * pe) auto drawnPixmap = model()->value() ? m_ledOnPixmap : m_ledOffPixmap; - p.drawPixmap( 0, rect().height() / 2 - drawnPixmap.height() / 2, drawnPixmap); + p.drawPixmap(0, rect().height() / 2 - drawnPixmap.height() / 2, drawnPixmap); QRect r = rect(); r -= QMargins(m_ledOffPixmap.width() + 5, 0, 0, 0);