Skip to content

Commit

Permalink
Add instrument plugins to Song Editor via right click (LMMS#6698)
Browse files Browse the repository at this point in the history
  • Loading branch information
LostRobotMusic authored May 6, 2023
1 parent 3440d49 commit 87a57db
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/PluginBrowser.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,14 @@ class PluginDescWidget : public QWidget
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};
Expand Down
24 changes: 24 additions & 0 deletions src/gui/PluginBrowser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@
#include <QHeaderView>
#include <QLabel>
#include <QLineEdit>
#include <QMenu>
#include <QMouseEvent>
#include <QPainter>
#include <QStyleOption>
#include <QTreeWidget>

#include "embed.h"
#include "Engine.h"
#include "InstrumentTrack.h"
#include "Song.h"
#include "StringPairDrag.h"
#include "TrackContainerView.h"
#include "PluginFactory.h"

namespace lmms::gui
Expand Down Expand Up @@ -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

0 comments on commit 87a57db

Please sign in to comment.