From a2c85a8531208194c992590fe4d89b853b057da2 Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Tue, 22 Feb 2022 17:40:50 +0000 Subject: [PATCH] App: Retranslate page header titles This fixes a bug that is only practically effects the title of the language page not updating the header when changing the language. --- launcher/ui/widgets/PageContainer.cpp | 14 ++++++++++++++ launcher/ui/widgets/PageContainer.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/launcher/ui/widgets/PageContainer.cpp b/launcher/ui/widgets/PageContainer.cpp index 558a98fb..b5a87f8b 100644 --- a/launcher/ui/widgets/PageContainer.cpp +++ b/launcher/ui/widgets/PageContainer.cpp @@ -162,6 +162,12 @@ void PageContainer::createUI() setLayout(m_layout); } +void PageContainer::retranslate() +{ + if (m_currentPage) + m_header->setText(m_currentPage->displayName()); +} + void PageContainer::addButtons(QWidget *buttons) { m_layout->addWidget(buttons, 2, 0, 1, 2); @@ -239,3 +245,11 @@ bool PageContainer::saveAll() } return true; } + +void PageContainer::changeEvent(QEvent* event) +{ + if (event->type() == QEvent::LanguageChange) { + retranslate(); + } + QWidget::changeEvent(event); +} diff --git a/launcher/ui/widgets/PageContainer.h b/launcher/ui/widgets/PageContainer.h index 8d2172db..b5d0e3c1 100644 --- a/launcher/ui/widgets/PageContainer.h +++ b/launcher/ui/widgets/PageContainer.h @@ -66,8 +66,11 @@ public: m_container = container; }; + void changeEvent(QEvent*) override; + private: void createUI(); + void retranslate(); public slots: void help();