This repository has been archived by the owner on Sep 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
LanguagesSettingsTab.cpp
268 lines (247 loc) · 11 KB
/
LanguagesSettingsTab.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
/***************************************************************************//**
* @brief Thumbnail me 3.0
* Thumbnail me is a user interface for Movie thumbnailer.
* Generate thumbnails from any movie is now easier !
*
* @file LanguagesSettingsTab.cpp
* @class LanguagesSettingsTab
* Cette classe permet de changer la langue de Thumbnail Me.
* Elle génère un widget disponible dans le widget "Settings".
*
* @author Quentin Rousseau\n
* @note Copyright (C) 2011-2012 Quentin Rousseau\n
* License: GNU General Public License version 2 (GPLv2) - http://www.gnu.org/licenses/gpl-2.0.html\n
* Site web: www.thumbnailme.com\n
* Email: [email protected]
*
* @since 3.0
* @version 3.0
* @date 2011-2012
*
* @changelog 08/14/2011 - Add Dutch Language.
* @changelog 09/24/2011 - Add Italian & Czech Language.
*******************************************************************************/
#include "LanguagesSettingsTab.h"
#include "IniManager.h"
#include "defines.h"
/**
*@brief Constructeur.
*/
LanguagesSettingsTab::LanguagesSettingsTab()
{
settings = new QSettings(QSettings::IniFormat,DEFAULT_PATH_INI,APPLICATION_NAME,DEFAULT_FILE_INI,this);
QLabel *pixmapLabelEnglish = new QLabel(this);
pixmapLabelEnglish->setPixmap(QPixmap(":/sprites/english.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelFrench = new QLabel(this);
pixmapLabelFrench->setPixmap(QPixmap(":/sprites/french.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelSpanish = new QLabel(this);
pixmapLabelSpanish->setPixmap(QPixmap(":/sprites/spanish.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelGerman = new QLabel(this);
pixmapLabelGerman->setPixmap(QPixmap(":/sprites/deutsch.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelDutch = new QLabel(this);
pixmapLabelDutch->setPixmap(QPixmap(":/sprites/dutch.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelItalian = new QLabel(this);
pixmapLabelItalian->setPixmap(QPixmap(":/sprites/italian.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelCzech = new QLabel(this);
pixmapLabelCzech->setPixmap(QPixmap(":/sprites/czech.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelHungarian = new QLabel(this);
pixmapLabelHungarian->setPixmap(QPixmap(":/sprites/hungarian.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelCroatian = new QLabel(this);
pixmapLabelCroatian->setPixmap(QPixmap(":/sprites/croatian.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelPortugese = new QLabel(this);
pixmapLabelPortugese->setPixmap(QPixmap(":/sprites/portugese.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelChinese = new QLabel(this);
pixmapLabelChinese->setPixmap(QPixmap(":/sprites/chinese.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelRussian = new QLabel(this);
pixmapLabelRussian->setPixmap(QPixmap(":/sprites/russian.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelVietnamese = new QLabel(this);
pixmapLabelVietnamese->setPixmap(QPixmap(":/sprites/portugese.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelTurkish = new QLabel(this);
pixmapLabelTurkish->setPixmap(QPixmap(":/sprites/chinese.png").scaledToHeight(48,Qt::SmoothTransformation));
QLabel *pixmapLabelSwedish = new QLabel(this);
pixmapLabelSwedish->setPixmap(QPixmap(":/sprites/russian.png").scaledToHeight(48,Qt::SmoothTransformation));
radioEnglish = new QRadioButton(this);
radioFrench = new QRadioButton(this);
radioSpanish = new QRadioButton(this);
radioGerman = new QRadioButton(this);
radioDutch = new QRadioButton(this);
radioItalian = new QRadioButton(this);
radioCzech = new QRadioButton(this);
radioHungarian = new QRadioButton(this);
radioCroatian = new QRadioButton(this);
radioPortugese = new QRadioButton(this);
radioChinese = new QRadioButton(this);
radioRussian = new QRadioButton(this);
radioVietnamese = new QRadioButton(this);
radioTurkish = new QRadioButton(this);
radioSwedish = new QRadioButton(this);
QGridLayout *languagesLayoutRight = new QGridLayout(this);
languagesLayoutRight->addWidget(radioEnglish,0,1);
languagesLayoutRight->addWidget(pixmapLabelEnglish,0,2);
languagesLayoutRight->addWidget(radioFrench,0,3);
languagesLayoutRight->addWidget(pixmapLabelFrench,0,4);
languagesLayoutRight->addWidget(radioSpanish,0,5);
languagesLayoutRight->addWidget(pixmapLabelSpanish,0,6);
languagesLayoutRight->addWidget(radioGerman,1,1);
languagesLayoutRight->addWidget(pixmapLabelGerman,1,2);
languagesLayoutRight->addWidget(radioDutch,1,3);
languagesLayoutRight->addWidget(pixmapLabelDutch,1,4);
languagesLayoutRight->addWidget(radioItalian,1,5);
languagesLayoutRight->addWidget(pixmapLabelItalian,1,6);
languagesLayoutRight->addWidget(radioCzech,2,1);
languagesLayoutRight->addWidget(pixmapLabelCzech,2,2);
languagesLayoutRight->addWidget(radioHungarian,2,3);
languagesLayoutRight->addWidget(pixmapLabelHungarian,2,4);
languagesLayoutRight->addWidget(radioCroatian,2,5);
languagesLayoutRight->addWidget(pixmapLabelCroatian,2,6);
languagesLayoutRight->addWidget(radioPortugese,3,1);
languagesLayoutRight->addWidget(pixmapLabelPortugese,3,2);
languagesLayoutRight->addWidget(radioChinese,3,3);
languagesLayoutRight->addWidget(pixmapLabelChinese,3,4);
languagesLayoutRight->addWidget(radioRussian,3,5);
languagesLayoutRight->addWidget(pixmapLabelRussian,3,6);
languagesLayoutRight->addWidget(radioVietnamese,4,1);
languagesLayoutRight->addWidget(pixmapLabelVietnamese,4,2);
languagesLayoutRight->addWidget(radioTurkish,4,3);
languagesLayoutRight->addWidget(pixmapLabelTurkish,4,4);
languagesLayoutRight->addWidget(radioSwedish,4,5);
languagesLayoutRight->addWidget(pixmapLabelSwedish,4,6);
languagesLayoutRight->setSpacing(5);
languagesTabGroupBox = new QGroupBox(this);
languagesTabGroupBox->setLayout(languagesLayoutRight);
QLabel *translationLabel = new QLabel(this);
translationLabel->setText(
"<p>"+tr("Can't see your language in this list?","Don't translate this sentence")+"</p></br>"+
"<p>"+tr("Help us to translate","Don't translate this sentence")+" "+APPLICATION_NAME+"."+"</p></br>"+
"<p>"+tr("More information at","Don't translate this sentence")+" <a href='"+TRANSLATION_HELP_URL+"'>"+TRANSLATION_HELP_URL+"</a>.</p>"
);
translationLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard);
translationLabel->setOpenExternalLinks(true);
QVBoxLayout *layoutPrincipal = new QVBoxLayout(this);
layoutPrincipal->addWidget(languagesTabGroupBox);
layoutPrincipal->addWidget(translationLabel);
this->initializeWidget();
this->setLayout(layoutPrincipal);
this->retranslate();
}
/**
*@brief Destructeur.
*/
LanguagesSettingsTab::~LanguagesSettingsTab()
{
}
/**
*@brief Initialisation des paramètres du widget.
*/
void LanguagesSettingsTab::initializeWidget()
{
/*On coche la radio associé à la langue lue dans le fichier de configuration*/
if (settings->value("Langs/lang") == "en")
radioEnglish->setChecked(true);
else if (settings->value("Langs/lang") == "fr")
radioFrench->setChecked(true);
else if (settings->value("Langs/lang") == "de")
radioGerman->setChecked(true);
else if (settings->value("Langs/lang") == "es")
radioSpanish->setChecked(true);
else if (settings->value("Langs/lang") == "nl")
radioDutch->setChecked(true);
else if (settings->value("Langs/lang") == "it")
radioItalian->setChecked(true);
else if (settings->value("Langs/lang") == "cz")
radioCzech->setChecked(true);
else if (settings->value("Langs/lang") == "hu")
radioHungarian->setChecked(true);
else if (settings->value("Langs/lang") == "hr")
radioCroatian->setChecked(true);
else if (settings->value("Langs/lang") == "pt")
radioPortugese->setChecked(true);
else if (settings->value("Langs/lang") == "cn")
radioChinese->setChecked(true);
else if (settings->value("Langs/lang") == "ru")
radioRussian->setChecked(true);
else if (settings->value("Langs/lang") == "vi")
radioVietnamese->setChecked(true);
else if (settings->value("Langs/lang") == "tr")
radioTurkish->setChecked(true);
else if (settings->value("Langs/lang") == "sv")
radioSwedish->setChecked(true);
else radioEnglish->setChecked(true);
}
/**
*@brief Retourne la langue cochée.
*@return Langue ("en" ou "fr" ou "de" ou "es").
*/
QString LanguagesSettingsTab::getLanguageChecked()
{
if (radioEnglish->isChecked())
return "en";
else if (radioFrench->isChecked())
return "fr";
else if (radioGerman->isChecked())
return "de";
else if (radioSpanish->isChecked())
return "es";
else if (radioDutch->isChecked())
return "nl";
else if (radioItalian->isChecked())
return "it";
else if (radioCzech->isChecked())
return "cz";
else if (radioHungarian->isChecked())
return "hu";
else if (radioCroatian->isChecked())
return "hr";
else if (radioPortugese->isChecked())
return "pt";
else if (radioChinese->isChecked())
return "cn";
else if (radioRussian->isChecked())
return "ru";
else if (radioVietnamese->isChecked())
return "vi";
else if (radioTurkish->isChecked())
return "tr";
else if (radioSwedish->isChecked())
return "sv";
else return "en";
}
/**
*@brief Fonction annulation - Réaffecte les paramètres d'origine.
*/
void LanguagesSettingsTab::reject()
{
this->initializeWidget();
}
/**
*@brief ChangeEvent.
*@param *event Evenement.
*/
void LanguagesSettingsTab::changeEvent(QEvent* event)
{
if (event->type() == QEvent::LanguageChange)
retranslate();
QWidget::changeEvent(event);
}
/**
*@brief Fonction de traduction dynamique.
*/
void LanguagesSettingsTab::retranslate()
{
languagesTabGroupBox->setTitle( tr("Select a language") );
radioEnglish->setText( tr("English") );
radioFrench->setText( tr("French") );
radioSpanish->setText( tr("Spanish") );
radioGerman->setText( tr("German") );
radioDutch->setText( tr("Dutch") );
radioItalian->setText( tr("Italian") );
radioCzech->setText( tr("Czech") );
radioHungarian->setText( tr("Hungarian") );
radioCroatian->setText( tr("Croatian") );
radioPortugese->setText( tr("Portuguese") );
radioChinese->setText( tr("Chinese") );
radioRussian->setText( tr("Russian") );
radioVietnamese->setText( tr("Vietnamese") );
radioTurkish->setText( tr("Turkish") );
radioSwedish->setText( tr("Swedish") );
}