1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
//! Activity, silence, and session notification settings.
use crate::SettingsUI;
use crate::search::SearchTag;
use crate::section::{SLIDER_WIDTH, keyword_section};
use std::collections::HashSet;
const SLIDER_HEIGHT: f32 = 18.0;
pub(crate) fn show_activity_section(
ui: &mut egui::Ui,
settings: &mut SettingsUI,
changes_this_frame: &mut bool,
collapsed: &mut HashSet<String>,
) {
keyword_section(
ui,
"Activity",
"notifications_activity",
&["idle", "shell exited"],
true,
collapsed,
|ui| {
ui.label("Activity Notifications:");
if ui
.checkbox(
&mut settings.config.notifications.notification_activity_enabled,
"Notify on activity after inactivity",
)
.search_tag(&["notification_activity_enabled"])
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
crate::dependent::dependent(
ui,
settings.config.notifications.notification_activity_enabled,
"Notify on activity after inactivity",
|ui| {
ui.horizontal(|ui| {
ui.label("Activity threshold:");
if ui
.add_sized(
[SLIDER_WIDTH, SLIDER_HEIGHT],
egui::Slider::new(
&mut settings
.config
.notifications
.notification_activity_threshold,
1..=300,
)
.suffix(" s"),
)
.search_tag(&["notification_activity_threshold"])
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
crate::reset::reset_button(ui, settings, changes_this_frame, |c| {
&mut c.notifications.notification_activity_threshold
});
});
},
);
ui.separator();
ui.label("Silence Notifications:");
if ui
.checkbox(
&mut settings.config.notifications.notification_silence_enabled,
"Notify after prolonged silence",
)
.search_tag(&["notification_silence_enabled"])
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
crate::dependent::dependent(
ui,
settings.config.notifications.notification_silence_enabled,
"Notify after prolonged silence",
|ui| {
ui.horizontal(|ui| {
ui.label("Silence threshold:");
if ui
.add_sized(
[SLIDER_WIDTH, SLIDER_HEIGHT],
egui::Slider::new(
&mut settings
.config
.notifications
.notification_silence_threshold,
1..=600,
)
.suffix(" s"),
)
.search_tag(&["notification_silence_threshold"])
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
crate::reset::reset_button(ui, settings, changes_this_frame, |c| {
&mut c.notifications.notification_silence_threshold
});
});
},
);
ui.separator();
ui.label("Shell Exit Notifications:");
if ui
.checkbox(
&mut settings.config.notifications.notification_session_ended,
"Notify when a shell exits",
)
.search_tag(&["notification_session_ended"])
.on_hover_text("Send a desktop notification when the shell process exits")
.changed()
{
settings.has_changes = true;
*changes_this_frame = true;
}
},
);
}