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

UndoStack: Support for translation.

However, this doesn't work, as command seems not to be translated...
parent 16bc2b9d
......@@ -49,6 +49,10 @@ void Commands::trigger( Commands::Generic* command )
Commands::Generic::Generic() :
m_valid( true )
{
//This is connected using a direct connection to ensure the view can be refreshed
//just after the signal has been emited.
connect( UndoStack::getInstance(), SIGNAL( retranslateRequired() ),
this, SLOT( retranslate() ), Qt::DirectConnection );
}
void
......
......@@ -53,13 +53,13 @@ namespace Commands
Generic();
virtual void internalRedo() = 0;
virtual void internalUndo() = 0;
virtual void retranslate() = 0;
void redo();
void undo();
bool isValid() const;
private:
bool m_valid;
protected slots:
virtual void retranslate() = 0;
void invalidate();
signals:
void invalidated();
......
......@@ -22,9 +22,12 @@
*****************************************************************************/
#include "UndoStack.h"
#include "Commands.h"
#include "project/GuiProjectManager.h"
#include "SettingsManager.h"
#include <QEvent>
#include <QUndoStack>
#include <QUndoCommand>
......@@ -92,3 +95,18 @@ 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;
}
}
......@@ -43,6 +43,9 @@ class UndoStack : public QUndoView, public QSingleton<UndoStack>
bool canUndo();
bool canRedo();
protected:
void changeEvent( QEvent *event );
private:
UndoStack( QWidget* parent );
......@@ -57,6 +60,7 @@ class UndoStack : public QUndoView, public QSingleton<UndoStack>
void cleanChanged( bool val );
void canRedoChanged( bool canRedo );
void canUndoChanged( bool canUndo );
void retranslateRequired();
friend class QSingleton<UndoStack>;
};
......
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