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.
This commit is contained in:
parent
02f5a7327c
commit
fb580dcda2
31 changed files with 326 additions and 58 deletions
|
@ -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());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue