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)
|
if (selectedLanguage() != defaultLangCode)
|
||||||
{
|
{
|
||||||
updateLanguage(selectedLanguage());
|
updateLanguage(selectedLanguage());
|
||||||
APPLICATION->settings()->set("Language", selectedLanguage());
|
|
||||||
}
|
}
|
||||||
|
APPLICATION->settings()->set("Language", selectedLanguage());
|
||||||
d->no_language_set = false;
|
d->no_language_set = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
#include "translations/TranslationsModel.h"
|
#include "translations/TranslationsModel.h"
|
||||||
|
#include "settings/Setting.h"
|
||||||
|
|
||||||
LanguageSelectionWidget::LanguageSelectionWidget(QWidget *parent) :
|
LanguageSelectionWidget::LanguageSelectionWidget(QWidget *parent) :
|
||||||
QWidget(parent)
|
QWidget(parent)
|
||||||
@ -37,6 +38,9 @@ LanguageSelectionWidget::LanguageSelectionWidget(QWidget *parent) :
|
|||||||
languageView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
languageView->header()->setSectionResizeMode(0, QHeaderView::Stretch);
|
||||||
connect(languageView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &LanguageSelectionWidget::languageRowChanged);
|
connect(languageView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &LanguageSelectionWidget::languageRowChanged);
|
||||||
verticalLayout->setContentsMargins(0,0,0,0);
|
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
|
QString LanguageSelectionWidget::getSelectedLanguageKey() const
|
||||||
@ -64,3 +68,10 @@ void LanguageSelectionWidget::languageRowChanged(const QModelIndex& current, con
|
|||||||
translations->selectLanguage(key);
|
translations->selectLanguage(key);
|
||||||
translations->updateLanguage(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 QVBoxLayout;
|
||||||
class QTreeView;
|
class QTreeView;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
|
class Setting;
|
||||||
|
|
||||||
class LanguageSelectionWidget: public QWidget
|
class LanguageSelectionWidget: public QWidget
|
||||||
{
|
{
|
||||||
@ -33,6 +34,7 @@ public:
|
|||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void languageRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
void languageRowChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
|
void languageSettingChanged(const Setting &, const QVariant);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVBoxLayout *verticalLayout = nullptr;
|
QVBoxLayout *verticalLayout = nullptr;
|
||||||
|
Loading…
Reference in New Issue
Block a user