Mercurial > hg > octave-lyh
comparison libgui/src/settings-dialog.cc @ 15972:22ab4fe661d7
gui: selectable language in settings dialog
* octave-gui.cc(octave_start_gu): install translators for gui and qt strings
* resource-manager.cc(get_gui_translation_dir): new function returning the
directory of the translator files
* resource-manager.cc(config_translators): new function replacing
find_trnaslator_file and configuring the translators for gui and qt strings
* resource-manager.h: declaration of new function in resource-manager.cc
* settings-dialog.ui: new combo box for selecting the desired language
* settings-dialog.cc(settings_dialog): look for available translator files and
the actual language setting and fill the language combo box
* settings-dialog.cc(write_changed_settings): get the selected element from
the language combo box and write the selection into the settings file
author | Torsten <ttl@justmail.de> |
---|---|
date | Sat, 19 Jan 2013 16:21:55 +0100 |
parents | 85f9aca30c76 |
children | 4bb1b82076e5 |
comparison
equal
deleted
inserted
replaced
15971:e27d9b9b71f4 | 15972:22ab4fe661d7 |
---|---|
26 | 26 |
27 #include "resource-manager.h" | 27 #include "resource-manager.h" |
28 #include "settings-dialog.h" | 28 #include "settings-dialog.h" |
29 #include "ui-settings-dialog.h" | 29 #include "ui-settings-dialog.h" |
30 #include <QSettings> | 30 #include <QSettings> |
31 #include <QDir> | |
32 #include <QFileInfo> | |
31 | 33 |
32 settings_dialog::settings_dialog (QWidget *p): | 34 settings_dialog::settings_dialog (QWidget *p): |
33 QDialog (p), ui (new Ui::settings_dialog) | 35 QDialog (p), ui (new Ui::settings_dialog) |
34 { | 36 { |
35 ui->setupUi (this); | 37 ui->setupUi (this); |
36 | 38 |
37 QSettings *settings = resource_manager::get_settings (); | 39 QSettings *settings = resource_manager::get_settings (); |
38 | |
39 // FIXME -- what should happen if settings is 0? | 40 // FIXME -- what should happen if settings is 0? |
40 | 41 |
42 // look for available language files and the actual settings | |
43 QString qm_dir_name = resource_manager::get_gui_translation_dir (); | |
44 QDir qm_dir (qm_dir_name); | |
45 QFileInfoList qm_files = qm_dir.entryInfoList (QStringList ("*.qm"), | |
46 QDir::Files | QDir::Readable, | |
47 QDir::Name); | |
48 for (int i = 0; i < qm_files.length (); i++) // insert available languages | |
49 ui->comboBox_language->addItem (qm_files.at (i).baseName ()); | |
50 ui->comboBox_language->insertItem (0,tr("System setting")); // System at beginning | |
51 ui->comboBox_language->insertSeparator (1); // separator after System | |
52 QString language = settings->value ("language","SYSTEM").toString (); | |
53 if (language == "SYSTEM") | |
54 language = tr("System setting"); | |
55 int selected = ui->comboBox_language->findText (language); | |
56 if (selected >= 0) | |
57 ui->comboBox_language->setCurrentIndex (selected); | |
58 else | |
59 ui->comboBox_language->setCurrentIndex (0); // System is default | |
60 | |
61 // which icon has to be selected | |
41 QString widget_icon_set = | 62 QString widget_icon_set = |
42 settings->value ("DockWidgets/widget_icon_set","NONE").toString (); | 63 settings->value ("DockWidgets/widget_icon_set","NONE").toString (); |
43 ui->general_icon_octave-> setChecked (true); // the default (if invalid set) | 64 ui->general_icon_octave-> setChecked (true); // the default (if invalid set) |
44 ui->general_icon_octave-> setChecked (widget_icon_set == "NONE"); | 65 ui->general_icon_octave-> setChecked (widget_icon_set == "NONE"); |
45 ui->general_icon_graphic-> setChecked (widget_icon_set == "GRAPHIC"); | 66 ui->general_icon_graphic-> setChecked (widget_icon_set == "GRAPHIC"); |
102 | 123 |
103 void | 124 void |
104 settings_dialog::write_changed_settings () | 125 settings_dialog::write_changed_settings () |
105 { | 126 { |
106 QSettings *settings = resource_manager::get_settings (); | 127 QSettings *settings = resource_manager::get_settings (); |
107 | |
108 // FIXME -- what should happen if settings is 0? | 128 // FIXME -- what should happen if settings is 0? |
109 | 129 |
130 // the icon set | |
110 QString widget_icon_set = "NONE"; | 131 QString widget_icon_set = "NONE"; |
111 if (ui->general_icon_letter->isChecked ()) | 132 if (ui->general_icon_letter->isChecked ()) |
112 widget_icon_set = "LETTER"; | 133 widget_icon_set = "LETTER"; |
113 else if (ui->general_icon_graphic->isChecked ()) | 134 else if (ui->general_icon_graphic->isChecked ()) |
114 widget_icon_set = "GRAPHIC"; | 135 widget_icon_set = "GRAPHIC"; |
115 settings->setValue ("DockWidgets/widget_icon_set",widget_icon_set); | 136 settings->setValue ("DockWidgets/widget_icon_set",widget_icon_set); |
137 | |
138 // language | |
139 QString language = ui->comboBox_language->currentText (); | |
140 if (language == tr("System setting")) | |
141 language = "SYSTEM"; | |
142 settings->setValue ("language", language); | |
143 | |
144 // other settings | |
116 settings->setValue ("useCustomFileEditor", ui->useCustomFileEditor->isChecked ()); | 145 settings->setValue ("useCustomFileEditor", ui->useCustomFileEditor->isChecked ()); |
117 settings->setValue ("customFileEditor", ui->customFileEditor->text ()); | 146 settings->setValue ("customFileEditor", ui->customFileEditor->text ()); |
118 settings->setValue ("editor/showLineNumbers", ui->editor_showLineNumbers->isChecked ()); | 147 settings->setValue ("editor/showLineNumbers", ui->editor_showLineNumbers->isChecked ()); |
119 settings->setValue ("editor/highlightCurrentLine", ui->editor_highlightCurrentLine->isChecked ()); | 148 settings->setValue ("editor/highlightCurrentLine", ui->editor_highlightCurrentLine->isChecked ()); |
120 settings->setValue ("editor/codeCompletion", ui->editor_codeCompletion->isChecked ()); | 149 settings->setValue ("editor/codeCompletion", ui->editor_codeCompletion->isChecked ()); |
136 settings->setValue ("proxyPort", ui->proxyPort->text ()); | 165 settings->setValue ("proxyPort", ui->proxyPort->text ()); |
137 settings->setValue ("proxyUserName", ui->proxyUserName->text ()); | 166 settings->setValue ("proxyUserName", ui->proxyUserName->text ()); |
138 settings->setValue ("proxyPassword", ui->proxyPassword->text ()); | 167 settings->setValue ("proxyPassword", ui->proxyPassword->text ()); |
139 settings->setValue ("terminal/cursorBlinking", ui->terminal_cursorBlinking->isChecked ()); | 168 settings->setValue ("terminal/cursorBlinking", ui->terminal_cursorBlinking->isChecked ()); |
140 | 169 |
170 // the cursor | |
141 QString cursorType; | 171 QString cursorType; |
142 switch (ui->terminal_cursorType->currentIndex ()) | 172 switch (ui->terminal_cursorType->currentIndex ()) |
143 { | 173 { |
144 case 0: cursorType = "ibeam"; break; | 174 case 0: cursorType = "ibeam"; break; |
145 case 1: cursorType = "block"; break; | 175 case 1: cursorType = "block"; break; |