3#include <score/tools/FilePath.hpp>
4#include <Process/Dataflow/ControlWidgets.hpp>
6#include <Media/MediaFileHandle.hpp>
8#include <score/tools/ProjectFiles.hpp>
10#include <nano_observer.hpp>
11#include <score_plugin_media_export.h>
14struct WaveformComputer;
21 ,
public QGraphicsItem
22 ,
public Nano::Observer
32 void pressed() E_SIGNAL(SCORE_PLUGIN_MEDIA_EXPORT, pressed);
33 void dropped(QString filename) E_SIGNAL(SCORE_PLUGIN_MEDIA_EXPORT, dropped, filename);
36 const QString& text()
const noexcept {
return m_string; }
39 bool hasWaveform() const noexcept {
return !m_images.empty(); }
44 void setFile(
const QString& s,
const QString& absolute);
45 QRectF boundingRect()
const override;
48 void on_finishedDecoding();
49 void mousePressEvent(QGraphicsSceneMouseEvent* event)
override;
50 void mouseMoveEvent(QGraphicsSceneMouseEvent* event)
override;
51 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
override;
53 void dragEnterEvent(QGraphicsSceneDragDropEvent* event)
override;
54 void dragMoveEvent(QGraphicsSceneDragDropEvent* event)
override;
55 void dragLeaveEvent(QGraphicsSceneDragDropEvent* event)
override;
56 void dropEvent(QGraphicsSceneDragDropEvent* event)
override;
58 void paint(QPainter* painter,
const QStyleOptionGraphicsItem* option, QWidget* widget)
62 std::shared_ptr<Media::AudioFile> m_file;
63 QVector<QImage*> m_images;
73 template <
typename T,
typename Control_T>
76 QGraphicsItem* parent, QObject* context)
79 auto on_open = [&inlet, &ctx] {
80 const auto current = QString::fromStdString(ossia::convert<std::string>(inlet.value()));
81 WidgetFactory::openFileToImport(
83 [&inlet, &ctx](
const QString& filename) {
86 auto path = score::relativizeFilePath(filename, ctx);
87 CommandDispatcher<>{ctx.commandStack}
88 .submit<WidgetFactory::SetControlValue<Control_T>>(
89 inlet, path.toStdString());
92 auto on_set = [&inlet, &ctx](
const QString& filename) {
93 if(filename.isEmpty())
97 .submit<WidgetFactory::SetControlValue<Control_T>>(
98 inlet, filename.toStdString());
100 QObject::connect(bt, &score::QGraphicsWaveformButton::pressed, &inlet, on_open);
101 QObject::connect(bt, &score::QGraphicsWaveformButton::dropped, &inlet, on_set);
102 auto set = [bt, &ctx](
const ossia::value& val) {
103 auto str = QString::fromStdString(ossia::convert<std::string>(val));
104 if(str != bt->text())
114 QObject::connect(&inlet, &Control_T::valueChanged, bt, set);
The CommandDispatcher class.
Definition CommandDispatcher.hpp:13
Base toolkit upon which the software is built.
Definition Application.cpp:117
QString locateFilePath(const QString &filename) noexcept
Definition File.cpp:84
QString pickerStartFolder(const QString ¤t, const score::DocumentContext &ctx) noexcept
Definition File.cpp:288
Definition DocumentContext.hpp:18