diff options
author | Lioncash <mathew1800@gmail.com> | 2019-06-05 18:39:46 -0400 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2019-06-05 21:57:21 -0400 |
commit | c09ff382a41cfc631efa9392bdb3143bd4c713a5 (patch) | |
tree | a1755331546012b9c1e5711d78372bc4dda1bce7 /src/yuzu/configuration/configure_profile_manager.cpp | |
parent | 8d7a012297ea884f0309ed2207eeb5e6c8d6a495 (diff) |
yuzu/configuration: Make all widgets and dialogs aware of language changes
To prepare for translation support, this makes all of the widgets
cognizant of the language change event that occurs whenever
installTranslator() is called and automatically retranslates their text
where necessary.
This is important as calling the backing UI's retranslateUi() is often
not enough, particularly in cases where we add our own strings that
aren't controlled by it. In that case we need to manually refresh the
strings ourselves.
Diffstat (limited to 'src/yuzu/configuration/configure_profile_manager.cpp')
-rw-r--r-- | src/yuzu/configuration/configure_profile_manager.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/yuzu/configuration/configure_profile_manager.cpp b/src/yuzu/configuration/configure_profile_manager.cpp index 7c1597488..c90f4cdd8 100644 --- a/src/yuzu/configuration/configure_profile_manager.cpp +++ b/src/yuzu/configuration/configure_profile_manager.cpp @@ -80,11 +80,10 @@ ConfigureProfileManager ::ConfigureProfileManager(QWidget* parent) profile_manager(std::make_unique<Service::Account::ProfileManager>()) { ui->setupUi(this); - layout = new QVBoxLayout; tree_view = new QTreeView; item_model = new QStandardItemModel(tree_view); + item_model->insertColumns(0, 1); tree_view->setModel(item_model); - tree_view->setAlternatingRowColors(true); tree_view->setSelectionMode(QHeaderView::SingleSelection); tree_view->setSelectionBehavior(QHeaderView::SelectRows); @@ -96,13 +95,11 @@ ConfigureProfileManager ::ConfigureProfileManager(QWidget* parent) tree_view->setIconSize({64, 64}); tree_view->setContextMenuPolicy(Qt::NoContextMenu); - item_model->insertColumns(0, 1); - item_model->setHeaderData(0, Qt::Horizontal, tr("Users")); - // We must register all custom types with the Qt Automoc system so that we are able to use it // with signals/slots. In this case, QList falls under the umbrells of custom types. qRegisterMetaType<QList<QStandardItem*>>("QList<QStandardItem*>"); + layout = new QVBoxLayout; layout->setContentsMargins(0, 0, 0, 0); layout->setSpacing(0); layout->addWidget(tree_view); @@ -120,10 +117,24 @@ ConfigureProfileManager ::ConfigureProfileManager(QWidget* parent) ui->current_user_icon->setScene(scene); SetConfiguration(); + RetranslateUI(); } ConfigureProfileManager::~ConfigureProfileManager() = default; +void ConfigureProfileManager::changeEvent(QEvent* event) { + if (event->type() == QEvent::LanguageChange) { + RetranslateUI(); + } + + QWidget::changeEvent(event); +} + +void ConfigureProfileManager::RetranslateUI() { + ui->retranslateUi(this); + item_model->setHeaderData(0, Qt::Horizontal, tr("Users")); +} + void ConfigureProfileManager::SetConfiguration() { enabled = !Core::System::GetInstance().IsPoweredOn(); item_model->removeRows(0, item_model->rowCount()); |