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

Fix pasting items in timeline to use mouse / cursor position depending on how...

Fix pasting items in timeline to use mouse / cursor position depending on how it is called menu / shortcut
parent c1b0f275
......@@ -271,7 +271,7 @@ Rectangle {
if (timeline.selection.indexOf(clipRoot.clipId) === -1) {
controller.requestAddToSelection(clipRoot.clipId, true)
}
root.mainFrame = Math.round(mouse.x / timeline.scaleFactor)
root.clickFrame = Math.round(mouse.x / timeline.scaleFactor)
root.showClipMenu(clipRoot.clipId)
root.autoScrolling = timeline.autoScroll
}
......
......@@ -388,7 +388,7 @@ Rectangle {
property color thumbColor1: timeline.thumbColor1
property color thumbColor2: timeline.thumbColor2
property int mainItemId: -1
property int mainFrame: -1
property int clickFrame: -1
property int clipBeingDroppedId: -1
property string clipBeingDroppedData
property int droppedPosition: -1
......@@ -1254,7 +1254,7 @@ Rectangle {
} else {
timeline.activeTrack = -2
}
root.mainFrame = Math.floor((mouse.x + scrollView.contentX) / timeline.scaleFactor)
root.clickFrame = Math.floor((mouse.x + scrollView.contentX) / timeline.scaleFactor)
root.showTimelineMenu()
} else {
// ruler menu
......
......@@ -611,17 +611,11 @@ bool TimelineController::pasteItem(int position, int tid)
{
QClipboard *clipboard = QApplication::clipboard();
QString txt = clipboard->text();
if (tid == -1) {
tid = getMouseTrack();
}
if (position == -1) {
position = getMousePos();
}
if (tid == -1) {
tid = m_activeTrack;
}
if (position == -1) {
position = pCore->getTimelinePosition();
position = getMenuOrTimelinePos();
}
return TimelineFunctions::pasteClips(m_model, txt, tid, position);
}
......@@ -2524,7 +2518,7 @@ QMap<QString, QString> TimelineController::documentProperties()
int TimelineController::getMenuOrTimelinePos() const
{
int frame = m_root->property("mainFrame").toInt();
int frame = m_root->property("clickFrame").toInt();
if (frame == -1) {
frame = pCore->getTimelinePosition();
}
......@@ -3028,7 +3022,7 @@ void TimelineController::addCompositionToClip(const QString &assetId, int clipId
}
}
if (offset == -1) {
offset = m_root->property("mainFrame").toInt();
offset = m_root->property("clickFrame").toInt();
}
int track = clipId > -1 ? m_model->getClipTrackId(clipId) : m_activeTrack;
int compoId = -1;
......
......@@ -132,9 +132,11 @@ void TimelineWidget::setTimelineMenu(QMenu *clipMenu, QMenu *compositionMenu, QM
// Fix qml focus issue
connect(m_headerMenu, &QMenu::aboutToHide, this, &TimelineWidget::slotUngrabHack, Qt::DirectConnection);
connect(m_timelineClipMenu, &QMenu::aboutToHide, this, &TimelineWidget::slotUngrabHack, Qt::DirectConnection);
connect(m_timelineClipMenu, &QMenu::triggered, this, &TimelineWidget::slotResetContextPos);
connect(m_timelineCompositionMenu, &QMenu::aboutToHide, this, &TimelineWidget::slotUngrabHack, Qt::DirectConnection);
connect(m_timelineRulerMenu, &QMenu::aboutToHide, this, &TimelineWidget::slotUngrabHack, Qt::DirectConnection);
connect(m_timelineMenu, &QMenu::aboutToHide, this, &TimelineWidget::slotUngrabHack, Qt::DirectConnection);
connect(m_timelineMenu, &QMenu::triggered, this, &TimelineWidget::slotResetContextPos);
connect(m_timelineSubtitleClipMenu, &QMenu::aboutToHide, this, &TimelineWidget::slotUngrabHack, Qt::DirectConnection);
m_timelineClipMenu->addMenu(m_favEffects);
......@@ -426,17 +428,23 @@ void TimelineWidget::slotUngrabHack()
{
// Workaround bug: https://bugreports.qt.io/browse/QTBUG-59044
// https://phabricator.kde.org/D5515
QTimer::singleShot(250, this, [this]() {
// Reset menu position, necessary if user closes the menu without selecting any action
rootObject()->setProperty("clickFrame", -1);
});
if (quickWindow() && quickWindow()->mouseGrabberItem()) {
quickWindow()->mouseGrabberItem()->ungrabMouse();
// Reset menu position
QTimer::singleShot(200, this, [this]() {
rootObject()->setProperty("mainFrame", -1);
});
QPoint mousePos = mapFromGlobal(QCursor::pos());
QMetaObject::invokeMethod(rootObject(), "regainFocus", Qt::DirectConnection, Q_ARG(QVariant, mousePos));
}
}
void TimelineWidget::slotResetContextPos(QAction *)
{
rootObject()->setProperty("clickFrame", -1);
m_clickPos = QPoint();
}
int TimelineWidget::zoomForScale(double value) const
{
int scale = int(100 / value);
......
......@@ -67,6 +67,7 @@ public slots:
private slots:
void slotUngrabHack();
void slotResetContextPos(QAction *);
void showClipMenu(int cid);
void showCompositionMenu();
void showTimelineMenu();
......
Supports Markdown
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