diff --git a/include/InstrumentTrackView.h b/include/InstrumentTrackView.h index cfde89bde82..c7d524b36cf 100644 --- a/include/InstrumentTrackView.h +++ b/include/InstrumentTrackView.h @@ -71,8 +71,6 @@ class InstrumentTrackView : public TrackView // Create a menu for assigning/creating channels for this track QMenu * createMixerMenu( QString title, QString newMixerLabel ) override; - QPixmap determinePixmap(); - protected: void modelChanged() override; diff --git a/src/gui/tracks/InstrumentTrackView.cpp b/src/gui/tracks/InstrumentTrackView.cpp index c812999fd62..1d9991c3107 100644 --- a/src/gui/tracks/InstrumentTrackView.cpp +++ b/src/gui/tracks/InstrumentTrackView.cpp @@ -41,7 +41,6 @@ #include "MixerView.h" #include "GuiApplication.h" #include "Instrument.h" -#include "InstrumentTrack.h" #include "InstrumentTrackWindow.h" #include "MainWindow.h" #include "MidiClient.h" @@ -397,12 +396,6 @@ QMenu * InstrumentTrackView::createMixerMenu(QString title, QString newMixerLabe return mixerMenu; } -QPixmap InstrumentTrackView::determinePixmap() -{ - return determinePixmap(dynamic_cast(getTrack())); -} - - QPixmap InstrumentTrackView::determinePixmap(InstrumentTrack* instrumentTrack) { if (instrumentTrack) diff --git a/src/gui/tracks/TrackLabelButton.cpp b/src/gui/tracks/TrackLabelButton.cpp index c164b780e75..871d42316e5 100644 --- a/src/gui/tracks/TrackLabelButton.cpp +++ b/src/gui/tracks/TrackLabelButton.cpp @@ -31,6 +31,8 @@ #include "ConfigManager.h" #include "embed.h" #include "InstrumentTrackView.h" +#include "Instrument.h" +#include "InstrumentTrack.h" #include "RenameDialog.h" #include "TrackRenameLineEdit.h" #include "TrackView.h" @@ -181,12 +183,27 @@ void TrackLabelButton::mouseReleaseEvent( QMouseEvent *_me ) void TrackLabelButton::paintEvent(QPaintEvent* pe) { - InstrumentTrackView* instrumentTrackView = dynamic_cast(m_trackView); - if (instrumentTrackView) + if (m_trackView->getTrack()->type() == Track::Type::Instrument) { - setIcon(instrumentTrackView->determinePixmap()); + 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); }