Add button to toggle use of timeline zone in insert editing (next to bigger/smaller tracks)

Ref: T1961
parent 2627e885
......@@ -1600,3 +1600,7 @@ void KdenliveDoc::getFileProperties(const QDomElement &xml, const QString &clipI
pCore->producerQueue()->getFileProperties(xml, clipId, imageHeight, replaceProducer);
}
void KdenliveDoc::doAddAction(const QString &name, QAction *a)
{
pCore->window()->actionCollection()->addAction(name, a);
}
......@@ -158,6 +158,7 @@ public:
void getFileProperties(const QDomElement &xml, const QString &clipId, int imageHeight, bool replaceProducer = true);
/** @brief Returns true if the profile file has changed. */
bool profileChanged(const QString &profile) const;
void doAddAction(const QString &name, QAction *a);
private:
QUrl m_url;
......
......@@ -198,7 +198,7 @@
<label>Vertical drag in timeline ruler zooms.</label>
<default>false</default>
</entry>
<entry name="trackheight" type="Int">
<label>Tracks height in pixel.</label>
<default>0</default>
......@@ -208,6 +208,11 @@
<label>Automatically split audio and video.</label>
<default>false</default>
</entry>
<entry name="useTimelineZoneToEdit" type="Bool">
<label>Use timeline zone as in/out editing points.</label>
<default>false</default>
</entry>
</group>
<group name="sdl">
......
......@@ -93,6 +93,8 @@ CustomRuler::CustomRuler(const Timecode &tc, CustomTrackView *parent) :
m_goMenu = m_contextMenu->addMenu(i18n("Go To"));
connect(m_goMenu, SIGNAL(triggered(QAction*)), this, SLOT(slotGoToGuide(QAction*)));
setMouseTracking(true);
m_zoneBG = palette().color(QPalette::Highlight);
m_zoneBG.setAlpha(KdenliveSettings::useTimelineZoneToEdit() ? 180 : 60);
}
void CustomRuler::updateProjectFps(const Timecode &t)
......@@ -396,7 +398,7 @@ void CustomRuler::paintEvent(QPaintEvent *e)
// Draw zone background
const int zoneStart = (int)(m_zoneStart * m_factor);
const int zoneEnd = (int)(m_zoneEnd * m_factor);
p.fillRect(zoneStart - m_offset, LABEL_SIZE + 2, zoneEnd - zoneStart, MAX_HEIGHT - LABEL_SIZE - 2, palette().color(QPalette::Highlight));
p.fillRect(zoneStart - m_offset, LABEL_SIZE + 2, zoneEnd - zoneStart, MAX_HEIGHT - LABEL_SIZE - 2, m_zoneBG);
double f, fend;
const int offsetmax = ((paintRect.right() + m_offset) / FRAME_SIZE + 1) * FRAME_SIZE;
......@@ -471,7 +473,7 @@ void CustomRuler::paintEvent(QPaintEvent *e)
pa.setPoints(4, zoneEnd - m_offset - FONT_WIDTH / 2, LABEL_SIZE + 2, zoneEnd - m_offset, LABEL_SIZE + 2, zoneEnd - m_offset, MAX_HEIGHT - 1, zoneEnd - m_offset - FONT_WIDTH / 2, MAX_HEIGHT - 1);
p.drawPolyline(pa);
}
// draw pointer
const int value = m_view->cursorPos() * m_factor - m_offset;
QPolygon pa(3);
......@@ -488,4 +490,9 @@ void CustomRuler::paintEvent(QPaintEvent *e)
}
void CustomRuler::activateZone()
{
m_zoneBG.setAlpha(KdenliveSettings::useTimelineZoneToEdit() ? 180 : 60);
update();
}
......@@ -49,6 +49,7 @@ public:
int offset() const;
void updateProjectFps(const Timecode &t);
void updateFrameSize();
void activateZone();
protected:
void paintEvent(QPaintEvent * /*e*/);
......@@ -69,6 +70,7 @@ private:
int m_offset;
/** @brief the position of the seek point */
int m_headPosition;
QColor m_zoneBG;
RULER_MOVE m_moveCursor;
QMenu *m_contextMenu;
QAction *m_editGuide;
......
......@@ -8069,13 +8069,19 @@ void CustomTrackView::insertZone(TimelineMode::EditMode sceneMode, const QString
return;
}
if (binZone.isNull()) return;
QPoint timelineZone = m_document->zone();
QPoint timelineZone;
if (KdenliveSettings::useTimelineZoneToEdit())
timelineZone = m_document->zone();
else {
timelineZone.setX(seekPosition());
timelineZone.setY(-1);
}
ItemInfo info;
int binLength = binZone.y() - binZone.x();
int timelineLength = timelineZone.y() - timelineZone.x();
info.startPos = GenTime(timelineZone.x(), m_document->fps());
info.cropStart = GenTime(binZone.x(), m_document->fps());
info.endPos = info.startPos + GenTime(timelineLength > binLength ? binLength : timelineLength, m_document->fps());
info.endPos = info.startPos + GenTime(KdenliveSettings::useTimelineZoneToEdit() ? timelineLength : binLength, m_document->fps());
info.cropDuration = info.endPos - info.startPos;
info.track = m_selectedTrack;
QUndoCommand *addCommand = new QUndoCommand();
......
......@@ -103,6 +103,16 @@ Timeline::Timeline(KdenliveDoc *doc, const QList<QAction *> &actions, bool *ok,
connect(butLarge, SIGNAL(clicked()), this, SLOT(slotVerticalZoomUp()));
sizeLayout->addWidget(butLarge);
QToolButton *enableZone = new QToolButton(this);
QAction *ac = new QAction(KoIconUtils::themedIcon(QStringLiteral("measure")), i18n("Use Timeline Zone for Insert"), this);
enableZone->setAutoRaise(true);
ac->setCheckable(true);
ac->setChecked(KdenliveSettings::useTimelineZoneToEdit());
enableZone->setDefaultAction(ac);
connect(ac, &QAction::toggled, this, &Timeline::slotEnableZone);
sizeLayout->addWidget(enableZone);
m_doc->doAddAction(QStringLiteral("use_timeline_zone_in_edit"), ac);
QHBoxLayout *tracksLayout = new QHBoxLayout;
tracksLayout->setContentsMargins(0, 0, 0, 0);
tracksLayout->setSpacing(0);
......@@ -866,6 +876,7 @@ void Timeline::updatePalette()
}
}
}
m_ruler->activateZone();
}
void Timeline::updateHeaders()
......@@ -1654,3 +1665,9 @@ void Timeline::switchTrackTarget()
}
}
}
void Timeline::slotEnableZone(bool enable)
{
KdenliveSettings::setUseTimelineZoneToEdit(enable);
m_ruler->activateZone();
}
......@@ -229,6 +229,8 @@ private slots:
void slotUpdateVerticalScroll(int min, int max);
/** @brief Update the track label showing applied effects.*/
void slotUpdateTrackEffectState(int);
/** @brief Toggle use of timeline zone for editing.*/
void slotEnableZone(bool enable);
signals:
void mousePosition(int);
......
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