Don't allow undo/redo while dragging a clip in timeline.

Related to #264
parent f991f153
Pipeline #4396 passed with stage
in 13 minutes and 54 seconds
......@@ -1408,10 +1408,22 @@ void MainWindow::setupActions()
QAction *undo = KStandardAction::undo(m_commandStack, SLOT(undo()), actionCollection());
undo->setEnabled(false);
connect(m_commandStack, &QUndoGroup::canUndoChanged, undo, &QAction::setEnabled);
connect(this, &MainWindow::enableUndo, [this, undo] (bool enable) {
if (enable) {
enable = m_commandStack->activeStack()->canUndo();
}
undo->setEnabled(enable);
});
QAction *redo = KStandardAction::redo(m_commandStack, SLOT(redo()), actionCollection());
redo->setEnabled(false);
connect(m_commandStack, &QUndoGroup::canRedoChanged, redo, &QAction::setEnabled);
connect(this, &MainWindow::enableUndo, [this, redo] (bool enable) {
if (enable) {
enable = m_commandStack->activeStack()->canRedo();
}
redo->setEnabled(enable);
});
auto *addClips = new QMenu(this);
......
......@@ -484,6 +484,8 @@ signals:
/** @brief Clear asset view if itemId is displayed. */
void clearAssetPanel(int itemId = -1);
void adjustAssetPanelRange(int itemId, int in, int out);
/** @brief Enable or disable the undo stack. For example undo/redo should not be enabled when dragging a clip in timeline or we risk corruption. */
void enableUndo(bool enable);
};
#endif
......@@ -16,11 +16,13 @@ Rectangle {
color: activePalette.window
property bool validMenu: false
property color textColor: activePalette.text
property bool dragInProgress: dragProxyArea.pressed || dragProxyArea.drag.active
signal clipClicked()
signal mousePosChanged(int position)
signal zoomIn(bool onMouse)
signal zoomOut(bool onMouse)
signal processingDrag(bool dragging)
FontMetrics {
id: fontMetrics
......@@ -33,6 +35,10 @@ Rectangle {
id: compositionMenu
}
onDragInProgressChanged: {
processingDrag(!root.dragInProgress)
}
function fitZoom() {
return scrollView.width / (timeline.duration * 1.1)
}
......@@ -164,7 +170,7 @@ Rectangle {
}
function isDragging() {
return dragProxy.draggedItem > -1 && dragProxyArea.pressed
return dragInProgress
}
function initDrag(itemObject, itemCoord, itemId, itemPos, itemTrack, isComposition) {
......
......@@ -136,6 +136,7 @@ void TimelineWidget::setModel(const std::shared_ptr<TimelineItemModel> &model)
connect(rootObject(), SIGNAL(mousePosChanged(int)), pCore->window(), SLOT(slotUpdateMousePosition(int)));
connect(rootObject(), SIGNAL(zoomIn(bool)), pCore->window(), SLOT(slotZoomIn(bool)));
connect(rootObject(), SIGNAL(zoomOut(bool)), pCore->window(), SLOT(slotZoomOut(bool)));
connect(rootObject(), SIGNAL(processingDrag(bool)), pCore->window(), SIGNAL(enableUndo(bool)));
m_proxy->setRoot(rootObject());
setVisible(true);
loading = false;
......
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