Fix "merge all streams"

Related to #382
parent 78459841
Pipeline #20125 passed with stage
in 9 minutes and 14 seconds
......@@ -110,10 +110,14 @@ QMap <int, QString> AudioStreamInfo::activeStreams() const
{
QMap <int, QString> active;
QMapIterator<int, QString> i(m_audioStreams);
while (i.hasNext()) {
i.next();
if (m_activeStreams.contains(i.key())) {
active.insert(i.key(), i.value());
if (m_activeStreams.size() == 1 && m_activeStreams.contains(INT_MAX)) {
active.insert(INT_MAX, i18n("Merged streams"));
} else {
while (i.hasNext()) {
i.next();
if (m_activeStreams.contains(i.key())) {
active.insert(i.key(), i.value());
}
}
}
return active;
......
......@@ -629,7 +629,6 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
m_audioStreamsView = new QListWidget(this);
m_audioStreamsView->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::MinimumExpanding);
audioVbox->addWidget(m_audioStreamsView);
//m_audioStream = new QComboBox(this);
QMapIterator<int, QString> i(audioStreamsInfo);
while (i.hasNext()) {
i.next();
......@@ -672,6 +671,12 @@ ClipPropertiesController::ClipPropertiesController(ClipController *controller, Q
}
} else if (checked) {
// Stream was selected
if (streamId == INT_MAX) {
// merge all streams should not have any other stream selected
activeStreams.clear();
} else {
activeStreams.removeAll(QString::number(INT_MAX));
}
activeStreams << QString::number(streamId);
activeStreams.sort();
streamModified = true;
......@@ -860,6 +865,7 @@ void ClipPropertiesController::slotReloadProperties()
//m_audioStream->setCurrentIndex(m_audioStream->findData(audio_ix));
}
QList <int> enabledStreams = m_controller->activeStreams().keys();
qDebug()<<"=== GOT ACTIVE STREAMS: "<<enabledStreams;
QSignalBlocker bk(m_audioStreamsView);
for (int ix = 0; ix < m_audioStreamsView->count(); ix++) {
QListWidgetItem *item = m_audioStreamsView->item(ix);
......
......@@ -283,14 +283,32 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
m_audioChannels = new QMenu(this);
m_streamsButton->setMenu(m_audioChannels);
m_streamAction->setVisible(false);
connect(m_audioChannels, &QMenu::triggered, [this] () {
m_audioChannels->show();
connect(m_audioChannels, &QMenu::triggered, [this] (QAction *ac) {
//m_audioChannels->show();
QList <QAction*> actions = m_audioChannels->actions();
QMap <int, QString> enabledStreams;
for (const auto act : actions) {
if (act->isChecked()) {
// Audio stream is selected
enabledStreams.insert(act->data().toInt(), act->text().remove(QLatin1Char('&')));
if (ac->data().toInt() == INT_MAX) {
// Merge stream selected, clear all others
enabledStreams.clear();
enabledStreams.insert(INT_MAX, i18n("Merged streams"));
// Disable all other streams
QSignalBlocker bk(m_audioChannels);
for (auto act : actions) {
if (act->isChecked() && act != ac) {
act->setChecked(false);
}
}
} else {
for (auto act : actions) {
if (act->isChecked()) {
// Audio stream is selected
if (act->data().toInt() == INT_MAX) {
QSignalBlocker bk(m_audioChannels);
act->setChecked(false);
} else {
enabledStreams.insert(act->data().toInt(), act->text().remove(QLatin1Char('&')));
}
}
}
}
if (!enabledStreams.isEmpty()) {
......
......@@ -42,6 +42,11 @@ Item {
font: fixedFont
}
Timer {
id: thumbTimer
interval: 3000; running: false;
}
signal editCurrentMarker()
onDurationChanged: {
......@@ -128,7 +133,7 @@ Item {
Item {
id: audioThumb
property bool stateVisible: (clipMonitorRuler.containsMouse || thumbMouseArea.containsMouse)
property bool stateVisible: (clipMonitorRuler.containsMouse || thumbMouseArea.containsMouse || thumbTimer.running)
property bool isAudioClip: controller.clipType == ProducerType.Audio
anchors {
left: parent.left
......@@ -179,6 +184,9 @@ Item {
Repeater {
id: streamThumb
model: controller.audioThumb.length
onCountChanged: {
thumbTimer.start()
}
property double streamHeight: parent.height / streamThumb.count
Item {
anchors.fill: parent
......
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