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

Fix various focus issues (related to #859)

Fix crash on insert space
parent 78f4cfea
......@@ -306,11 +306,14 @@ Rectangle {
dragProxy.height = tentativeClip.height
dragProxy.masterObject = tentativeClip
dragProxy.sourceTrack = tk
console.log('missing item', tentativeClip.clipId, ', COORDS: ', tentativeClip.x, 'x', tentativeClip.y, ', TK id: ', tk, ', TKY: ', Logic.getTrackYFromId(tk))
dragProxy.sourceFrame = tentativeClip.modelStart
dragProxy.isComposition = tentativeClip.isComposition
console.log('missing item', tentativeClip.clipId, ', COORDS: ', tentativeClip.x, 'x', tentativeClip.y, ', TK id: ', tk, ', TKY: ', Logic.getTrackYFromId(tk),' STARTFRM: ', dragProxy.sourceFrame)
} else {
console.log('item not found')
if (dragProxy.draggedItem > -1) {
endDrag()
}
}
}
......
......@@ -2105,7 +2105,21 @@ void TimelineController::insertSpace(int trackId, int frame)
pCore->displayMessage(i18n("No clips found to insert space"), ErrorMessage, 500);
return;
}
int start = m_model->getItemPosition(cid);
int start = -1;
if (m_model->isGroup(cid)) {
std::unordered_set<int> sub = m_model->m_groups->getLeaves(cid);
cid = *sub.cbegin();
int start = m_model->getItemPosition(cid);
for (int current_id : sub) {
int st = m_model->getItemPosition(current_id);
if (st < start) {
cid = current_id;
start = st;
}
}
} else {
start = m_model->getItemPosition(cid);
}
requestSpacerEndOperation(cid, start, start + spaceDuration, affectAllTracks ? -1 : trackId);
}
......@@ -2187,8 +2201,10 @@ void TimelineController::changeItemSpeed(int clipId, double speed)
}
QScopedPointer<SpeedDialog> d(new SpeedDialog(QApplication::activeWindow(), std::abs(speed), duration, minSpeed, maxSpeed, speed < 0, pitchCompensate));
if (d->exec() != QDialog::Accepted) {
emit regainFocus();
return;
}
emit regainFocus();
speed = d->getValue();
pitchCompensate = d->getPitchCompensate();
qDebug() << "requesting speed " << speed;
......@@ -3158,6 +3174,7 @@ void TimelineController::editItemDuration(int id)
undo();
}
}
emit regainFocus();
}
void TimelineController::editTitleClip(int id)
......@@ -4152,6 +4169,7 @@ void TimelineController::importSubtitle(const QString path)
}
subtitleModel->importSubtitle(view.subtitle_url->url().toLocalFile(), offset, true);
}
emit regainFocus();
}
void TimelineController::exportSubtitle()
......
......@@ -753,6 +753,7 @@ signals:
void effectZoneChanged();
void masterZonesChanged();
Q_INVOKABLE void ungrabHack();
void regainFocus();
};
#endif
......@@ -68,6 +68,7 @@ TimelineWidget::TimelineWidget(QWidget *parent)
m_proxy = new TimelineController(this);
connect(m_proxy, &TimelineController::zoneMoved, this, &TimelineWidget::zoneMoved);
connect(m_proxy, &TimelineController::ungrabHack, this, &TimelineWidget::slotUngrabHack);
connect(m_proxy, &TimelineController::regainFocus, this, &TimelineWidget::regainFocus, Qt::DirectConnection);
setResizeMode(QQuickWidget::SizeRootObjectToView);
engine()->addImageProvider(QStringLiteral("thumbnail"), new ThumbnailProvider);
setVisible(false);
......@@ -445,6 +446,8 @@ void TimelineWidget::slotUngrabHack()
QTimer::singleShot(200, this, [this]() {
rootObject()->setProperty("mainFrame", -1);
});
QPoint mousePos = mapFromGlobal(QCursor::pos());
QMetaObject::invokeMethod(rootObject(), "regainFocus", Qt::DirectConnection, Q_ARG(QVariant, mousePos));
}
}
......@@ -502,9 +505,10 @@ bool TimelineWidget::eventFilter(QObject *object, QEvent *event)
void TimelineWidget::regainFocus()
{
qDebug()<<"=== REG FOCUS: "<<underMouse();
if (underMouse() && rootObject()) {
QPoint mousePos = mapFromGlobal(QCursor::pos());
QMetaObject::invokeMethod(rootObject(), "regainFocus", Q_ARG(QVariant, mousePos));
QMetaObject::invokeMethod(rootObject(), "regainFocus", Qt::DirectConnection, Q_ARG(QVariant, mousePos));
}
}
......
......@@ -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);
void regainFocus();
void unsetModel();
protected:
......@@ -79,6 +78,7 @@ public slots:
void endDrag();
/** @brief Show menu to switch track target audio stream */
void showTargetMenu(int tid = -1);
void regainFocus();
private slots:
void slotUngrabHack();
......
......@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>329</width>
<height>618</height>
<height>650</height>
</rect>
</property>
<property name="windowTitle">
......@@ -144,6 +144,9 @@
<property name="text">
<string>Parameters (see &lt;a href=&quot;https://www.mltframework.org/plugins/ConsumerAvformat/&quot;&gt;MLT documentation&lt;/a&gt;)</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
......
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