Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
luyikei
VLMC
Commits
b9d011ca
Commit
b9d011ca
authored
Nov 12, 2009
by
Clement CHAVANCE
Browse files
Language Settings are now included in the application settings widget
parent
a62a130f
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/Configuration/VLMCSettingsDefault.cpp
View file @
b9d011ca
...
...
@@ -33,4 +33,12 @@ void VLMCSettingsDefault::loadVLMCDefaults( const QString& part )
void
VLMCSettingsDefault
::
loadlanguageDefaults
(
const
QString
&
part
)
{
SettingsManager
*
setMan
=
SettingsManager
::
getInstance
();
QVariant
defaultLang
=
"fr"
;
setMan
->
setValue
(
part
,
"VLMCLang"
,
defaultLang
);
return
;
}
src/GUI/LanguagePreferences.cpp
View file @
b9d011ca
...
...
@@ -4,6 +4,7 @@
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Christophe Courtaut <christophe.courtaut@gmail.com>
* Authors: Clement CHAVANCE <kinder@vlmcorg>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
...
...
@@ -19,60 +20,49 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include
<QVariant>
#include
"SettingsManager.h"
#include
"LanguagePreferences.h"
#include
"ui_LanguagePreferences.h"
QTranslator
*
Preferences
::
m_currentLang
=
NULL
;
Preferences
*
Preferences
::
m_instance
=
NULL
;
QTranslator
*
LanguagePreferences
::
m_currentLang
=
NULL
;
Preferences
::
Preferences
(
QWidget
*
parent
)
:
QDialog
(
parent
)
LanguagePreferences
::
LanguagePreferences
(
QWidget
*
parent
)
:
PreferenceWidget
(
parent
)
{
m_ui
.
setupUi
(
this
);
m_ui
.
comboBoxLanguage
->
addItem
(
tr
(
"English"
),
""
);
m_ui
.
comboBoxLanguage
->
addItem
(
tr
(
"English"
),
"
en
"
);
m_ui
.
comboBoxLanguage
->
addItem
(
tr
(
"French"
),
"fr"
);
m_ui
.
comboBoxLanguage
->
addItem
(
tr
(
"Spanish"
),
"es"
);
m_ui
.
comboBoxLanguage
->
addItem
(
tr
(
"Swedish"
),
"sv"
);
connect
(
qApp
,
SIGNAL
(
aboutToQuit
()
),
this
,
SLOT
(
deleteLater
()
)
);
}
void
Preferences
::
changeEvent
(
QEvent
*
e
)
{
QWidget
::
changeEvent
(
e
);
switch
(
e
->
type
()
)
{
case
QEvent
::
LanguageChange
:
m_ui
.
retranslateUi
(
this
);
break
;
default:
break
;
}
}
LanguagePreferences
::~
LanguagePreferences
()
{}
Preferences
*
Preferences
::
instance
()
void
Language
Preferences
::
load
()
{
if
(
m_instance
)
return
m_instance
;
m_instance
=
new
Preferences
();
return
m_instance
;
}
const
QString
&
part
=
m_defaults
?
"default"
:
m_settName
;
SettingsManager
*
setMan
=
SettingsManager
::
getInstance
();
QVariant
lang
=
setMan
->
getValue
(
part
,
"VLMCLang"
);
int
idx
=
m_ui
.
comboBoxLanguage
->
findData
(
lang
);
void
Preferences
::
on_pushButtonCancel_clicked
(
)
{
close
()
;
if
(
idx
!=
-
1
)
m_ui
.
comboBoxLanguage
->
setCurrentIndex
(
idx
);
return
;
}
void
Preferences
::
on_pushButtonApply_clicked
()
void
Language
Preferences
::
save
()
{
Preferences
::
changeLang
(
m_ui
.
comboBoxLanguage
->
itemData
(
m_ui
.
comboBoxLanguage
->
currentIndex
()
).
toString
()
);
close
();
SettingsManager
*
setMan
=
SettingsManager
::
getInstance
();
QVariant
lang
=
m_ui
.
comboBoxLanguage
->
itemData
(
m_ui
.
comboBoxLanguage
->
currentIndex
()
);
setMan
->
setValue
(
m_settName
,
"VLMCLang"
,
lang
);
changeLang
(
lang
.
toString
()
);
}
void
Preferences
::
changeLang
(
QString
langValue
)
void
Language
Preferences
::
changeLang
(
QString
langValue
)
{
QSettings
settings
;
QString
lang
=
settings
.
value
(
"Lang"
).
toString
();
settings
.
setValue
(
"Lang"
,
langValue
);
if
(
m_currentLang
!=
NULL
)
{
qApp
->
removeTranslator
(
m_currentLang
);
...
...
@@ -86,3 +76,16 @@ void Preferences::changeLang( QString langValue )
qApp
->
installTranslator
(
m_currentLang
);
}
}
void
LanguagePreferences
::
changeEvent
(
QEvent
*
e
)
{
QWidget
::
changeEvent
(
e
);
switch
(
e
->
type
()
)
{
case
QEvent
::
LanguageChange
:
m_ui
.
retranslateUi
(
this
);
break
;
default:
break
;
}
}
src/GUI/LanguagePreferences.h
View file @
b9d011ca
...
...
@@ -4,6 +4,7 @@
* Copyright (C) 2008-2009 the VLMC team
*
* Authors: Christophe Courtaut <christophe.courtaut@gmail.com>
* Authors: Clement CHAVANCE <kinder@vlmc.org>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
...
...
@@ -23,33 +24,26 @@
#ifndef PREFERENCES_H
#define PREFERENCES_H
#include
<QtGui/QWidget>
#include
<QTranslator>
#include
<QApplication>
#include
<QSettings>
#include
<QtDebug>
#include
"PreferenceWidget.h"
#include
"ui_LanguagePreferences.h"
class
Preferences
:
public
QDialog
class
Language
Preferences
:
public
PreferenceWidget
{
Q_OBJECT
Q_DISABLE_COPY
(
Preferences
)
public:
static
Preferences
*
instance
();
static
void
changeLang
(
QString
lang
);
public:
LanguagePreferences
(
QWidget
*
parent
=
0
);
~
LanguagePreferences
();
void
load
();
void
save
();
void
changeLang
(
QString
lang
);
protected:
virtual
void
changeEvent
(
QEvent
*
e
);
protected:
virtual
void
changeEvent
(
QEvent
*
e
);
private:
explicit
Preferences
(
QWidget
*
parent
=
0
);
Ui
::
LanguagePreferences
m_ui
;
static
QTranslator
*
m_currentLang
;
static
Preferences
*
m_instance
;
private
slots
:
void
on_pushButtonCancel_clicked
();
void
on_pushButtonApply_clicked
();
private:
Ui
::
LanguagePreferences
m_ui
;
static
QTranslator
*
m_currentLang
;
};
#endif // PREFERENCES_H
src/GUI/MainWindow.cpp
View file @
b9d011ca
...
...
@@ -55,6 +55,7 @@
#include
"VLMCPreferences.h"
#include
"Import.h"
#include
"MediaLibraryWidget.h"
#include
"LanguagePreferences.h"
MainWindow
::
MainWindow
(
QWidget
*
parent
)
:
QMainWindow
(
parent
),
m_renderer
(
NULL
)
...
...
@@ -315,6 +316,10 @@ void MainWindow::createGlobalPreferences()
new
VLMCPreferences
(
m_globalPreferences
),
"../images/vlmc.png"
,
"VLMC settings"
);
m_globalPreferences
->
addWidget
(
"Language preferences"
,
new
LanguagePreferences
(
m_globalPreferences
),
"../images/vlmc.png"
,
"Langage settings"
);
m_globalPreferences
->
build
();
}
...
...
@@ -353,7 +358,7 @@ void MainWindow::on_actionQuit_triggered()
void
MainWindow
::
on_actionPreferences_triggered
()
{
m_
project
Preferences
->
show
();
m_
global
Preferences
->
show
();
}
void
MainWindow
::
on_actionAbout_triggered
()
...
...
src/GUI/ui/LanguagePreferences.ui
View file @
b9d011ca
<?xml version="1.0" encoding="UTF-8"?>
<ui
version=
"4.0"
>
<class>
LanguagePreferences
</class>
<widget
class=
"Q
Dialog
"
name=
"LanguagePreferences"
>
<widget
class=
"Q
Widget
"
name=
"LanguagePreferences"
>
<property
name=
"geometry"
>
<rect>
<x>
0
</x>
<y>
0
</y>
<width>
4
44
</width>
<height>
388
</height>
<width>
4
00
</width>
<height>
114
</height>
</rect>
</property>
<property
name=
"windowTitle"
>
<string>
Preferences
</string>
<string>
Form
</string>
</property>
<layout
class=
"QGridLayout"
name=
"gridLayout"
>
<item
row=
"0"
column=
"0"
colspan=
"2"
>
<widget
class=
"Q
T
ab
Widget
"
name=
"
t
ab
Widget
"
>
<property
name=
"t
abPosition
"
>
<
enum>
QTabWidget::North
</enum
>
<item
row=
"0"
column=
"0"
>
<widget
class=
"Q
L
ab
el
"
name=
"
l
ab
el
"
>
<property
name=
"t
ext
"
>
<
string>
Language
</string
>
</property>
<property
name=
"currentIndex"
>
<number>
0
</number>
</property>
<widget
class=
"QWidget"
name=
"TabGeneral"
>
<attribute
name=
"title"
>
<string>
General
</string>
</attribute>
<widget
class=
"QLabel"
name=
"label"
>
<property
name=
"geometry"
>
<rect>
<x>
10
</x>
<y>
10
</y>
<width>
81
</width>
<height>
21
</height>
</rect>
</property>
<property
name=
"text"
>
<string>
Language
</string>
</property>
</widget>
<widget
class=
"QComboBox"
name=
"comboBoxLanguage"
>
<property
name=
"geometry"
>
<rect>
<x>
110
</x>
<y>
10
</y>
<width>
121
</width>
<height>
24
</height>
</rect>
</property>
</widget>
</widget>
</widget>
</item>
<item
row=
"1"
column=
"0"
>
<spacer
name=
"horizontalSpacer"
>
<property
name=
"orientation"
>
<enum>
Qt::Horizontal
</enum>
</property>
<property
name=
"sizeHint"
stdset=
"0"
>
<size>
<width>
293
</width>
<height>
20
</height>
</size>
</property>
</spacer>
<item
row=
"0"
column=
"1"
>
<widget
class=
"QComboBox"
name=
"comboBoxLanguage"
/>
</item>
</layout>
</widget>
...
...
src/main.cpp
View file @
b9d011ca
...
...
@@ -50,8 +50,8 @@ int main( int argc, char **argv )
app
.
setOrganizationName
(
"vlmc"
);
app
.
setOrganizationDomain
(
"vlmc.org"
);
app
.
setApplicationVersion
(
STRINGIFY
(
VLMC_VERSION
)
);
QSettings
::
setDefaultFormat
(
QSettings
::
IniFormat
);
Preferences
::
changeLang
(
QSettings
().
value
(
"Lang"
).
toString
()
);
//
QSettings::setDefaultFormat( QSettings::IniFormat );
//
Preferences::changeLang( QSettings().value( "Lang" ).toString() );
#ifdef Q_OS_WIN
// Ugly workaround
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment