[vlmc-devel] commit: Settings: Translate the side buttons text. ( Hugo Beauzée-Luyssen )

git at videolan.org git at videolan.org
Sat Oct 30 17:26:34 CEST 2010


vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Tue Oct 26 17:33:43 2010 +0200| [29b97c37da4adedf0eca8e2ff3a6cdc3bf64db20] | committer: Hugo Beauzée-Luyssen 

Settings: Translate the side buttons text.

> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=29b97c37da4adedf0eca8e2ff3a6cdc3bf64db20
---

 src/Gui/MainWindow.cpp        |   35 ++++++++++++++---------------------
 src/Gui/settings/Panel.cpp    |   20 +++++++++++++++++---
 src/Gui/settings/Panel.h      |   20 +++++++++++++-------
 src/Gui/settings/Settings.cpp |    6 +++---
 src/Gui/settings/Settings.h   |    3 +--
 5 files changed, 48 insertions(+), 36 deletions(-)

diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp
index ea3c2ac..a2d178c 100644
--- a/src/Gui/MainWindow.cpp
+++ b/src/Gui/MainWindow.cpp
@@ -518,18 +518,14 @@ void
 MainWindow::createGlobalPreferences()
 {
     m_globalPreferences = new Settings( SettingsManager::Vlmc, this );
-    m_globalPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "general" ), SettingsManager::Vlmc,
-                                     QIcon( ":/images/vlmc" ),
-                                     tr ( "General" ) );
-    m_globalPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "keyboard" ), SettingsManager::Vlmc,
-                                     QIcon( ":/images/keyboard" ),
-                                     tr( "Keyboard" ) );
-    m_globalPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "youtube" ), SettingsManager::Vlmc,
-                                     QIcon( ":/images/youtube" ),
-                                     tr( "Youtube" ) );
-    m_globalPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "network" ), SettingsManager::Vlmc,
-                                     QIcon( ":/images/network" ),
-                                     tr( "Network" ) );
+    m_globalPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "General" ), SettingsManager::Vlmc,
+                                     QIcon( ":/images/vlmc" ) );
+    m_globalPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "Keyboard" ), SettingsManager::Vlmc,
+                                     QIcon( ":/images/keyboard" ) );
+    m_globalPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "YouTube" ), SettingsManager::Vlmc,
+                                     QIcon( ":/images/youtube" ) );
+    m_globalPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "Network" ), SettingsManager::Vlmc,
+                                     QIcon( ":/images/network" ) );
 }
 
 void
@@ -555,15 +551,12 @@ void
 MainWindow::createProjectPreferences()
 {
     m_projectPreferences = new Settings( SettingsManager::Project, this );
-    m_projectPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "general" ), SettingsManager::Project,
-                                   QIcon( ":/images/vlmc" ),
-                                   tr ( "General" ) );
-    m_projectPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "video" ), SettingsManager::Project,
-                                   QIcon( ":/images/video" ),
-                                   tr ( "Video" ) );
-    m_projectPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "audio" ), SettingsManager::Project,
-                                   QIcon( ":/images/audio" ),
-                                   tr ( "Audio" ) );
+    m_projectPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "General" ), SettingsManager::Project,
+                                   QIcon( ":/images/vlmc" ) );
+    m_projectPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "Video" ), SettingsManager::Project,
+                                   QIcon( ":/images/video" ) );
+    m_projectPreferences->addCategory( QT_TRANSLATE_NOOP( "Settings", "Audio" ), SettingsManager::Project,
+                                   QIcon( ":/images/audio" ) );
 }
 
 void
diff --git a/src/Gui/settings/Panel.cpp b/src/Gui/settings/Panel.cpp
index 164f33b..b58faea 100644
--- a/src/Gui/settings/Panel.cpp
+++ b/src/Gui/settings/Panel.cpp
@@ -22,6 +22,7 @@
  *****************************************************************************/
 
 #include "Panel.h"
+#include "Settings.h"
 
 #include <QWidget>
 #include <QVBoxLayout>
@@ -33,7 +34,6 @@
 #include <QSize>
 #include <QShowEvent>
 
-
 const int   Panel::M_ICON_HEIGHT = 64;
 
 Panel::Panel( QWidget* parent ) : QWidget( parent )
