*Switch timeline composition menu to QWidget instead of qml

*Fix crash editing composition position from timeline context menu
parent 3600b896
Pipeline #14011 passed with stage
in 19 minutes and 8 seconds
......@@ -504,6 +504,7 @@ void MainWindow::init()
loadDockActions();
loadClipActions();
// Timeline clip menu
QMenu *timelineMenu = new QMenu(this);
timelineMenu->addAction(actionCollection()->action(QStringLiteral("edit_copy")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("edit_paste")));
......@@ -525,6 +526,12 @@ void MainWindow::init()
timelineMenu->addAction(actionCollection()->action(QStringLiteral("clip_in_project_tree")));
timelineMenu->addAction(actionCollection()->action(QStringLiteral("cut_timeline_clip")));
// Timeline composition menu
QMenu *compositionMenu = new QMenu(this);
compositionMenu->addAction(actionCollection()->action(QStringLiteral("edit_item_duration")));
compositionMenu->addAction(actionCollection()->action(QStringLiteral("edit_copy")));
compositionMenu->addAction(actionCollection()->action(QStringLiteral("delete_timeline_clip")));
QMenu *openGLMenu = static_cast<QMenu *>(factory()->container(QStringLiteral("qt_opengl"), this));
#if defined(Q_OS_WIN)
connect(openGLMenu, &QMenu::triggered, [&](QAction *ac) {
......@@ -662,7 +669,7 @@ void MainWindow::init()
#ifdef USE_JOGSHUTTLE
new JogManager(this);
#endif
getMainTimeline()->setTimelineMenu(timelineMenu);
getMainTimeline()->setTimelineMenu(timelineMenu, compositionMenu);
scmanager->slotCheckActiveScopes();
// m_messageLabel->setMessage(QStringLiteral("This is a beta version. Always backup your data"), MltError);
}
......
......@@ -154,14 +154,12 @@ Item {
onPressed: {
root.autoScrolling = false
compositionRoot.forceActiveFocus();
root.mainItemId = compositionRoot.clipId
if (mouse.button == Qt.RightButton) {
if (timeline.selection.indexOf(compositionRoot.clipId) == -1) {
timeline.addSelection(compositionRoot.clipId, true)
controller.requestAddToSelection(compositionRoot.clipId, true)
}
compositionMenu.clipId = compositionRoot.clipId
compositionMenu.grouped = compositionRoot.grouped
compositionMenu.trackId = compositionRoot.trackId
compositionMenu.popup()
root.showCompositionMenu()
}
}
onReleased: {
......
......@@ -20,6 +20,7 @@ Rectangle {
signal clipClicked()
signal mousePosChanged(int position)
signal showClipMenu()
signal showCompositionMenu()
signal zoomIn(bool onMouse)
signal zoomOut(bool onMouse)
signal processingDrag(bool dragging)
......@@ -29,10 +30,6 @@ Rectangle {
font: smallFont
}
CompositionMenu {
id: compositionMenu
}
onDragInProgressChanged: {
processingDrag(!root.dragInProgress)
}
......
......@@ -2230,7 +2230,7 @@ void TimelineController::editItemDuration(int id)
result = m_model->requestClipMove(partner, m_model->getItemTrackId(partner), newPos, true, true, true, true, undo, redo);
}
} else {
result = m_model->requestCompositionMove(id, trackId, newPos, m_model->m_allCompositions[id]->getForcedTrack(), true, true, undo, redo);
result = m_model->requestCompositionMove(id, trackId, m_model->m_allCompositions[id]->getForcedTrack(), newPos, true, true, undo, redo);
}
if (result && newIn != in) {
m_model->requestItemResize(id, duration + (in - newIn), false, true, undo, redo);
......@@ -2266,7 +2266,7 @@ void TimelineController::editItemDuration(int id)
}
} else {
result = result &&
m_model->requestCompositionMove(id, trackId, newPos, m_model->m_allCompositions[id]->getForcedTrack(), true, true, undo, redo);
m_model->requestCompositionMove(id, trackId, m_model->m_allCompositions[id]->getForcedTrack(), newPos, true, true, undo, redo);
}
}
}
......
......@@ -133,9 +133,10 @@ const QMap<QString, QString> TimelineWidget::sortedItems(const QStringList &item
return sortedItems;
}
void TimelineWidget::setTimelineMenu(QMenu *menu)
void TimelineWidget::setTimelineMenu(QMenu *clipMenu, QMenu *compositionMenu)
{
m_timelineClipMenu = menu;
m_timelineClipMenu = clipMenu;
m_timelineCompositionMenu = compositionMenu;
updateEffectFavorites();
updateTransitionFavorites();
connect(m_favEffects, &QMenu::triggered, [&] (QAction *ac) {
......@@ -179,6 +180,7 @@ void TimelineWidget::setModel(const std::shared_ptr<TimelineItemModel> &model, M
connect(m_proxy, &TimelineController::seeked, proxy, &MonitorProxy::setPosition);
rootObject()->setProperty("dar", pCore->getCurrentDar());
connect(rootObject(), SIGNAL(showClipMenu()), this, SLOT(showClipMenu()));
connect(rootObject(), SIGNAL(showCompositionMenu()), this, SLOT(showCompositionMenu()));
m_proxy->setRoot(rootObject());
setVisible(true);
loading = false;
......@@ -200,6 +202,14 @@ void TimelineWidget::showClipMenu()
});
}
void TimelineWidget::showCompositionMenu()
{
m_timelineCompositionMenu->popup(m_clickPos);
connect(m_timelineCompositionMenu, &QMenu::aboutToHide, [this]() {
slotUngrabHack();
});
}
void TimelineWidget::slotChangeZoom(int value, bool zoomOnMouse)
{
double pixelScale = QFontMetrics(font()).maxWidth() * 2;
......
......@@ -54,7 +54,7 @@ public:
/* @brief Give keyboard focus to timeline qml */
void focusTimeline();
/** @brief Initiate timeline clip context menu */
void setTimelineMenu(QMenu *menu);
void setTimelineMenu(QMenu *clipMenu, QMenu *compositionMenu);
bool loading;
protected:
......@@ -72,10 +72,12 @@ public slots:
private slots:
void slotUngrabHack();
void showClipMenu();
void showCompositionMenu();
private:
TimelineController *m_proxy;
QMenu *m_timelineClipMenu;
QMenu *m_timelineCompositionMenu;
QMenu *m_favEffects;
QMenu *m_favCompositions;
static const int comboScale[];
......
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