mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-18 16:27:34 +01:00
[apps] Add Shift + Ans shortcut to go to the last application (#196)
This commit is contained in:
@@ -225,6 +225,7 @@ bool AppsContainer::dispatchEvent(Ion::Events::Event event) {
|
|||||||
return didProcessEvent || alphaLockWantsRedraw;
|
return didProcessEvent || alphaLockWantsRedraw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List of keys that are used to switch between apps, in order of app to go (eg. 0 : First App, 1 : Second App, 2 : Third App, ...)
|
||||||
static constexpr Ion::Events::Event switch_events[] = {
|
static constexpr Ion::Events::Event switch_events[] = {
|
||||||
Ion::Events::ShiftSeven, Ion::Events::ShiftEight, Ion::Events::ShiftNine,
|
Ion::Events::ShiftSeven, Ion::Events::ShiftEight, Ion::Events::ShiftNine,
|
||||||
Ion::Events::ShiftFour, Ion::Events::ShiftFive, Ion::Events::ShiftSix,
|
Ion::Events::ShiftFour, Ion::Events::ShiftFive, Ion::Events::ShiftSix,
|
||||||
@@ -236,14 +237,17 @@ bool AppsContainer::processEvent(Ion::Events::Event event) {
|
|||||||
// Warning: if the window is dirtied, you need to call window()->redraw()
|
// Warning: if the window is dirtied, you need to call window()->redraw()
|
||||||
if (event == Ion::Events::USBPlug) {
|
if (event == Ion::Events::USBPlug) {
|
||||||
if (Ion::USB::isPlugged()) {
|
if (Ion::USB::isPlugged()) {
|
||||||
|
// If the exam mode is enabled, we ask to disable it, else, we enable USB
|
||||||
if (GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
|
if (GlobalPreferences::sharedGlobalPreferences()->isInExamMode()) {
|
||||||
displayExamModePopUp(GlobalPreferences::ExamMode::Off);
|
displayExamModePopUp(GlobalPreferences::ExamMode::Off);
|
||||||
window()->redraw();
|
window()->redraw();
|
||||||
} else {
|
} else {
|
||||||
Ion::USB::enable();
|
Ion::USB::enable();
|
||||||
}
|
}
|
||||||
|
// Update brightness when USB is plugged
|
||||||
Ion::Backlight::setBrightness(GlobalPreferences::sharedGlobalPreferences()->brightnessLevel());
|
Ion::Backlight::setBrightness(GlobalPreferences::sharedGlobalPreferences()->brightnessLevel());
|
||||||
} else {
|
} else {
|
||||||
|
// If the USB isn't plugged in USBPlug event, we disable USB
|
||||||
Ion::USB::disable();
|
Ion::USB::disable();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -274,20 +278,38 @@ bool AppsContainer::processEvent(Ion::Events::Event event) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add Shift + Ans shortcut to go to the previous app
|
||||||
|
if (event == Ion::Events::ShiftAns) {
|
||||||
|
switchTo(appSnapshotAtIndex(m_lastAppIndex));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the event is the OnOff key, we suspend the calculator.
|
||||||
if (event == Ion::Events::OnOff) {
|
if (event == Ion::Events::OnOff) {
|
||||||
suspend(true);
|
suspend(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// If the event is a brightness event, we update the brightness according to the event.
|
||||||
if (event == Ion::Events::BrightnessPlus || event == Ion::Events::BrightnessMinus) {
|
if (event == Ion::Events::BrightnessPlus || event == Ion::Events::BrightnessMinus) {
|
||||||
int delta = Ion::Backlight::MaxBrightness/GlobalPreferences::NumberOfBrightnessStates;
|
int delta = Ion::Backlight::MaxBrightness/GlobalPreferences::NumberOfBrightnessStates;
|
||||||
int NumberOfStepsPerShortcut = GlobalPreferences::sharedGlobalPreferences()->brightnessShortcut();
|
int NumberOfStepsPerShortcut = GlobalPreferences::sharedGlobalPreferences()->brightnessShortcut();
|
||||||
int direction = (event == Ion::Events::BrightnessPlus) ? NumberOfStepsPerShortcut*delta : -delta*NumberOfStepsPerShortcut;
|
int direction = (event == Ion::Events::BrightnessPlus) ? NumberOfStepsPerShortcut*delta : -delta*NumberOfStepsPerShortcut;
|
||||||
GlobalPreferences::sharedGlobalPreferences()->setBrightnessLevel(GlobalPreferences::sharedGlobalPreferences()->brightnessLevel()+direction);
|
GlobalPreferences::sharedGlobalPreferences()->setBrightnessLevel(GlobalPreferences::sharedGlobalPreferences()->brightnessLevel()+direction);
|
||||||
}
|
}
|
||||||
|
// Else, the event was not processed.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AppsContainer::switchTo(App::Snapshot * snapshot) {
|
bool AppsContainer::switchTo(App::Snapshot * snapshot) {
|
||||||
|
// Get app index of the snapshot
|
||||||
|
int m_appIndexToSwitch = appIndexFromSnapshot(snapshot);
|
||||||
|
// If the app is home, skip app index saving
|
||||||
|
if (m_appIndexToSwitch != 0) {
|
||||||
|
// Save last app index
|
||||||
|
m_lastAppIndex = m_currentAppIndex;
|
||||||
|
// Save current app index
|
||||||
|
m_currentAppIndex = m_appIndexToSwitch;
|
||||||
|
}
|
||||||
if (s_activeApp && snapshot != s_activeApp->snapshot()) {
|
if (s_activeApp && snapshot != s_activeApp->snapshot()) {
|
||||||
resetShiftAlphaStatus();
|
resetShiftAlphaStatus();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ public:
|
|||||||
static bool poincareCircuitBreaker();
|
static bool poincareCircuitBreaker();
|
||||||
virtual int numberOfApps() = 0;
|
virtual int numberOfApps() = 0;
|
||||||
virtual App::Snapshot * appSnapshotAtIndex(int index) = 0;
|
virtual App::Snapshot * appSnapshotAtIndex(int index) = 0;
|
||||||
|
virtual int appIndexFromSnapshot(App::Snapshot * snapshot) = 0;
|
||||||
App::Snapshot * initialAppSnapshot();
|
App::Snapshot * initialAppSnapshot();
|
||||||
App::Snapshot * hardwareTestAppSnapshot();
|
App::Snapshot * hardwareTestAppSnapshot();
|
||||||
App::Snapshot * onBoardingAppSnapshot();
|
App::Snapshot * onBoardingAppSnapshot();
|
||||||
@@ -67,6 +68,8 @@ private:
|
|||||||
static KDColor k_promptFGColors[];
|
static KDColor k_promptFGColors[];
|
||||||
static KDColor k_promptBGColors[];
|
static KDColor k_promptBGColors[];
|
||||||
static int k_promptNumberOfMessages;
|
static int k_promptNumberOfMessages;
|
||||||
|
int m_currentAppIndex; // Home isn't included after the second app switching
|
||||||
|
int m_lastAppIndex;
|
||||||
AppsWindow m_window;
|
AppsWindow m_window;
|
||||||
EmptyBatteryWindow m_emptyBatteryWindow;
|
EmptyBatteryWindow m_emptyBatteryWindow;
|
||||||
Shared::GlobalContext m_globalContext;
|
Shared::GlobalContext m_globalContext;
|
||||||
|
|||||||
@@ -36,3 +36,20 @@ App::Snapshot * AppsContainerStorage::appSnapshotAtIndex(int index) {
|
|||||||
assert(index >= 0 && index < k_numberOfCommonApps);
|
assert(index >= 0 && index < k_numberOfCommonApps);
|
||||||
return snapshots[index];
|
return snapshots[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the index of the app from its snapshot
|
||||||
|
int AppsContainerStorage::appIndexFromSnapshot(App::Snapshot * snapshot) {
|
||||||
|
App::Snapshot * snapshots[] = {
|
||||||
|
homeAppSnapshot()
|
||||||
|
APPS_CONTAINER_SNAPSHOT_LIST
|
||||||
|
};
|
||||||
|
assert(sizeof(snapshots)/sizeof(snapshots[0]) == k_numberOfCommonApps);
|
||||||
|
for (int i = 0; i < k_numberOfCommonApps; i++) {
|
||||||
|
if (snapshots[i] == snapshot) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Achievement unlock : how did you get here ?
|
||||||
|
assert(false);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public:
|
|||||||
AppsContainerStorage();
|
AppsContainerStorage();
|
||||||
int numberOfApps() override;
|
int numberOfApps() override;
|
||||||
App::Snapshot * appSnapshotAtIndex(int index) override;
|
App::Snapshot * appSnapshotAtIndex(int index) override;
|
||||||
|
int appIndexFromSnapshot(App::Snapshot * snapshot) override;
|
||||||
void * currentAppBuffer() override { return &m_apps; };
|
void * currentAppBuffer() override { return &m_apps; };
|
||||||
private:
|
private:
|
||||||
union Apps {
|
union Apps {
|
||||||
|
|||||||
@@ -185,6 +185,7 @@ constexpr Event ShiftSeven = Event::ShiftKey(Keyboard::Key::Seven);
|
|||||||
constexpr Event ShiftEight = Event::ShiftKey(Keyboard::Key::Eight);
|
constexpr Event ShiftEight = Event::ShiftKey(Keyboard::Key::Eight);
|
||||||
constexpr Event ShiftNine = Event::ShiftKey(Keyboard::Key::Nine);
|
constexpr Event ShiftNine = Event::ShiftKey(Keyboard::Key::Nine);
|
||||||
|
|
||||||
|
constexpr Event ShiftAns = Event::ShiftKey(Keyboard::Key::Ans);
|
||||||
constexpr Event ShiftEXE = Event::ShiftKey(Keyboard::Key::EXE);
|
constexpr Event ShiftEXE = Event::ShiftKey(Keyboard::Key::EXE);
|
||||||
|
|
||||||
// Alpha
|
// Alpha
|
||||||
|
|||||||
Reference in New Issue
Block a user