Skip to content

Commit a1cbb96

Browse files
committed
qmlui: bring back audio waveform preview in Show Manager
1 parent 6662407 commit a1cbb96

File tree

6 files changed

+560
-0
lines changed

6 files changed

+560
-0
lines changed

qmlui/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ set(SRC_FILES
6767
uimanager.cpp uimanager.h
6868
videoeditor.cpp videoeditor.h
6969
videoprovider.cpp videoprovider.h
70+
waveformimageprovider.cpp waveformimageprovider.h
7071
virtualconsole/vcanimation.cpp virtualconsole/vcanimation.h
7172
virtualconsole/vcaudiotriggers.cpp virtualconsole/vcaudiotriggers.h
7273
virtualconsole/vcbutton.cpp virtualconsole/vcbutton.h

qmlui/qml/showmanager/ShowItem.qml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,37 @@ Item
115115
visible: sfRef ? (sfRef.locked ? true : false) : false
116116
}
117117

118+
/* Waveform for audio items */
119+
Image
120+
{
121+
id: waveformImage
122+
z: 3
123+
anchors.fill: parent
124+
visible: funcRef && funcRef.type === QLCFunction.AudioType
125+
cache: false
126+
fillMode: Image.Stretch
127+
128+
source: (funcRef && funcRef.type === QLCFunction.AudioType) ? "image://waveform/" + funcRef.id : ""
129+
130+
function reload()
131+
{
132+
const old = source;
133+
source = "";
134+
source = old;
135+
}
136+
137+
Connections
138+
{
139+
target: waveformProvider
140+
141+
function onWaveformUpdated(fid)
142+
{
143+
if (funcRef && fid === funcRef.id)
144+
waveformImage.reload()
145+
}
146+
}
147+
}
148+
118149
Canvas
119150
{
120151
id: prCanvas

qmlui/showmanager.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include <QQmlContext>
2121

22+
#include "waveformimageprovider.h"
2223
#include "showmanager.h"
2324
#include "sequence.h"
2425
#include "tardis.h"
@@ -43,6 +44,12 @@ ShowManager::ShowManager(QQuickView *view, Doc *doc, QObject *parent)
4344
qmlRegisterType<Track>("org.qlcplus.classes", 1, 0, "Track");
4445
qmlRegisterUncreatableType<ShowFunction>("org.qlcplus.classes", 1, 0, "ShowFunction", "Can't create a ShowFunction");
4546

47+
48+
/* Create and register a Waveform image provider */
49+
m_waveformProvider = new WaveformImageProvider(doc);
50+
view->engine()->addImageProvider(QLatin1String("waveform"), m_waveformProvider);
51+
view->rootContext()->setContextProperty("waveformProvider", m_waveformProvider);
52+
4653
setContextResource("qrc:/ShowManager.qml");
4754
setContextTitle(tr("Show Manager"));
4855
}
@@ -52,6 +59,9 @@ void ShowManager::initialize()
5259
App *app = qobject_cast<App *>(m_view);
5360
m_tickSize = app->pixelDensity() * 18;
5461

62+
if (m_waveformProvider)
63+
m_waveformProvider->setPixelDensity(app->pixelDensity());
64+
5565
siComponent = new QQmlComponent(m_view->engine(), QUrl("qrc:/ShowItem.qml"));
5666
if (siComponent->isError())
5767
qDebug() << siComponent->errors();

qmlui/showmanager.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ class Doc;
3030
class Track;
3131
class Function;
3232
class ShowFunction;
33+
class WaveformImageProvider;
3334

3435
typedef struct
3536
{
@@ -311,6 +312,8 @@ protected slots:
311312

312313
/** Holds the item currently ready for pasting */
313314
QList<SelectedShowItem> m_clipboard;
315+
316+
WaveformImageProvider *m_waveformProvider;
314317
};
315318

316319
#endif // SHOWMANAGER_H

0 commit comments

Comments
 (0)