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

Don't snap on subtitles when track is hidden

parent daf52f0c
......@@ -916,6 +916,10 @@
<default>#000000</default>
</entry>
<entry name="showSubtitles" type="Bool">
<label>Show subtitle track.</label>
<default>false</default>
</entry>
<entry name="thumbColor1" type="Color">
<label>Color to draw even audio channels.</label>
......
......@@ -4208,7 +4208,7 @@ void MainWindow::resetSubtitles()
{
// Hide subtitle track
m_buttonSubtitleEditTool->setChecked(false);
getMainTimeline()->showSubtitles = false;
KdenliveSettings::setShowSubtitles(false);
pCore->subtitleWidget()->setModel(nullptr);
if (pCore->currentDoc()) {
const QString workPath = pCore->currentDoc()->subTitlePath(false);
......@@ -4241,18 +4241,18 @@ void MainWindow::slotEditSubtitle(QMap<QString, QString> subProperties)
getMainTimeline()->controller()->subtitlesLockedChanged();
getMainTimeline()->controller()->subtitlesDisabledChanged();
}
getMainTimeline()->showSubtitles = true;
KdenliveSettings::setShowSubtitles(true);
m_buttonSubtitleEditTool->setChecked(true);
getMainTimeline()->connectSubtitleModel(true);
} else {
getMainTimeline()->showSubtitles = m_buttonSubtitleEditTool->isChecked();
KdenliveSettings::setShowSubtitles(m_buttonSubtitleEditTool->isChecked());
getMainTimeline()->connectSubtitleModel(false);
}
}
void MainWindow::slotAddSubtitle()
{
if (pCore->getSubtitleModel() == nullptr || !getMainTimeline()->showSubtitles) {
if (pCore->getSubtitleModel() == nullptr || !KdenliveSettings::showSubtitles()) {
slotEditSubtitle();
m_buttonSubtitleEditTool->setChecked(true);
}
......@@ -4271,7 +4271,7 @@ void MainWindow::slotLockSubtitle()
void MainWindow::slotImportSubtitle()
{
if (pCore->getSubtitleModel() == nullptr || !getMainTimeline()->showSubtitles) {
if (pCore->getSubtitleModel() == nullptr || !KdenliveSettings::showSubtitles()) {
slotEditSubtitle();
m_buttonSubtitleEditTool->setChecked(true);
}
......
......@@ -3878,7 +3878,14 @@ int TimelineModel::getNextSnapPos(int pos, std::vector<int> &snaps)
++it;
}
bool hasSubtitles = m_subtitleModel && !m_allSubtitles.empty();
if ((tracks.isEmpty() || tracks.count() == (int) m_allTracks.size()) && (!hasSubtitles || !m_subtitleModel->isLocked())) {
bool filterOutSubtitles = false;
if (hasSubtitles) {
// If subtitle track is locked or hidden, don't snap to it
if (m_subtitleModel->isLocked() || !KdenliveSettings::showSubtitles()) {
filterOutSubtitles = true;
}
}
if ((tracks.isEmpty() || tracks.count() == (int) m_allTracks.size()) && !filterOutSubtitles) {
// No active track, use all possible snap points
return m_snaps->getNextPoint((int)pos);
}
......@@ -3891,7 +3898,7 @@ int TimelineModel::getNextSnapPos(int pos, std::vector<int> &snaps)
}
}
// Subtitle snaps
if (hasSubtitles && !m_subtitleModel->isLocked()) {
if (hasSubtitles && !filterOutSubtitles) {
// Add subtitle snaps
m_subtitleModel->allSnaps(snaps);
}
......@@ -3917,7 +3924,14 @@ int TimelineModel::getPreviousSnapPos(int pos, std::vector<int> &snaps)
++it;
}
bool hasSubtitles = m_subtitleModel && !m_allSubtitles.empty();
if ((tracks.isEmpty() || tracks.count() == (int) m_allTracks.size()) && (!hasSubtitles || !m_subtitleModel->isLocked())) {
bool filterOutSubtitles = false;
if (hasSubtitles) {
// If subtitle track is locked or hidden, don't snap to it
if (m_subtitleModel->isLocked() || !KdenliveSettings::showSubtitles()) {
filterOutSubtitles = true;
}
}
if ((tracks.isEmpty() || tracks.count() == (int) m_allTracks.size()) && !filterOutSubtitles) {
// No active track, use all possible snap points
return m_snaps->getPreviousPoint((int)pos);
}
......@@ -3930,7 +3944,7 @@ int TimelineModel::getPreviousSnapPos(int pos, std::vector<int> &snaps)
}
}
// Subtitle snaps
if (hasSubtitles && !m_subtitleModel->isLocked()) {
if (hasSubtitles && !filterOutSubtitles) {
// Add subtitle snaps
m_subtitleModel->allSnaps(snaps);
}
......
......@@ -502,7 +502,7 @@ void TimelineWidget::connectSubtitleModel(bool firstConnect)
else
{
//qDebug()<<"null ptr NOT here at root context";
rootObject()->setProperty("showSubtitles", showSubtitles);
rootObject()->setProperty("showSubtitles", KdenliveSettings::showSubtitles());
if (firstConnect) {
rootContext()->setContextProperty("subtitleModel", pCore->getSubtitleModel().get());
}
......
......@@ -57,7 +57,6 @@ public:
void setTimelineMenu(QMenu *clipMenu, QMenu *compositionMenu, QMenu *timelineMenu, QMenu *timelineRulerMenu, QMenu *guideMenu, QAction *editGuideAction, QMenu *headerMenu, QMenu *thumbsMenu, QMenu *subtitleClipMenu);
bool loading;
void connectSubtitleModel(bool firstConnect);
bool showSubtitles=false;
protected:
void mousePressEvent(QMouseEvent *event) override;
......
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