crates/veilvoice-gui/src/autolock.rs
veilvoice-gui · 369 lines · read the source here · or on GitHub
Locking the window again after a period of no use.
Roadmap item 92. On at half an hour, and the delay is the user's to choose: anything from five minutes to forty eight hours from a list, a number typed in if none of those fit, and the ends of that range movable by anybody who wants a shorter or longer one.
Why it is on by default, having been off
It was off, on the argument that a lock engaging part way through a recording is a lock that gets removed, and that VeilVoice cannot know whether a given user is the one who walks away or the one who leaves a job running -- so it should ask rather than assume.
The asking is the part that was wrong. A default nobody is shown is not a question, it is an answer, and the answer it gave was "no protection" to everybody who never opened the settings tab. The people most helped by an autolock are the least likely to go looking for one.
So it is on, and the first-run setup shows it rather than leaving it to be discovered: half an hour, with the choice and the off switch right there. The original concern is answered by the delay rather than by the default -- thirty minutes of an untouched window is not somebody part way through anything -- and by the fact that this has never counted a running job as use, which is deliberate and explained below.
What counts as use
Any keystroke, click, scroll or pointer movement over the window, which is what egui reports as input. Deliberately not the passage of a job: somebody who starts a long render and leaves the room has left the room, and the recording they are producing is the thing worth locking away.
The clock is egui's own frame time rather than the system clock, so moving the machine's clock does not bring the lock forward or push it back. It also means the countdown only advances while the window is being drawn, which is the honest limit of this: a window nobody is drawing is a window nobody is looking at, and it locks the moment it is looked at again.
In plain words
Locks the window again if you have not touched it for half an hour.
On to begin with, and setup shows you the switch. You pick how long, from five minutes up to two days, or type your own, and you can turn it off. Starting a long job does not count as using it: if you walk away while something is rendering, that is exactly when you would want it locked.
WHAT THIS FILE CONTAINS
369 lines defining 7 functions (6 public), 1 type and 4 constants. Everything below is read out of the source, so it cannot disagree with the code.
The types it owns.
struct Autolockline 83 · How the autolock is configured.
What happens when it runs. These are the ways in: public, and nothing else in this file calls them, so they are what an outside caller reaches first.
Autolock::saneline 114 · Bring every field into a state that can be offered and obeyed.Autolock::expiredline 139 · Whether idle has reached the delay.
reachesafterAutolock::describeline 144 · The delay in the words a person uses for it.
reachesdescribe_secsparseline 176 · Read a delay somebody typed.
WHAT CALLS WHAT
The functions this file defines, and the calls between them. An edge means the callee's name appears, called, inside the caller's body. This is a syntactic reading, not a type-resolved one.
The same graph as Mermaid source
%%{init: {"theme":"base","themeVariables":{"background":"#1a1b26","primaryColor":"#1f2335","primaryTextColor":"#c0caf5","primaryBorderColor":"#7aa2f7","secondaryColor":"#16161e","tertiaryColor":"#16161e","lineColor":"#737aa2","textColor":"#c0caf5","mainBkg":"#1f2335","nodeBorder":"#7aa2f7","clusterBkg":"#16161e","clusterBorder":"#2f3549","fontFamily":"ui-monospace, SFMono-Regular, Consolas, monospace","fontSize":"14px"}}}%%
flowchart TD
n_default["Autolock::default<br/>line 95"]
n_sane(["Autolock::sane<br/>line 114"])
n_after["Autolock::after<br/>line 130"]
n_expired(["Autolock::expired<br/>line 139"])
n_describe(["Autolock::describe<br/>line 144"])
n_describe_secs["describe_secs<br/>line 153"]
n_parse(["parse<br/>line 176"])
n_describe --> n_describe_secs
n_expired --> n_after
click n_default href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/autolock.rs#L95" "open the source"
click n_sane href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/autolock.rs#L114" "open the source"
click n_after href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/autolock.rs#L130" "open the source"
click n_expired href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/autolock.rs#L139" "open the source"
click n_describe href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/autolock.rs#L144" "open the source"
click n_describe_secs href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/autolock.rs#L153" "open the source"
click n_parse href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-gui/src/autolock.rs#L176" "open the source"
classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
class n_sane,n_expired,n_describe,n_parse entry
classDef api fill:#1f2335,stroke:#7dcfff,color:#c0caf5
class n_after,n_describe_secs api
classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
class n_default helper
This site loads no third-party script, so it cannot run Mermaid; the diagram above is the same nodes and edges drawn by the generator instead. GitHub renders the source below directly.
ITEMS
| Item | Line | Documentation |
|---|---|---|
DEFAULT_SECS pub const | 57 | The delay a fresh installation uses: half an hour. |
FLOOR_SECS pub const | 60 | The shortest delay the list offers, in seconds. |
CEILING_SECS pub const | 62 | The longest, in seconds. |
CHOICES pub const | 68 | The delays offered without typing anything, in seconds. |
Autolock pub struct | 83 | How the autolock is configured. |
Autolock::default fn | 95 | |
Autolock::sane pub fn | 114 | Bring every field into a state that can be offered and obeyed. |
Autolock::after pub fn | 130 | The delay as a Duration. |
Autolock::expired pub fn | 139 | Whether idle has reached the delay. |
Autolock::describe pub fn | 144 | The delay in the words a person uses for it. |
describe_secs pub fn | 153 | A number of seconds as a phrase. |
parse pub fn | 176 | Read a delay somebody typed. |