Commit 2279f2d7 authored by Ludovic Fauvet's avatar Ludovic Fauvet

Code normalization.

Please use aggregation and not aggregation as pointer for UIs.
parent 0a717960
......@@ -25,17 +25,17 @@
QTranslator* Preferences::m_currentLang = NULL;
Preferences::Preferences( QWidget *parent ) : QWidget( parent ), m_ui( new Ui::Preferences )
Preferences::Preferences( QWidget *parent ) : QWidget( parent )
{
m_ui->setupUi( this );
m_ui->comboBoxLanguage->addItem( tr( "English" ), "" );
m_ui->comboBoxLanguage->addItem( tr( "French" ), "fr" );
m_ui->comboBoxLanguage->addItem( tr( "Spanish" ), "es" );
m_ui.setupUi( this );
m_ui.comboBoxLanguage->addItem( tr( "English" ), "" );
m_ui.comboBoxLanguage->addItem( tr( "French" ), "fr" );
m_ui.comboBoxLanguage->addItem( tr( "Spanish" ), "es" );
}
Preferences::~Preferences()
{
delete m_ui;
}
void Preferences::changeEvent( QEvent *e )
......@@ -44,7 +44,7 @@ void Preferences::changeEvent( QEvent *e )
switch ( e->type() )
{
case QEvent::LanguageChange:
m_ui->retranslateUi( this );
m_ui.retranslateUi( this );
break;
default:
break;
......@@ -53,25 +53,25 @@ void Preferences::changeEvent( QEvent *e )
void Preferences::on_pushButtonCancel_clicked()
{
this->close();
close();
}
void Preferences::on_pushButtonApply_clicked()
{
QSettings settings;
QString lang = settings.value( "Lang" ).toString();
QString langValue = this->m_ui->comboBoxLanguage->itemData( this->m_ui->comboBoxLanguage->currentIndex() ).toString();
if (this->m_currentLang != NULL )
QString langValue = m_ui.comboBoxLanguage->itemData( m_ui.comboBoxLanguage->currentIndex() ).toString();
if ( m_currentLang != NULL )
{
qApp->removeTranslator( this->m_currentLang );
delete this->m_currentLang;
this->m_currentLang = NULL;
qApp->removeTranslator( m_currentLang );
delete m_currentLang;
m_currentLang = NULL;
}
if ( langValue != "" )
if ( !langValue.isEmpty() )
{
m_currentLang = new QTranslator();
m_currentLang->load( "vlmc_" + langValue, QApplication::applicationDirPath() + "/../" );
qApp->installTranslator( m_currentLang );
}
this->close();
close();
}
......@@ -28,10 +28,7 @@
#include <QApplication>
#include <QSettings>
#include <QtDebug>
namespace Ui {
class Preferences;
}
#include "ui_Preferences.h"
class Preferences : public QWidget
{
......@@ -45,7 +42,7 @@ protected:
virtual void changeEvent( QEvent *e );
private:
Ui::Preferences *m_ui;
Ui::Preferences m_ui;
static QTranslator* m_currentLang;
private slots:
......
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