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