[vlmc-devel] commit: Fix dock titles retranslation (Ludovic Fauvet )
git at videolan.org
git at videolan.org
Tue Apr 13 13:38:03 CEST 2010
vlmc | branch: master | Ludovic Fauvet <etix at l0cal.com> | Tue Apr 13 13:28:40 2010 +0200| [7afea915940b89f7a6c682217b38aafa4cf4cb0a] | committer: Ludovic Fauvet
Fix dock titles retranslation
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=7afea915940b89f7a6c682217b38aafa4cf4cb0a
---
src/Gui/DockWidgetManager.cpp | 17 ++++++++++++++---
src/Gui/DockWidgetManager.h | 5 +++--
src/Gui/MainWindow.cpp | 10 ++++++----
3 files changed, 23 insertions(+), 9 deletions(-)
diff --git a/src/Gui/DockWidgetManager.cpp b/src/Gui/DockWidgetManager.cpp
index bf80281..fcd04b4 100644
--- a/src/Gui/DockWidgetManager.cpp
+++ b/src/Gui/DockWidgetManager.cpp
@@ -22,6 +22,7 @@
#include <QtDebug>
#include <QApplication>
#include <QMap>
+#include <QMapIterator>
#include <QDockWidget>
#include "DockWidgetManager.h"
@@ -51,7 +52,7 @@ void DockWidgetManager::setMainWindow( MainWindow *mainWin )
}
QDockWidget* DockWidgetManager::addDockedWidget( QWidget *widget,
- const QString &qs_name,
+ const char *qs_name,
Qt::DockWidgetAreas areas,
QDockWidget::DockWidgetFeature features,
Qt::DockWidgetArea startArea)
@@ -59,15 +60,25 @@ QDockWidget* DockWidgetManager::addDockedWidget( QWidget *widget,
if ( m_dockWidgets.contains( qs_name ) )
return 0;
- QDockWidget* dock = new QDockWidget( qs_name, m_mainWin );
+ QDockWidget* dock = new QDockWidget( tr( qs_name ), m_mainWin );
m_dockWidgets.insert( qs_name, dock );
dock->setWidget( widget );
dock->setAllowedAreas( areas );
dock->setFeatures( features );
- dock->setObjectName( qs_name );
m_mainWin->addDockWidget( startArea, dock );
m_mainWin->registerWidgetInWindowMenu( dock );
widget->show();
return dock;
}
+
+void DockWidgetManager::retranslateUi()
+{
+ QMapIterator<const char*, QDockWidget*> i( m_dockWidgets );
+
+ while ( i.hasNext() )
+ {
+ i.next();
+ i.value()->setWindowTitle( tr( i.key() ) );
+ }
+}
diff --git a/src/Gui/DockWidgetManager.h b/src/Gui/DockWidgetManager.h
index 8c75d66..dfbde78 100644
--- a/src/Gui/DockWidgetManager.h
+++ b/src/Gui/DockWidgetManager.h
@@ -41,10 +41,11 @@ class DockWidgetManager : public QObject, public QSingleton<DockWidgetManager>
static DockWidgetManager *instance( QObject *parent = 0 );
void setMainWindow( MainWindow *mainWin );
QDockWidget* addDockedWidget( QWidget *widget,
- const QString &qs_name,
+ const char *qs_name,
Qt::DockWidgetAreas areas,
QDockWidget::DockWidgetFeature features,
Qt::DockWidgetArea startArea );
+ void retranslateUi();
private:
explicit DockWidgetManager( QObject *parent = 0 );
@@ -53,7 +54,7 @@ class DockWidgetManager : public QObject, public QSingleton<DockWidgetManager>
DockWidgetManager & operator = ( const DockWidgetManager & );
MainWindow *m_mainWin;
- QMap<QString, QDockWidget*> m_dockWidgets;
+ QMap<const char*, QDockWidget*> m_dockWidgets;
friend class QSingleton<DockWidgetManager>;
};
diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index 21ca849..e66e0b0 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -156,6 +156,8 @@ void MainWindow::changeEvent( QEvent *e )
{
case QEvent::LanguageChange:
m_ui.retranslateUi( this );
+ DockWidgetManager::getInstance()->retranslateUi();
+ qDebug() << "Retranslation";
break;
default:
break;
@@ -241,7 +243,7 @@ MainWindow::setupLibrary()
const ClipRenderer* clipRenderer = qobject_cast<const ClipRenderer*>( m_clipPreview->getGenericRenderer() );
Q_ASSERT( clipRenderer != NULL );
- DockWidgetManager::getInstance()->addDockedWidget( libraryWidget, tr( "Media Library" ),
+ DockWidgetManager::getInstance()->addDockedWidget( libraryWidget, QT_TRANSLATE_NOOP( "DockWidgetManager", "Media Library" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea );
@@ -346,7 +348,7 @@ void MainWindow::initializeDockWidgets( void )
m_clipPreview = new PreviewWidget( new ClipRenderer, this );
dockManager->addDockedWidget( m_clipPreview,
- tr( "Clip Preview" ),
+ QT_TRANSLATE_NOOP( "DockWidgetManager", "Clip Preview" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea );
@@ -355,7 +357,7 @@ void MainWindow::initializeDockWidgets( void )
m_projectPreview = new PreviewWidget( m_renderer, this );
dockManager->addDockedWidget( m_projectPreview,
- tr( "Project Preview" ),
+ QT_TRANSLATE_NOOP( "DockWidgetManager", "Project Preview" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::TopDockWidgetArea );
@@ -363,7 +365,7 @@ void MainWindow::initializeDockWidgets( void )
connect( renderShortcut, SIGNAL( activated() ), m_projectPreview, SLOT( on_pushButtonPlay_clicked() ) );
QDockWidget* dock = dockManager->addDockedWidget( UndoStack::getInstance( this ),
- tr( "History" ),
+ QT_TRANSLATE_NOOP( "DockWidgetManager", "History" ),
Qt::AllDockWidgetAreas,
QDockWidget::AllDockWidgetFeatures,
Qt::LeftDockWidgetArea );
More information about the Vlmc-devel
mailing list