Update selected language automatically
This commit is contained in:
parent
126e6d13aa
commit
2dd2555a63
@ -179,8 +179,8 @@ void TranslationsModel::translationDirChanged(const QString& path)
|
||||
if (selectedLanguage() != defaultLangCode)
|
||||
{
|
||||
updateLanguage(selectedLanguage());
|
||||
APPLICATION->settings()->set("Language", selectedLanguage());
|
||||
}
|
||||
APPLICATION->settings()->set("Language", selectedLanguage());
|
||||
d->no_language_set = false;
|
||||
}
|
||||
else
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <QLabel>
|
||||
#include "Application.h"
|
||||
#include "translations/TranslationsModel.h"
|
||||
#include "settings/Setting.h"
|
||||
|
||||
LanguageSelectionWidget::LanguageSelectionWidget(QWidget *parent) :
|
||||
QWidget(parent)
|
||||
@ -37,6 +38,9 @@ LanguageSelectionWidget::LanguageSelectionWidget(QWidget *parent) :
|
||||
languageView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||
connect(languageView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &LanguageSelectionWidget::languageRowChanged);
|
||||
verticalLayout->setContentsMargins(0,0,0,0);
|
||||
|
||||
auto language_setting = APPLICATION->settings()->getSetting("Language");
|
||||
connect(language_setting.get(), &Setting::SettingChanged, this, &LanguageSelectionWidget::languageSettingChanged);
|
||||
}
|
||||
|
||||
QString LanguageSelectionWidget::getSelectedLanguageKey() const
|
||||
@ -64,3 +68,10 @@ void LanguageSelectionWidget::languageRowChanged(const QModelIndex& current, con
|
||||
translations->selectLanguage(key);
|
||||
translations->updateLanguage(key);
|
||||
}
|
||||
|
||||
void LanguageSelectionWidget::languageSettingChanged(const Setting &, const QVariant)
|
||||
{
|
||||
auto translations = APPLICATION->translations();
|
||||
auto index = translations->selectedIndex();
|
||||
languageView->setCurrentIndex(index);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
class QVBoxLayout;
|
||||
class QTreeView;
|
||||
class QLabel;
|
||||
class Setting;
|
||||
|
||||
class LanguageSelectionWidget: public QWidget
|
||||
{
|
||||
@ -33,6 +34,7 @@ public:
|
||||
|
||||
protected slots:
|
||||
void languageRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
void languageSettingChanged(const Setting &, const QVariant);
|
||||
|
||||
private:
|
||||
QVBoxLayout *verticalLayout = nullptr;
|
||||
|
Loading…
Reference in New Issue
Block a user