Changed: added language support per profiles

--HG--
branch : installer
hg/compatibility-develop
Inky 6 years ago
parent e4ea12409b
commit 85be9aed36

@ -877,6 +877,8 @@ bool COperationDialog::createDefaultProfile()
profile.comments = "Default profile created by Ryzom Installer"; profile.comments = "Default profile created by Ryzom Installer";
profile.desktopShortcut = false; profile.desktopShortcut = false;
profile.menuShortcut = false; profile.menuShortcut = false;
// default use locale
profile.language = config->getLanguage();
#ifdef Q_OS_WIN32 #ifdef Q_OS_WIN32
QStringList paths; QStringList paths;

@ -33,6 +33,7 @@ void CProfile::loadFromSettings(const QSettings &settings)
executable = settings.value("executable").toString(); executable = settings.value("executable").toString();
arguments = settings.value("arguments").toString(); arguments = settings.value("arguments").toString();
comments = settings.value("comments").toString(); comments = settings.value("comments").toString();
language = settings.value("language").toString();
desktopShortcut = settings.value("desktop_shortcut").toBool(); desktopShortcut = settings.value("desktop_shortcut").toBool();
menuShortcut = settings.value("menu_shortcut").toBool(); menuShortcut = settings.value("menu_shortcut").toBool();
} }
@ -45,6 +46,7 @@ void CProfile::saveToSettings(QSettings &settings) const
settings.setValue("executable", executable); settings.setValue("executable", executable);
settings.setValue("arguments", arguments); settings.setValue("arguments", arguments);
settings.setValue("comments", comments); settings.setValue("comments", comments);
settings.setValue("language", language);
settings.setValue("desktop_shortcut", desktopShortcut); settings.setValue("desktop_shortcut", desktopShortcut);
settings.setValue("menu_shortcut", menuShortcut); settings.setValue("menu_shortcut", menuShortcut);
} }
@ -175,7 +177,7 @@ bool CProfile::createClientConfig() const
// create the 2 initial lines of client.cfg // create the 2 initial lines of client.cfg
QString rootConfigFilenameLine = QString("RootConfigFilename = \"%1\";").arg(s.getDefaultClientConfigFullPath()); QString rootConfigFilenameLine = QString("RootConfigFilename = \"%1\";").arg(s.getDefaultClientConfigFullPath());
QString languageCodeline = QString("LanguageCode = \"%1\";\n").arg(CConfigFile::getInstance()->getLanguage()); QString languageCodeline = QString("LanguageCode = \"%1\";\n").arg(language);
QString content; QString content;

@ -34,6 +34,7 @@ public:
QString executable; QString executable;
QString arguments; QString arguments;
QString comments; QString comments;
QString language;
bool desktopShortcut; bool desktopShortcut;
bool menuShortcut; bool menuShortcut;

@ -108,6 +108,7 @@ void CProfilesDialog::displayProfile(int index)
serverComboBox->setEnabled(enabled); serverComboBox->setEnabled(enabled);
argumentsEdit->setEnabled(enabled); argumentsEdit->setEnabled(enabled);
commentsEdit->setEnabled(enabled); commentsEdit->setEnabled(enabled);
langComboBox->setEnabled(enabled);
if (index < 0) return; if (index < 0) return;
@ -134,6 +135,7 @@ void CProfilesDialog::displayProfile(int index)
directoryPathLabel->setText(profileDirectory); directoryPathLabel->setText(profileDirectory);
desktopShortcutCheckBox->setChecked(profile.desktopShortcut); desktopShortcutCheckBox->setChecked(profile.desktopShortcut);
menuShortcutCheckBox->setChecked(profile.menuShortcut); menuShortcutCheckBox->setChecked(profile.menuShortcut);
langComboBox->setCurrentIndex(getIndexFromProfileLanguage(profile.language));
// disable click on button if directory doesn't exist // disable click on button if directory doesn't exist
directoryButton->setEnabled(QFile::exists(profileDirectory)); directoryButton->setEnabled(QFile::exists(profileDirectory));
@ -155,6 +157,7 @@ void CProfilesDialog::saveProfile(int index)
profile.comments = commentsEdit->toPlainText(); profile.comments = commentsEdit->toPlainText();
profile.desktopShortcut = desktopShortcutCheckBox->isChecked(); profile.desktopShortcut = desktopShortcutCheckBox->isChecked();
profile.menuShortcut = menuShortcutCheckBox->isChecked(); profile.menuShortcut = menuShortcutCheckBox->isChecked();
profile.language = getProfileLanguageFromIndex(langComboBox->currentIndex());
} }
void CProfilesDialog::deleteProfile(int index) void CProfilesDialog::deleteProfile(int index)
@ -216,6 +219,7 @@ void CProfilesDialog::addProfile()
// set default parameters // set default parameters
profile.id = QString::number(nextId); profile.id = QString::number(nextId);
profile.server = server.id; profile.server = server.id;
profile.language = config->getLanguage(); // locale
profilesListView->setCurrentIndex(m_model->index(index, 0)); profilesListView->setCurrentIndex(m_model->index(index, 0));
displayProfile(index); displayProfile(index);
@ -312,3 +316,25 @@ void CProfilesDialog::onProfileDirectoryClicked()
QDesktopServices::openUrl(QUrl::fromLocalFile(profileDirectory)); QDesktopServices::openUrl(QUrl::fromLocalFile(profileDirectory));
} }
int CProfilesDialog::getIndexFromProfileLanguage(const QString &lang) const
{
if (lang == "en") return 0;
if (lang == "fr") return 1;
if (lang == "de") return 2;
if (lang == "es") return 3;
if (lang == "ru") return 4;
return -1;
}
QString CProfilesDialog::getProfileLanguageFromIndex(int index) const
{
if (index == 0) return "en";
if (index == 1) return "fr";
if (index == 2) return "de";
if (index == 3) return "es";
if (index == 4) return "ru";
// locale
return CConfigFile::getInstance()->getLanguage();
}

@ -54,6 +54,10 @@ private slots:
void onExecutableDefaultClicked(); void onExecutableDefaultClicked();
void onExecutableBrowseClicked(); void onExecutableBrowseClicked();
int getIndexFromProfileLanguage(const QString &langId) const;
QString getProfileLanguageFromIndex(int index) const;
private: private:
CProfilesModel *m_model; CProfilesModel *m_model;
CServersModel *m_serversModel; CServersModel *m_serversModel;

Loading…
Cancel
Save