[apps/settings] Reload the title bar when changing language

Before, the "Settings" title would not be immediately translated into
the new language.
This commit is contained in:
Léa Saviot
2019-02-27 17:12:37 +01:00
committed by Émilie Feral
parent 40c057f0ee
commit d0300c0e7f
7 changed files with 19 additions and 1 deletions

View File

@@ -300,6 +300,10 @@ void AppsContainer::refreshPreferences() {
m_window.refreshPreferences();
}
void AppsContainer::reloadTitleBarView() {
m_window.reloadTitleBarView();
}
void AppsContainer::displayExamModePopUp(bool activate) {
m_examPopUpController.setActivatingExamMode(activate);
activeApp()->displayModalViewController(&m_examPopUpController, 0.f, 0.f, Metric::ExamPopUpTopMargin, Metric::PopUpRightMargin, Metric::ExamPopUpBottomMargin, Metric::PopUpLeftMargin);

View File

@@ -41,6 +41,7 @@ public:
void run() override;
bool updateBatteryState();
void refreshPreferences();
void reloadTitleBarView();
void displayExamModePopUp(bool activate);
void shutdownDueToLowBattery();
void setShiftAlphaStatus(Ion::Events::ShiftAlphaStatus newStatus);

View File

@@ -31,6 +31,10 @@ void AppsWindow::refreshPreferences() {
m_titleBarView.refreshPreferences();
}
void AppsWindow::reloadTitleBarView() {
m_titleBarView.reload();
}
bool AppsWindow::updateAlphaLock() {
return m_titleBarView.setShiftAlphaLockStatus(Ion::Events::shiftAlphaStatus());
}

View File

@@ -12,6 +12,7 @@ public:
bool updateIsChargingState();
bool updatePluggedState();
void refreshPreferences();
void reloadTitleBarView();
bool updateAlphaLock();
void hideTitleBarView(bool hide);
private:

View File

@@ -41,8 +41,10 @@ void LanguageController::viewWillAppear() {
bool LanguageController::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
GlobalPreferences::sharedGlobalPreferences()->setLanguage((I18n::Language)(selectedRow()+1));
/* We need to reload the whole title bar in order to translate both the
* "Settings" title and the degree preference. */
AppsContainer * myContainer = (AppsContainer * )app()->container();
myContainer->refreshPreferences();
myContainer->reloadTitleBarView();
return true;
}
return false;

View File

@@ -98,3 +98,8 @@ void TitleBarView::refreshPreferences() {
// Layout the exam mode icon if needed
layoutSubviews();
}
void TitleBarView::reload() {
refreshPreferences();
markRectAsDirty(bounds());
}

View File

@@ -16,6 +16,7 @@ public:
bool setIsPlugged(bool isPlugged);
bool setShiftAlphaLockStatus(Ion::Events::ShiftAlphaStatus status);
void refreshPreferences();
void reload();
private:
constexpr static KDCoordinate k_alphaRightMargin = 5;
constexpr static KDCoordinate k_examIconWidth = 18;