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

*Fix recent regression in timeline selection

*Allow typing text in empty subtitle widget for next added subtitle
parent f6fdb1ad
......@@ -141,12 +141,12 @@ void Core::initGUI(bool isAppImage, const QString &MltPath, const QUrl &Url, con
connect(m_mixerWidget, &MixerManager::updateRecVolume, m_capture.get(), &MediaCapture::setAudioVolume);
m_monitorManager = new MonitorManager(this);
connect(m_monitorManager, &MonitorManager::cleanMixer, m_mixerWidget, &MixerManager::clearMixers);
connect(m_subtitleWidget, &SubtitleEdit::addSubtitle, [this]() {
connect(m_subtitleWidget, &SubtitleEdit::addSubtitle, this, [this](const QString &text) {
if (m_guiConstructed && m_mainWindow->getCurrentTimeline()->controller()) {
m_mainWindow->getCurrentTimeline()->controller()->addSubtitle();
m_mainWindow->getCurrentTimeline()->controller()->addSubtitle(-1, text);
}
});
connect(m_subtitleWidget, &SubtitleEdit::cutSubtitle, [this](int id, int cursorPos) {
connect(m_subtitleWidget, &SubtitleEdit::cutSubtitle, this, [this](int id, int cursorPos) {
if (m_guiConstructed && m_mainWindow->getCurrentTimeline()->controller()) {
m_mainWindow->getCurrentTimeline()->controller()->cutSubtitle(id, cursorPos);
}
......
......@@ -120,8 +120,10 @@ SubtitleEdit::SubtitleEdit(QWidget *parent)
}
m_model->requestResize(m_activeSub, value, true);
});
connect(buttonAdd, &QToolButton::clicked, this, &SubtitleEdit::addSubtitle);
connect(buttonCut, &QToolButton::clicked, [this]() {
connect(buttonAdd, &QToolButton::clicked, this, [this]() {
emit addSubtitle(subText->toPlainText());
});
connect(buttonCut, &QToolButton::clicked, this, [this]() {
if (m_activeSub > -1 && subText->hasFocus()) {
int pos = subText->textCursor().position();
if (buttonApply->isEnabled()) {
......@@ -154,7 +156,6 @@ void SubtitleEdit::setModel(std::shared_ptr<SubtitleModel> model)
{
m_model = model;
m_activeSub = -1;
subText->setEnabled(false);
buttonApply->setEnabled(false);
buttonCut->setEnabled(false);
if (m_model == nullptr) {
......@@ -207,7 +208,6 @@ void SubtitleEdit::setActiveSubtitle(int id)
m_position->setEnabled(false);
m_endPosition->setEnabled(false);
m_duration->setEnabled(false);
subText->setEnabled(false);
frame_position->setEnabled(false);
buttonDelete->setEnabled(false);
QSignalBlocker bk(subText);
......
......@@ -74,7 +74,7 @@ private:
GenTime m_endPos;
signals:
void addSubtitle();
void addSubtitle(const QString &);
void cutSubtitle(int id, int cursorPos);
};
......
......@@ -80,9 +80,6 @@ TimelineController::TimelineController(QObject *parent)
{
m_disablePreview = pCore->currentDoc()->getAction(QStringLiteral("disable_preview"));
connect(m_disablePreview, &QAction::triggered, this, &TimelineController::disablePreview);
connect(this, &TimelineController::selectionChanged, this, &TimelineController::updateClipActions);
connect(this, &TimelineController::videoTargetChanged, this, &TimelineController::updateVideoTarget);
connect(this, &TimelineController::audioTargetChanged, this, &TimelineController::updateAudioTarget);
m_disablePreview->setEnabled(false);
connect(pCore.get(), &Core::finalizeRecording, this, &TimelineController::finishRecording);
connect(pCore.get(), &Core::autoScrollChanged, this, &TimelineController::autoScrollChanged);
......@@ -129,6 +126,9 @@ void TimelineController::setModel(std::shared_ptr<TimelineItemModel> model)
showMasterEffects();
}
});
connect(this, &TimelineController::selectionChanged, this, &TimelineController::updateClipActions);
connect(this, &TimelineController::videoTargetChanged, this, &TimelineController::updateVideoTarget);
connect(this, &TimelineController::audioTargetChanged, this, &TimelineController::updateAudioTarget);
connect(m_model.get(), &TimelineItemModel::requestMonitorRefresh, [&]() { pCore->requestMonitorRefresh(); });
connect(m_model.get(), &TimelineModel::invalidateZone, this, &TimelineController::invalidateZone, Qt::DirectConnection);
connect(m_model.get(), &TimelineModel::durationUpdated, this, &TimelineController::checkDuration);
......@@ -4100,7 +4100,7 @@ void TimelineController::resizeSubtitle(int startFrame, int endFrame, int oldEnd
}
void TimelineController::addSubtitle(int startframe)
void TimelineController::addSubtitle(int startframe, QString text)
{
if (startframe == -1) {
startframe = pCore->getTimelinePosition();
......@@ -4108,13 +4108,16 @@ void TimelineController::addSubtitle(int startframe)
int endframe = startframe + pCore->getDurationFromString(KdenliveSettings::subtitle_duration());
auto subtitleModel = pCore->getSubtitleModel(true);
int id = TimelineModel::getNextId();
if (text.isEmpty()) {
text = i18n("Add text");
}
Fun local_undo = [subtitleModel, id, startframe, endframe]() {
subtitleModel->removeSubtitle(id);
pCore->refreshProjectRange({startframe, endframe});
return true;
};
Fun local_redo = [subtitleModel, id, startframe, endframe]() {
if (subtitleModel->addSubtitle(id, GenTime(startframe, pCore->getCurrentFps()), GenTime(endframe, pCore->getCurrentFps()), i18n("Add text"))) {
Fun local_redo = [subtitleModel, id, startframe, endframe, text]() {
if (subtitleModel->addSubtitle(id, GenTime(startframe, pCore->getCurrentFps()), GenTime(endframe, pCore->getCurrentFps()), text)) {
pCore->refreshProjectRange({startframe, endframe});
return true;
}
......
......@@ -607,7 +607,7 @@ public:
/** @brief Edit the subtitle end */
Q_INVOKABLE void resizeSubtitle(int startFrame, int endFrame, int oldEndFrame, bool refreshModel);
/** @brief Add subtitle clip at cursor's position in timeline */
Q_INVOKABLE void addSubtitle(int startframe = -1);
Q_INVOKABLE void addSubtitle(int startframe = -1, QString text = QString());
/** @brief Cut a subtitle and split the text at @param pos */
void cutSubtitle(int id, int cursorPos);
/** @brief Delete subtitle clip with frame as start position*/
......
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