Refresh clip properties panel when switching audio stream from monitor and reverse

parent 36b0928a
Pipeline #19343 passed with stage
in 9 minutes and 41 seconds
......@@ -2389,6 +2389,13 @@ void Bin::reloadMonitorIfActive(const QString &id)
}
}
void Bin::reloadMonitorStreamIfActive(const QString &id)
{
if (m_monitor->activeClipId() == id) {
m_monitor->reloadActiveStream();
}
}
QStringList Bin::getBinFolderClipIds(const QString &id) const
{
QStringList ids;
......
......@@ -219,6 +219,8 @@ public:
/** @brief refresh monitor (if clip changed) */
void reloadMonitorIfActive(const QString &id);
/** @brief refresh monitor stream selector */
void reloadMonitorStreamIfActive(const QString &id);
void doMoveClip(const QString &id, const QString &newParentId);
void doMoveFolder(const QString &id, const QString &newParentId);
......
......@@ -1062,10 +1062,7 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
updateTimelineClips({TimelineModel::NameRole});
}
}
if (refreshPanel) {
// Some of the clip properties have changed through a command, update properties panel
emit refreshPropertiesPanel();
}
bool audioStreamChanged = properties.contains(QStringLiteral("audio_index"));
if (reload) {
// producer has changed, refresh monitor and thumbnail
if (hasProxy()) {
......@@ -1073,7 +1070,6 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
setProducerProperty(QStringLiteral("_overwriteproxy"), 1);
pCore->jobManager()->startJob<ProxyJob>({clipId()}, -1, QString());
} else {
bool audioStreamChanged = properties.contains(QStringLiteral("audio_index"));
reloadProducer(refreshOnly, audioStreamChanged, audioStreamChanged || (!refreshOnly && !properties.contains(QStringLiteral("kdenlive:proxy"))));
}
if (refreshOnly) {
......@@ -1084,6 +1080,17 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
if (!updateRoles.isEmpty()) {
updateTimelineClips(updateRoles);
}
} else {
if (audioStreamChanged) {
discardAudioThumb();
pCore->bin()->reloadMonitorStreamIfActive(clipId());
pCore->jobManager()->startJob<AudioThumbJob>({clipId()}, -1, QString());
refreshPanel = true;
}
}
if (refreshPanel) {
// Some of the clip properties have changed through a command, update properties panel
emit refreshPropertiesPanel();
}
if (!passProperties.isEmpty() && (!reload || refreshOnly)) {
for (auto &p : m_audioProducers) {
......
......@@ -166,6 +166,7 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
, m_id(controller->binId())
, m_type(controller->clipType())
, m_properties(new Mlt::Properties(controller->properties()))
, m_audioStream(nullptr)
, m_textEdit(nullptr)
{
m_controller->mirrorOriginalProperties(m_sourceProperties);
......@@ -612,42 +613,42 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
tbv->setAutoRaise(true);
hlay->addWidget(tbv);
hlay->addWidget(new QLabel(i18n("Audio stream")));
auto *audioStream = new QComboBox(this);
m_audioStream = new QComboBox(this);
QMapIterator<int, QString> i(audioStreamsInfo);
while (i.hasNext()) {
i.next();
audioStream->addItem(QString("%1: %2").arg(i.key()).arg(i.value()), i.key());
m_audioStream->addItem(QString("%1: %2").arg(i.key()).arg(i.value()), i.key());
}
if (audioStream->count() > 1) {
audioStream->addItem(i18n("Merge all streams"), INT_MAX);
if (m_audioStream->count() > 1) {
m_audioStream->addItem(i18n("Merge all streams"), INT_MAX);
}
if (!vix.isEmpty() && vix.toInt() != -1) {
audioStream->setCurrentIndex(audioStream->findData(QVariant(vix)));
m_audioStream->setCurrentIndex(m_audioStream->findData(QVariant(vix)));
}
ac->setActive(vix.toInt() == -1);
audioStream->setEnabled(vix.toInt() > -1);
audioStream->setVisible(audioStreamsInfo.size() > 0);
connect(ac, &KDualAction::activeChanged, [this, audioStream](bool activated) {
m_audioStream->setEnabled(vix.toInt() > -1);
m_audioStream->setVisible(audioStreamsInfo.size() > 0);
connect(ac, &KDualAction::activeChanged, [this](bool activated) {
QMap<QString, QString> properties;
int vindx = -1;
if (activated) {
audioStream->setEnabled(false);
m_audioStream->setEnabled(false);
} else {
audioStream->setEnabled(true);
vindx = audioStream->currentData().toInt();
m_audioStream->setEnabled(true);
vindx = m_audioStream->currentData().toInt();
}
properties.insert(QStringLiteral("audio_index"), QString::number(vindx));
properties.insert(QStringLiteral("set.test_audio"), vindx > -1 ? QStringLiteral("0") : QStringLiteral("1"));
emit updateClipProperties(m_id, m_originalProperties, properties);
m_originalProperties = properties;
});
QObject::connect(audioStream, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this, audioStream]() {
QObject::connect(m_audioStream, static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), [this]() {
QMap<QString, QString> properties;
properties.insert(QStringLiteral("audio_index"), QString::number(audioStream->currentData().toInt()));
properties.insert(QStringLiteral("audio_index"), QString::number(m_audioStream->currentData().toInt()));
emit updateClipProperties(m_id, m_originalProperties, properties);
m_originalProperties = properties;
});
hlay->addWidget(audioStream);
hlay->addWidget(m_audioStream);
vbox->addLayout(hlay);
// Audio sync
......@@ -777,6 +778,15 @@ void ClipPropertiesController::slotReloadProperties()
m_originalProperties.insert(QStringLiteral("kdenlive:proxy"), proxy);
emit proxyModified(proxy);
}
if (m_audioStream && m_audioStream->isEnabled()) {
int audio_ix = m_properties->get_int("audio_index");
if (audio_ix != m_originalProperties.value(QStringLiteral("audio_index")).toInt()) {
QSignalBlocker bk(m_audioStream);
m_originalProperties.insert(QStringLiteral("audio_index"), QString::number(audio_ix));
// update combo
m_audioStream->setCurrentIndex(m_audioStream->findData(audio_ix));
}
}
break;
}
default:
......
......@@ -34,6 +34,7 @@ class ClipController;
class QMimeData;
class QTextEdit;
class QLabel;
class QComboBox;
class AnalysisTree : public QTreeWidget
{
......@@ -107,6 +108,7 @@ private:
QWidget *m_markersPage;
QWidget *m_metaPage;
QWidget *m_analysisPage;
QComboBox *m_audioStream;
QTreeView *m_markerTree;
AnalysisTree *m_analysisTree;
QTextEdit *m_textEdit;
......
......@@ -1445,9 +1445,11 @@ void Monitor::slotOpenClip(const std::shared_ptr<ProjectClip> &controller, int i
ac->setChecked(true);
}
m_audioChannelsGroup->addAction(ac);
connect(m_audioChannelsGroup, &QActionGroup::triggered, [controller] (QAction *ac) {
int selectedStream = ac->data().toInt();
controller->setProducerProperty(QStringLiteral("audio_index"), QString::number(selectedStream));
connect(m_audioChannelsGroup, &QActionGroup::triggered, [controller] (QAction *act) {
int selectedStream = act->data().toInt();
QMap <QString, QString> props;
props.insert(QStringLiteral("audio_index"), QString::number(selectedStream));
controller->setProperties(props, true);
});
m_audioChannels->menuAction()->setVisible(true);
} else {
......@@ -1508,6 +1510,22 @@ void Monitor::slotOpenClip(const std::shared_ptr<ProjectClip> &controller, int i
checkOverlay();
}
void Monitor::reloadActiveStream()
{
if (m_controller) {
int activeStream = m_controller->getProducerIntProperty(QLatin1String("audio_index"));
QList <QAction*> actions = m_audioChannels->actions();
QSignalBlocker bk(m_audioChannelsGroup);
for (QAction *ac : actions) {
if (ac->data().toInt() == activeStream) {
ac->setChecked(true);
break;
}
}
}
}
const QString Monitor::activeClipId()
{
if (m_controller) {
......
......@@ -157,6 +157,7 @@ public:
void updateMultiTrackView(int tid);
/** @brief Returns true if monitor is currently fullscreen */
bool monitorIsFullScreen() const;
void reloadActiveStream();
protected:
void mousePressEvent(QMouseEvent *event) override;
......
......@@ -1240,7 +1240,6 @@ void TitleWidget::slotValueChanged(int type)
double length;
// Scaling factor
double scale = 1;
double scalex = t.scalex;
double scaley = t.scaley;
......@@ -2934,7 +2933,7 @@ void TitleWidget::prepareTools(QGraphicsItem *referenceItem)
enableToolbars(TITLE_IMAGE);
QSignalBlocker bk(preserveAspectRatio);
Transform t = m_transformations.value(referenceItem);
preserveAspectRatio->setChecked(t.scalex == t.scaley);
preserveAspectRatio->setChecked(qFuzzyCompare(t.scalex, t.scaley));
} else {
showToolbars(TITLE_SELECT);
......
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