## Summary * **What is the goal of this PR?** Mainly fixes #2196, but also allows users to set a sleep time of 1~30 min or to never sleep. * **What changes are included?** 1. Revert changes from #1948 and #2137 (Sorry @Uri-Tauber) 2. Cherrypick changes from https://github.com/uxjulia/CrossInk/commit/0cb91c3dd1c63f0559d4392fadc4a8340af5bdde and https://github.com/uxjulia/CrossInk/commit/4e6bd634b6ede51ff1a7107ba3e8efcd152bc6ee for a timeout interval picker UI, the custom sleep time feature, and migrate the existing setting in v1.3.0, `sleepTimeout`, to `sleepTimeoutMinutes` (Thanks! @uxjulia) 3. Add a "Never" at the far right of the timeout interval picker --- ### AI Usage While CrossPoint doesn't have restrictions on AI tools in contributing, please be transparent about their usage as it helps set the right context for reviewers. Did you use AI tools to help write this code? _**PARTIALLY**_ --------- Co-authored-by: Julia <julia@uxj.io>
79 lines
1.5 KiB
C++
79 lines
1.5 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include <string>
|
|
#include <type_traits>
|
|
#include <utility>
|
|
#include <variant>
|
|
|
|
struct WifiResult {
|
|
bool connected = false;
|
|
std::string ssid;
|
|
std::string ip;
|
|
};
|
|
|
|
struct KeyboardResult {
|
|
std::string text;
|
|
};
|
|
|
|
struct MenuResult {
|
|
int action = -1;
|
|
uint8_t orientation = 0;
|
|
uint8_t pageTurnOption = 0;
|
|
};
|
|
|
|
struct ChapterResult {
|
|
int spineIndex = 0;
|
|
std::string anchor;
|
|
};
|
|
|
|
struct PercentResult {
|
|
int percent = 0;
|
|
};
|
|
|
|
struct IntervalResult {
|
|
uint32_t value = 0;
|
|
};
|
|
|
|
struct PageResult {
|
|
uint32_t page = 0;
|
|
};
|
|
|
|
struct ProgressChangeResult {
|
|
int spineIndex = 0;
|
|
int page = 0;
|
|
};
|
|
|
|
enum class NetworkMode;
|
|
|
|
struct NetworkModeResult {
|
|
NetworkMode mode;
|
|
};
|
|
|
|
struct FootnoteResult {
|
|
std::string href;
|
|
};
|
|
|
|
struct FilePathResult {
|
|
std::string path;
|
|
};
|
|
|
|
using ResultVariant =
|
|
std::variant<std::monostate, WifiResult, KeyboardResult, MenuResult, ChapterResult, PercentResult, IntervalResult,
|
|
PageResult, ProgressChangeResult, NetworkModeResult, FootnoteResult, FilePathResult>;
|
|
|
|
struct ActivityResult {
|
|
bool isCancelled = false;
|
|
ResultVariant data;
|
|
|
|
explicit ActivityResult() = default;
|
|
|
|
template <typename ResultType>
|
|
requires std::is_constructible_v<ResultVariant, ResultType&&>
|
|
// cppcheck-suppress noExplicitConstructor
|
|
ActivityResult(ResultType&& result) : data{std::forward<ResultType>(result)} {}
|
|
};
|
|
|
|
using ActivityResultHandler = std::function<void(const ActivityResult&)>;
|