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

Settings: Translate the side buttons text.

parent 66c9069d
......@@ -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
......
......@@ -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;
}
}
......@@ -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 );
......
......@@ -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();
}
......@@ -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 );
......
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