diff --git a/include/FileBrowser.h b/include/FileBrowser.h index 75b0c0c78..d02434c86 100644 --- a/include/FileBrowser.h +++ b/include/FileBrowser.h @@ -192,11 +192,12 @@ private: private slots: - void activateListItem( QTreeWidgetItem * item, int column ); - void openInNewInstrumentTrack( lmms::gui::FileItem* item, bool songEditor ); - bool openInNewSampleTrack( lmms::gui::FileItem* item ); - void sendToActiveInstrumentTrack( lmms::gui::FileItem* item ); - void updateDirectory( QTreeWidgetItem * item ); + void activateListItem(QTreeWidgetItem* item, int column); + void openInNewInstrumentTrack(FileItem* item, bool songEditor); + bool openInNewSampleTrack(FileItem* item); + void openInSlicerT(FileItem* item); + void sendToActiveInstrumentTrack(FileItem* item); + void updateDirectory(QTreeWidgetItem* item); } ; diff --git a/plugins/SlicerT/SlicerT.cpp b/plugins/SlicerT/SlicerT.cpp index cbc543fa6..82afffcd9 100644 --- a/plugins/SlicerT/SlicerT.cpp +++ b/plugins/SlicerT/SlicerT.cpp @@ -329,6 +329,11 @@ void SlicerT::updateFile(QString file) emit dataChanged(); } +void SlicerT::loadFile(const QString& file) +{ + updateFile(file); +} + void SlicerT::updateSlices() { findSlices(); diff --git a/plugins/SlicerT/SlicerT.h b/plugins/SlicerT/SlicerT.h index f8bc64fb2..ded15b3bc 100644 --- a/plugins/SlicerT/SlicerT.h +++ b/plugins/SlicerT/SlicerT.h @@ -82,6 +82,7 @@ public: void saveSettings(QDomDocument& document, QDomElement& element) override; void loadSettings(const QDomElement& element) override; + void loadFile(const QString& file) override; void findSlices(); void findBPM(); diff --git a/src/gui/FileBrowser.cpp b/src/gui/FileBrowser.cpp index d0dbbc613..6a367bf4b 100644 --- a/src/gui/FileBrowser.cpp +++ b/src/gui/FileBrowser.cpp @@ -54,6 +54,7 @@ #include "KeyboardShortcuts.h" #include "MainWindow.h" #include "PatternStore.h" +#include "Plugin.h" #include "PluginFactory.h" #include "PresetPreviewPlayHandle.h" #include "Sample.h" @@ -65,6 +66,7 @@ #include "StringPairDrag.h" #include "TextFloat.h" #include "ThreadPool.h" +#include "Track.h" #include "embed.h" namespace lmms::gui @@ -730,6 +732,16 @@ void FileBrowserTreeWidget::contextMenuEvent(QContextMenuEvent* e) if (!contextMenu.isEmpty()) { contextMenu.exec(e->globalPos()); } } +void FileBrowserTreeWidget::openInSlicerT(FileItem* item) +{ + TrackContainer* tc = Engine::getSong(); + + auto* track = dynamic_cast(Track::create(Track::Type::Instrument, tc)); + + track->loadInstrument("slicert"); + track->instrument()->loadFile(item->fullName()); +} + QList FileBrowserTreeWidget::getContextActions(FileItem* file, bool songEditor) { QList result = QList(); @@ -740,19 +752,27 @@ QList FileBrowserTreeWidget::getContextActions(FileItem* file, bool so tr("Send to new instrument track"); QString shortcutMod = songEditor ? "" : UI_CTRL_KEY + QString(" + "); - auto toInstrument = new QAction(instrumentAction + tr(" (%2Enter)").arg(shortcutMod), nullptr); + auto toInstrument = new QAction(instrumentAction + tr(" (%2Enter)").arg(shortcutMod)); connect(toInstrument, &QAction::triggered, [=, this]{ openInNewInstrumentTrack(file, songEditor); }); result.append(toInstrument); if (songEditor && fileIsSample) { - auto toSampleTrack = new QAction(tr("Send to new sample track (Shift + Enter)"), nullptr); + auto toSampleTrack = new QAction(tr("Send to new sample track (Shift + Enter)")); connect(toSampleTrack, &QAction::triggered, [=, this]{ openInNewSampleTrack(file); }); result.append(toSampleTrack); } + if (fileIsSample && !PluginFactory::instance()->pluginInfo("slicert").isNull()) + { + auto openInSlicer = new QAction(tr("Send to new SlicerT instance")); + connect(openInSlicer, &QAction::triggered, + [=, this]{ openInSlicerT(file); }); + result.append(openInSlicer); + } + return result; } @@ -983,7 +1003,6 @@ void FileBrowserTreeWidget::handleFile(FileItem * f, InstrumentTrack * it) case FileItem::FileHandling::NotSupported: default: break; - } Engine::audioEngine()->doneChangeInModel(); }