diff --git a/include/InstrumentTrackView.h b/include/InstrumentTrackView.h index 0c645926ca3..f7f270cea3a 100644 --- a/include/InstrumentTrackView.h +++ b/include/InstrumentTrackView.h @@ -79,6 +79,7 @@ class InstrumentTrackView : public TrackView private slots: + void onInstrumentChanged(); void toggleInstrumentWindow( bool _on ); void toggleMidiCCRack(); void activityIndicatorPressed(); diff --git a/src/gui/tracks/InstrumentTrackView.cpp b/src/gui/tracks/InstrumentTrackView.cpp index 782b4e6a664..7fca5ef9a59 100644 --- a/src/gui/tracks/InstrumentTrackView.cpp +++ b/src/gui/tracks/InstrumentTrackView.cpp @@ -80,6 +80,8 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV connect(ConfigManager::inst(), SIGNAL(valueChanged(QString,QString,QString)), this, SLOT(handleConfigChange(QString,QString,QString))); + connect(_it, &InstrumentTrack::instrumentChanged, this, &InstrumentTrackView::onInstrumentChanged); + m_mixerChannelNumber = new MixerChannelLcdSpinBox(2, getTrackSettingsWidget(), tr("Mixer channel"), this); m_mixerChannelNumber->show(); @@ -167,6 +169,8 @@ InstrumentTrackView::InstrumentTrackView( InstrumentTrack * _it, TrackContainerV m_activityIndicator, SLOT(noteEnd())); setModel( _it ); + + onInstrumentChanged(); } @@ -300,6 +304,15 @@ void InstrumentTrackView::dropEvent( QDropEvent * _de ) +void InstrumentTrackView::onInstrumentChanged() +{ + // Check if an instrument has been loaded, if not disable the track label button to prevent opening an empty instrument window. + m_tlb->setEnabled(model()->m_instrument != nullptr); +} + + + + void InstrumentTrackView::toggleInstrumentWindow( bool _on ) { if (_on && ConfigManager::inst()->value("ui", "oneinstrumenttrackwindow").toInt())