implement history panel

This commit is contained in:
itsmattkc
2023-03-11 22:26:21 -08:00
parent 0beecfaaa6
commit 019f095ee4
33 changed files with 428 additions and 68 deletions
+1
View File
@@ -27,6 +27,7 @@ add_subdirectory(filefield)
add_subdirectory(flowlayout)
add_subdirectory(focusablelineedit)
add_subdirectory(handmovableview)
add_subdirectory(history)
add_subdirectory(keyframeview)
add_subdirectory(manageddisplay)
add_subdirectory(menu)
+22
View File
@@ -0,0 +1,22 @@
# Olive - Non-Linear Video Editor
# Copyright (C) 2023 Olive Studios LLC
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
set(OLIVE_SOURCES
${OLIVE_SOURCES}
widget/history/historywidget.cpp
widget/history/historywidget.h
PARENT_SCOPE
)
+49
View File
@@ -0,0 +1,49 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2023 Olive Studios LLC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#include "historywidget.h"
#include "core.h"
namespace olive {
HistoryWidget::HistoryWidget(QWidget *parent) :
QTreeView(parent)
{
stack_ = Core::instance()->undo_stack();
this->setModel(stack_);
this->setRootIsDecorated(false);
connect(stack_, &UndoStack::indexChanged, this, &HistoryWidget::indexChanged);
connect(this->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &HistoryWidget::currentRowChanged);
}
void HistoryWidget::indexChanged(int i)
{
this->selectionModel()->select(this->model()->index(i-1, 0), QItemSelectionModel::ClearAndSelect | QItemSelectionModel::Rows);
}
void HistoryWidget::currentRowChanged(const QModelIndex &current, const QModelIndex &previous)
{
size_t jump_to = (current.row() + 1);
stack_->jump(jump_to);
}
}
+50
View File
@@ -0,0 +1,50 @@
/***
Olive - Non-Linear Video Editor
Copyright (C) 2023 Olive Studios LLC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
***/
#ifndef HISTORYWIDGET_H
#define HISTORYWIDGET_H
#include <QTreeView>
#include "undo/undostack.h"
namespace olive {
class HistoryWidget : public QTreeView
{
Q_OBJECT
public:
HistoryWidget(QWidget *parent = nullptr);
private:
UndoStack *stack_;
size_t current_row_;
private slots:
void indexChanged(int i);
void currentRowChanged(const QModelIndex &current, const QModelIndex &previous);
};
}
#endif // HISTORYWIDGET_H
+2 -2
View File
@@ -61,7 +61,7 @@ void KeyframeView::DeleteSelected()
command->add_child(new NodeParamRemoveKeyframeCommand(key));
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
}
@@ -247,7 +247,7 @@ bool KeyframeView::Paste(std::function<Node *(const QString &)> find_node_functi
}
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
return true;
}
+1 -1
View File
@@ -646,7 +646,7 @@ bool NodeParamView::Paste(QWidget *parent, std::function<QHash<Node *, Node*>(co
}
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
return true;
}
@@ -180,7 +180,7 @@ void NodeParamViewContext::AddEffectMenuItemTriggered(QAction *a)
command->add_child(new NodeEdgeAddCommand(n, ctx_input));
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
}
@@ -176,7 +176,7 @@ void NodeParamViewKeyframeControl::ToggleKeyframe(bool e)
}
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
void NodeParamViewKeyframeControl::UpdateState()
@@ -276,7 +276,7 @@ void NodeParamViewKeyframeControl::KeyframeEnableBtnClicked(bool e)
}
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
void NodeParamViewKeyframeControl::KeyframeEnableChanged(const NodeInput &input, bool e)
@@ -190,7 +190,7 @@ void NodeParamViewWidgetBridge::SetInputValue(const QVariant &value, int track)
SetInputValueInternal(value, track, command, true);
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
void NodeParamViewWidgetBridge::SetInputValueInternal(const QVariant &value, int track, MultiUndoCommand *command, bool insert_on_all_tracks_if_no_key)
@@ -314,7 +314,7 @@ void NodeParamViewWidgetBridge::WidgetCallback()
n->SetInputProperty(GetInnerInput().input(), QStringLiteral("col_look"), c.color_output().look());
n->blockSignals(false);
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
break;
}
case NodeValue::kText:
+4 -4
View File
@@ -411,7 +411,7 @@ void NodeView::keyPressEvent(QKeyEvent *event)
}
}
}
Core::instance()->undo_stack()->pushIfHasChildren(pos_command);
Core::instance()->undo_stack()->push(pos_command);
break;
}
case Qt::Key_Escape:
@@ -581,7 +581,7 @@ void NodeView::mouseReleaseEvent(QMouseEvent *event)
}
dragging_items_.clear();
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
if (!had_attached_items) {
super::mouseReleaseEvent(event);
@@ -674,7 +674,7 @@ void NodeView::dropEvent(QDropEvent *event)
if (Node *drop_ctx = GetContextAtMousePos(event->pos())) {
MultiUndoCommand *command = new MultiUndoCommand();
QVector<Node*> select_nodes = ProcessDroppingAttachedNodes(command, drop_ctx, event->pos());
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
DeselectAll();
scene_.context_map().value(drop_ctx)->Select(select_nodes);
@@ -1680,7 +1680,7 @@ void NodeView::EndEdgeDrag(bool cancel)
}
create_edge_expanded_items_.clear();
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
void NodeView::PostPaste(const QVector<Node *> &new_nodes, const Node::PositionMap &map)
@@ -666,7 +666,7 @@ void ProjectExplorer::DeleteSelected()
bool check_if_item_is_in_use = true;
if (DeleteItemsInternal(selected, check_if_item_is_in_use, command)) {
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
} else {
delete command;
}
@@ -374,7 +374,7 @@ bool ProjectViewModel::dropMimeData(const QMimeData *data, Qt::DropAction action
}
}
Core::instance()->undo_stack()->pushIfHasChildren(move_command);
Core::instance()->undo_stack()->push(move_command);
return true;
+8 -10
View File
@@ -545,7 +545,7 @@ void TimelineWidget::DeleteSelected(bool ripple)
command->add_child(ripple_command);
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
// Ensures any current drag operations are cancelled
ClearGhosts();
@@ -773,7 +773,7 @@ void TimelineWidget::ToggleSelectedEnabled()
!i->is_enabled()));
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
void TimelineWidget::SetColorLabel(int index)
@@ -845,7 +845,7 @@ void TimelineWidget::RecordingCallback(const QString &filename, const TimeRange
import_command->add_child(subimport_command);
import_tool_->PlaceAt({task.GetImportedFootage().front()}, time.in(), false, import_command, track.index());
Core::instance()->undo_stack()->pushIfHasChildren(import_command);
Core::instance()->undo_stack()->push(import_command);
}
}
@@ -1452,7 +1452,7 @@ void TimelineWidget::RenameSelectedBlocks()
}
Core::instance()->LabelNodes(nodes);
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
void TimelineWidget::TrackAboutToBeDeleted(Track *track)
@@ -1475,7 +1475,7 @@ void TimelineWidget::SetSelectedClipsAutocaching(bool e)
}
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
void TimelineWidget::CacheClips()
@@ -1574,7 +1574,7 @@ void TimelineWidget::MulticamEnabledTriggered(bool e)
}
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
void TimelineWidget::ForceUpdateRubberBand()
@@ -1918,7 +1918,7 @@ void TimelineWidget::EditTo(Timeline::MovementMode mode)
}
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
void TimelineWidget::UpdateViewports(const Track::Type &type)
@@ -1953,8 +1953,6 @@ bool TimelineWidget::PasteInternal(bool insert)
}
}
qDebug() << "pasing" << res.GetLoadData().nodes.size() << "nodes";
for (auto it = res.GetLoadData().promised_connections.cbegin(); it != res.GetLoadData().promised_connections.cend(); it++) {
auto oc = *it;
command->add_child(new NodeEdgeAddCommand(oc.first, oc.second));
@@ -1988,7 +1986,7 @@ bool TimelineWidget::PasteInternal(bool insert)
paste_start + in));
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
return true;
}
+1 -1
View File
@@ -184,7 +184,7 @@ void ImportTool::DragDrop(TimelineViewMouseEvent *event)
if (!dragged_footage_.isEmpty()) {
auto command = new MultiUndoCommand();
DropGhosts(event->GetModifiers() & Qt::ControlModifier, command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
event->accept();
} else {
+1 -1
View File
@@ -815,7 +815,7 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event)
}
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
Timeline::MovementMode PointerTool::IsCursorInTrimHandle(Block *block, qreal cursor_x)
+1 -1
View File
@@ -80,7 +80,7 @@ void SlipTool::FinishDrag(TimelineViewMouseEvent *event)
}
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
}
+4 -4
View File
@@ -116,7 +116,7 @@ void SeekableWidget::DeleteSelected()
command->add_child(new MarkerRemoveCommand(marker));
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
}
@@ -249,7 +249,7 @@ void SeekableWidget::mouseReleaseEvent(QMouseEvent *event)
if (selection_manager_.IsDragging()) {
MultiUndoCommand *command = new MultiUndoCommand();
selection_manager_.DragStop(command);
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
if (GetSnapService()) {
@@ -364,7 +364,7 @@ void SeekableWidget::SetMarkerColor(int c)
command->add_child(new MarkerChangeColorCommand(marker, c));
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
void SeekableWidget::ShowMarkerProperties()
@@ -614,7 +614,7 @@ void SeekableWidget::CommitResizeHandle()
command->add_child(new WorkareaSetRangeCommand(workarea, workarea->range(), resize_item_range_));
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
}
}
+1 -1
View File
@@ -557,7 +557,7 @@ void ViewerWidget::CreateAddableAt(const QRectF &f)
shape->SetRect(f, s->GetVideoParams(), command);
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
SetGizmos(clip);
}
}
+1 -1
View File
@@ -946,7 +946,7 @@ bool ViewerDisplayWidget::OnMouseRelease(QMouseEvent *e)
if (DraggableGizmo *draggable = dynamic_cast<DraggableGizmo*>(current_gizmo_)) {
draggable->DragEnd(command);
}
Core::instance()->undo_stack()->pushIfHasChildren(command);
Core::instance()->undo_stack()->push(command);
gizmo_drag_started_ = false;
}
current_gizmo_ = nullptr;