global: made every user action set a project "modified" state that will prevent
the main window from closing instantly
This commit is contained in:
+27
-9
@@ -351,7 +351,7 @@ void Core::ImportTaskComplete(QUndoCommand *command)
|
||||
|
||||
bool Core::ConfirmImageSequence(const QString& filename)
|
||||
{
|
||||
QMessageBox mb;
|
||||
QMessageBox mb(main_window_);
|
||||
|
||||
mb.setIcon(QMessageBox::Question);
|
||||
mb.setWindowTitle(tr("Possible image sequence detected"));
|
||||
@@ -429,6 +429,8 @@ void Core::SaveProjectInternal(Project *project)
|
||||
// Create save manager
|
||||
ProjectSaveManager* psm = new ProjectSaveManager(project);
|
||||
|
||||
connect(psm, &Task::Succeeded, this, &Core::ProjectSaveSucceeded);
|
||||
|
||||
TaskDialog* task_dialog = new TaskDialog(psm, tr("Save Project"), main_window());
|
||||
task_dialog->open();
|
||||
}
|
||||
@@ -442,6 +444,11 @@ void Core::SaveAutorecovery()
|
||||
}
|
||||
}
|
||||
|
||||
void Core::ProjectSaveSucceeded()
|
||||
{
|
||||
SetProjectModified(false);
|
||||
}
|
||||
|
||||
Project *Core::GetActiveProject()
|
||||
{
|
||||
ProjectPanel* active_project_panel = PanelManager::instance()->MostRecentlyFocused<ProjectPanel>();
|
||||
@@ -475,10 +482,15 @@ Folder *Core::GetSelectedFolderInActiveProject()
|
||||
}
|
||||
}
|
||||
|
||||
void Core::SetProjectModified()
|
||||
void Core::SetProjectModified(bool e)
|
||||
{
|
||||
main_window()->setWindowModified(true);
|
||||
queue_autorecovery_ = true;
|
||||
main_window()->setWindowModified(e);
|
||||
queue_autorecovery_ = e;
|
||||
}
|
||||
|
||||
bool Core::IsProjectModified() const
|
||||
{
|
||||
return main_window_->isWindowModified();
|
||||
}
|
||||
|
||||
void Core::SetAutorecoveryInterval(int minutes)
|
||||
@@ -487,27 +499,29 @@ void Core::SetAutorecoveryInterval(int minutes)
|
||||
autorecovery_timer_.setInterval(minutes * 60000);
|
||||
}
|
||||
|
||||
void Core::SaveActiveProject()
|
||||
bool Core::SaveActiveProject()
|
||||
{
|
||||
Project* active_project = GetActiveProject();
|
||||
|
||||
if (!active_project) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (active_project->filename().isEmpty()) {
|
||||
SaveActiveProjectAs();
|
||||
return SaveActiveProjectAs();
|
||||
} else {
|
||||
SaveProjectInternal(active_project);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void Core::SaveActiveProjectAs()
|
||||
bool Core::SaveActiveProjectAs()
|
||||
{
|
||||
Project* active_project = GetActiveProject();
|
||||
|
||||
if (!active_project) {
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
QString fn = QFileDialog::getSaveFileName(main_window_,
|
||||
@@ -519,7 +533,11 @@ void Core::SaveActiveProjectAs()
|
||||
active_project->set_filename(fn);
|
||||
|
||||
SaveProjectInternal(active_project);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
QList<rational> Core::SupportedFrameRates()
|
||||
|
||||
+7
-3
@@ -131,7 +131,9 @@ public:
|
||||
* Call this function whenever a change is made to a currently active project. Saving the project will automatically
|
||||
* unset this.
|
||||
*/
|
||||
void SetProjectModified();
|
||||
void SetProjectModified(bool e);
|
||||
|
||||
bool IsProjectModified() const;
|
||||
|
||||
/**
|
||||
* @brief Set how frequently an autorecovery should be saved (if the project has changed, see SetProjectModified())
|
||||
@@ -193,12 +195,12 @@ public slots:
|
||||
*
|
||||
* If the project hasn't been saved before, this will be equivalent to calling SaveActiveProjectAs().
|
||||
*/
|
||||
void SaveActiveProject();
|
||||
bool SaveActiveProject();
|
||||
|
||||
/**
|
||||
* @brief Save the currently active project with a new filename
|
||||
*/
|
||||
void SaveActiveProjectAs();
|
||||
bool SaveActiveProjectAs();
|
||||
|
||||
/**
|
||||
* @brief Set the current application-wide tool
|
||||
@@ -353,6 +355,8 @@ private:
|
||||
private slots:
|
||||
void SaveAutorecovery();
|
||||
|
||||
void ProjectSaveSucceeded();
|
||||
|
||||
/**
|
||||
* @brief Adds a project to the "open projects" list
|
||||
*/
|
||||
|
||||
@@ -124,38 +124,38 @@ void FootagePropertiesDialog::accept() {
|
||||
}
|
||||
|
||||
FootagePropertiesDialog::FootageChangeCommand::FootageChangeCommand(Footage *footage, const QString &name, QUndoCommand* command) :
|
||||
QUndoCommand(command),
|
||||
UndoCommand(command),
|
||||
footage_(footage),
|
||||
new_name_(name)
|
||||
{
|
||||
}
|
||||
|
||||
void FootagePropertiesDialog::FootageChangeCommand::redo()
|
||||
void FootagePropertiesDialog::FootageChangeCommand::redo_internal()
|
||||
{
|
||||
old_name_ = footage_->name();
|
||||
|
||||
footage_->set_name(new_name_);
|
||||
}
|
||||
|
||||
void FootagePropertiesDialog::FootageChangeCommand::undo()
|
||||
void FootagePropertiesDialog::FootageChangeCommand::undo_internal()
|
||||
{
|
||||
footage_->set_name(old_name_);
|
||||
}
|
||||
|
||||
FootagePropertiesDialog::StreamEnableChangeCommand::StreamEnableChangeCommand(StreamPtr stream, bool enabled, QUndoCommand *command) :
|
||||
QUndoCommand(command),
|
||||
UndoCommand(command),
|
||||
stream_(stream),
|
||||
old_enabled_(stream->enabled()),
|
||||
new_enabled_(enabled)
|
||||
{
|
||||
}
|
||||
|
||||
void FootagePropertiesDialog::StreamEnableChangeCommand::redo()
|
||||
void FootagePropertiesDialog::StreamEnableChangeCommand::redo_internal()
|
||||
{
|
||||
stream_->set_enabled(new_enabled_);
|
||||
}
|
||||
|
||||
void FootagePropertiesDialog::StreamEnableChangeCommand::undo()
|
||||
void FootagePropertiesDialog::StreamEnableChangeCommand::undo_internal()
|
||||
{
|
||||
stream_->set_enabled(old_enabled_);
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
#include <QLineEdit>
|
||||
#include <QListWidget>
|
||||
#include <QStackedWidget>
|
||||
#include <QUndoCommand>
|
||||
|
||||
#include "project/item/footage/footage.h"
|
||||
#include "undo/undocommand.h"
|
||||
|
||||
/**
|
||||
* @brief The MediaPropertiesDialog class
|
||||
@@ -54,14 +54,15 @@ public:
|
||||
*/
|
||||
FootagePropertiesDialog(QWidget *parent, Footage* footage);
|
||||
private:
|
||||
class FootageChangeCommand : public QUndoCommand {
|
||||
class FootageChangeCommand : public UndoCommand {
|
||||
public:
|
||||
FootageChangeCommand(Footage* footage,
|
||||
const QString& name,
|
||||
QUndoCommand *command = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Footage* footage_;
|
||||
@@ -70,14 +71,15 @@ private:
|
||||
QString old_name_;
|
||||
};
|
||||
|
||||
class StreamEnableChangeCommand : public QUndoCommand {
|
||||
class StreamEnableChangeCommand : public UndoCommand {
|
||||
public:
|
||||
StreamEnableChangeCommand(StreamPtr stream,
|
||||
bool enabled,
|
||||
QUndoCommand* command = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
StreamPtr stream_;
|
||||
|
||||
@@ -71,14 +71,14 @@ VideoStreamProperties::VideoStreamChangeCommand::VideoStreamChangeCommand(ImageS
|
||||
bool premultiplied,
|
||||
QString colorspace,
|
||||
QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
stream_(stream),
|
||||
new_premultiplied_(premultiplied),
|
||||
new_colorspace_(colorspace)
|
||||
{
|
||||
}
|
||||
|
||||
void VideoStreamProperties::VideoStreamChangeCommand::redo()
|
||||
void VideoStreamProperties::VideoStreamChangeCommand::redo_internal()
|
||||
{
|
||||
old_premultiplied_ = stream_->premultiplied_alpha();
|
||||
old_colorspace_ = stream_->colorspace();
|
||||
@@ -87,7 +87,7 @@ void VideoStreamProperties::VideoStreamChangeCommand::redo()
|
||||
stream_->set_colorspace(new_colorspace_);
|
||||
}
|
||||
|
||||
void VideoStreamProperties::VideoStreamChangeCommand::undo()
|
||||
void VideoStreamProperties::VideoStreamChangeCommand::undo_internal()
|
||||
{
|
||||
stream_->set_premultiplied_alpha(old_premultiplied_);
|
||||
stream_->set_colorspace(old_colorspace_);
|
||||
|
||||
@@ -23,10 +23,10 @@
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QUndoCommand>
|
||||
|
||||
#include "project/item/footage/videostream.h"
|
||||
#include "streamproperties.h"
|
||||
#include "undo/undocommand.h"
|
||||
|
||||
class VideoStreamProperties : public StreamProperties
|
||||
{
|
||||
@@ -51,15 +51,16 @@ private:
|
||||
*/
|
||||
QComboBox* video_color_space_;
|
||||
|
||||
class VideoStreamChangeCommand : public QUndoCommand {
|
||||
class VideoStreamChangeCommand : public UndoCommand {
|
||||
public:
|
||||
VideoStreamChangeCommand(ImageStreamPtr stream,
|
||||
bool premultiplied,
|
||||
QString colorspace,
|
||||
QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
ImageStreamPtr stream_;
|
||||
|
||||
@@ -198,7 +198,7 @@ SequenceDialog::SequenceParamCommand::SequenceParamCommand(Sequence* s,
|
||||
const AudioParams& audio_params,
|
||||
const QString& name,
|
||||
QUndoCommand* parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
sequence_(s),
|
||||
new_video_params_(video_params),
|
||||
new_audio_params_(audio_params),
|
||||
@@ -209,14 +209,14 @@ SequenceDialog::SequenceParamCommand::SequenceParamCommand(Sequence* s,
|
||||
{
|
||||
}
|
||||
|
||||
void SequenceDialog::SequenceParamCommand::redo()
|
||||
void SequenceDialog::SequenceParamCommand::redo_internal()
|
||||
{
|
||||
sequence_->set_video_params(new_video_params_);
|
||||
sequence_->set_audio_params(new_audio_params_);
|
||||
sequence_->set_name(new_name_);
|
||||
}
|
||||
|
||||
void SequenceDialog::SequenceParamCommand::undo()
|
||||
void SequenceDialog::SequenceParamCommand::undo_internal()
|
||||
{
|
||||
sequence_->set_video_params(old_video_params_);
|
||||
sequence_->set_audio_params(old_audio_params_);
|
||||
|
||||
@@ -24,9 +24,9 @@
|
||||
#include <QComboBox>
|
||||
#include <QDialog>
|
||||
#include <QSpinBox>
|
||||
#include <QUndoCommand>
|
||||
|
||||
#include "project/item/sequence/sequence.h"
|
||||
#include "undo/undocommand.h"
|
||||
|
||||
/**
|
||||
* @brief A dialog for editing Sequence parameters
|
||||
@@ -112,7 +112,7 @@ private:
|
||||
/**
|
||||
* @brief A QUndoCommand for setting the parameters on a sequence
|
||||
*/
|
||||
class SequenceParamCommand : public QUndoCommand {
|
||||
class SequenceParamCommand : public UndoCommand {
|
||||
public:
|
||||
SequenceParamCommand(Sequence* s,
|
||||
const VideoParams& video_params,
|
||||
@@ -120,8 +120,10 @@ private:
|
||||
const QString& name,
|
||||
QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Sequence* sequence_;
|
||||
|
||||
|
||||
@@ -333,18 +333,18 @@ void SpeedDurationDialog::DurationChanged()
|
||||
}
|
||||
|
||||
BlockReverseCommand::BlockReverseCommand(Block *block, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
block_(block)
|
||||
{
|
||||
}
|
||||
|
||||
void BlockReverseCommand::redo()
|
||||
void BlockReverseCommand::redo_internal()
|
||||
{
|
||||
block_->set_media_in(block_->media_out());
|
||||
block_->set_speed(-block_->speed());
|
||||
}
|
||||
|
||||
void BlockReverseCommand::undo()
|
||||
void BlockReverseCommand::undo_internal()
|
||||
{
|
||||
redo();
|
||||
redo_internal();
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@
|
||||
|
||||
#include <QCheckBox>
|
||||
#include <QDialog>
|
||||
#include <QUndoCommand>
|
||||
|
||||
#include "node/block/clip/clip.h"
|
||||
#include "node/output/track/track.h"
|
||||
#include "widget/slider/floatslider.h"
|
||||
#include "widget/slider/timeslider.h"
|
||||
#include "undo/undocommand.h"
|
||||
|
||||
class SpeedDurationDialog : public QDialog
|
||||
{
|
||||
@@ -44,12 +44,13 @@ private slots:
|
||||
void DurationChanged();
|
||||
};
|
||||
|
||||
class BlockReverseCommand : public QUndoCommand {
|
||||
class BlockReverseCommand : public UndoCommand {
|
||||
public:
|
||||
BlockReverseCommand(Block* block, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
|
||||
@@ -490,7 +490,7 @@ ProjectViewModel::MoveItemCommand::MoveItemCommand(ProjectViewModel *model,
|
||||
Item *item,
|
||||
Folder *destination,
|
||||
QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
model_(model),
|
||||
item_(item),
|
||||
destination_(destination)
|
||||
@@ -500,18 +500,18 @@ ProjectViewModel::MoveItemCommand::MoveItemCommand(ProjectViewModel *model,
|
||||
setText(tr("Move Item"));
|
||||
}
|
||||
|
||||
void ProjectViewModel::MoveItemCommand::redo()
|
||||
void ProjectViewModel::MoveItemCommand::redo_internal()
|
||||
{
|
||||
model_->MoveItemInternal(item_, destination_);
|
||||
}
|
||||
|
||||
void ProjectViewModel::MoveItemCommand::undo()
|
||||
void ProjectViewModel::MoveItemCommand::undo_internal()
|
||||
{
|
||||
model_->MoveItemInternal(item_, source_);
|
||||
}
|
||||
|
||||
ProjectViewModel::RenameItemCommand::RenameItemCommand(ProjectViewModel* model, Item *item, const QString &name, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
model_(model),
|
||||
item_(item),
|
||||
new_name_(name)
|
||||
@@ -521,18 +521,18 @@ ProjectViewModel::RenameItemCommand::RenameItemCommand(ProjectViewModel* model,
|
||||
setText(tr("Rename Item"));
|
||||
}
|
||||
|
||||
void ProjectViewModel::RenameItemCommand::redo()
|
||||
void ProjectViewModel::RenameItemCommand::redo_internal()
|
||||
{
|
||||
model_->RenameChild(item_, new_name_);
|
||||
}
|
||||
|
||||
void ProjectViewModel::RenameItemCommand::undo()
|
||||
void ProjectViewModel::RenameItemCommand::undo_internal()
|
||||
{
|
||||
model_->RenameChild(item_, old_name_);
|
||||
}
|
||||
|
||||
ProjectViewModel::AddItemCommand::AddItemCommand(ProjectViewModel* model, Item* folder, ItemPtr child, QUndoCommand* parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
model_(model),
|
||||
parent_(folder),
|
||||
child_(child),
|
||||
@@ -544,14 +544,14 @@ ProjectViewModel::AddItemCommand::~AddItemCommand()
|
||||
{
|
||||
}
|
||||
|
||||
void ProjectViewModel::AddItemCommand::redo()
|
||||
void ProjectViewModel::AddItemCommand::redo_internal()
|
||||
{
|
||||
model_->AddChild(parent_, child_);
|
||||
|
||||
done_ = true;
|
||||
}
|
||||
|
||||
void ProjectViewModel::AddItemCommand::undo()
|
||||
void ProjectViewModel::AddItemCommand::undo_internal()
|
||||
{
|
||||
model_->RemoveChild(parent_, child_.get());
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
#define VIEWMODEL_H
|
||||
|
||||
#include <QAbstractItemModel>
|
||||
#include <QUndoCommand>
|
||||
|
||||
#include "project.h"
|
||||
#include "undo/undocommand.h"
|
||||
|
||||
/**
|
||||
* @brief An adapter that interprets the data in a Project into a Qt item model for usage in ViewModel Views.
|
||||
@@ -108,13 +108,14 @@ public:
|
||||
/**
|
||||
* @brief A QUndoCommand for moving an item from one folder to another folder
|
||||
*/
|
||||
class MoveItemCommand : public QUndoCommand {
|
||||
class MoveItemCommand : public UndoCommand {
|
||||
public:
|
||||
MoveItemCommand(ProjectViewModel* model, Item* item, Folder* destination, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
|
||||
virtual void undo() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
ProjectViewModel* model_;
|
||||
@@ -127,13 +128,14 @@ public:
|
||||
/**
|
||||
* @brief A QUndoCommand for renaming an item
|
||||
*/
|
||||
class RenameItemCommand : public QUndoCommand {
|
||||
class RenameItemCommand : public UndoCommand {
|
||||
public:
|
||||
RenameItemCommand(ProjectViewModel* model, Item* item, const QString& name, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
|
||||
virtual void undo() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
ProjectViewModel* model_;
|
||||
@@ -145,15 +147,16 @@ public:
|
||||
/**
|
||||
* @brief A QUndoCommand for adding an item
|
||||
*/
|
||||
class AddItemCommand : public QUndoCommand {
|
||||
class AddItemCommand : public UndoCommand {
|
||||
public:
|
||||
AddItemCommand(ProjectViewModel* model, Item* folder, ItemPtr child, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual ~AddItemCommand() override;
|
||||
|
||||
virtual void redo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
|
||||
virtual void undo() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
ProjectViewModel* model_;
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
|
||||
set(OLIVE_SOURCES
|
||||
${OLIVE_SOURCES}
|
||||
undo/undocommand.h
|
||||
undo/undocommand.cpp
|
||||
undo/undostack.h
|
||||
undo/undostack.cpp
|
||||
PARENT_SCOPE
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
#include "undocommand.h"
|
||||
|
||||
#include "core.h"
|
||||
|
||||
UndoCommand::UndoCommand(QUndoCommand *parent) :
|
||||
QUndoCommand(parent)
|
||||
{
|
||||
}
|
||||
|
||||
void UndoCommand::redo()
|
||||
{
|
||||
redo_internal();
|
||||
|
||||
modified_ = Core::instance()->IsProjectModified();
|
||||
Core::instance()->SetProjectModified(true);
|
||||
}
|
||||
|
||||
void UndoCommand::undo()
|
||||
{
|
||||
undo_internal();
|
||||
|
||||
Core::instance()->SetProjectModified(modified_);
|
||||
}
|
||||
|
||||
void UndoCommand::redo_internal()
|
||||
{
|
||||
QUndoCommand::redo();
|
||||
}
|
||||
|
||||
void UndoCommand::undo_internal()
|
||||
{
|
||||
QUndoCommand::undo();
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef UNDOCOMMAND_H
|
||||
#define UNDOCOMMAND_H
|
||||
|
||||
#include <QUndoCommand>
|
||||
|
||||
class UndoCommand : public QUndoCommand
|
||||
{
|
||||
public:
|
||||
UndoCommand(QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
|
||||
protected:
|
||||
virtual void redo_internal();
|
||||
virtual void undo_internal();
|
||||
|
||||
private:
|
||||
bool modified_;
|
||||
|
||||
};
|
||||
|
||||
#endif // UNDOCOMMAND_H
|
||||
@@ -1,25 +1,25 @@
|
||||
#include "keyframeviewundo.h"
|
||||
|
||||
KeyframeSetTypeCommand::KeyframeSetTypeCommand(NodeKeyframePtr key, NodeKeyframe::Type type, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
key_(key),
|
||||
old_type_(key->type()),
|
||||
new_type_(type)
|
||||
{
|
||||
}
|
||||
|
||||
void KeyframeSetTypeCommand::redo()
|
||||
void KeyframeSetTypeCommand::redo_internal()
|
||||
{
|
||||
key_->set_type(new_type_);
|
||||
}
|
||||
|
||||
void KeyframeSetTypeCommand::undo()
|
||||
void KeyframeSetTypeCommand::undo_internal()
|
||||
{
|
||||
key_->set_type(old_type_);
|
||||
}
|
||||
|
||||
KeyframeSetBezierControlPoint::KeyframeSetBezierControlPoint(NodeKeyframePtr key, NodeKeyframe::BezierType mode, const QPointF& point, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
key_(key),
|
||||
mode_(mode),
|
||||
old_point_(key->bezier_control(mode_)),
|
||||
@@ -28,7 +28,7 @@ KeyframeSetBezierControlPoint::KeyframeSetBezierControlPoint(NodeKeyframePtr key
|
||||
}
|
||||
|
||||
KeyframeSetBezierControlPoint::KeyframeSetBezierControlPoint(NodeKeyframePtr key, NodeKeyframe::BezierType mode, const QPointF &new_point, const QPointF &old_point, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
key_(key),
|
||||
mode_(mode),
|
||||
old_point_(old_point),
|
||||
@@ -36,12 +36,12 @@ KeyframeSetBezierControlPoint::KeyframeSetBezierControlPoint(NodeKeyframePtr key
|
||||
{
|
||||
}
|
||||
|
||||
void KeyframeSetBezierControlPoint::redo()
|
||||
void KeyframeSetBezierControlPoint::redo_internal()
|
||||
{
|
||||
key_->set_bezier_control(mode_, new_point_);
|
||||
}
|
||||
|
||||
void KeyframeSetBezierControlPoint::undo()
|
||||
void KeyframeSetBezierControlPoint::undo_internal()
|
||||
{
|
||||
key_->set_bezier_control(mode_, old_point_);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
#ifndef KEYFRAMEVIEWUNDO_H
|
||||
#define KEYFRAMEVIEWUNDO_H
|
||||
|
||||
#include <QUndoCommand>
|
||||
|
||||
#include "node/keyframe.h"
|
||||
#include "undo/undocommand.h"
|
||||
|
||||
class KeyframeSetTypeCommand : public QUndoCommand {
|
||||
class KeyframeSetTypeCommand : public UndoCommand {
|
||||
public:
|
||||
KeyframeSetTypeCommand(NodeKeyframePtr key, NodeKeyframe::Type type, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
NodeKeyframePtr key_;
|
||||
@@ -21,13 +21,14 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class KeyframeSetBezierControlPoint : public QUndoCommand {
|
||||
class KeyframeSetBezierControlPoint : public UndoCommand {
|
||||
public:
|
||||
KeyframeSetBezierControlPoint(NodeKeyframePtr key, NodeKeyframe::BezierType mode, const QPointF& point, QUndoCommand* parent = nullptr);
|
||||
KeyframeSetBezierControlPoint(NodeKeyframePtr key, NodeKeyframe::BezierType mode, const QPointF& new_point, const QPointF& old_point, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
NodeKeyframePtr key_;
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
#include "nodeparamviewundo.h"
|
||||
|
||||
NodeParamSetKeyframingCommand::NodeParamSetKeyframingCommand(NodeInput *input, bool setting, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
input_(input),
|
||||
setting_(setting)
|
||||
{
|
||||
Q_ASSERT(setting != input_->is_keyframing());
|
||||
}
|
||||
|
||||
void NodeParamSetKeyframingCommand::redo()
|
||||
void NodeParamSetKeyframingCommand::redo_internal()
|
||||
{
|
||||
input_->set_is_keyframing(setting_);
|
||||
}
|
||||
|
||||
void NodeParamSetKeyframingCommand::undo()
|
||||
void NodeParamSetKeyframingCommand::undo_internal()
|
||||
{
|
||||
input_->set_is_keyframing(!setting_);
|
||||
}
|
||||
|
||||
NodeParamSetKeyframeValueCommand::NodeParamSetKeyframeValueCommand(NodeKeyframePtr key, const QVariant& value, QUndoCommand* parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
key_(key),
|
||||
old_value_(key_->value()),
|
||||
new_value_(value)
|
||||
@@ -27,7 +27,7 @@ NodeParamSetKeyframeValueCommand::NodeParamSetKeyframeValueCommand(NodeKeyframeP
|
||||
}
|
||||
|
||||
NodeParamSetKeyframeValueCommand::NodeParamSetKeyframeValueCommand(NodeKeyframePtr key, const QVariant &new_value, const QVariant &old_value, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
key_(key),
|
||||
old_value_(old_value),
|
||||
new_value_(new_value)
|
||||
@@ -35,18 +35,18 @@ NodeParamSetKeyframeValueCommand::NodeParamSetKeyframeValueCommand(NodeKeyframeP
|
||||
|
||||
}
|
||||
|
||||
void NodeParamSetKeyframeValueCommand::redo()
|
||||
void NodeParamSetKeyframeValueCommand::redo_internal()
|
||||
{
|
||||
key_->set_value(new_value_);
|
||||
}
|
||||
|
||||
void NodeParamSetKeyframeValueCommand::undo()
|
||||
void NodeParamSetKeyframeValueCommand::undo_internal()
|
||||
{
|
||||
key_->set_value(old_value_);
|
||||
}
|
||||
|
||||
NodeParamInsertKeyframeCommand::NodeParamInsertKeyframeCommand(NodeInput *input, NodeKeyframePtr keyframe, QUndoCommand* parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
input_(input),
|
||||
keyframe_(keyframe),
|
||||
done_(false)
|
||||
@@ -54,45 +54,45 @@ NodeParamInsertKeyframeCommand::NodeParamInsertKeyframeCommand(NodeInput *input,
|
||||
}
|
||||
|
||||
NodeParamInsertKeyframeCommand::NodeParamInsertKeyframeCommand(NodeInput *input, NodeKeyframePtr keyframe, bool already_done, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
input_(input),
|
||||
keyframe_(keyframe),
|
||||
done_(already_done)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeParamInsertKeyframeCommand::redo()
|
||||
void NodeParamInsertKeyframeCommand::redo_internal()
|
||||
{
|
||||
if (!done_) {
|
||||
input_->insert_keyframe(keyframe_);
|
||||
}
|
||||
}
|
||||
|
||||
void NodeParamInsertKeyframeCommand::undo()
|
||||
void NodeParamInsertKeyframeCommand::undo_internal()
|
||||
{
|
||||
input_->remove_keyframe(keyframe_);
|
||||
done_ = false;
|
||||
}
|
||||
|
||||
NodeParamRemoveKeyframeCommand::NodeParamRemoveKeyframeCommand(NodeInput *input, NodeKeyframePtr keyframe, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
input_(input),
|
||||
keyframe_(keyframe)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeParamRemoveKeyframeCommand::redo()
|
||||
void NodeParamRemoveKeyframeCommand::redo_internal()
|
||||
{
|
||||
input_->remove_keyframe(keyframe_);
|
||||
}
|
||||
|
||||
void NodeParamRemoveKeyframeCommand::undo()
|
||||
void NodeParamRemoveKeyframeCommand::undo_internal()
|
||||
{
|
||||
input_->insert_keyframe(keyframe_);
|
||||
}
|
||||
|
||||
NodeParamSetKeyframeTimeCommand::NodeParamSetKeyframeTimeCommand(NodeKeyframePtr key, const rational &time, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
key_(key),
|
||||
old_time_(key->time()),
|
||||
new_time_(time)
|
||||
@@ -100,25 +100,25 @@ NodeParamSetKeyframeTimeCommand::NodeParamSetKeyframeTimeCommand(NodeKeyframePtr
|
||||
}
|
||||
|
||||
NodeParamSetKeyframeTimeCommand::NodeParamSetKeyframeTimeCommand(NodeKeyframePtr key, const rational &new_time, const rational &old_time, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
key_(key),
|
||||
old_time_(old_time),
|
||||
new_time_(new_time)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeParamSetKeyframeTimeCommand::redo()
|
||||
void NodeParamSetKeyframeTimeCommand::redo_internal()
|
||||
{
|
||||
key_->set_time(new_time_);
|
||||
}
|
||||
|
||||
void NodeParamSetKeyframeTimeCommand::undo()
|
||||
void NodeParamSetKeyframeTimeCommand::undo_internal()
|
||||
{
|
||||
key_->set_time(old_time_);
|
||||
}
|
||||
|
||||
NodeParamSetStandardValueCommand::NodeParamSetStandardValueCommand(NodeInput *input, int track, const QVariant &value, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
input_(input),
|
||||
track_(track),
|
||||
old_value_(input_->get_standard_value()),
|
||||
@@ -127,7 +127,7 @@ NodeParamSetStandardValueCommand::NodeParamSetStandardValueCommand(NodeInput *in
|
||||
}
|
||||
|
||||
NodeParamSetStandardValueCommand::NodeParamSetStandardValueCommand(NodeInput *input, int track, const QVariant &new_value, const QVariant &old_value, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
input_(input),
|
||||
track_(track),
|
||||
old_value_(old_value),
|
||||
@@ -135,12 +135,12 @@ NodeParamSetStandardValueCommand::NodeParamSetStandardValueCommand(NodeInput *in
|
||||
{
|
||||
}
|
||||
|
||||
void NodeParamSetStandardValueCommand::redo()
|
||||
void NodeParamSetStandardValueCommand::redo_internal()
|
||||
{
|
||||
input_->set_standard_value(new_value_, track_);
|
||||
}
|
||||
|
||||
void NodeParamSetStandardValueCommand::undo()
|
||||
void NodeParamSetStandardValueCommand::undo_internal()
|
||||
{
|
||||
input_->set_standard_value(old_value_, track_);
|
||||
}
|
||||
|
||||
@@ -1,29 +1,30 @@
|
||||
#ifndef NODEPARAMVIEWUNDO_H
|
||||
#define NODEPARAMVIEWUNDO_H
|
||||
|
||||
#include <QUndoCommand>
|
||||
|
||||
#include "node/input.h"
|
||||
#include "undo/undocommand.h"
|
||||
|
||||
class NodeParamSetKeyframingCommand : public QUndoCommand {
|
||||
class NodeParamSetKeyframingCommand : public UndoCommand {
|
||||
public:
|
||||
NodeParamSetKeyframingCommand(NodeInput* input, bool setting, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
NodeInput* input_;
|
||||
bool setting_;
|
||||
};
|
||||
|
||||
class NodeParamInsertKeyframeCommand : public QUndoCommand {
|
||||
class NodeParamInsertKeyframeCommand : public UndoCommand {
|
||||
public:
|
||||
NodeParamInsertKeyframeCommand(NodeInput* input, NodeKeyframePtr keyframe, QUndoCommand *parent = nullptr);
|
||||
NodeParamInsertKeyframeCommand(NodeInput* input, NodeKeyframePtr keyframe, bool already_done, QUndoCommand *parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
NodeInput* input_;
|
||||
@@ -34,12 +35,13 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class NodeParamRemoveKeyframeCommand : public QUndoCommand {
|
||||
class NodeParamRemoveKeyframeCommand : public UndoCommand {
|
||||
public:
|
||||
NodeParamRemoveKeyframeCommand(NodeInput* input, NodeKeyframePtr keyframe, QUndoCommand *parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
NodeInput* input_;
|
||||
@@ -48,13 +50,14 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class NodeParamSetKeyframeTimeCommand : public QUndoCommand {
|
||||
class NodeParamSetKeyframeTimeCommand : public UndoCommand {
|
||||
public:
|
||||
NodeParamSetKeyframeTimeCommand(NodeKeyframePtr key, const rational& time, QUndoCommand* parent = nullptr);
|
||||
NodeParamSetKeyframeTimeCommand(NodeKeyframePtr key, const rational& new_time, const rational& old_time, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
NodeKeyframePtr key_;
|
||||
@@ -64,13 +67,14 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class NodeParamSetKeyframeValueCommand : public QUndoCommand {
|
||||
class NodeParamSetKeyframeValueCommand : public UndoCommand {
|
||||
public:
|
||||
NodeParamSetKeyframeValueCommand(NodeKeyframePtr key, const QVariant& value, QUndoCommand* parent = nullptr);
|
||||
NodeParamSetKeyframeValueCommand(NodeKeyframePtr key, const QVariant& new_value, const QVariant& old_value, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
NodeKeyframePtr key_;
|
||||
@@ -80,13 +84,14 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class NodeParamSetStandardValueCommand : public QUndoCommand {
|
||||
class NodeParamSetStandardValueCommand : public UndoCommand {
|
||||
public:
|
||||
NodeParamSetStandardValueCommand(NodeInput* input, int track, const QVariant& value, QUndoCommand* parent = nullptr);
|
||||
NodeParamSetStandardValueCommand(NodeInput* input, int track, const QVariant& new_value, const QVariant& old_value, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
NodeInput* input_;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "nodeviewundo.h"
|
||||
|
||||
NodeEdgeAddCommand::NodeEdgeAddCommand(NodeOutput *output, NodeInput *input, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
output_(output),
|
||||
input_(input),
|
||||
old_edge_(nullptr),
|
||||
@@ -9,7 +9,7 @@ NodeEdgeAddCommand::NodeEdgeAddCommand(NodeOutput *output, NodeInput *input, QUn
|
||||
{
|
||||
}
|
||||
|
||||
void NodeEdgeAddCommand::redo()
|
||||
void NodeEdgeAddCommand::redo_internal()
|
||||
{
|
||||
if (done_) {
|
||||
return;
|
||||
@@ -22,7 +22,7 @@ void NodeEdgeAddCommand::redo()
|
||||
done_ = true;
|
||||
}
|
||||
|
||||
void NodeEdgeAddCommand::undo()
|
||||
void NodeEdgeAddCommand::undo_internal()
|
||||
{
|
||||
if (!done_) {
|
||||
return;
|
||||
@@ -38,7 +38,7 @@ void NodeEdgeAddCommand::undo()
|
||||
}
|
||||
|
||||
NodeEdgeRemoveCommand::NodeEdgeRemoveCommand(NodeOutput *output, NodeInput *input, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
output_(output),
|
||||
input_(input),
|
||||
done_(false)
|
||||
@@ -46,14 +46,14 @@ NodeEdgeRemoveCommand::NodeEdgeRemoveCommand(NodeOutput *output, NodeInput *inpu
|
||||
}
|
||||
|
||||
NodeEdgeRemoveCommand::NodeEdgeRemoveCommand(NodeEdgePtr edge, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
output_(edge->output()),
|
||||
input_(edge->input()),
|
||||
done_(false)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeEdgeRemoveCommand::redo()
|
||||
void NodeEdgeRemoveCommand::redo_internal()
|
||||
{
|
||||
if (done_) {
|
||||
return;
|
||||
@@ -63,7 +63,7 @@ void NodeEdgeRemoveCommand::redo()
|
||||
done_ = true;
|
||||
}
|
||||
|
||||
void NodeEdgeRemoveCommand::undo()
|
||||
void NodeEdgeRemoveCommand::undo_internal()
|
||||
{
|
||||
if (!done_) {
|
||||
return;
|
||||
@@ -74,7 +74,7 @@ void NodeEdgeRemoveCommand::undo()
|
||||
}
|
||||
|
||||
NodeAddCommand::NodeAddCommand(NodeGraph *graph, Node *node, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
graph_(graph),
|
||||
node_(node)
|
||||
{
|
||||
@@ -82,24 +82,24 @@ NodeAddCommand::NodeAddCommand(NodeGraph *graph, Node *node, QUndoCommand *paren
|
||||
node_->setParent(&memory_manager_);
|
||||
}
|
||||
|
||||
void NodeAddCommand::redo()
|
||||
void NodeAddCommand::redo_internal()
|
||||
{
|
||||
graph_->AddNode(node_);
|
||||
}
|
||||
|
||||
void NodeAddCommand::undo()
|
||||
void NodeAddCommand::undo_internal()
|
||||
{
|
||||
graph_->TakeNode(node_, &memory_manager_);
|
||||
}
|
||||
|
||||
NodeRemoveCommand::NodeRemoveCommand(NodeGraph *graph, const QList<Node *> &nodes, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
graph_(graph),
|
||||
nodes_(nodes)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeRemoveCommand::redo()
|
||||
void NodeRemoveCommand::redo_internal()
|
||||
{
|
||||
// Cache edges for undoing
|
||||
foreach (Node* n, nodes_) {
|
||||
@@ -119,7 +119,7 @@ void NodeRemoveCommand::redo()
|
||||
}
|
||||
}
|
||||
|
||||
void NodeRemoveCommand::undo()
|
||||
void NodeRemoveCommand::undo_internal()
|
||||
{
|
||||
// Re-add nodes to graph
|
||||
foreach (Node* n, nodes_) {
|
||||
@@ -135,7 +135,7 @@ void NodeRemoveCommand::undo()
|
||||
}
|
||||
|
||||
NodeRemoveWithExclusiveDeps::NodeRemoveWithExclusiveDeps(NodeGraph *graph, Node *node, QUndoCommand *parent) :
|
||||
QUndoCommand(parent)
|
||||
UndoCommand(parent)
|
||||
{
|
||||
QList<Node*> node_and_its_deps;
|
||||
node_and_its_deps.append(node);
|
||||
@@ -145,7 +145,7 @@ NodeRemoveWithExclusiveDeps::NodeRemoveWithExclusiveDeps(NodeGraph *graph, Node
|
||||
}
|
||||
|
||||
NodeCopyInputsCommand::NodeCopyInputsCommand(Node *src, Node *dest, bool include_connections, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
src_(src),
|
||||
dest_(dest),
|
||||
include_connections_(include_connections)
|
||||
@@ -153,14 +153,14 @@ NodeCopyInputsCommand::NodeCopyInputsCommand(Node *src, Node *dest, bool include
|
||||
}
|
||||
|
||||
NodeCopyInputsCommand::NodeCopyInputsCommand(Node *src, Node *dest, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
src_(src),
|
||||
dest_(dest),
|
||||
include_connections_(true)
|
||||
{
|
||||
}
|
||||
|
||||
void NodeCopyInputsCommand::redo()
|
||||
void NodeCopyInputsCommand::redo_internal()
|
||||
{
|
||||
Node::CopyInputs(src_, dest_, include_connections_);
|
||||
}
|
||||
|
||||
@@ -6,18 +6,20 @@
|
||||
#include "node/graph.h"
|
||||
#include "node/node.h"
|
||||
#include "nodeviewitem.h"
|
||||
#include "undo/undocommand.h"
|
||||
|
||||
/**
|
||||
* @brief An undoable commnd for connecting two NodeParams together
|
||||
*
|
||||
* Can be considered a QUndoCommand wrapper for NodeParam::ConnectEdge()/
|
||||
*/
|
||||
class NodeEdgeAddCommand : public QUndoCommand {
|
||||
class NodeEdgeAddCommand : public UndoCommand {
|
||||
public:
|
||||
NodeEdgeAddCommand(NodeOutput* output, NodeInput* input, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
NodeOutput* output_;
|
||||
@@ -33,13 +35,14 @@ private:
|
||||
*
|
||||
* Can be considered a QUndoCommand wrapper for NodeParam::DisonnectEdge()/
|
||||
*/
|
||||
class NodeEdgeRemoveCommand : public QUndoCommand {
|
||||
class NodeEdgeRemoveCommand : public UndoCommand {
|
||||
public:
|
||||
NodeEdgeRemoveCommand(NodeOutput* output, NodeInput* input, QUndoCommand* parent = nullptr);
|
||||
NodeEdgeRemoveCommand(NodeEdgePtr edge, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
NodeOutput* output_;
|
||||
@@ -48,12 +51,13 @@ private:
|
||||
bool done_;
|
||||
};
|
||||
|
||||
class NodeAddCommand : public QUndoCommand {
|
||||
class NodeAddCommand : public UndoCommand {
|
||||
public:
|
||||
NodeAddCommand(NodeGraph* graph, Node* node, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
QObject memory_manager_;
|
||||
@@ -62,14 +66,15 @@ private:
|
||||
Node* node_;
|
||||
};
|
||||
|
||||
class NodeRemoveCommand : public QUndoCommand {
|
||||
class NodeRemoveCommand : public UndoCommand {
|
||||
public:
|
||||
NodeRemoveCommand(NodeGraph* graph,
|
||||
const QList<Node*>& nodes,
|
||||
QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
QObject memory_manager_;
|
||||
@@ -79,7 +84,7 @@ private:
|
||||
QList<NodeEdgePtr> edges_;
|
||||
};
|
||||
|
||||
class NodeRemoveWithExclusiveDeps : public QUndoCommand {
|
||||
class NodeRemoveWithExclusiveDeps : public UndoCommand {
|
||||
public:
|
||||
NodeRemoveWithExclusiveDeps(NodeGraph* graph,
|
||||
Node* node,
|
||||
@@ -89,7 +94,7 @@ private:
|
||||
NodeRemoveCommand* remove_command_;
|
||||
};
|
||||
|
||||
class NodeCopyInputsCommand : public QUndoCommand {
|
||||
class NodeCopyInputsCommand : public UndoCommand {
|
||||
public:
|
||||
NodeCopyInputsCommand(Node* src,
|
||||
Node* dest,
|
||||
@@ -100,7 +105,8 @@ public:
|
||||
Node* dest,
|
||||
QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
|
||||
private:
|
||||
Node* src_;
|
||||
|
||||
@@ -198,6 +198,7 @@ void TimelineWidget::ImportTool::DragDrop(TimelineViewMouseEvent *event)
|
||||
|
||||
QMessageBox mbox(parent());
|
||||
|
||||
mbox.setIcon(QMessageBox::Question);
|
||||
mbox.setWindowTitle(tr("No Active Sequence"));
|
||||
mbox.setText(tr("No sequence is currently open. Would you like to create one?"));
|
||||
mbox.setCheckBox(dont_ask_again_box);
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "undo.h"
|
||||
|
||||
#include "core.h"
|
||||
#include "node/graph.h"
|
||||
#include "node/block/transition/transition.h"
|
||||
|
||||
@@ -31,73 +32,73 @@ Node* TakeNodeFromParentGraph(Node* n, QObject* new_parent = nullptr)
|
||||
}
|
||||
|
||||
BlockResizeCommand::BlockResizeCommand(Block *block, rational new_length, QUndoCommand* parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
block_(block),
|
||||
old_length_(block->length()),
|
||||
new_length_(new_length)
|
||||
{
|
||||
}
|
||||
|
||||
void BlockResizeCommand::redo()
|
||||
void BlockResizeCommand::redo_internal()
|
||||
{
|
||||
block_->set_length_and_media_out(new_length_);
|
||||
}
|
||||
|
||||
void BlockResizeCommand::undo()
|
||||
void BlockResizeCommand::undo_internal()
|
||||
{
|
||||
block_->set_length_and_media_out(old_length_);
|
||||
}
|
||||
|
||||
BlockResizeWithMediaInCommand::BlockResizeWithMediaInCommand(Block *block, rational new_length, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
block_(block),
|
||||
old_length_(block->length()),
|
||||
new_length_(new_length)
|
||||
{
|
||||
}
|
||||
|
||||
void BlockResizeWithMediaInCommand::redo()
|
||||
void BlockResizeWithMediaInCommand::redo_internal()
|
||||
{
|
||||
block_->set_length_and_media_in(new_length_);
|
||||
}
|
||||
|
||||
void BlockResizeWithMediaInCommand::undo()
|
||||
void BlockResizeWithMediaInCommand::undo_internal()
|
||||
{
|
||||
block_->set_length_and_media_in(old_length_);
|
||||
}
|
||||
|
||||
BlockSetMediaInCommand::BlockSetMediaInCommand(Block *block, rational new_media_in, QUndoCommand* parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
block_(block),
|
||||
old_media_in_(block->media_in()),
|
||||
new_media_in_(new_media_in)
|
||||
{
|
||||
}
|
||||
|
||||
void BlockSetMediaInCommand::redo()
|
||||
void BlockSetMediaInCommand::redo_internal()
|
||||
{
|
||||
block_->set_media_in(new_media_in_);
|
||||
}
|
||||
|
||||
void BlockSetMediaInCommand::undo()
|
||||
void BlockSetMediaInCommand::undo_internal()
|
||||
{
|
||||
block_->set_media_in(old_media_in_);
|
||||
}
|
||||
|
||||
TrackRippleRemoveBlockCommand::TrackRippleRemoveBlockCommand(TrackOutput *track, Block *block, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
track_(track),
|
||||
block_(block)
|
||||
{
|
||||
}
|
||||
|
||||
void TrackRippleRemoveBlockCommand::redo()
|
||||
void TrackRippleRemoveBlockCommand::redo_internal()
|
||||
{
|
||||
before_ = block_->previous();
|
||||
track_->RippleRemoveBlock(block_);
|
||||
}
|
||||
|
||||
void TrackRippleRemoveBlockCommand::undo()
|
||||
void TrackRippleRemoveBlockCommand::undo_internal()
|
||||
{
|
||||
if (before_) {
|
||||
track_->InsertBlockAfter(block_, before_);
|
||||
@@ -110,25 +111,25 @@ TrackInsertBlockAfterCommand::TrackInsertBlockAfterCommand(TrackOutput *track,
|
||||
Block *block,
|
||||
Block *before,
|
||||
QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
track_(track),
|
||||
block_(block),
|
||||
before_(before)
|
||||
{
|
||||
}
|
||||
|
||||
void TrackInsertBlockAfterCommand::redo()
|
||||
void TrackInsertBlockAfterCommand::redo_internal()
|
||||
{
|
||||
track_->InsertBlockAfter(block_, before_);
|
||||
}
|
||||
|
||||
void TrackInsertBlockAfterCommand::undo()
|
||||
void TrackInsertBlockAfterCommand::undo_internal()
|
||||
{
|
||||
track_->RippleRemoveBlock(block_);
|
||||
}
|
||||
|
||||
TrackRippleRemoveAreaCommand::TrackRippleRemoveAreaCommand(TrackOutput *track, rational in, rational out, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
track_(track),
|
||||
in_(in),
|
||||
out_(out),
|
||||
@@ -144,7 +145,7 @@ void TrackRippleRemoveAreaCommand::SetInsert(Block *insert)
|
||||
insert_ = insert;
|
||||
}
|
||||
|
||||
void TrackRippleRemoveAreaCommand::redo()
|
||||
void TrackRippleRemoveAreaCommand::redo_internal()
|
||||
{
|
||||
// Iterate through blocks determining which need trimming/removing/splitting
|
||||
foreach (Block* block, track_->Blocks()) {
|
||||
@@ -237,7 +238,7 @@ void TrackRippleRemoveAreaCommand::redo()
|
||||
track_->InvalidateCache(in_, insert_ ? out_ : RATIONAL_MAX);
|
||||
}
|
||||
|
||||
void TrackRippleRemoveAreaCommand::undo()
|
||||
void TrackRippleRemoveAreaCommand::undo_internal()
|
||||
{
|
||||
track_->BlockInvalidateCache();
|
||||
|
||||
@@ -291,7 +292,7 @@ TrackPlaceBlockCommand::TrackPlaceBlockCommand(TrackList *timeline, int track, B
|
||||
insert_ = block;
|
||||
}
|
||||
|
||||
void TrackPlaceBlockCommand::redo()
|
||||
void TrackPlaceBlockCommand::redo_internal()
|
||||
{
|
||||
added_track_count_ = 0;
|
||||
|
||||
@@ -321,11 +322,11 @@ void TrackPlaceBlockCommand::redo()
|
||||
out_ = in_ + insert_->length();
|
||||
|
||||
// Place the Block at this point
|
||||
TrackRippleRemoveAreaCommand::redo();
|
||||
TrackRippleRemoveAreaCommand::redo_internal();
|
||||
}
|
||||
}
|
||||
|
||||
void TrackPlaceBlockCommand::undo()
|
||||
void TrackPlaceBlockCommand::undo_internal()
|
||||
{
|
||||
if (append_) {
|
||||
track_->RippleRemoveBlock(insert_);
|
||||
@@ -335,7 +336,7 @@ void TrackPlaceBlockCommand::undo()
|
||||
delete TakeNodeFromParentGraph(gap_);
|
||||
}
|
||||
} else {
|
||||
TrackRippleRemoveAreaCommand::undo();
|
||||
TrackRippleRemoveAreaCommand::undo_internal();
|
||||
}
|
||||
|
||||
for (;added_track_count_>0;added_track_count_--) {
|
||||
@@ -344,7 +345,7 @@ void TrackPlaceBlockCommand::undo()
|
||||
}
|
||||
|
||||
BlockSplitCommand::BlockSplitCommand(TrackOutput* track, Block *block, rational point, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
track_(track),
|
||||
block_(block),
|
||||
new_length_(point - block->in()),
|
||||
@@ -367,7 +368,7 @@ BlockSplitCommand::BlockSplitCommand(TrackOutput* track, Block *block, rational
|
||||
}
|
||||
}
|
||||
|
||||
void BlockSplitCommand::redo()
|
||||
void BlockSplitCommand::redo_internal()
|
||||
{
|
||||
track_->BlockInvalidateCache();
|
||||
|
||||
@@ -390,7 +391,7 @@ void BlockSplitCommand::redo()
|
||||
track_->UnblockInvalidateCache();
|
||||
}
|
||||
|
||||
void BlockSplitCommand::undo()
|
||||
void BlockSplitCommand::undo_internal()
|
||||
{
|
||||
track_->BlockInvalidateCache();
|
||||
|
||||
@@ -413,7 +414,7 @@ Block *BlockSplitCommand::new_block()
|
||||
}
|
||||
|
||||
TrackSplitAtTimeCommand::TrackSplitAtTimeCommand(TrackOutput *track, rational point, QUndoCommand *parent) :
|
||||
QUndoCommand(parent)
|
||||
UndoCommand(parent)
|
||||
{
|
||||
// Find Block that contains this time
|
||||
foreach (Block* b, track->Blocks()) {
|
||||
@@ -429,42 +430,42 @@ TrackSplitAtTimeCommand::TrackSplitAtTimeCommand(TrackOutput *track, rational po
|
||||
}
|
||||
|
||||
TrackReplaceBlockCommand::TrackReplaceBlockCommand(TrackOutput* track, Block *old, Block *replace, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
track_(track),
|
||||
old_(old),
|
||||
replace_(replace)
|
||||
{
|
||||
}
|
||||
|
||||
void TrackReplaceBlockCommand::redo()
|
||||
void TrackReplaceBlockCommand::redo_internal()
|
||||
{
|
||||
track_->ReplaceBlock(old_, replace_);
|
||||
}
|
||||
|
||||
void TrackReplaceBlockCommand::undo()
|
||||
void TrackReplaceBlockCommand::undo_internal()
|
||||
{
|
||||
track_->ReplaceBlock(replace_, old_);
|
||||
}
|
||||
|
||||
TrackPrependBlockCommand::TrackPrependBlockCommand(TrackOutput *track, Block *block, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
track_(track),
|
||||
block_(block)
|
||||
{
|
||||
}
|
||||
|
||||
void TrackPrependBlockCommand::redo()
|
||||
void TrackPrependBlockCommand::redo_internal()
|
||||
{
|
||||
track_->PrependBlock(block_);
|
||||
}
|
||||
|
||||
void TrackPrependBlockCommand::undo()
|
||||
void TrackPrependBlockCommand::undo_internal()
|
||||
{
|
||||
track_->RippleRemoveBlock(block_);
|
||||
}
|
||||
|
||||
BlockSplitPreservingLinksCommand::BlockSplitPreservingLinksCommand(const QVector<Block *> &blocks, const QList<rational> ×, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
blocks_(blocks),
|
||||
times_(times)
|
||||
{
|
||||
@@ -516,13 +517,13 @@ BlockSplitPreservingLinksCommand::BlockSplitPreservingLinksCommand(const QVector
|
||||
}
|
||||
|
||||
TrackCleanGapsCommand::TrackCleanGapsCommand(TrackList *track_list, int index, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
track_list_(track_list),
|
||||
track_index_(index)
|
||||
{
|
||||
}
|
||||
|
||||
void TrackCleanGapsCommand::redo()
|
||||
void TrackCleanGapsCommand::redo_internal()
|
||||
{
|
||||
GapBlock* on_gap = nullptr;
|
||||
QList<GapBlock*> consecutive_gaps;
|
||||
@@ -572,7 +573,7 @@ void TrackCleanGapsCommand::redo()
|
||||
}
|
||||
}
|
||||
|
||||
void TrackCleanGapsCommand::undo()
|
||||
void TrackCleanGapsCommand::undo_internal()
|
||||
{
|
||||
TrackOutput* track = track_list_->TrackAt(track_index_);
|
||||
|
||||
@@ -605,19 +606,19 @@ void TrackCleanGapsCommand::undo()
|
||||
}
|
||||
|
||||
BlockSetSpeedCommand::BlockSetSpeedCommand(Block *block, const rational &new_speed, QUndoCommand *parent) :
|
||||
QUndoCommand(parent),
|
||||
UndoCommand(parent),
|
||||
block_(block),
|
||||
old_speed_(block->speed()),
|
||||
new_speed_(new_speed)
|
||||
{
|
||||
}
|
||||
|
||||
void BlockSetSpeedCommand::redo()
|
||||
void BlockSetSpeedCommand::redo_internal()
|
||||
{
|
||||
block_->set_speed(new_speed_);
|
||||
}
|
||||
|
||||
void BlockSetSpeedCommand::undo()
|
||||
void BlockSetSpeedCommand::undo_internal()
|
||||
{
|
||||
block_->set_speed(old_speed_);
|
||||
}
|
||||
|
||||
@@ -27,13 +27,15 @@
|
||||
#include "node/block/gap/gap.h"
|
||||
#include "node/output/track/track.h"
|
||||
#include "node/output/track/tracklist.h"
|
||||
#include "undo/undocommand.h"
|
||||
|
||||
class BlockResizeCommand : public QUndoCommand {
|
||||
class BlockResizeCommand : public UndoCommand {
|
||||
public:
|
||||
BlockResizeCommand(Block* block, rational new_length, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
@@ -41,12 +43,13 @@ private:
|
||||
rational new_length_;
|
||||
};
|
||||
|
||||
class BlockResizeWithMediaInCommand : public QUndoCommand {
|
||||
class BlockResizeWithMediaInCommand : public UndoCommand {
|
||||
public:
|
||||
BlockResizeWithMediaInCommand(Block* block, rational new_length, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
@@ -54,12 +57,13 @@ private:
|
||||
rational new_length_;
|
||||
};
|
||||
|
||||
class BlockSetMediaInCommand : public QUndoCommand {
|
||||
class BlockSetMediaInCommand : public UndoCommand {
|
||||
public:
|
||||
BlockSetMediaInCommand(Block* block, rational new_media_in, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
@@ -67,12 +71,13 @@ private:
|
||||
rational new_media_in_;
|
||||
};
|
||||
|
||||
class BlockSetSpeedCommand : public QUndoCommand {
|
||||
class BlockSetSpeedCommand : public UndoCommand {
|
||||
public:
|
||||
BlockSetSpeedCommand(Block* block, const rational& new_speed, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
Block* block_;
|
||||
@@ -81,12 +86,13 @@ private:
|
||||
rational new_speed_;
|
||||
};
|
||||
|
||||
class TrackRippleRemoveBlockCommand : public QUndoCommand {
|
||||
class TrackRippleRemoveBlockCommand : public UndoCommand {
|
||||
public:
|
||||
TrackRippleRemoveBlockCommand(TrackOutput* track, Block* block, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
TrackOutput* track_;
|
||||
@@ -96,24 +102,26 @@ private:
|
||||
Block* before_;
|
||||
};
|
||||
|
||||
class TrackPrependBlockCommand : public QUndoCommand {
|
||||
class TrackPrependBlockCommand : public UndoCommand {
|
||||
public:
|
||||
TrackPrependBlockCommand(TrackOutput* track, Block* block, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
TrackOutput* track_;
|
||||
Block* block_;
|
||||
};
|
||||
|
||||
class TrackInsertBlockAfterCommand : public QUndoCommand {
|
||||
class TrackInsertBlockAfterCommand : public UndoCommand {
|
||||
public:
|
||||
TrackInsertBlockAfterCommand(TrackOutput* track, Block* block, Block* before, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
TrackOutput* track_;
|
||||
@@ -130,14 +138,15 @@ private:
|
||||
* By default, nothing takes this area meaning all subsequent clips are pushed backward, however you can specify
|
||||
* a block to insert at the `in` point. No checking is done to ensure `insert` is the same length as `in` to `out`.
|
||||
*/
|
||||
class TrackRippleRemoveAreaCommand : public QUndoCommand {
|
||||
class TrackRippleRemoveAreaCommand : public UndoCommand {
|
||||
public:
|
||||
TrackRippleRemoveAreaCommand(TrackOutput* track, rational in, rational out, QUndoCommand* parent = nullptr);
|
||||
|
||||
void SetInsert(Block* insert);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
protected:
|
||||
TrackOutput* track_;
|
||||
@@ -172,8 +181,9 @@ class TrackPlaceBlockCommand : public TrackRippleRemoveAreaCommand {
|
||||
public:
|
||||
TrackPlaceBlockCommand(TrackList *timeline, int track, Block* block, rational in, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
TrackList* timeline_;
|
||||
@@ -183,15 +193,16 @@ private:
|
||||
int added_track_count_;
|
||||
};
|
||||
|
||||
class BlockSplitCommand : public QUndoCommand {
|
||||
class BlockSplitCommand : public UndoCommand {
|
||||
public:
|
||||
BlockSplitCommand(TrackOutput* track, Block* block, rational point, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
|
||||
Block* new_block();
|
||||
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
TrackOutput* track_;
|
||||
Block* block_;
|
||||
@@ -208,12 +219,12 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class TrackSplitAtTimeCommand : public QUndoCommand {
|
||||
class TrackSplitAtTimeCommand : public UndoCommand {
|
||||
public:
|
||||
TrackSplitAtTimeCommand(TrackOutput* track, rational point, QUndoCommand* parent = nullptr);
|
||||
};
|
||||
|
||||
class BlockSplitPreservingLinksCommand : public QUndoCommand {
|
||||
class BlockSplitPreservingLinksCommand : public UndoCommand {
|
||||
public:
|
||||
BlockSplitPreservingLinksCommand(const QVector<Block *> &blocks, const QList<rational>& times, QUndoCommand* parent = nullptr);
|
||||
|
||||
@@ -228,12 +239,13 @@ private:
|
||||
*
|
||||
* Both blocks must have equal lengths.
|
||||
*/
|
||||
class TrackReplaceBlockCommand : public QUndoCommand {
|
||||
class TrackReplaceBlockCommand : public UndoCommand {
|
||||
public:
|
||||
TrackReplaceBlockCommand(TrackOutput* track, Block* old, Block* replace, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
TrackOutput* track_;
|
||||
@@ -241,12 +253,13 @@ private:
|
||||
Block* replace_;
|
||||
};
|
||||
|
||||
class TrackCleanGapsCommand : public QUndoCommand {
|
||||
class TrackCleanGapsCommand : public UndoCommand {
|
||||
public:
|
||||
TrackCleanGapsCommand(TrackList* track_list, int index, QUndoCommand* parent = nullptr);
|
||||
|
||||
virtual void redo() override;
|
||||
virtual void undo() override;
|
||||
protected:
|
||||
virtual void redo_internal() override;
|
||||
virtual void undo_internal() override;
|
||||
|
||||
private:
|
||||
struct MergedGap {
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include <QApplication>
|
||||
#include <QDebug>
|
||||
#include <QDesktopWidget>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "mainmenu.h"
|
||||
#include "mainstatusbar.h"
|
||||
@@ -160,6 +161,28 @@ void MainWindow::ProjectOpen(Project* p)
|
||||
|
||||
void MainWindow::closeEvent(QCloseEvent *e)
|
||||
{
|
||||
if (isWindowModified()) {
|
||||
QMessageBox mb(this);
|
||||
|
||||
mb.setIcon(QMessageBox::Question);
|
||||
mb.setWindowTitle(tr("Unsaved Changes"));
|
||||
mb.setText(tr("The project '%1' has unsaved changes. Would you like to save them?")
|
||||
.arg(Core::instance()->GetActiveProject()->name()));
|
||||
|
||||
QPushButton* yes_btn = mb.addButton(tr("Save"), QMessageBox::YesRole);
|
||||
mb.addButton(tr("Don't Save"), QMessageBox::NoRole);
|
||||
QPushButton* cancel_btn = mb.addButton(QMessageBox::Cancel);
|
||||
|
||||
mb.exec();
|
||||
|
||||
if (mb.clickedButton() == cancel_btn
|
||||
|| (mb.clickedButton() == yes_btn && !Core::instance()->SaveActiveProject())) {
|
||||
// Don't close if the user clicked cancel on this messagebox OR they cancelled a save as operation
|
||||
e->ignore();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Close viewers first since we don't want to delete any nodes while they might be mid-render
|
||||
QList<ViewerPanel*> viewers = PanelManager::instance()->GetPanelsOfType<ViewerPanel>();
|
||||
foreach (ViewerPanel* viewer, viewers) {
|
||||
@@ -173,9 +196,9 @@ void MainWindow::closeEvent(QCloseEvent *e)
|
||||
|
||||
void MainWindow::UpdateTitle()
|
||||
{
|
||||
setWindowTitle(QStringLiteral("%1 %2 - %3").arg(QApplication::applicationName(),
|
||||
QApplication::applicationVersion(),
|
||||
tr("<untitled>")));
|
||||
setWindowTitle(QStringLiteral("%1 %2 - [*]%3").arg(QApplication::applicationName(),
|
||||
QApplication::applicationVersion(),
|
||||
tr("(untitled)")));
|
||||
}
|
||||
|
||||
void MainWindow::SetDefaultLayout()
|
||||
@@ -186,14 +209,14 @@ void MainWindow::SetDefaultLayout()
|
||||
curve_panel_->setFloating(true);
|
||||
|
||||
resizeDocks({node_panel_, param_panel_, viewer_panel_},
|
||||
{width()/3, width()/3, width()/3},
|
||||
{width()/3, width()/3, width()/3},
|
||||
Qt::Horizontal);
|
||||
|
||||
resizeDocks({project_panel_, tool_panel_, timeline_panel_, audio_monitor_panel_},
|
||||
{width()/4, 1, width(), 1},
|
||||
{width()/4, 1, width(), 1},
|
||||
Qt::Horizontal);
|
||||
|
||||
resizeDocks({node_panel_, project_panel_},
|
||||
{height()/2, height()/2},
|
||||
{height()/2, height()/2},
|
||||
Qt::Vertical);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user