Commit 328188cf authored by Ludovic Fauvet's avatar Ludovic Fauvet

Undo/redo now works even if the history dock is closed.

parent 9003b2d2
......@@ -459,6 +459,16 @@ void MainWindow::on_actionClose_Project_triggered()
ProjectManager::getInstance()->closeProject();
}
void MainWindow::on_actionUndo_triggered()
{
UndoStack::getInstance( this )->undo();
}
void MainWindow::on_actionRedo_triggered()
{
UndoStack::getInstance( this )->redo();
}
#define INIT_SHORTCUT( instName, shortcutName, actionInstance ) \
const SettingValue* instName = SettingsManager::getInstance()->getValue( "keyboard_shortcut", shortcutName );\
KeyboardShortcutHelper* helper##instName = new KeyboardShortcutHelper( shortcutName, this, true ); \
......@@ -478,6 +488,8 @@ void MainWindow::initializeMenuKeyboardShortcut()
INIT_SHORTCUT( closeProject, "Close project", actionClose_Project );
INIT_SHORTCUT( importProject, "Import media", actionImport );
INIT_SHORTCUT( renderProject, "Render project", actionRender );
INIT_SHORTCUT( undo, "Undo", actionUndo );
INIT_SHORTCUT( redo, "Redo", actionRedo );
}
#undef INIT_SHORTCUT
......@@ -507,6 +519,10 @@ void MainWindow::keyboardShortcutChanged( const QString& name, const QString&
m_ui.actionImport->setShortcut( val );
else if ( name == "Render project" )
m_ui.actionRender->setShortcut( val );
else if ( name == "Undo" )
m_ui.actionUndo->setShortcut( val );
else if ( name == "Redo" )
m_ui.actionRedo->setShortcut( val );
else
qWarning() << "Unknown shortcut:" << name;
}
......
......@@ -102,6 +102,8 @@ private slots:
void on_actionHelp_triggered();
void on_actionProject_Preferences_triggered();
void on_actionClose_Project_triggered();
void on_actionUndo_triggered();
void on_actionRedo_triggered();
void on_actionCrash_triggered();
void on_actionImport_triggered();
void toolButtonClicked( int id );
......
......@@ -40,11 +40,6 @@ UndoStack::UndoStack( QWidget* parent ) : QUndoView( parent )
connect( ProjectManager::getInstance(), SIGNAL( projectSaved() ),
m_undoStack, SLOT( setClean() ) );
m_undoShortcut = new KeyboardShortcutHelper( "Undo", this );
m_redoShortcut = new KeyboardShortcutHelper( "Redo", this );
connect( m_undoShortcut, SIGNAL( activated() ), m_undoStack, SLOT( undo() ) );
connect( m_redoShortcut, SIGNAL( activated() ), m_undoStack, SLOT( redo() ) );
connect( ProjectManager::getInstance(), SIGNAL( projectClosed() ), this, SLOT( clear() ) );
}
......@@ -67,3 +62,13 @@ void UndoStack::clear()
{
m_undoStack->clear();
}
void UndoStack::undo()
{
m_undoStack->undo();
}
void UndoStack::redo()
{
m_undoStack->redo();
}
......@@ -45,11 +45,11 @@ class UndoStack : public QUndoView, public QSingleton<UndoStack>
UndoStack( QWidget* parent );
QUndoStack* m_undoStack;
KeyboardShortcutHelper* m_undoShortcut;
KeyboardShortcutHelper* m_redoShortcut;
public slots:
void clear();
void undo();
void redo();
signals:
void cleanChanged( bool val );
......
......@@ -50,6 +50,9 @@
<property name="title">
<string>Edit</string>
</property>
<addaction name="actionUndo"/>
<addaction name="actionRedo"/>
<addaction name="separator"/>
<addaction name="actionPreferences"/>
<addaction name="actionProject_Preferences"/>
</widget>
......@@ -217,6 +220,16 @@
<string>Crash</string>
</property>
</action>
<action name="actionUndo">
<property name="text">
<string>Undo</string>
</property>
</action>
<action name="actionRedo">
<property name="text">
<string>Redo</string>
</property>
</action>
</widget>
<resources>
<include location="../../../ressources.qrc"/>
......
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