src/settingseditor/settingseditor.cpp

changeset 286
04478da357d0
parent 285
99af8bf63d10
child 296
38f6fad61bad
equal deleted inserted replaced
285:99af8bf63d10 286:04478da357d0
44 delete &this->ui; 44 delete &this->ui;
45 } 45 }
46 46
47 void SettingsEditor::saveSettings() 47 void SettingsEditor::saveSettings()
48 { 48 {
49 setSetting<Setting::Locale>(this->ui.language->currentData().toString()); 49 //setSetting<Setting::Locale>(this->ui.language->currentData().toString());
50 setSetting<Setting::MainColor>(this->ui.mainColorButton->color()); 50 setSetting<Setting::MainColor>(this->ui.mainColorButton->color());
51 setSetting<Setting::BackgroundColor>(this->ui.backgroundColorButton->color()); 51 setSetting<Setting::BackgroundColor>(this->ui.backgroundColorButton->color());
52 setSetting<Setting::SelectedColor>(this->ui.selectedColorButton->color()); 52 setSetting<Setting::SelectedColor>(this->ui.selectedColorButton->color());
53 setSetting<Setting::LineThickness>(static_cast<GLfloat>(this->ui.lineThickness->value())); 53 setSetting<Setting::LineThickness>(static_cast<GLfloat>(this->ui.lineThickness->value()));
54 setSetting<Setting::LineAntiAliasing>(this->ui.lineAntiAliasing->isChecked()); 54 setSetting<Setting::LineAntiAliasing>(this->ui.lineAntiAliasing->isChecked());
61 Q_EMIT this->settingsChanged(); 61 Q_EMIT this->settingsChanged();
62 } 62 }
63 63
64 void SettingsEditor::loadLocales() 64 void SettingsEditor::loadLocales()
65 { 65 {
66 /*
66 this->ui.language->clear(); 67 this->ui.language->clear();
67 QDir dir{":/locale"}; 68 QDir dir{":/locale"};
68 // Collect translation files in built-in resources 69 // Collect translation files in built-in resources
69 QVector<QString> localeCodes = {"en"}; // English is the default locale 70 QVector<QString> localeCodes = {"en"}; // English is the default locale
70 for (const QFileInfo& file : dir.entryInfoList(QDir::Files)) 71 for (const QFileInfo& file : dir.entryInfoList(QDir::Files))
79 const QString languageName = QLocale::languageToString(locale.language()); 80 const QString languageName = QLocale::languageToString(locale.language());
80 const QIcon flag{":/flags/" + localeCode + ".png"}; 81 const QIcon flag{":/flags/" + localeCode + ".png"};
81 this->ui.language->addItem(languageName, localeCode); 82 this->ui.language->addItem(languageName, localeCode);
82 this->ui.language->setItemIcon(this->ui.language->count() - 1, flag); 83 this->ui.language->setItemIcon(this->ui.language->count() - 1, flag);
83 } 84 }
85 */
84 } 86 }
85 87
86 void SettingsEditor::loadSettings() 88 void SettingsEditor::loadSettings()
87 { 89 {
88 this->libraries.restoreFromSettings(); 90 this->libraries.restoreFromSettings();
89 this->setCurrentLanguage(setting<Setting::Locale>()); 91 //this->setCurrentLanguage(setting<Setting::Locale>());
90 this->ui.mainColorButton->setColor(setting<Setting::MainColor>()); 92 this->ui.mainColorButton->setColor(setting<Setting::MainColor>());
91 this->ui.backgroundColorButton->setColor(setting<Setting::BackgroundColor>()); 93 this->ui.backgroundColorButton->setColor(setting<Setting::BackgroundColor>());
92 this->ui.selectedColorButton->setColor(setting<Setting::SelectedColor>()); 94 this->ui.selectedColorButton->setColor(setting<Setting::SelectedColor>());
93 this->ui.lineThickness->setValue(double_cast(setting<Setting::LineThickness>())); 95 this->ui.lineThickness->setValue(double_cast(setting<Setting::LineThickness>()));
94 this->ui.lineAntiAliasing->setChecked(setting<Setting::LineAntiAliasing>()); 96 this->ui.lineAntiAliasing->setChecked(setting<Setting::LineAntiAliasing>());
99 } 101 }
100 } 102 }
101 103
102 void SettingsEditor::setCurrentLanguage(const QString& localeCode) 104 void SettingsEditor::setCurrentLanguage(const QString& localeCode)
103 { 105 {
106 /*
104 for (int i = 0; i < this->ui.language->count(); i += 1) 107 for (int i = 0; i < this->ui.language->count(); i += 1)
105 { 108 {
106 if (this->ui.language->itemData(i) == localeCode) 109 if (this->ui.language->itemData(i) == localeCode)
107 { 110 {
108 this->ui.language->setCurrentIndex(i); 111 this->ui.language->setCurrentIndex(i);
109 break; 112 break;
110 } 113 }
111 } 114 }
115 */
112 } 116 }

mercurial