Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Cleanup timelinecontroller (don't depend on timelinewidget), start timeline zone

parent 0ab0c9ee
......@@ -1400,7 +1400,7 @@ void Bin::selectClipById(const QString &clipId, int frame, const QPoint &zone)
m_monitor->slotSeek(frame);
}
if (!zone.isNull()) {
m_monitor->slotLoadClipZone(zone.x(), zone.y());
m_monitor->slotLoadClipZone(zone);
}
return;
}
......@@ -1420,7 +1420,7 @@ void Bin::selectClipById(const QString &clipId, int frame, const QPoint &zone)
m_monitor->slotSeek(frame);
}
if (!zone.isNull()) {
m_monitor->slotLoadClipZone(zone.x(), zone.y());
m_monitor->slotLoadClipZone(zone);
}
}
}
......
......@@ -2091,7 +2091,8 @@ void MainWindow::connectDocument()
void MainWindow::slotZoneMoved(int start, int end)
{
pCore->projectManager()->current()->setZone(start, end);
m_projectMonitor->slotLoadClipZone(start, end);
QPoint zone(start, end);
m_projectMonitor->slotLoadClipZone(zone);
}
void MainWindow::slotGuidesUpdated()
......
......@@ -296,7 +296,7 @@ Monitor::Monitor(Kdenlive::MonitorId id, MonitorManager *manager, QWidget *paren
if (id != Kdenlive::ClipMonitor) {
//TODO: reimplement
//connect(render, &Render::durationChanged, this, &Monitor::durationChanged);
//connect(m_ruler, SIGNAL(zoneChanged(QPoint)), this, SIGNAL(zoneUpdated(QPoint)));
connect(m_glMonitor->getControllerProxy(), SIGNAL(zoneChanged()), this, SLOT(updateTimelineClipZone()));
} else {
connect(m_glMonitor->getControllerProxy(), SIGNAL(zoneChanged()), this, SLOT(updateClipZone()));
}
......@@ -650,9 +650,9 @@ GenTime Monitor::getSnapForPos(bool previous)
return GenTime(frame, pCore->getCurrentFps());
}
void Monitor::slotLoadClipZone(int start, int end)
void Monitor::slotLoadClipZone(const QPoint &zone)
{
m_glMonitor->getControllerProxy()->setZone(start, end);
m_glMonitor->getControllerProxy()->setZone(zone.x(), zone.y());
checkOverlay();
}
......@@ -661,6 +661,9 @@ void Monitor::slotSetZoneStart()
m_glMonitor->getControllerProxy()->setZoneIn(m_glMonitor->getCurrentPos());
if (m_controller) {
m_controller->setZone(m_glMonitor->getControllerProxy()->zone());
} else {
// timeline
emit timelineZoneChanged();
}
checkOverlay();
}
......@@ -1434,6 +1437,11 @@ void Monitor::updateClipZone()
m_controller->setZone(m_glMonitor->getControllerProxy()->zone());
}
void Monitor::updateTimelineClipZone()
{
emit zoneUpdated(m_glMonitor->getControllerProxy()->zone());
}
void Monitor::switchDropFrames(bool drop)
{
render->setDropFrames(drop);
......
......@@ -276,6 +276,8 @@ private slots:
void slotEnableSceneZoom(bool enable);
/** @brief Pan monitor view */
void panView(QPoint diff);
/** @brief Project monitor zone changed, inform timeline */
void updateTimelineClipZone();
public slots:
void slotOpenDvdFile(const QString &);
......@@ -305,7 +307,7 @@ public slots:
void slotSetZoneEnd(bool discardLastFrame = false);
void slotZoneStart();
void slotZoneEnd();
void slotLoadClipZone(int start, int end);
void slotLoadClipZone(const QPoint &zone);
void slotSeekToNextSnap();
void slotSeekToPreviousSnap();
void adjustRulerSize(int length, std::shared_ptr<MarkerListModel> markerModel = nullptr);
......@@ -339,6 +341,7 @@ signals:
void durationChanged(int);
void refreshClipThumbnail(const QString &);
void zoneUpdated(const QPoint &);
void timelineZoneChanged();
/** @brief Editing transitions / effects over the monitor requires the renderer to send frames as QImage.
* This causes a major slowdown, so we only enable it if required */
void requestFrameForAnalysis(bool);
......
......@@ -74,5 +74,87 @@ Rectangle {
color: activePalette.windowText
}
}
// monitor zone
Rectangle {
id: zone
visible: timeline.zoneOut > timeline.zoneIn
color: activePalette.highlight
x: timeline.zoneIn * timeScale
width: (timeline.zoneOut - timeline.zoneIn) * timeScale
anchors.bottom: parent.bottom
height: ruler.height / 3
opacity: 0.4
Rectangle {
id: trimIn
anchors.left: parent.left
anchors.leftMargin: 0
height: parent.height
width: 5
color: 'lawngreen'
opacity: 0
Drag.active: trimInMouseArea.drag.active
Drag.proposedAction: Qt.MoveAction
MouseArea {
id: trimInMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.SizeHorCursor
drag.target: parent
drag.axis: Drag.XAxis
drag.smoothed: false
onPressed: {
parent.anchors.left = undefined
}
onReleased: {
parent.anchors.left = zone.left
}
onPositionChanged: {
if (mouse.buttons === Qt.LeftButton) {
timeline.zoneIn = timeline.zoneIn + Math.round(trimIn.x / timeScale)
}
}
onEntered: parent.opacity = 0.5
onExited: parent.opacity = 0
}
}
Rectangle {
id: trimOut
anchors.right: parent.right
anchors.rightMargin: 0
height: parent.height
width: 5
color: 'darkred'
opacity: 0
Drag.active: trimOutMouseArea.drag.active
Drag.proposedAction: Qt.MoveAction
MouseArea {
id: trimOutMouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.SizeHorCursor
drag.target: parent
drag.axis: Drag.XAxis
drag.smoothed: false
onPressed: {
parent.anchors.right = undefined
}
onReleased: {
parent.anchors.right = zone.right
}
onPositionChanged: {
if (mouse.buttons === Qt.LeftButton) {
timeline.zoneOut = timeline.zoneIn + Math.round((trimOut.x + trimOut.width) / timeScale)
}
}
onEntered: parent.opacity = 0.5
onExited: parent.opacity = 0
}
}
}
}
......@@ -38,9 +38,9 @@
int TimelineController::m_duration = 0;
TimelineController::TimelineController(KActionCollection *actionCollection, TimelineWidget *parent) :
TimelineController::TimelineController(KActionCollection *actionCollection, QObject *parent) :
QObject(parent)
, q(parent)
, m_root(nullptr)
, m_actionCollection(actionCollection)
, m_position(0)
, m_seekPosition(-1)
......@@ -48,9 +48,10 @@ TimelineController::TimelineController(KActionCollection *actionCollection, Time
{
}
void TimelineController::setModel(std::shared_ptr<TimelineItemModel> model)
void TimelineController::setModel(std::shared_ptr<TimelineItemModel> model, QQuickItem *root)
{
m_model = std::move(model);
m_root = root;
}
Mlt::Tractor *TimelineController::tractor()
......@@ -152,14 +153,14 @@ void TimelineController::emitSelectedFromSelection()
QList<int> TimelineController::selection() const
{
if (!q->rootObject()) return QList<int>();
if (!m_root) return QList<int>();
return m_selection.selectedClips;
}
void TimelineController::selectMultitrack()
{
setSelection(QList<int>(), -1, true);
QMetaObject::invokeMethod(q->rootObject(), "selectMultitrack");
QMetaObject::invokeMethod(m_root, "selectMultitrack");
// emit selected(m_model.tractor());
}
......@@ -285,7 +286,7 @@ void TimelineController::unGroupSelection(int cid)
void TimelineController::setInPoint()
{
int cursorPos = q->rootObject()->property("seekPos").toInt();
int cursorPos = m_root->property("seekPos").toInt();
if (cursorPos < 0) {
cursorPos = m_position;
}
......@@ -298,7 +299,7 @@ void TimelineController::setInPoint()
void TimelineController::setOutPoint()
{
int cursorPos = q->rootObject()->property("seekPos").toInt();
int cursorPos = m_root->property("seekPos").toInt();
if (cursorPos < 0) {
cursorPos = m_position;
}
......@@ -313,7 +314,7 @@ void TimelineController::editMarker(const QString &cid, int frame)
{
ProjectClip *clip = pCore->bin()->getBinClip(cid);
CommentedTime marker = clip->getMarker(GenTime(frame, pCore->getCurrentFps()));
QPointer<MarkerDialog> d = new MarkerDialog(clip, marker, pCore->bin()->projectTimecode(), i18n("Edit Marker"), q);
QPointer<MarkerDialog> d = new MarkerDialog(clip, marker, pCore->bin()->projectTimecode(), i18n("Edit Marker"), qApp->activeWindow());
if (d->exec() == QDialog::Accepted) {
QList<CommentedTime> markers;
CommentedTime newMarker = d->newMarker();
......@@ -330,7 +331,7 @@ void TimelineController::editMarker(const QString &cid, int frame)
void TimelineController::editGuide(int frame)
{
CommentedTime marker = pCore->projectManager()->current()->getGuideModel().get()->getMarker(GenTime(frame, pCore->getCurrentFps()));
QPointer<MarkerDialog> d = new MarkerDialog(nullptr, marker, pCore->bin()->projectTimecode(), i18n("Edit Marker"), q);
QPointer<MarkerDialog> d = new MarkerDialog(nullptr, marker, pCore->bin()->projectTimecode(), i18n("Edit Marker"), qApp->activeWindow());
if (d->exec() == QDialog::Accepted) {
QList<CommentedTime> markers;
CommentedTime newMarker = d->newMarker();
......@@ -384,7 +385,7 @@ void TimelineController::showAsset(int id)
void TimelineController::seek(int position)
{
q->rootObject()->setProperty("seekPos", position);
m_root->setProperty("seekPos", position);
emit seeked(position);
}
......@@ -408,3 +409,21 @@ void TimelineController::onSeeked(int position)
emit seekPositionChanged();
}
}
void TimelineController::setZone(const QPoint &zone)
{
m_zone = zone;
emit zoneChanged();
}
void TimelineController::setZoneIn(int inPoint)
{
m_zone.setX(inPoint);
emit zoneMoved(m_zone);
}
void TimelineController::setZoneOut(int outPoint)
{
m_zone.setY(outPoint);
emit zoneMoved(m_zone);
}
......@@ -43,6 +43,8 @@ class TimelineController : public QObject
/* @brief holds the current timeline position
*/
Q_PROPERTY(int position READ position WRITE setPosition NOTIFY positionChanged)
Q_PROPERTY(int zoneIn READ zoneIn NOTIFY zoneChanged)
Q_PROPERTY(int zoneOut READ zoneOut NOTIFY zoneChanged)
Q_PROPERTY(int seekPosition READ seekPosition WRITE setSeekPosition NOTIFY seekPositionChanged)
Q_PROPERTY(bool snap READ snap NOTIFY snapChanged)
Q_PROPERTY(bool ripple READ ripple NOTIFY rippleChanged)
......@@ -52,8 +54,8 @@ class TimelineController : public QObject
Q_PROPERTY(bool showAudioThumbnails READ showAudioThumbnails NOTIFY showAudioThumbnailsChanged)
public:
TimelineController(KActionCollection *actionCollection, TimelineWidget *parent);
void setModel(std::shared_ptr<TimelineItemModel> model);
TimelineController(KActionCollection *actionCollection, QObject *parent);
void setModel(std::shared_ptr<TimelineItemModel> model, QQuickItem *root);
Q_INVOKABLE bool isMultitrackSelected() const { return m_selection.isMultitrackSelected; }
Q_INVOKABLE int selectedTrack() const { return m_selection.selectedTrack; }
......@@ -75,6 +77,14 @@ public:
/* @brief Returns the seek request position (-1 = no seek pending)
*/
Q_INVOKABLE int seekPosition() const { return m_seekPosition; }
/* @brief Request a seek operation
@param position is the desired new timeline position
*/
Q_INVOKABLE int zoneIn() const { return m_zone.x(); }
Q_INVOKABLE int zoneOut() const { return m_zone.y(); }
Q_INVOKABLE void setZoneIn(int inPoint);
Q_INVOKABLE void setZoneOut(int outPoint);
void setZone(const QPoint &zone);
/* @brief Request a seek operation
@param position is the desired new timeline position
*/
......@@ -186,7 +196,7 @@ public slots:
private:
TimelineWidget *q;
QQuickItem *m_root;
KActionCollection *m_actionCollection;
std::shared_ptr<TimelineItemModel> m_model;
struct Selection
......@@ -197,6 +207,7 @@ private:
};
int m_position;
int m_seekPosition;
QPoint m_zone;
double m_scale;
static int m_duration;
Selection m_selection;
......@@ -220,6 +231,8 @@ signals:
void rippleChanged();
void scrubChanged();
void seeked(int position);
void zoneChanged();
void zoneMoved(const QPoint &zone);
/* @brief Requests that a given parameter model is displayed in the asset panel */
void showTransitionModel(std::shared_ptr<AssetParameterModel>);
};
......
......@@ -40,6 +40,8 @@ TimelineTabs::TimelineTabs(QWidget *parent)
// Resize to 0 the size of the close button of the main timeline, so that the user cannnot close it.
tabBar()->tabButton(0, QTabBar::RightSide)->resize(0, 0);
connect(pCore->monitorManager()->projectMonitor(), &Monitor::zoneUpdated, m_mainTimeline, &TimelineWidget::zoneUpdated);
connect(m_mainTimeline, &TimelineWidget::zoneMoved, pCore->monitorManager()->projectMonitor(), &Monitor::slotLoadClipZone);
}
TimelineWidget *TimelineTabs::getMainTimeline() const
......
......@@ -58,6 +58,7 @@ TimelineWidget::TimelineWidget(KActionCollection *actionCollection, std::shared_
m_transitionProxyModel->setSortRole(AssetTreeModel::NameRole);
m_transitionProxyModel->sort(0, Qt::AscendingOrder);
m_proxy = new TimelineController(actionCollection, this);
connect(m_proxy, &TimelineController::zoneMoved, this, &TimelineWidget::zoneMoved);
KDeclarative::KDeclarative kdeclarative;
kdeclarative.setDeclarativeEngine(engine());
kdeclarative.setupBindings();
......@@ -77,7 +78,6 @@ TimelineWidget::~TimelineWidget()
void TimelineWidget::setModel(std::shared_ptr<TimelineItemModel> model)
{
m_thumbnailer->resetProject();
m_proxy->setModel(model);
auto *proxyModel = new QSortFilterProxyModel(this);
proxyModel->setSourceModel(model.get());
proxyModel->setSortRole(TimelineItemModel::ItemIdRole);
......@@ -89,6 +89,7 @@ void TimelineWidget::setModel(std::shared_ptr<TimelineItemModel> model)
rootContext()->setContextProperty("transitionModel", m_transitionProxyModel.get());
rootContext()->setContextProperty("guidesModel", pCore->projectManager()->current()->getGuideModel().get());
setSource(QUrl(QStringLiteral("qrc:/qml/timeline.qml")));
m_proxy->setModel(model, rootObject());
setVisible(true);
m_proxy->checkDuration();
resize(QSize(4000, 4000));
......@@ -130,3 +131,7 @@ TimelineController *TimelineWidget::controller()
return m_proxy;
}
void TimelineWidget::zoneUpdated(const QPoint &zone)
{
m_proxy->setZone(zone);
}
......@@ -54,6 +54,7 @@ protected:
public slots:
void slotChangeZoom(int value, bool zoomOnMouse);
void zoneUpdated(const QPoint &zone);
private:
std::shared_ptr<BinController> m_binController;
......@@ -73,6 +74,7 @@ signals:
@param zoomOnMouse is set to true if we want to center zoom on mouse, otherwise we center on timeline cursor position
*/
void zoomOut(bool zoomOnMouse);
void zoneMoved(const QPoint &zone);
};
......
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