Commit a15081d9 authored by Christophe Courtaut's avatar Christophe Courtaut

Preferences code cleanup

parent 6b4f2094
......@@ -79,8 +79,7 @@ void MainWindow::on_actionQuit_triggered()
void MainWindow::on_actionPreferences_triggered()
{
Preferences* pref = new Preferences();
pref->show();
Preferences::instance()->exec();
}
void MainWindow::on_actionAbout_triggered()
......
......@@ -24,19 +24,16 @@
#include "ui_Preferences.h"
QTranslator* Preferences::m_currentLang = NULL;
Preferences* Preferences::m_instance = NULL;
Preferences::Preferences( QWidget *parent ) : QWidget( parent )
Preferences::Preferences( QWidget *parent ) : QDialog( 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.comboBoxLanguage->addItem( tr( "Swedish" ), "sv" );
}
Preferences::~Preferences()
{
connect( qApp, SIGNAL( aboutToQuit() ), this, SLOT( deleteLater() ) );
}
void Preferences::changeEvent( QEvent *e )
......@@ -52,6 +49,14 @@ void Preferences::changeEvent( QEvent *e )
}
}
Preferences* Preferences::instance()
{
if ( m_instance )
return m_instance;
m_instance = new Preferences();
return m_instance;
}
void Preferences::on_pushButtonCancel_clicked()
{
close();
......
......@@ -30,22 +30,22 @@
#include <QtDebug>
#include "ui_Preferences.h"
class Preferences : public QWidget
class Preferences : public QDialog
{
Q_OBJECT
Q_DISABLE_COPY( Preferences )
public:
explicit Preferences( QWidget *parent = 0 );
virtual ~Preferences();
static Preferences* instance();
static void changeLang(QString lang);
protected:
virtual void changeEvent( QEvent *e );
private:
explicit Preferences( QWidget *parent = 0 );
Ui::Preferences m_ui;
static QTranslator* m_currentLang;
static Preferences* m_instance;
private slots:
void on_pushButtonCancel_clicked();
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Preferences</class>
<widget class="QWidget" name="Preferences">
<property name="windowModality">
<enum>Qt::ApplicationModal</enum>
</property>
<widget class="QDialog" name="Preferences">
<property name="geometry">
<rect>
<x>0</x>
......
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