1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Save & load language selection

This commit is contained in:
Ivan Savenko 2022-12-25 23:06:22 +02:00
parent b012cd9490
commit 4cd91ffbed
3 changed files with 13 additions and 2 deletions

View File

@ -17,7 +17,7 @@
"type" : "object",
"default": {},
"additionalProperties" : false,
"required" : [ "playerName", "showfps", "music", "sound", "encoding", "swipe", "saveRandomMaps", "saveFrequency", "notifications", "extraDump" ],
"required" : [ "playerName", "showfps", "music", "sound", "encoding", "language", "swipe", "saveRandomMaps", "saveFrequency", "notifications", "extraDump" ],
"properties" : {
"playerName" : {
"type":"string",
@ -51,6 +51,10 @@
"type":"string",
"default" : "Maps/Arrogance"
},
"language" : {
"type":"string",
"default" : "english"
},
"lastSave" : {
"type":"string",
"default" : "NEWGAME"

View File

@ -51,6 +51,7 @@ MainWindow::MainWindow(QWidget * parent)
: QMainWindow(parent), ui(new Ui::MainWindow)
{
load(); // load FS before UI
updateTranslation(); // load translation
ui->setupUi(this);

View File

@ -114,6 +114,11 @@ void CSettingsView::loadSettings()
if(encodingIndex < ui->comboBoxEncoding->count())
ui->comboBoxEncoding->setCurrentIndex((int)encodingIndex);
ui->comboBoxAutoSave->setCurrentIndex(settings["general"]["saveFrequency"].Integer() > 0 ? 1 : 0);
std::string language = settings["general"]["language"].String();
size_t languageIndex = boost::range::find(languageTagList, language) - languageTagList;
if(languageIndex < ui->comboBoxLanguage->count())
ui->comboBoxLanguage->setCurrentIndex((int)languageIndex);
}
void CSettingsView::fillValidResolutions(bool isExtraResolutionsModEnabled)
@ -319,7 +324,8 @@ void CSettingsView::on_comboBoxLanguage_currentIndexChanged(int index)
Settings node = settings.write["general"]["language"];
node->String() = languageTagList[index];
dynamic_cast<MainWindow*>(qApp->activeWindow())->updateTranslation();
if ( qApp->activeWindow() && dynamic_cast<MainWindow*>(qApp->activeWindow()) )
dynamic_cast<MainWindow*>(qApp->activeWindow())->updateTranslation();
}
void CSettingsView::changeEvent(QEvent *event)