Move icon determination into TrackLabelButton again (#7209)
Move icon determination into TrackLabelButton again Fully undo the changes made in commit88e0e94dcdbecause the intermediate revert made in commit04ecf73395seems to have led to a performance problem due to the icon being set over and over again in `TrackLabelButton::paintEvent`. The original intention of the changes made in pull request #7114 was to remove the painting code that dynamically determines the icon over and over again. Ideally the icon that is used by an instrument should be somewhat of a "static" property that should be known very early on when an instrument view is created. There should not be any need to dynamically resolve the icon over and over, especially not in a button class very far down in the widget hierarchy. However, due to technical reasons this is not the case in the current code. See pull request #7132 for more details.
This commit is contained in:
committed by
GitHub
parent
d2c2a80506
commit
d5e1d9e853
@@ -71,8 +71,6 @@ public:
|
||||
// Create a menu for assigning/creating channels for this track
|
||||
QMenu * createMixerMenu( QString title, QString newMixerLabel ) override;
|
||||
|
||||
QPixmap determinePixmap();
|
||||
|
||||
|
||||
protected:
|
||||
void modelChanged() override;
|
||||
|
||||
@@ -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<InstrumentTrack*>(getTrack()));
|
||||
}
|
||||
|
||||
|
||||
QPixmap InstrumentTrackView::determinePixmap(InstrumentTrack* instrumentTrack)
|
||||
{
|
||||
if (instrumentTrack)
|
||||
|
||||
@@ -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<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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user