Fix the "About" tab being empty when the language is not set (#280)

Fixes #267.
This commit is contained in:
Daniel Kamil Kozar 2020-04-18 16:26:53 +02:00 committed by GitHub
parent 5d40242700
commit f044a88c35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -237,7 +237,7 @@ QString getComboBoxTrackText(int idx, const QtvCodecInfo &codecInfo)
void initLanguageComboBox(QComboBox *comboBox)
{
comboBox->addItem("English", "en");
comboBox->addItem("English", "en"); // 0th index is also used as default if the language isn't set in the settings.
comboBox->addItem(QString::fromUtf8("Русский"), "ru");
comboBox->setCurrentIndex(-1); // makes sure currentIndexChanged() is emitted when reading settings.
}
@ -1881,6 +1881,7 @@ void TsMuxerWindow::onLanguageComboBoxIndexChanged(int idx)
qWarning() << "Failed to open about.html for language" << lang << aboutContent.errorString();
ui->textEdit->clear();
}
writeSettings();
}
void TsMuxerWindow::updateMetaLines()
@ -2819,6 +2820,17 @@ bool TsMuxerWindow::readSettings()
bool TsMuxerWindow::readGeneralSettings(const QString &prefix)
{
settings->beginGroup(prefix);
auto lang = settings->value("language");
if (lang.isValid())
{
ui->languageSelectComboBox->setCurrentText(lang.toString());
}
else
{
ui->languageSelectComboBox->setCurrentIndex(0);
}
if (!settings->contains("outputDir"))
{
settings->endGroup();
@ -2840,8 +2852,6 @@ bool TsMuxerWindow::readGeneralSettings(const QString &prefix)
ui->radioButtonOutoutInInput->setChecked(settings->value("outputToInputFolder").toBool());
ui->radioButtonStoreOutput->setChecked(!ui->radioButtonOutoutInInput->isChecked());
ui->languageSelectComboBox->setCurrentText(settings->value("language").toString());
settings->endGroup();
return true;
}