diff --git a/include/InstrumentTrackView.h b/include/InstrumentTrackView.h index d7d5fb83a..ef3d7f360 100644 --- a/include/InstrumentTrackView.h +++ b/include/InstrumentTrackView.h @@ -93,6 +93,8 @@ private slots: void handleConfigChange(QString cls, QString attr, QString value); +private: + QPixmap determinePixmap(InstrumentTrack * instrumentTrack); private: InstrumentTrackWindow * m_window; diff --git a/include/TrackLabelButton.h b/include/TrackLabelButton.h index 0d1c6e163..af50b078b 100644 --- a/include/TrackLabelButton.h +++ b/include/TrackLabelButton.h @@ -55,7 +55,6 @@ protected: void mousePressEvent( QMouseEvent * _me ) override; void mouseDoubleClickEvent( QMouseEvent * _me ) override; void mouseReleaseEvent( QMouseEvent * _me ) override; - void paintEvent( QPaintEvent * _pe ) override; void resizeEvent( QResizeEvent * _re ) override; diff --git a/src/gui/tracks/InstrumentTrackView.cpp b/src/gui/tracks/InstrumentTrackView.cpp index 8087af423..d72f276fa 100644 --- a/src/gui/tracks/InstrumentTrackView.cpp +++ b/src/gui/tracks/InstrumentTrackView.cpp @@ -40,6 +40,7 @@ #include "Mixer.h" #include "MixerView.h" #include "GuiApplication.h" +#include "Instrument.h" #include "InstrumentTrack.h" #include "InstrumentTrackWindow.h" #include "MainWindow.h" @@ -62,7 +63,7 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV m_tlb = new TrackLabelButton( this, getTrackSettingsWidget() ); m_tlb->setCheckable( true ); - m_tlb->setIcon( embed::getIconPixmap( "instrument_track" ) ); + m_tlb->setIcon(determinePixmap(_it)); m_tlb->show(); connect( m_tlb, SIGNAL(toggled(bool)), @@ -393,4 +394,27 @@ QMenu * InstrumentTrackView::createMixerMenu(QString title, QString newMixerLabe } +QPixmap InstrumentTrackView::determinePixmap(InstrumentTrack * instrumentTrack) +{ + if (instrumentTrack) + { + Instrument * instrument = instrumentTrack->instrument(); + + if (instrument && instrument->descriptor()) + { + const PixmapLoader * pl = instrument->key().isValid() ? + instrument->key().logo() : + instrument->descriptor()->logo; + + if(pl) + { + return pl->pixmap(); + } + } + } + + return embed::getIconPixmap("instrument_track"); +} + + } // namespace lmms::gui diff --git a/src/gui/tracks/TrackLabelButton.cpp b/src/gui/tracks/TrackLabelButton.cpp index 2a50a4aa2..247f9ee52 100644 --- a/src/gui/tracks/TrackLabelButton.cpp +++ b/src/gui/tracks/TrackLabelButton.cpp @@ -31,8 +31,6 @@ #include "ConfigManager.h" #include "embed.h" #include "Engine.h" -#include "Instrument.h" -#include "InstrumentTrack.h" #include "RenameDialog.h" #include "Song.h" #include "TrackRenameLineEdit.h" @@ -185,35 +183,6 @@ void TrackLabelButton::mouseReleaseEvent( QMouseEvent *_me ) -void TrackLabelButton::paintEvent( QPaintEvent * _pe ) -{ - if( m_trackView->getTrack()->type() == Track::Type::Instrument ) - { - auto it = dynamic_cast(m_trackView->getTrack()); - const PixmapLoader * pl; - auto get_logo = [](InstrumentTrack* it) -> const PixmapLoader* - { - return it->instrument()->key().isValid() - ? it->instrument()->key().logo() - : it->instrument()->descriptor()->logo; - }; - if( it && it->instrument() && - it->instrument()->descriptor() && - ( pl = get_logo(it) ) ) - { - if( pl->pixmapName() != m_iconName ) - { - m_iconName = pl->pixmapName(); - setIcon( pl->pixmap() ); - } - } - } - QToolButton::paintEvent( _pe ); -} - - - - void TrackLabelButton::resizeEvent(QResizeEvent *_re) { setText( elideName( m_trackView->getTrack()->displayName() ) );