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
|
/***************************************************************************
* Copyright (C) 2006-2012 by Thomas Schweitzer *
* thomas-schweitzer(at)arcor.de *
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License version 2.0 as *
* published by the Free Software Foundation. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program in the file LICENSE.GPL; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
***************************************************************************/
#include "UiGuiSettingsDialog.h"
#include "ui_UiGuiSettingsDialog.h"
#include "UiGuiSettings.h"
/*
\class UiGuiSettingsDialog
\ingroup grp_Settings
\brief Displays a dialog window with settings for UniversalIndentGUI
*/
/*
\brief The constructor calls the setup function for the ui created by uic.
*/
UiGuiSettingsDialog::UiGuiSettingsDialog(TQWidget *parent,
TQSharedPointer<UiGuiSettings> settings) :
TQDialog(parent)
{
// Remember pointer to the UiGuiSettings object.
_settings = settings;
// Init the user interface created by the UIC.
_settingsDialogForm = new Ui::SettingsDialog();
_settingsDialogForm->setupUi(this);
//TODO: This call has to be removed when the properties for the highlighters can be set
// with the settings dialog.
_settingsDialogForm->groupBoxSyntaxHighlighterProperties->setToolTip(
"(Will be implemented soon)" +
_settingsDialogForm->groupBoxSyntaxHighlighterProperties->toolTip());
// Connect the accepted signal to own function, to write values back to the UiGuiSettings object.
connect(this, SIGNAL(accepted()), this, SLOT(writeWidgetValuesToSettings()));
// Init the language selection combobox.
initTranslationSelection();
}
/*
\brief By calling this function the combobox for selecting the application language will
be initialized.
Also the translation itself will be reinitialized.
*/
void UiGuiSettingsDialog::initTranslationSelection()
{
// First empty the combo box.
_settingsDialogForm->languageSelectionComboBox->clear();
// Now add an entry into the box for every language short.
foreach(TQString languageShort, _settings->getAvailableTranslations())
{
// Identify the language mnemonic and set the full name.
if (languageShort == "en")
{
_settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-"
+ languageShort + ".png")), tr("English"));
}
else if (languageShort == "fr")
{
_settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-"
+ languageShort + ".png")), tr("French"));
}
else if (languageShort == "de")
{
_settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-"
+ languageShort + ".png")), tr("German"));
}
else if (languageShort == "zh_TW")
{
_settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-"
+ languageShort + ".png")), tr("Chinese (Taiwan)"));
}
else if (languageShort == "ja")
{
_settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-"
+ languageShort + ".png")), tr("Japanese"));
}
else if (languageShort == "ru")
{
_settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-"
+ languageShort + ".png")), tr("Russian"));
}
else if (languageShort == "uk")
{
_settingsDialogForm->languageSelectionComboBox->addItem(TQIcon(TQString(":/language/language-"
+ languageShort + ".png")), tr("Ukrainian"));
}
else
{
_settingsDialogForm->languageSelectionComboBox->addItem(tr(
"Unknown language mnemonic ") + languageShort);
}
}
}
/*
\brief Displays the dialog by calling the dialogs exec function.
Before it gets all the values needed from the UiGuiSettings object.
*/
int UiGuiSettingsDialog::showDialog()
{
// Init all settings dialog objects with values from settings.
_settings->setObjectPropertyToSettingValueRecursive(this);
// Execute the dialog.
return exec();
}
/*
\brief This slot is called when the dialog box is closed by pressing the Ok button.
Writes all settings to the UiGuiSettings object.
*/
void UiGuiSettingsDialog::writeWidgetValuesToSettings()
{
// Write settings dialog object values to settings.
_settings->setSettingToObjectPropertyValueRecursive(this);
}
/*
\brief Catches language change events and retranslates all needed widgets.
*/
void UiGuiSettingsDialog::changeEvent(TQEvent *event)
{
if (event->type() == TQEvent::LanguageChange)
{
_settingsDialogForm->retranslateUi(this);
// If this is not explicit set here, TQt < 4.3.0 does not translate the buttons.
_settingsDialogForm->buttonBox->setStandardButtons(
TQDialogButtonBox::Cancel | TQDialogButtonBox::NoButton | TQDialogButtonBox::Ok);
//TODO: This has to be removed when the properties for the highlighters can be set.
_settingsDialogForm->groupBoxSyntaxHighlighterProperties->setToolTip(
"(Will be implemented soon)" +
_settingsDialogForm->groupBoxSyntaxHighlighterProperties->toolTip());
TQStringList languageShortList = _settings->getAvailableTranslations();
// Now retranslate every entry in the language selection box.
for (int i = 0; i < languageShortList.size(); i++)
{
TQString languageShort = languageShortList.at(i);
// Identify the language mnemonic and set the full name.
if (languageShort == "en")
{
_settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("English"));
}
else if (languageShort == "fr")
{
_settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("French"));
}
else if (languageShort == "de")
{
_settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("German"));
}
else if (languageShort == "zh_TW")
{
_settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Chinese (Taiwan)"));
}
else if (languageShort == "ja")
{
_settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Japanese"));
}
else if (languageShort == "ru")
{
_settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Russian"));
}
else if (languageShort == "uk")
{
_settingsDialogForm->languageSelectionComboBox->setItemText(i, tr("Ukrainian"));
}
else
{
_settingsDialogForm->languageSelectionComboBox->setItemText(i,
tr("Unknown language mnemonic ") + languageShort);
}
}
}
else
{
TQWidget::changeEvent(event);
}
}
|