[vlmc-devel] commit: UndoStack: Support for translation. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Mon Oct 11 00:07:24 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Mon Oct 11 00:04:01 2010 +0200| [fee19b53ff685f38ff4e4a10757f49011263b15e] | committer: Hugo Beauzée-Luyssen
UndoStack: Support for translation.
However, this doesn't work, as command seems not to be translated...
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=fee19b53ff685f38ff4e4a10757f49011263b15e
---
src/Commands/Commands.cpp | 4 ++++
src/Commands/Commands.h | 2 +-
src/Gui/UndoStack.cpp | 18 ++++++++++++++++++
src/Gui/UndoStack.h | 4 ++++
4 files changed, 27 insertions(+), 1 deletions(-)
diff --git a/src/Commands/Commands.cpp b/src/Commands/Commands.cpp
index 3fca835..af9c1b4 100644
--- a/src/Commands/Commands.cpp
+++ b/src/Commands/Commands.cpp
@@ -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
diff --git a/src/Commands/Commands.h b/src/Commands/Commands.h
index 1fcf269..596b9b3 100644
--- a/src/Commands/Commands.h
+++ b/src/Commands/Commands.h
@@ -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();
diff --git a/src/Gui/UndoStack.cpp b/src/Gui/UndoStack.cpp
index 4c15b42..21adddb 100644
--- a/src/Gui/UndoStack.cpp
+++ b/src/Gui/UndoStack.cpp
@@ -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;
+ }
+}
diff --git a/src/Gui/UndoStack.h b/src/Gui/UndoStack.h
index 865be30..ed49a6d 100644
--- a/src/Gui/UndoStack.h
+++ b/src/Gui/UndoStack.h
@@ -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>;
};
More information about the Vlmc-devel
mailing list