mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] Add a brightness level in preferences
This commit is contained in:
@@ -103,7 +103,7 @@ void AppsContainer::suspend(bool checkIfPowerKeyReleased) {
|
||||
/* Ion::Power::suspend() completely shuts down the LCD controller. Therefore
|
||||
* the frame memory is lost. That's why we need to force a window redraw
|
||||
* upon wakeup, otherwise the screen is filled with noise. */
|
||||
Ion::Backlight::setBrightness(Ion::Backlight::MaxBrightness);
|
||||
Ion::Backlight::setBrightness(GlobalPreferences::sharedGlobalPreferences()->brightnessLevel());
|
||||
m_backlightDimmingTimer.reset();
|
||||
window()->redraw(true);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
|
||||
if (event.isKeyboardEvent()) {
|
||||
m_backlightDimmingTimer.reset();
|
||||
m_suspendTimer.reset();
|
||||
Ion::Backlight::setBrightness(Ion::Backlight::MaxBrightness);
|
||||
Ion::Backlight::setBrightness(GlobalPreferences::sharedGlobalPreferences()->brightnessLevel());
|
||||
}
|
||||
if (!didProcessEvent && alphaLockWantsRedraw) {
|
||||
window()->redraw();
|
||||
|
||||
@@ -5,7 +5,8 @@ static GlobalPreferences s_globalPreferences;
|
||||
GlobalPreferences::GlobalPreferences() :
|
||||
m_language(I18n::Language::French),
|
||||
m_examMode(ExamMode::Desactivate),
|
||||
m_showUpdatePopUp(true)
|
||||
m_showUpdatePopUp(true),
|
||||
m_brightnessLevel(Ion::Backlight::MaxBrightness)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -42,3 +43,16 @@ void GlobalPreferences::setShowUpdatePopUp(bool showUpdatePopUp) {
|
||||
m_showUpdatePopUp = showUpdatePopUp;
|
||||
}
|
||||
}
|
||||
|
||||
int GlobalPreferences::brightnessLevel() const {
|
||||
return m_brightnessLevel;
|
||||
}
|
||||
|
||||
void GlobalPreferences::setBrightnessLevel(int brightnessLevel) {
|
||||
if (m_brightnessLevel != brightnessLevel) {
|
||||
brightnessLevel = brightnessLevel < 0 ? 0 : brightnessLevel;
|
||||
brightnessLevel = brightnessLevel > Ion::Backlight::MaxBrightness ? Ion::Backlight::MaxBrightness : brightnessLevel;
|
||||
m_brightnessLevel = brightnessLevel;
|
||||
Ion::Backlight::setBrightness(m_brightnessLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,10 +17,14 @@ public:
|
||||
void setExamMode(ExamMode examMode);
|
||||
bool showUpdatePopUp() const;
|
||||
void setShowUpdatePopUp(bool showUpdatePopUp);
|
||||
int brightnessLevel() const;
|
||||
void setBrightnessLevel(int brightnessLevel);
|
||||
constexpr static int NumberOfBrightnessStates = 5;
|
||||
private:
|
||||
I18n::Language m_language;
|
||||
ExamMode m_examMode;
|
||||
bool m_showUpdatePopUp;
|
||||
int m_brightnessLevel;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user