Added opening samples in SlicerT from the file browser (#8100)
Co-authored-by: Dalton Messmer <messmer.dalton@gmail.com>
This commit is contained in:
@@ -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);
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
@@ -329,6 +329,11 @@ void SlicerT::updateFile(QString file)
|
||||
emit dataChanged();
|
||||
}
|
||||
|
||||
void SlicerT::loadFile(const QString& file)
|
||||
{
|
||||
updateFile(file);
|
||||
}
|
||||
|
||||
void SlicerT::updateSlices()
|
||||
{
|
||||
findSlices();
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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<InstrumentTrack*>(Track::create(Track::Type::Instrument, tc));
|
||||
|
||||
track->loadInstrument("slicert");
|
||||
track->instrument()->loadFile(item->fullName());
|
||||
}
|
||||
|
||||
QList<QAction*> FileBrowserTreeWidget::getContextActions(FileItem* file, bool songEditor)
|
||||
{
|
||||
QList<QAction*> result = QList<QAction*>();
|
||||
@@ -740,19 +752,27 @@ QList<QAction*> 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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user