Commit 11a1217d authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Remove UndoStack.

We now use plain Qt types QUndoStack & QUndoView. Other components are
comsuming the regular QUndoStack
parent 6fd5068c
......@@ -112,7 +112,6 @@ ELSE(NOT WITH_GUI)
Gui/IntroDialog.cpp
Gui/LanguageHelper.cpp
Gui/MainWindow.cpp
Gui/UndoStack.cpp
Gui/WorkflowFileRendererDialog.cpp
Gui/effectsengine/EffectInstanceWidget.cpp
Gui/effectsengine/EffectInstanceListModel.cpp
......
......@@ -31,21 +31,11 @@
#include "EffectsEngine/EffectInstance.h"
#include "Workflow/TrackWorkflow.h"
#ifdef WITH_GUI
# include "Gui/UndoStack.h"
void
Commands::trigger( QUndoCommand* command )
{
Project::getInstance()->undoStack()->push( command );
}
#else
void
Commands::trigger( Commands::Generic* command )
{
command->redo();
}
#endif
Commands::Generic::Generic() :
m_valid( true )
......
......@@ -29,6 +29,8 @@
#include <QSlider>
#include <QMessageBox>
#include <QDesktopServices>
#include <QUndoView>
#include <QUndoStack>
#include <QUrl>
#include <QNetworkProxy>
#include <QSettings>
......@@ -51,7 +53,6 @@
#include "WorkflowFileRendererDialog.h"
#include "export/RendererSettings.h"
#include "export/ShareOnInternet.h"
#include "UndoStack.h"
/* Widgets */
#include "DockWidgetManager.h"
......@@ -69,6 +70,7 @@
#include "settings/Settings.h"
#include "Settings/SettingsManager.h"
#include "LanguageHelper.h"
#include "Commands/KeyboardShortcutHelper.h"
MainWindow::MainWindow( Backend::IBackend* backend, QWidget *parent ) :
QMainWindow( parent ), m_backend( backend ), m_fileRenderer( NULL )
......@@ -465,8 +467,8 @@ MainWindow::setupUndoRedoWidget()
QT_TRANSLATE_NOOP( "DockWidgetManager", "History" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures );
// FIXME: This will break undo stack layout, though we need to split the UI part form the actual stack
QWidget *undoRedoWidget = Project::getInstance()->undoStack();
QWidget *undoRedoWidget = new QUndoView( Project::getInstance()->undoStack(), dockedWidget );
DockWidgetManager::getInstance()->addDockedWidget( dockedWidget, undoRedoWidget, Qt::TopDockWidgetArea );
}
......
/*****************************************************************************
* UndoStack.cpp: UndoStack For Undo/Redo Purposes
*****************************************************************************
* Copyright (C) 2008-2014 VideoLAN
*
* Authors: Christophe Courtaut <christophe.courtaut@gmail.com>
* Hugo Beauzée-Luyssen <hugo@beauzee.fr>
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include "UndoStack.h"
#include "Commands/Commands.h"
#include "project/GuiProjectManager.h"
#include "Settings/SettingsManager.h"
#include <QEvent>
#include <QUndoStack>
#include <QUndoCommand>
UndoStack::UndoStack( QWidget *parent ) : QUndoView( parent )
{
setEmptyLabel( tr( "Nothing to undo" ) );
m_undoStack = new QUndoStack( this );
setStack( m_undoStack );
connect( m_undoStack, SIGNAL( cleanChanged( bool ) ),
GUIProjectManager::getInstance(), SLOT( cleanChanged( bool ) ) );
connect( GUIProjectManager::getInstance(), SIGNAL( projectSaved() ),
m_undoStack, SLOT( setClean() ) );
connect( m_undoStack, SIGNAL( canRedoChanged( bool ) ), this, SIGNAL( canRedoChanged( bool ) ) );
connect( m_undoStack, SIGNAL( canUndoChanged( bool ) ), this, SIGNAL( canUndoChanged( bool ) ) );
connect( GUIProjectManager::getInstance(), SIGNAL( projectClosed() ), this, SLOT( clear() ) );
}
void
UndoStack::push( QUndoCommand *command )
{
m_undoStack->push( command );
}
void
UndoStack::beginMacro( const QString& text )
{
m_undoStack->beginMacro( text );
}
void
UndoStack::endMacro()
{
m_undoStack->endMacro();
}
bool
UndoStack::canUndo()
{
return m_undoStack->canUndo();
}
bool
UndoStack::canRedo()
{
return m_undoStack->canRedo();
}
void
UndoStack::clear()
{
m_undoStack->clear();
}
void
UndoStack::undo()
{
m_undoStack->undo();
}
void
UndoStack::redo()
{
m_undoStack->redo();
}
void
UndoStack::changeEvent( QEvent *event )
{
switch ( event->type() )
{
case QEvent::LanguageChange:
setEmptyLabel( tr( "Nothing to undo" ) );
emit retranslateRequired();
update( rootIndex() );
break;
default:
break;
}
}
/*****************************************************************************
* UndoStack.h: UndoStack For Undo/Redo Purposes
*****************************************************************************
* Copyright (C) 2008-2014 VideoLAN
*
* Authors: Christophe Courtaut <christophe.courtaut@gmail.com>
*
* 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 2
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifndef UNDOSTACK_H
#define UNDOSTACK_H
#include <QUndoView>
#include "Commands/KeyboardShortcutHelper.h"
class QUndoStack;
class QUndoCommand;
class UndoStack : public QUndoView
{
Q_OBJECT
Q_DISABLE_COPY( UndoStack );
public:
UndoStack( QWidget* parent );
void push( QUndoCommand *command );
void beginMacro( const QString &text );
void endMacro();
bool canUndo();
bool canRedo();
protected:
void changeEvent( QEvent *event );
private:
QUndoStack* m_undoStack;
public slots:
void clear();
void undo();
void redo();
signals:
void cleanChanged( bool val );
void canRedoChanged( bool canRedo );
void canUndoChanged( bool canUndo );
void retranslateRequired();
};
#endif // UNDOSTACK_H
......@@ -35,6 +35,7 @@
#include <QFileDialog>
#include <QMessageBox>
#include <QTimer>
#include <QUndoStack>
GUIProjectManager::GUIProjectManager()
{
......@@ -67,6 +68,11 @@ GUIProjectManager::GUIProjectManager()
Core::getInstance()->settings()->watchValue( "vlmc/ProjectName", this,
SLOT(projectNameChanged(QVariant) ),
SettingsManager::Project );
connect( Project::getInstance()->undoStack(), SIGNAL( cleanChanged( bool ) ),
this, SLOT( cleanChanged( bool ) ) );
connect( this, SIGNAL( projectSaved() ),
Project::getInstance()->undoStack(), SLOT( setClean() ) );
}
bool
......@@ -172,6 +178,7 @@ GUIProjectManager::closeProject()
return false;
bool ret = ProjectManager::closeProject();
//This one is for the mainwindow, to update the title bar
Project::getInstance()->undoStack()->clear();
emit projectUpdated( projectName(), true );
return ret;
}
......
......@@ -32,7 +32,6 @@
#include "Settings/SettingsManager.h"
#include "Timeline.h"
#include "Workflow/TrackWorkflow.h"
#include "UndoStack.h"
#include <QMessageBox>
#include <QKeyEvent>
......
......@@ -42,7 +42,6 @@
#include "TracksRuler.h"
//} this should be fixed, it breaks the design
#include "Workflow/TrackWorkflow.h"
#include "Gui/UndoStack.h"
#include "Tools/VlmcDebug.h"
#include "Renderer/WorkflowRenderer.h"
......
......@@ -22,16 +22,17 @@
#include "Project.h"
#include <QUndoStack>
#include "Library/Library.h"
#include "Workflow/MainWorkflow.h"
#include "Gui/UndoStack.h"
#include "Project/Workspace.h"
Project::Project()
{
m_library = new Library;
m_workflow = new MainWorkflow;
m_undoStack = new UndoStack( NULL );
m_undoStack = new QUndoStack();
m_workspace = new Workspace;
}
......@@ -55,7 +56,7 @@ Project::workflow()
return m_workflow;
}
UndoStack*
QUndoStack*
Project::undoStack()
{
return m_undoStack;
......
......@@ -25,8 +25,9 @@
#include "Tools/Singleton.hpp"
class QUndoStack;
class Library;
class UndoStack;
class MainWorkflow;
class Workspace;
......@@ -40,13 +41,13 @@ public:
// Insert settings here
Library* library();
MainWorkflow* workflow();
UndoStack* undoStack();
QUndoStack* undoStack();
Workspace* workspace();
private:
Library* m_library;
MainWorkflow* m_workflow;
UndoStack* m_undoStack;
QUndoStack* m_undoStack;
Workspace* m_workspace;
friend class Singleton<Project>;
......
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