mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
* Added backlight settings * Changed location of the brightness setting * Fix row size of brightness settings * [apps/settings/brightness] Update translations * Fix dimmer * Update translations * [apps/settings] Add dimmer duration setting * [apps/settings] Ensure of the brightness level is greater than the dimmed brightness level * Make transition smooth * Removed transition time setting I personally think that this setting is completely useless except if you absolutely want a transition that is not smooth, which is weird. * Moved everything related to brightness in one submenu * Some refactoring * Update defaults * Removed unnecessary translation * [apps/settings] Fix Shift + Minus/Plus in settings * Apply suggestions from code review * [apps/shared] Remove a think that I don't know what it is * Apply review suggestions Co-authored-by: Joachim LF <joachimlf@pm.me> Co-authored-by: lolocomotive <lolocomotive181@gmail.com>
66 lines
2.3 KiB
C++
66 lines
2.3 KiB
C++
#include "global_preferences.h"
|
|
|
|
GlobalPreferences * GlobalPreferences::sharedGlobalPreferences() {
|
|
static GlobalPreferences globalPreferences;
|
|
return &globalPreferences;
|
|
}
|
|
|
|
GlobalPreferences::ExamMode GlobalPreferences::examMode() const {
|
|
if (m_examMode == ExamMode::Unknown) {
|
|
uint8_t mode = Ion::ExamMode::FetchExamMode();
|
|
assert(mode >= 0 && mode < 5); // mode can be cast in ExamMode (Off, Standard, NoSym, Dutch or NoSymNoText)
|
|
m_examMode = (ExamMode)mode;
|
|
}
|
|
return m_examMode;
|
|
}
|
|
|
|
GlobalPreferences::ExamMode GlobalPreferences::tempExamMode() const {
|
|
return m_tempExamMode;
|
|
}
|
|
|
|
|
|
void GlobalPreferences::setExamMode(ExamMode mode) {
|
|
ExamMode currentMode = examMode();
|
|
if (currentMode == mode) {
|
|
return;
|
|
}
|
|
assert(mode != ExamMode::Unknown);
|
|
int8_t deltaMode = (int8_t)mode - (int8_t)currentMode;
|
|
deltaMode = deltaMode < 0 ? deltaMode + 4 : deltaMode;
|
|
assert(deltaMode > 0);
|
|
Ion::ExamMode::IncrementExamMode(deltaMode);
|
|
m_examMode = mode;
|
|
}
|
|
|
|
void GlobalPreferences::setTempExamMode(ExamMode mode) {
|
|
m_tempExamMode = mode;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
|
|
void GlobalPreferences::setIdleBeforeSuspendSeconds(int idleBeforeSuspendSeconds) {
|
|
if (m_idleBeforeSuspendSeconds != idleBeforeSuspendSeconds) {
|
|
idleBeforeSuspendSeconds = idleBeforeSuspendSeconds < 5 ? 5 : idleBeforeSuspendSeconds;
|
|
idleBeforeSuspendSeconds = idleBeforeSuspendSeconds > 7200 ? 7200 : idleBeforeSuspendSeconds;
|
|
m_idleBeforeSuspendSeconds = idleBeforeSuspendSeconds;
|
|
}
|
|
}
|
|
|
|
void GlobalPreferences::setIdleBeforeDimmingSeconds(int idleBeforeDimmingSeconds) {
|
|
if (m_idleBeforeDimmingSeconds != idleBeforeDimmingSeconds) {
|
|
idleBeforeDimmingSeconds = idleBeforeDimmingSeconds < 3 ? 3 : idleBeforeDimmingSeconds;
|
|
idleBeforeDimmingSeconds = idleBeforeDimmingSeconds > 1200 ? 1200 : idleBeforeDimmingSeconds;
|
|
m_idleBeforeDimmingSeconds = idleBeforeDimmingSeconds;
|
|
}
|
|
}
|
|
|
|
void GlobalPreferences::setBrightnessShortcut(int brightnessShortcut){
|
|
m_brightnessShortcut = brightnessShortcut;
|
|
}
|