Add instrument plugins to Song Editor via right click (#6698)
This commit is contained in:
@@ -63,13 +63,14 @@ public:
|
||||
using PluginKey = Plugin::Descriptor::SubPluginFeatures::Key;
|
||||
PluginDescWidget( const PluginKey & _pk, QWidget * _parent );
|
||||
QString name() const;
|
||||
|
||||
void openInNewInstrumentTrack(QString value);
|
||||
|
||||
protected:
|
||||
void enterEvent( QEvent * _e ) override;
|
||||
void leaveEvent( QEvent * _e ) override;
|
||||
void mousePressEvent( QMouseEvent * _me ) override;
|
||||
void paintEvent( QPaintEvent * _pe ) override;
|
||||
void contextMenuEvent(QContextMenuEvent* e) override;
|
||||
|
||||
private:
|
||||
constexpr static int DEFAULT_HEIGHT{24};
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <QHeaderView>
|
||||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QStyleOption>
|
||||
@@ -34,7 +35,10 @@
|
||||
|
||||
#include "embed.h"
|
||||
#include "Engine.h"
|
||||
#include "InstrumentTrack.h"
|
||||
#include "Song.h"
|
||||
#include "StringPairDrag.h"
|
||||
#include "TrackContainerView.h"
|
||||
#include "PluginFactory.h"
|
||||
|
||||
namespace lmms::gui
|
||||
@@ -287,4 +291,24 @@ void PluginDescWidget::mousePressEvent( QMouseEvent * _me )
|
||||
}
|
||||
|
||||
|
||||
void PluginDescWidget::contextMenuEvent(QContextMenuEvent* e)
|
||||
{
|
||||
QMenu contextMenu(this);
|
||||
contextMenu.addAction(
|
||||
tr("Send to new instrument track"),
|
||||
[=]{ openInNewInstrumentTrack(m_pluginKey.desc->name); }
|
||||
);
|
||||
contextMenu.exec(e->globalPos());
|
||||
}
|
||||
|
||||
|
||||
void PluginDescWidget::openInNewInstrumentTrack(QString value)
|
||||
{
|
||||
TrackContainer* tc = Engine::getSong();
|
||||
auto it = dynamic_cast<InstrumentTrack*>(Track::create(Track::InstrumentTrack, tc));
|
||||
auto ilt = new InstrumentLoaderThread(this, it, value);
|
||||
ilt->start();
|
||||
}
|
||||
|
||||
|
||||
} // namespace lmms::gui
|
||||
|
||||
Reference in New Issue
Block a user