@@ -53,13 +53,14 @@ Panel::Panel( QWidget* parent ) : QWidget( parent )
                    QSizePolicy::Expanding );
 }
 
-void    Panel::addButton( const QString& label,
+void    Panel::addButton( const char* name,
                           const QIcon& icon,
                           int index )
 {
     QToolButton*    button = new QToolButton( this );
 
-    button->setText( label );
+    m_buttonsNames[button] = name;
+    button->setText( tr( name ) );
     button->setIcon( icon );
     button->setAutoRaise( true );
     button->setCheckable( true );
@@ -82,3 +83,16 @@ void    Panel::showEvent( QShowEvent *event )
     if ( !event->spontaneous() && !m_buttons->buttons().isEmpty() )
         m_buttons->buttons().first()->setChecked( true );
 }
+
+void
+Panel::retranslate()
+{
+    QMap<QToolButton*, const char*>::iterator       it = m_buttonsNames.begin();
+    QMap<QToolButton*, const char*>::iterator       ite = m_buttonsNames.end();
+
+    while ( it != ite )
+    {
+        it.key()->setText( Settings::tr( it.value() ) );
+        ++it;
+    }
+}
diff --git a/src/Gui/settings/Panel.h b/src/Gui/settings/Panel.h
index 76649c1..9f77cbf 100644
--- a/src/Gui/settings/Panel.h
+++ b/src/Gui/settings/Panel.h
@@ -26,11 +26,13 @@
 
 #include <QWidget>
 #include <QString>
+#include <QMap>
 
-class QVBoxLayout;
-class QButtonGroup;
+class   QVBoxLayout;
+class   QButtonGroup;
 
-class QButtonGroup;
+class   QButtonGroup;
+class   QToolButton;
 
 class   Panel : public QWidget
 {
@@ -41,15 +43,19 @@ public:
     Panel( QWidget* parent = 0 );
     virtual ~Panel() { }
 
-    void    addButton( const QString& label,
+    void    addButton( const char* label,
                        const QIcon& icon,
                        int index );
+    void    retranslate();
 
 private:
     virtual void        showEvent( QShowEvent * );
-    QVBoxLayout*        m_layout;
-    QButtonGroup*       m_buttons;
-    static const int    M_ICON_HEIGHT;
+
+private:
+    QVBoxLayout*                    m_layout;
+    QButtonGroup*                   m_buttons;
+    static const int                M_ICON_HEIGHT;
+    QMap<QToolButton*, const char*> m_buttonsNames;
 
 signals:
     void   changePanel( int index );
diff --git a/src/Gui/settings/Settings.cpp b/src/Gui/settings/Settings.cpp
index ab98d16..9a817d4 100644
--- a/src/Gui/settings/Settings.cpp
+++ b/src/Gui/settings/Settings.cpp
@@ -64,15 +64,14 @@ Settings::Settings( SettingsManager::Type type, QWidget *parent ) :
 void
 Settings::addCategory( const char *name,
                        SettingsManager::Type type,
-                       const QIcon &icon,
-                       const QString &label )
+                       const QIcon &icon )
 {
     PreferenceWidget    *pWidget = new PreferenceWidget( name, type, this );
 
     m_stackedLayout->addWidget( pWidget );
 
     // Create a button linked to the widget using its index
-    m_panel->addButton( label, icon, m_stackedLayout->count() - 1 );
+    m_panel->addButton( name, icon, m_stackedLayout->count() - 1 );
 
     switchWidget( 0 );
 }
@@ -171,4 +170,5 @@ Settings::retranslateUi()
         setWindowTitle( tr( "Project preferences" ) );
     else
         setWindowTitle( tr( "VLMC Settings" ) );
+    m_panel->retranslate();
 }
diff --git a/src/Gui/settings/Settings.h b/src/Gui/settings/Settings.h
index fe0279b..3379280 100644
--- a/src/Gui/settings/Settings.h
+++ b/src/Gui/settings/Settings.h
@@ -49,8 +49,7 @@ class   Settings : public QDialog
 
         void                        addCategory( const char *name,
                                                  SettingsManager::Type type,
-                                                 const QIcon &icon,
-                                                 const QString &label );
+                                                 const QIcon &icon );
 
     protected:
         void                        changeEvent( QEvent *e );



More information about the Vlmc-devel mailing list