Esempio n. 1
0
void ConfigDialog::setIniPath(const QString & _strIniPath)
{
    m_strIniPath = _strIniPath;

    QStringList translationFiles;
    _getTranslations(translationFiles);

    const QString currentTranslation = getTranslationFile();
    int listIndex = 0;
    QStringList translationLanguages("English");
    for (int i = 0; i < translationFiles.size(); ++i) {
        // get locale extracted by filename
        QString locale = translationFiles[i]; // "TranslationExample_de.qm"
        const bool bCurrent = locale == currentTranslation;
        locale.truncate(locale.lastIndexOf('.')); // "TranslationExample_de"
        locale.remove(0, locale.indexOf('_') + 1); // "de"
        QString language = QLocale::languageToString(QLocale(locale).language());
        if (bCurrent) {
            listIndex = i + 1;
        }
        translationLanguages << language;
    }

    ui->translationsComboBox->insertItems(0, translationLanguages);
    ui->translationsComboBox->setCurrentIndex(listIndex);
}
Esempio n. 2
0
void ConfigDialog::setIniPath(const QString & _strIniPath)
{
	m_strIniPath = _strIniPath;

	QStringList translationFiles;
	_getTranslations(translationFiles);

	const QString currentTranslation = getTranslationFile();
	int listIndex = 0;
	QStringList translationLanguages("English");
	for (int i = 0; i < translationFiles.size(); ++i) {
		// get locale extracted by filename
		QString locale = translationFiles[i]; // "TranslationExample_de.qm"
		const bool bCurrent = locale == currentTranslation;
		locale.truncate(locale.lastIndexOf('.')); // "TranslationExample_de"
		locale.remove(0, locale.indexOf('_') + 1); // "de"
		QString language = QLocale(locale).nativeLanguageName();
		language = language.left(1).toUpper() + language.remove(0, 1);
		if (bCurrent) {
			listIndex = i + 1;
		}
		translationLanguages << language;
	}

	ui->translationsComboBox->insertItems(0, translationLanguages);
	ui->translationsComboBox->setCurrentIndex(listIndex);

	// Profile
	ui->profilesComboBox->blockSignals(true);
	const QStringList aProfiles = getProfiles(m_strIniPath);
	ui->profilesComboBox->addItems(aProfiles);
	ui->profilesComboBox->setCurrentIndex(aProfiles.indexOf(getCurrentProfile(m_strIniPath)));
	ui->profilesComboBox->blockSignals(false);
	ui->removeProfilePushButton->setEnabled(ui->profilesComboBox->count() > 1);
}