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

Subtitles style: use undo/redo, enable styling widget when no subtitle is selected

parent 04ebbe08
Pipeline #184665 passed with stage
in 6 minutes and 44 seconds
......@@ -62,10 +62,21 @@ SubtitleModel::SubtitleModel(Mlt::Tractor *tractor, std::shared_ptr<TimelineItem
void SubtitleModel::setStyle(const QString &style)
{
m_subtitleFilter->set("av.force_style", style.toUtf8().constData());
// Force refresh to show the new style
pCore->requestMonitorRefresh();
pCore->setDocumentModified();
QString oldStyle = m_subtitleFilter->get("av.force_style");
Fun redo = [this, style]() {
m_subtitleFilter->set("av.force_style", style.toUtf8().constData());
// Force refresh to show the new style
pCore->requestMonitorRefresh();
return true;
};
Fun undo = [this, oldStyle]() {
m_subtitleFilter->set("av.force_style", oldStyle.toUtf8().constData());
// Force refresh to show the new style
pCore->requestMonitorRefresh();
return true;
};
redo();
pCore->pushUndo(undo, redo, i18n("Edit subtitle style"));
}
const QString SubtitleModel::getStyle() const
......
......@@ -199,6 +199,7 @@ void SubtitleEdit::setModel(std::shared_ptr<SubtitleModel> model)
QSignalBlocker bk(subText);
subText->clear();
loadStyle(QString());
frame_position->setEnabled(false);
} else {
connect(m_model.get(), &SubtitleModel::updateSubtitleStyle, this, &SubtitleEdit::loadStyle);
connect(m_model.get(), &SubtitleModel::dataChanged, this, [this](const QModelIndex &start, const QModelIndex &, const QVector<int> &roles) {
......@@ -209,6 +210,8 @@ void SubtitleEdit::setModel(std::shared_ptr<SubtitleModel> model)
}
}
});
frame_position->setEnabled(true);
stackedWidget->widget(0)->setEnabled(false);
}
}
......@@ -305,7 +308,7 @@ void SubtitleEdit::setActiveSubtitle(int id)
if (m_model && id > -1) {
subText->setEnabled(true);
QSignalBlocker bk(subText);
frame_position->setEnabled(true);
stackedWidget->widget(0)->setEnabled(true);
buttonDelete->setEnabled(true);
QSignalBlocker bk2(m_position);
QSignalBlocker bk3(m_endPosition);
......@@ -324,7 +327,7 @@ void SubtitleEdit::setActiveSubtitle(int id)
m_position->setEnabled(false);
m_endPosition->setEnabled(false);
m_duration->setEnabled(false);
frame_position->setEnabled(false);
stackedWidget->widget(0)->setEnabled(false);
buttonDelete->setEnabled(false);
QSignalBlocker bk(subText);
subText->clear();
......
Supports Markdown
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