Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move icon determination into TrackLabelButton again #7209

Merged
merged 2 commits into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions include/InstrumentTrackView.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 0 additions & 7 deletions src/gui/tracks/InstrumentTrackView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -397,12 +396,6 @@ QMenu * InstrumentTrackView::createMixerMenu(QString title, QString newMixerLabe
return mixerMenu;
}

QPixmap InstrumentTrackView::determinePixmap()
{
return determinePixmap(dynamic_cast<InstrumentTrack*>(getTrack()));
}


QPixmap InstrumentTrackView::determinePixmap(InstrumentTrack* instrumentTrack)
{
if (instrumentTrack)
Expand Down
25 changes: 21 additions & 4 deletions src/gui/tracks/TrackLabelButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -181,12 +183,27 @@ void TrackLabelButton::mouseReleaseEvent( QMouseEvent *_me )

void TrackLabelButton::paintEvent(QPaintEvent* pe)
{
InstrumentTrackView* instrumentTrackView = dynamic_cast<InstrumentTrackView*>(m_trackView);
if (instrumentTrackView)
if (m_trackView->getTrack()->type() == Track::Type::Instrument)
{
setIcon(instrumentTrackView->determinePixmap());
auto it = dynamic_cast<InstrumentTrack*>(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);
}

Expand Down
Loading