Commit f92be62a authored by Clement CHAVANCE's avatar Clement CHAVANCE

Docked widget titles are now translated

parent 540fedc1
/***************************************************************************** /*****************************************************************************
* main.cpp: VLMC main * DockWidgetManager.cpp: Object managing the application docked widget
***************************************************************************** *****************************************************************************
* Copyright (C) 2008-2009 the VLMC team * Copyright (C) 2008-2009 the VLMC team
* *
...@@ -19,15 +19,18 @@ ...@@ -19,15 +19,18 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
#include <QtDebug>
#include <QApplication>
#include <QMap>
#include "DockWidgetManager.h" #include "DockWidgetManager.h"
DockWidgetManager *DockWidgetManager::m_instance = 0; DockWidgetManager *DockWidgetManager::m_instance = 0;
DockWidgetManager *DockWidgetManager::instance() DockWidgetManager *DockWidgetManager::instance( QObject *parent )
{ {
if (m_instance == 0) if (m_instance == 0)
m_instance = new DockWidgetManager(); m_instance = new DockWidgetManager( parent );
return (m_instance); return (m_instance);
} }
...@@ -43,8 +46,12 @@ void DockWidgetManager::addDockedWidget( QWidget *widget, ...@@ -43,8 +46,12 @@ void DockWidgetManager::addDockedWidget( QWidget *widget,
QDockWidget::DockWidgetFeature features, QDockWidget::DockWidgetFeature features,
Qt::DockWidgetArea startArea) Qt::DockWidgetArea startArea)
{ {
if ( m_dockWidgets.contains( qs_name ) )
return ;
QDockWidget* dock = new QDockWidget( tr( qs_name.toStdString().c_str() ), m_mainWin ); QDockWidget* dock = new QDockWidget( tr( qs_name.toStdString().c_str() ), m_mainWin );
m_dockWidgets.insert(qs_name, dock);
dock->setWidget( widget ); dock->setWidget( widget );
dock->setAllowedAreas( areas ); dock->setAllowedAreas( areas );
dock->setFeatures( features ); dock->setFeatures( features );
...@@ -52,6 +59,36 @@ void DockWidgetManager::addDockedWidget( QWidget *widget, ...@@ -52,6 +59,36 @@ void DockWidgetManager::addDockedWidget( QWidget *widget,
widget->show(); widget->show();
} }
DockWidgetManager::DockWidgetManager()
DockWidgetManager::DockWidgetManager( QObject *parent )
: QObject( parent )
{
QObject::connect( qApp,
SIGNAL( aboutToQuit() ),
this,
SLOT( deleteLater() ) );
}
DockWidgetManager::~DockWidgetManager()
{ {
QList<QDockWidget*> widgets = m_dockWidgets.values();
QDockWidget* widget;
foreach(widget, widgets)
{
delete widget;
}
}
void DockWidgetManager::transLateWidgetTitle()
{
QMap<QString, QDockWidget*>::iterator ed = m_dockWidgets.end();
QMap<QString, QDockWidget*>::iterator it;
for ( it = m_dockWidgets.begin() ; it != ed ; ++it )
{
QDockWidget *widget = it.value();
widget->setWindowTitle( QApplication::translate( "MainWindow",
it.key().toStdString().c_str() ) );
}
} }
/***************************************************************************** /*****************************************************************************
* main.cpp: VLMC main * DockWidgetManager.h: Object managing the application docked widget
***************************************************************************** *****************************************************************************
* Copyright (C) 2008-2009 the VLMC team * Copyright (C) 2008-2009 the VLMC team
* *
...@@ -28,13 +28,14 @@ ...@@ -28,13 +28,14 @@
#include <QWidget> #include <QWidget>
#include <QDockWidget> #include <QDockWidget>
#include <QString> #include <QString>
#include <QMap>
class DockWidgetManager : public QObject class DockWidgetManager : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
static DockWidgetManager *instance(); static DockWidgetManager *instance( QObject *parent = 0 );
void setMainWindow( QMainWindow *mainWin ); void setMainWindow( QMainWindow *mainWin );
void addDockedWidget( QWidget *widget, void addDockedWidget( QWidget *widget,
const QString &qs_name, const QString &qs_name,
...@@ -42,13 +43,21 @@ class DockWidgetManager : public QObject ...@@ -42,13 +43,21 @@ class DockWidgetManager : public QObject
QDockWidget::DockWidgetFeature features, QDockWidget::DockWidgetFeature features,
Qt::DockWidgetArea startArea ); Qt::DockWidgetArea startArea );
protected:
//virtual void changeEvent( QEvent *e );
private: private:
explicit DockWidgetManager(); explicit DockWidgetManager( QObject *parent = 0 );
virtual ~DockWidgetManager() { delete m_instance; } virtual ~DockWidgetManager();
DockWidgetManager(const DockWidgetManager &); DockWidgetManager(const DockWidgetManager &);
DockWidgetManager & operator = ( const DockWidgetManager & ); DockWidgetManager & operator = ( const DockWidgetManager & );
QMainWindow *m_mainWin; QMainWindow *m_mainWin;
QMap<QString, QDockWidget*> m_dockWidgets;
static DockWidgetManager *m_instance; static DockWidgetManager *m_instance;
public slots:
void transLateWidgetTitle();
}; };
#endif #endif
...@@ -32,8 +32,13 @@ MainWindow::MainWindow( QWidget *parent ) : ...@@ -32,8 +32,13 @@ MainWindow::MainWindow( QWidget *parent ) :
QMainWindow( parent ) QMainWindow( parent )
{ {
m_ui.setupUi( this ); m_ui.setupUi( this );
DockWidgetManager::instance()->setMainWindow( this ); DockWidgetManager::instance( this )->setMainWindow( this );
m_initializeDockWidgets(); m_initializeDockWidgets();
QObject::connect( this,
SIGNAL( translateDockWidgetTitle() ),
DockWidgetManager::instance(),
SLOT(transLateWidgetTitle() ) );
} }
void MainWindow::changeEvent( QEvent *e ) void MainWindow::changeEvent( QEvent *e )
...@@ -42,6 +47,7 @@ void MainWindow::changeEvent( QEvent *e ) ...@@ -42,6 +47,7 @@ void MainWindow::changeEvent( QEvent *e )
{ {
case QEvent::LanguageChange: case QEvent::LanguageChange:
m_ui.retranslateUi( this ); m_ui.retranslateUi( this );
emit translateDockWidgetTitle();
break; break;
default: default:
break; break;
......
...@@ -50,9 +50,11 @@ private: ...@@ -50,9 +50,11 @@ private:
private slots: private slots:
void on_actionQuit_triggered(); void on_actionQuit_triggered();
void on_actionAbout_triggered(); void on_actionAbout_triggered();
void on_actionPreferences_triggered(); void on_actionPreferences_triggered();
}
; signals:
void translateDockWidgetTitle();
};
#endif // MAINWINDOW_H #endif // MAINWINDOW_H
...@@ -2,65 +2,98 @@ ...@@ -2,65 +2,98 @@
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.0" language="es" sourcelanguage="en"> <TS version="2.0" language="es" sourcelanguage="en">
<defaultcodec>UTF-8</defaultcodec> <defaultcodec>UTF-8</defaultcodec>
<context>
<name>About</name>
<message>
<location filename="../src/gui/ui/About.ui" line="20"/>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/gui/ui/About.ui" line="48"/>
<source>VideoLAN Movie Creator</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/gui/ui/About.ui" line="59"/>
<source>About</source>
<translation type="unfinished">A propósito de</translation>
</message>
<message>
<location filename="../src/gui/ui/About.ui" line="65"/>
<source>Authors</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/gui/ui/About.ui" line="79"/>
<source>Translators</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/gui/ui/About.ui" line="93"/>
<source>License</source>
<translation type="unfinished"></translation>
</message>
</context>
<context> <context>
<name>LibraryWidget</name> <name>LibraryWidget</name>
<message> <message>
<location filename="src/gui/LibraryWidget.cpp" line="99"/> <location filename="../src/gui/LibraryWidget.cpp" line="109"/>
<source>Open Audios</source> <source>Open Audios</source>
<translation>Abrir un sonido</translation> <translation>Abrir un sonido</translation>
</message> </message>
<message> <message>
<location filename="src/gui/LibraryWidget.cpp" line="100"/> <location filename="../src/gui/LibraryWidget.cpp" line="110"/>
<source>Audio Files</source> <source>Audio Files</source>
<translation>archivo de audio</translation> <translation>archivo de audio</translation>
</message> </message>
<message> <message>
<location filename="src/gui/LibraryWidget.cpp" line="105"/> <location filename="../src/gui/LibraryWidget.cpp" line="115"/>
<source>Video Files</source> <source>Video Files</source>
<translation>archivo de vídeo</translation> <translation>archivo de vídeo</translation>
</message> </message>
<message> <message>
<location filename="src/gui/LibraryWidget.cpp" line="110"/> <location filename="../src/gui/LibraryWidget.cpp" line="120"/>
<source>Images Files</source> <source>Images Files</source>
<translation>Imágenes</translation> <translation>Imágenes</translation>
</message> </message>
<message> <message>
<location filename="src/gui/LibraryWidget.cpp" line="104"/> <location filename="../src/gui/LibraryWidget.cpp" line="114"/>
<source>Open Videos</source> <source>Open Videos</source>
<translation>Abrir un archivo de vídeo</translation> <translation>Abrir un archivo de vídeo</translation>
</message> </message>
<message> <message>
<location filename="src/gui/LibraryWidget.cpp" line="109"/> <location filename="../src/gui/LibraryWidget.cpp" line="119"/>
<source>Open Images</source> <source>Open Images</source>
<translation>Abrir una imagen</translation> <translation>Abrir una imagen</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/LibraryWidget.ui" line="14"/> <location filename="../src/gui/ui/LibraryWidget.ui" line="14"/>
<source>Form</source> <source>Form</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/LibraryWidget.ui" line="33"/> <location filename="../src/gui/ui/LibraryWidget.ui" line="33"/>
<source>Audio</source> <source>Audio</source>
<translation>Audio</translation> <translation>Audio</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/LibraryWidget.ui" line="59"/> <location filename="../src/gui/ui/LibraryWidget.ui" line="59"/>
<source>Videos</source> <source>Videos</source>
<translation>Vídeos</translation> <translation>Vídeos</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/LibraryWidget.ui" line="85"/> <location filename="../src/gui/ui/LibraryWidget.ui" line="85"/>
<source>Images</source> <source>Images</source>
<translation>Imágenes</translation> <translation>Imágenes</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/LibraryWidget.ui" line="114"/> <location filename="../src/gui/ui/LibraryWidget.ui" line="114"/>
<source>Add Media</source> <source>Add Media</source>
<translation>añadir media</translation> <translation>añadir media</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/LibraryWidget.ui" line="130"/> <location filename="../src/gui/ui/LibraryWidget.ui" line="130"/>
<source>Remove Media</source> <source>Remove Media</source>
<translation>suprimir media</translation> <translation>suprimir media</translation>
</message> </message>
...@@ -68,68 +101,68 @@ ...@@ -68,68 +101,68 @@
<context> <context>
<name>MainWindow</name> <name>MainWindow</name>
<message> <message>
<location filename="src/gui/MainWindow.cpp" line="61"/> <location filename="../src/gui/MainWindow.cpp" line="67"/>
<source>Media Library</source> <source>Media Library</source>
<translation type="unfinished">Biblioteca multimedia</translation> <translation type="unfinished">Biblioteca multimedia</translation>
</message> </message>
<message> <message>
<location filename="src/gui/MainWindow.cpp" line="67"/> <location filename="../src/gui/MainWindow.cpp" line="73"/>
<source>Preview</source> <source>Preview</source>
<translation type="unfinished">Vista previa</translation> <translation type="unfinished">Vista previa</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/MainWindow.ui" line="14"/> <location filename="../src/gui/ui/MainWindow.ui" line="14"/>
<source>VideoLAN Movie Creator</source> <source>VideoLAN Movie Creator</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/MainWindow.ui" line="31"/> <location filename="../src/gui/ui/MainWindow.ui" line="35"/>
<source>File</source> <source>File</source>
<translation>Archivo</translation> <translation>Archivo</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/MainWindow.ui" line="37"/> <location filename="../src/gui/ui/MainWindow.ui" line="41"/>
<source>Edit</source> <source>Edit</source>
<translation>Edición</translation> <translation>Edición</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/MainWindow.ui" line="43"/> <location filename="../src/gui/ui/MainWindow.ui" line="47"/>
<source>View</source> <source>View</source>
<translation type="unfinished">Vista</translation> <translation type="unfinished">Vista</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/MainWindow.ui" line="48"/> <location filename="../src/gui/ui/MainWindow.ui" line="52"/>
<source>Effects</source> <source>Effects</source>
<translation>Efectos</translation> <translation>Efectos</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/MainWindow.ui" line="53"/> <location filename="../src/gui/ui/MainWindow.ui" line="57"/>
<source>Tools</source> <source>Tools</source>
<translation type="unfinished">Herramientas</translation> <translation type="unfinished">Herramientas</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/MainWindow.ui" line="58"/> <location filename="../src/gui/ui/MainWindow.ui" line="62"/>
<source>Window</source> <source>Window</source>
<translation type="unfinished">Ventana</translation> <translation type="unfinished">Ventana</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/MainWindow.ui" line="63"/> <location filename="../src/gui/ui/MainWindow.ui" line="67"/>
<location filename="src/gui/ui/MainWindow.ui" line="90"/> <location filename="../src/gui/ui/MainWindow.ui" line="94"/>
<source>Help</source> <source>Help</source>
<translation>Ayuda</translation> <translation>Ayuda</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/MainWindow.ui" line="80"/> <location filename="../src/gui/ui/MainWindow.ui" line="84"/>
<source>Quit</source> <source>Quit</source>
<translation>Salir</translation> <translation>Salir</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/MainWindow.ui" line="85"/> <location filename="../src/gui/ui/MainWindow.ui" line="89"/>
<source>About</source> <source>About</source>
<translation>A propósito de</translation> <translation>A propósito de</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/MainWindow.ui" line="95"/> <location filename="../src/gui/ui/MainWindow.ui" line="99"/>
<source>Preferences</source> <source>Preferences</source>
<translation>Preferencias</translation> <translation>Preferencias</translation>
</message> </message>
...@@ -137,50 +170,55 @@ ...@@ -137,50 +170,55 @@
<context> <context>
<name>Preferences</name> <name>Preferences</name>
<message> <message>
<location filename="src/gui/ui/Preferences.ui" line="17"/> <location filename="../src/gui/ui/Preferences.ui" line="14"/>
<source>Preferences</source> <source>Preferences</source>
<translation type="unfinished">Preferencias</translation> <translation type="unfinished">Preferencias</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/Preferences.ui" line="30"/> <location filename="../src/gui/ui/Preferences.ui" line="27"/>
<source>General</source> <source>General</source>
<translation type="unfinished">General</translation> <translation type="unfinished">General</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/Preferences.ui" line="42"/> <location filename="../src/gui/ui/Preferences.ui" line="39"/>
<source>Language</source> <source>Language</source>
<translation type="unfinished">Idioma</translation> <translation type="unfinished">Idioma</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/Preferences.ui" line="74"/> <location filename="../src/gui/ui/Preferences.ui" line="71"/>
<source>Apply</source> <source>Apply</source>
<translation type="unfinished">Aplicar</translation> <translation type="unfinished">Aplicar</translation>
</message> </message>
<message> <message>
<location filename="src/gui/ui/Preferences.ui" line="81"/> <location filename="../src/gui/ui/Preferences.ui" line="78"/>
<source>Cancel</source> <source>Cancel</source>
<translation type="unfinished">Cancelar</translation> <translation type="unfinished">Cancelar</translation>
</message> </message>
<message> <message>
<location filename="src/gui/Preferences.cpp" line="9"/> <location filename="../src/gui/Preferences.cpp" line="32"/>
<source>English</source> <source>English</source>
<translation>Inglés</translation> <translation>Inglés</translation>
</message> </message>
<message> <message>
<location filename="src/gui/Preferences.cpp" line="10"/> <location filename="../src/gui/Preferences.cpp" line="33"/>
<source>French</source> <source>French</source>
<translation>Francés</translation> <translation>Francés</translation>
</message> </message>
<message> <message>
<location filename="src/gui/Preferences.cpp" line="11"/> <location filename="../src/gui/Preferences.cpp" line="34"/>
<source>Spanish</source> <source>Spanish</source>
<translation>Español</translation> <translation>Español</translation>
</message> </message>
<message>
<location filename="../src/gui/Preferences.cpp" line="35"/>
<source>Swedish</source>
<translation type="unfinished"></translation>
</message>
</context> </context>
<context> <context>
<name>PreviewWidget</name> <name>PreviewWidget</name>
<message> <message>
<location filename="src/gui/ui/PreviewWidget.ui" line="17"/> <location filename="../src/gui/ui/PreviewWidget.ui" line="17"/>
<source>Dialog</source> <source>Dialog</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
...@@ -188,7 +226,7 @@ ...@@ -188,7 +226,7 @@
<context> <context>
<name>Timeline</name> <name>Timeline</name>
<message> <message>
<location filename="src/gui/ui/Timeline.ui" line="20"/> <location filename="../src/gui/ui/Timeline.ui" line="20"/>
<source>Form</source> <source>Form</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
......
...@@ -2,65 +2,98 @@ ...@@ -2,65 +2,98 @@
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.0" language="fr" sourcelanguage="en"> <TS version="2.0" language="fr" sourcelanguage="en">
<defaultcodec>UTF-8</defaultcodec> <defaultcodec>UTF-8</defaultcodec>
<context>
<name>About</name>
<message>
<location filename="../src/gui/ui/About.ui" line="20"/>
<source>Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../src/gui/ui/About.ui" line="48"/>
<source>VideoLAN Movie Creator</source>
<translation type="unfinished"></translation>
</message>