Commit bdc7ab9c authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Bring back separate channels audio thumbs

parent 804dfaac
......@@ -876,6 +876,11 @@ void KdenliveSettingsDialog::updateSettings()
KdenliveSettings::setTabposition(m_configMisc.kcfg_tabposition->currentIndex());
}
if (m_configTimeline.kcfg_displayallchannels->isChecked() != KdenliveSettings::displayallchannels()) {
KdenliveSettings::setDisplayallchannels(m_configTimeline.kcfg_displayallchannels->isChecked());
emit audioThumbFormatChanged();
}
if (m_modified) {
// The transcoding profiles were modified, save.
m_modified = false;
......
......@@ -125,6 +125,8 @@ signals:
/** @brief A settings changed that requires a Kdenlive restart, trigger it */
void restartKdenlive();
void checkTabPosition();
/** @brief Switch between merged / separate channels for audio thumbs */
void audioThumbFormatChanged();
};
#endif
......@@ -2143,6 +2143,7 @@ void MainWindow::slotPreferences(int page, int option)
connect(dialog, &KdenliveSettingsDialog::checkTabPosition, this, &MainWindow::slotCheckTabPosition);
connect(dialog, &KdenliveSettingsDialog::restartKdenlive, this, &MainWindow::slotRestart);
connect(dialog, &KdenliveSettingsDialog::updateLibraryFolder, pCore.get(), &Core::updateLibraryPath);
connect(dialog, &KdenliveSettingsDialog::audioThumbFormatChanged, pCore->projectManager(), &ProjectManager::audioThumbFormatChanged);
dialog->show();
if (page != -1) {
......@@ -2214,7 +2215,7 @@ void MainWindow::slotSwitchAudioThumbs()
{
KdenliveSettings::setAudiothumbnails(!KdenliveSettings::audiothumbnails());
pCore->binController()->checkAudioThumbs();
if (pCore->projectManager()->currentTimeline()) {
if (pCore->projectManager()->currentTimelineWidget()) {
pCore->projectManager()->currentTimelineWidget()->showAudioThumbnailsChanged();
}
m_buttonAudioThumbs->setChecked(KdenliveSettings::audiothumbnails());
......
......@@ -893,3 +893,10 @@ void ProjectManager::updateTimeline(Mlt::Tractor tractor)
m_timelineWidget->buildFromMelt(tractor);
m_timelineWidget->setUndoStack(m_project->commandStack());
}
void ProjectManager::audioThumbFormatChanged()
{
if (m_timelineWidget) {
m_timelineWidget->audioThumbFormatChanged();
}
}
......@@ -124,6 +124,9 @@ public slots:
/** @brief Un/Set current track as target */
void slotSwitchTrackTarget();
/** @brief Request repaint of audio thumbs */
void audioThumbFormatChanged();
private slots:
void slotRevert();
/** @brief Open the project's backupdialog. */
......
......@@ -175,6 +175,7 @@ Rectangle {
width: Math.min(waveform.innerWidth, waveform.maxWidth)
height: waveform.height
fillColor: 'red'
format: timeline.audioThumbFormat
property int channels: 2
inPoint: Math.round((clipRoot.inPoint + index * waveform.maxWidth / timeScale) * speed) * channels
outPoint: inPoint + Math.round(width / timeScale * speed) * channels
......@@ -226,7 +227,7 @@ Rectangle {
anchors.fill: parent
Rectangle {
id: markerBase
width: 1 // modelDa
width: 1
height: parent.height
x: (markers[2 * modelData] - clipRoot.inPoint) * timeScale;
color: 'red'
......
......@@ -81,7 +81,6 @@ Rectangle {
property int clipBeingMovedId: -1
property real timeScale: timeline.scaleFactor
property int trackHeight
//property alias ripple: toolbar.ripple
//onCurrentTrackChanged: timeline.selection = []
onTimeScaleChanged: {
......
......@@ -4,6 +4,7 @@
#include <QPainterPath>
#include <QPalette>
#include <QQuickPaintedItem>
#include "kdenlivesettings.h"
class TimelineTriangle : public QQuickPaintedItem
{
......@@ -39,6 +40,7 @@ class TimelineWaveform : public QQuickPaintedItem
Q_PROPERTY(QColor fillColor MEMBER m_color NOTIFY propertyChanged)
Q_PROPERTY(int inPoint MEMBER m_inPoint NOTIFY inPointChanged)
Q_PROPERTY(int outPoint MEMBER m_outPoint NOTIFY outPointChanged)
Q_PROPERTY(bool format MEMBER m_format NOTIFY propertyChanged)
public:
TimelineWaveform()
......@@ -53,22 +55,54 @@ public:
if (data.isEmpty()) return;
const qreal indicesPrPixel = qreal(m_outPoint - m_inPoint) / width();
QPen pen = painter->pen();
pen.setWidthF(0.5);
pen.setColor(m_color.darker());
painter->setPen(pen);
painter->setBrush(QBrush(m_color.lighter()));
QPainterPath path;
path.moveTo(-1, height());
int i = 0;
for (; i < width(); ++i) {
int idx = m_inPoint + int(i * indicesPrPixel);
if (idx + 1 >= data.length()) break;
qreal level = qMax(data.at(idx).toReal(), data.at(idx + 1).toReal()) / 256;
path.lineTo(i, height() - level * height());
if (!KdenliveSettings::displayallchannels()) {
// Draw merged channels
QPainterPath path;
path.moveTo(-1, height());
int i = 0;
for (; i < width(); ++i) {
int idx = m_inPoint + int(i * indicesPrPixel);
if (idx + 1 >= data.length()) break;
qreal level = qMax(data.at(idx).toReal(), data.at(idx + 1).toReal()) / 256;
path.lineTo(i, height() - level * height());
}
path.lineTo(i, height());
painter->drawPath(path);
} else {
// Draw separate channels
QMap<int, QPainterPath> positiveChannelPaths;
QMap<int, QPainterPath> negativeChannelPaths;
// TODO: get channels count
int channels = 2;
int i = 0;
for (int channel = 0; channel < channels; channel++) {
int y = height() - (2 * channel + 1) * height() / 4;
positiveChannelPaths[channel].moveTo(-1, y);
negativeChannelPaths[channel].moveTo(-1, y);
// Draw channel median line
painter->drawLine(0, y, width(), y);
for (i = 0; i < width(); ++i) {
int idx = m_inPoint + int(i * indicesPrPixel);
if (idx + channel >= data.length()) break;
qreal level = data.at(idx + channel).toReal() / 256;
positiveChannelPaths[channel].lineTo(i, y - level * height() / 4);
negativeChannelPaths[channel].lineTo(i, y + level * height() / 4);
}
}
for (int channel = 0; channel < channels; channel++) {
int y = height() - (2 * channel + 1) * height() / 4;
positiveChannelPaths[channel].lineTo(i, y);
negativeChannelPaths[channel].lineTo(i, y);
painter->drawPath(positiveChannelPaths.value(channel));
painter->drawPath(negativeChannelPaths.value(channel));
}
}
path.lineTo(i, height());
painter->fillPath(path, m_color.lighter());
QPen pen(painter->pen());
pen.setColor(m_color.darker());
painter->strokePath(path, pen);
}
signals:
......@@ -81,6 +115,7 @@ private:
int m_inPoint;
int m_outPoint;
QColor m_color;
bool m_format;
};
void registerTimelineItems()
......
......@@ -314,6 +314,11 @@ bool TimelineWidget::showAudioThumbnails() const
return KdenliveSettings::audiothumbnails();
}
bool TimelineWidget::audioThumbFormat() const
{
return KdenliveSettings::displayallchannels();
}
bool TimelineWidget::showWaveforms() const
{
return KdenliveSettings::audiothumbnails();
......
......@@ -43,6 +43,7 @@ class TimelineWidget : public QQuickWidget
/* @brief holds the current project duration
*/
Q_PROPERTY(int duration READ duration NOTIFY durationChanged)
Q_PROPERTY(bool audioThumbFormat READ audioThumbFormat NOTIFY audioThumbFormatChanged)
/* @brief holds the current timeline position
*/
Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
......@@ -128,6 +129,7 @@ public:
*/
bool showThumbnails() const;
bool showAudioThumbnails() const;
bool audioThumbFormat() const;
/* @brief Do we want to display audio thumbnails
*/
Q_INVOKABLE bool showWaveforms() const;
......@@ -197,6 +199,7 @@ signals:
void selected(Mlt::Producer *producer);
void trackHeightChanged();
void scaleFactorChanged();
void audioThumbFormatChanged();
void durationChanged();
void positionChanged();
void showThumbnailsChanged();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment