1
/***************************************************************************
2
* Copyright (C) 2006-2008 by Thomas Schweitzer *
3
* thomas-schweitzer(at)arcor.de *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License version 2.0 as *
7
* published by the Free Software Foundation. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program in the file LICENSE.GPL; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18
***************************************************************************/
20
#include "uiguisettingsdialog.h"
23
\class UiGuiSettingsDialog
25
\brief Displays a dialog window with settings for UniversalIndentGUI
29
\brief The constructor calls the setup function for the ui created by uic. and adds
31
UiGuiSettingsDialog::UiGuiSettingsDialog(QWidget* parent, UiGuiSettings* settings) : QDialog(parent)
33
// Remember pointer to the UiGuiSettings object.
34
this->settings = settings;
36
// Init the user interface created by the UIC.
38
//TODO: This has to be removed when the properties for the highlighters can be set.
39
groupBoxSyntaxHighlighterProperties->setToolTip( "(Will be implemented soon)" + groupBoxSyntaxHighlighterProperties->toolTip() );
41
// Get all check boxes that are used for settings.
42
checkBoxes = findChildren<QCheckBox*>( QRegExp("uiGui*") );
44
// Get all spin boxes that are used for settings.
45
spinBoxes = findChildren<QSpinBox*>( QRegExp("uiGui*") );
47
// Get all combo boxes that are used for settings.
48
comboBoxes = findChildren<QComboBox*>( QRegExp("uiGui*") );
50
// Connect the accepted signal to own function, to write values back to the UiGuiSettings object.
51
connect(this, SIGNAL(accepted()), this, SLOT(writeWidgetValuesToSettings()) );
53
// Init the language selection combobox.
54
initTranslationSelection();
58
\brief By calling this function the combobox for selecting the application language will
61
Also the translation itself will be reinitialized.
63
void UiGuiSettingsDialog::initTranslationSelection() {
64
// First empty the combo box.
65
uiGuiLanguage->clear();
67
// Now add an entry into the box for every language short.
68
foreach (QString languageShort, settings->getAvailableTranslations() ) {
69
// Identify the language mnemonic and set the full name.
70
if ( languageShort == "en" ) {
71
uiGuiLanguage->addItem( QIcon(QString(":/language/language-"+languageShort+".png")), tr("English") );
73
else if ( languageShort == "de" ) {
74
uiGuiLanguage->addItem( QIcon(QString(":/language/language-"+languageShort+".png")), tr("German") );
76
else if ( languageShort == "zh_TW" ) {
77
uiGuiLanguage->addItem( QIcon(QString(":/language/language-"+languageShort+".png")), tr("Chinese (Taiwan)") );
79
else if ( languageShort == "ja_JP" ) {
80
uiGuiLanguage->addItem( QIcon(QString(":/language/language-"+languageShort+".png")), tr("Japanese") );
83
uiGuiLanguage->addItem( tr("Unknown language mnemonic ") + languageShort );
90
\brief Displays the dialog by calling the dialogs exec function.
92
Before it gets all the values needed from the UiGuiSettings object.
94
int UiGuiSettingsDialog::showDialog() {
95
// Get the values for the check boxes from the settings object.
96
foreach (QCheckBox* checkBox, checkBoxes) {
97
// Get the objects name and remove "uiGui" from its beginning.
98
QString objectName = checkBox->objectName();
99
objectName.remove(0,5);
101
// Get value from settings and assign it to the checkbox.
102
bool value = settings->getValueByName( objectName ).toBool();
103
checkBox->setChecked(value);
106
// Get the values for the spin boxes from the settings object.
107
foreach (QSpinBox* spinBox, spinBoxes) {
108
// Get the objects name and remove "uiGui" from its beginning.
109
QString objectName = spinBox->objectName();
110
objectName.remove(0,5);
112
// Get value from settings and assign it to the checkbox.
113
int value = settings->getValueByName( objectName ).toInt();
114
spinBox->setValue(value);
117
// Get the values for the combo boxes from the settings object.
118
foreach (QComboBox* comboBox, comboBoxes) {
119
// Get the objects name and remove "uiGui" from its beginning.
120
QString objectName = comboBox->objectName();
121
objectName.remove(0,5);
123
// Get value from settings and assign it to the checkbox.
124
int value = settings->getValueByName( objectName ).toInt();
125
comboBox->setCurrentIndex(value);
128
// Execute the dialog.
134
\brief This slot is called when the dialog box is closed by pressing the Ok button.
136
Writes all settings to the UiGuiSettings object.
138
void UiGuiSettingsDialog::writeWidgetValuesToSettings() {
139
// Write the values of the check boxes to the settings object.
140
foreach (QCheckBox* checkBox, checkBoxes) {
141
// Get the objects name and remove "uiGui" from its beginning.
142
QString objectName = checkBox->objectName();
143
objectName.remove(0,5);
145
// Write the check box value to the settings.
146
settings->setValueByName( objectName, checkBox->isChecked() );
149
// Write the values for the spin boxes to the settings object.
150
foreach (QSpinBox* spinBox, spinBoxes) {
151
// Get the objects name and remove "uiGui" from its beginning.
152
QString objectName = spinBox->objectName();
153
objectName.remove(0,5);
155
// Write the spin box value to the settings.
156
settings->setValueByName( objectName, spinBox->value() );
159
// Write the values for the spin boxes to the settings object.
160
foreach (QComboBox* comboBox, comboBoxes) {
161
// Get the objects name and remove "uiGui" from its beginning.
162
QString objectName = comboBox->objectName();
163
objectName.remove(0,5);
165
// Write the spin box value to the settings.
166
settings->setValueByName( objectName, comboBox->currentIndex() );
172
\brief Catches language change events and retranslates all needed widgets.
174
void UiGuiSettingsDialog::changeEvent(QEvent *event) {
175
if (event->type() == QEvent::LanguageChange) {
177
// If this is not explicit set here, Qt < 4.3.0 does not translate the buttons.
178
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok);
180
//TODO: This has to be removed when the properties for the highlighters can be set.
181
groupBoxSyntaxHighlighterProperties->setToolTip( "(Will be implemented soon)" + groupBoxSyntaxHighlighterProperties->toolTip() );
182
uiGuiRecentlyOpenedListSize->setToolTip( "(Will be implemented soon)" + uiGuiRecentlyOpenedListSize->toolTip() );
184
QStringList languageShortList = settings->getAvailableTranslations();
186
// Now retranslate every entry in the language selection box.
187
for (int i = 0; i < languageShortList.size(); i++ ) {
188
QString languageShort = languageShortList.at(i);
190
// Identify the language mnemonic and set the full name.
191
if ( languageShort == "en" ) {
192
uiGuiLanguage->setItemText( i, tr("English") );
194
else if ( languageShort == "de" ) {
195
uiGuiLanguage->setItemText( i, tr("German") );
197
else if ( languageShort == "zh_TW" ) {
198
uiGuiLanguage->setItemText( i, tr("Chinese (Taiwan)") );
200
else if ( languageShort == "ja_JP" ) {
201
uiGuiLanguage->setItemText( i, tr("Japanese") );
204
uiGuiLanguage->setItemText( i, tr("Unknown language mnemonic ") + languageShort );
209
QWidget::changeEvent(event);
1
/***************************************************************************
2
* Copyright (C) 2006-2008 by Thomas Schweitzer *
3
* thomas-schweitzer(at)arcor.de *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License version 2.0 as *
7
* published by the Free Software Foundation. *
9
* This program is distributed in the hope that it will be useful, *
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
* GNU General Public License for more details. *
14
* You should have received a copy of the GNU General Public License *
15
* along with this program in the file LICENSE.GPL; if not, write to the *
16
* Free Software Foundation, Inc., *
17
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18
***************************************************************************/
20
#include "uiguisettingsdialog.h"
23
\class UiGuiSettingsDialog
25
\brief Displays a dialog window with settings for UniversalIndentGUI
29
\brief The constructor calls the setup function for the ui created by uic. and adds
31
UiGuiSettingsDialog::UiGuiSettingsDialog(QWidget* parent, UiGuiSettings* settings) : QDialog(parent)
33
// Remember pointer to the UiGuiSettings object.
34
this->settings = settings;
36
// Init the user interface created by the UIC.
38
//TODO: This has to be removed when the properties for the highlighters can be set.
39
groupBoxSyntaxHighlighterProperties->setToolTip( "(Will be implemented soon)" + groupBoxSyntaxHighlighterProperties->toolTip() );
41
// Get all check boxes that are used for settings.
42
checkBoxes = findChildren<QCheckBox*>( QRegExp("uiGui*") );
44
// Get all spin boxes that are used for settings.
45
spinBoxes = findChildren<QSpinBox*>( QRegExp("uiGui*") );
47
// Get all combo boxes that are used for settings.
48
comboBoxes = findChildren<QComboBox*>( QRegExp("uiGui*") );
50
// Connect the accepted signal to own function, to write values back to the UiGuiSettings object.
51
connect(this, SIGNAL(accepted()), this, SLOT(writeWidgetValuesToSettings()) );
53
// Init the language selection combobox.
54
initTranslationSelection();
58
\brief By calling this function the combobox for selecting the application language will
61
Also the translation itself will be reinitialized.
63
void UiGuiSettingsDialog::initTranslationSelection() {
64
// First empty the combo box.
65
uiGuiLanguage->clear();
67
// Now add an entry into the box for every language short.
68
foreach (QString languageShort, settings->getAvailableTranslations() ) {
69
// Identify the language mnemonic and set the full name.
70
if ( languageShort == "en" ) {
71
uiGuiLanguage->addItem( QIcon(QString(":/language/language-"+languageShort+".png")), tr("English") );
73
else if ( languageShort == "de" ) {
74
uiGuiLanguage->addItem( QIcon(QString(":/language/language-"+languageShort+".png")), tr("German") );
76
else if ( languageShort == "zh_TW" ) {
77
uiGuiLanguage->addItem( QIcon(QString(":/language/language-"+languageShort+".png")), tr("Chinese (Taiwan)") );
79
else if ( languageShort == "ja_JP" ) {
80
uiGuiLanguage->addItem( QIcon(QString(":/language/language-"+languageShort+".png")), tr("Japanese") );
82
else if ( languageShort == "ru" ) {
83
uiGuiLanguage->addItem( QIcon(QString(":/language/language-"+languageShort+".png")), tr("Russian") );
85
else if ( languageShort == "uk" ) {
86
uiGuiLanguage->addItem( QIcon(QString(":/language/language-"+languageShort+".png")), tr("Ukrainian") );
89
uiGuiLanguage->addItem( tr("Unknown language mnemonic ") + languageShort );
96
\brief Displays the dialog by calling the dialogs exec function.
98
Before it gets all the values needed from the UiGuiSettings object.
100
int UiGuiSettingsDialog::showDialog() {
101
// Get the values for the check boxes from the settings object.
102
foreach (QCheckBox* checkBox, checkBoxes) {
103
// Get the objects name and remove "uiGui" from its beginning.
104
QString objectName = checkBox->objectName();
105
objectName.remove(0,5);
107
// Get value from settings and assign it to the checkbox.
108
bool value = settings->getValueByName( objectName ).toBool();
109
checkBox->setChecked(value);
112
// Get the values for the spin boxes from the settings object.
113
foreach (QSpinBox* spinBox, spinBoxes) {
114
// Get the objects name and remove "uiGui" from its beginning.
115
QString objectName = spinBox->objectName();
116
objectName.remove(0,5);
118
// Get value from settings and assign it to the checkbox.
119
int value = settings->getValueByName( objectName ).toInt();
120
spinBox->setValue(value);
123
// Get the values for the combo boxes from the settings object.
124
foreach (QComboBox* comboBox, comboBoxes) {
125
// Get the objects name and remove "uiGui" from its beginning.
126
QString objectName = comboBox->objectName();
127
objectName.remove(0,5);
129
// Get value from settings and assign it to the checkbox.
130
int value = settings->getValueByName( objectName ).toInt();
131
comboBox->setCurrentIndex(value);
134
// Execute the dialog.
140
\brief This slot is called when the dialog box is closed by pressing the Ok button.
142
Writes all settings to the UiGuiSettings object.
144
void UiGuiSettingsDialog::writeWidgetValuesToSettings() {
145
// Write the values of the check boxes to the settings object.
146
foreach (QCheckBox* checkBox, checkBoxes) {
147
// Get the objects name and remove "uiGui" from its beginning.
148
QString objectName = checkBox->objectName();
149
objectName.remove(0,5);
151
// Write the check box value to the settings.
152
settings->setValueByName( objectName, checkBox->isChecked() );
155
// Write the values for the spin boxes to the settings object.
156
foreach (QSpinBox* spinBox, spinBoxes) {
157
// Get the objects name and remove "uiGui" from its beginning.
158
QString objectName = spinBox->objectName();
159
objectName.remove(0,5);
161
// Write the spin box value to the settings.
162
settings->setValueByName( objectName, spinBox->value() );
165
// Write the values for the spin boxes to the settings object.
166
foreach (QComboBox* comboBox, comboBoxes) {
167
// Get the objects name and remove "uiGui" from its beginning.
168
QString objectName = comboBox->objectName();
169
objectName.remove(0,5);
171
// Write the spin box value to the settings.
172
settings->setValueByName( objectName, comboBox->currentIndex() );
178
\brief Catches language change events and retranslates all needed widgets.
180
void UiGuiSettingsDialog::changeEvent(QEvent *event) {
181
if (event->type() == QEvent::LanguageChange) {
183
// If this is not explicit set here, Qt < 4.3.0 does not translate the buttons.
184
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::NoButton|QDialogButtonBox::Ok);
186
//TODO: This has to be removed when the properties for the highlighters can be set.
187
groupBoxSyntaxHighlighterProperties->setToolTip( "(Will be implemented soon)" + groupBoxSyntaxHighlighterProperties->toolTip() );
188
uiGuiRecentlyOpenedListSize->setToolTip( "(Will be implemented soon)" + uiGuiRecentlyOpenedListSize->toolTip() );
190
QStringList languageShortList = settings->getAvailableTranslations();
192
// Now retranslate every entry in the language selection box.
193
for (int i = 0; i < languageShortList.size(); i++ ) {
194
QString languageShort = languageShortList.at(i);
196
// Identify the language mnemonic and set the full name.
197
if ( languageShort == "en" ) {
198
uiGuiLanguage->setItemText( i, tr("English") );
200
else if ( languageShort == "de" ) {
201
uiGuiLanguage->setItemText( i, tr("German") );
203
else if ( languageShort == "zh_TW" ) {
204
uiGuiLanguage->setItemText( i, tr("Chinese (Taiwan)") );
206
else if ( languageShort == "ja_JP" ) {
207
uiGuiLanguage->setItemText( i, tr("Japanese") );
209
else if ( languageShort == "ru" ) {
210
uiGuiLanguage->setItemText( i, tr("Russian") );
212
else if ( languageShort == "uk" ) {
213
uiGuiLanguage->setItemText( i, tr("Ukrainian") );
216
uiGuiLanguage->setItemText( i, tr("Unknown language mnemonic ") + languageShort );
221
QWidget::changeEvent(event);