1use serde::{Deserialize, Serialize};
2
3use super::super::Action;
4
5#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
10pub enum ActionRingIcon {
11 Pointer,
13 Mouse,
15 Copy,
17 Paste,
19 Cut,
21 Search,
23 Save,
25 Keyboard,
27 Applications,
29 Grid,
31 Layers,
33 Monitor,
35 Lock,
37 Camera,
39 Play,
41 Volume,
43 Gauge,
45 Refresh,
47 ArrowUp,
49 ArrowDown,
51 ArrowLeft,
53 ArrowRight,
55 Undo,
57 Redo,
59 SelectAll,
61 MouseBack,
63 MouseForward,
65 NewTab,
67 CloseTab,
69 ReopenTab,
71 NextTab,
73 PreviousTab,
75 Reload,
77 PreviousDesktop,
79 NextDesktop,
81 PreviousTrack,
83 NextTrack,
85 VolumeDown,
87 Mute,
89 ScrollLeft,
91 ScrollRight,
93 Folder,
95 File,
97 Globe,
99 Terminal,
101 Settings,
103 Star,
105 Heart,
107 Calendar,
109 Bell,
111 User,
113 Palette,
115 Book,
117 Ban,
119}
120
121impl ActionRingIcon {
122 pub const ALL: [Self; 54] = [
124 Self::Pointer,
125 Self::Mouse,
126 Self::Copy,
127 Self::Paste,
128 Self::Cut,
129 Self::Search,
130 Self::Save,
131 Self::Keyboard,
132 Self::Applications,
133 Self::Grid,
134 Self::Layers,
135 Self::Monitor,
136 Self::Lock,
137 Self::Camera,
138 Self::Play,
139 Self::Volume,
140 Self::Gauge,
141 Self::Refresh,
142 Self::ArrowUp,
143 Self::ArrowDown,
144 Self::ArrowLeft,
145 Self::ArrowRight,
146 Self::Undo,
147 Self::Redo,
148 Self::SelectAll,
149 Self::MouseBack,
150 Self::MouseForward,
151 Self::NewTab,
152 Self::CloseTab,
153 Self::ReopenTab,
154 Self::NextTab,
155 Self::PreviousTab,
156 Self::Reload,
157 Self::PreviousDesktop,
158 Self::NextDesktop,
159 Self::PreviousTrack,
160 Self::NextTrack,
161 Self::VolumeDown,
162 Self::Mute,
163 Self::ScrollLeft,
164 Self::ScrollRight,
165 Self::Folder,
166 Self::File,
167 Self::Globe,
168 Self::Terminal,
169 Self::Settings,
170 Self::Star,
171 Self::Heart,
172 Self::Calendar,
173 Self::Bell,
174 Self::User,
175 Self::Palette,
176 Self::Book,
177 Self::Ban,
178 ];
179
180 #[must_use]
182 pub fn for_action(action: &Action) -> Self {
183 match action {
184 Action::None => Self::Ban,
185 Action::LeftClick | Action::RightClick => Self::Pointer,
186 Action::MiddleClick => Self::Mouse,
187 Action::MouseBack => Self::MouseBack,
188 Action::MouseForward => Self::MouseForward,
189 Action::Copy => Self::Copy,
190 Action::Paste => Self::Paste,
191 Action::Cut => Self::Cut,
192 Action::Undo => Self::Undo,
193 Action::Redo => Self::Redo,
194 Action::SelectAll => Self::SelectAll,
195 Action::Find => Self::Search,
196 Action::Save => Self::Save,
197 Action::BrowserBack => Self::ArrowLeft,
198 Action::BrowserForward => Self::ArrowRight,
199 Action::NewTab => Self::NewTab,
200 Action::CloseTab => Self::CloseTab,
201 Action::ReopenTab => Self::ReopenTab,
202 Action::NextTab => Self::NextTab,
203 Action::PrevTab => Self::PreviousTab,
204 Action::ReloadPage => Self::Reload,
205 Action::MissionControl | Action::ShowActionsRing => Self::Grid,
206 Action::AppExpose => Self::Layers,
207 Action::PreviousDesktop => Self::PreviousDesktop,
208 Action::NextDesktop => Self::NextDesktop,
209 Action::ShowDesktop | Action::Sleep => Self::Monitor,
210 Action::LaunchpadShow | Action::OpenApplication(_) => Self::Applications,
211 Action::LockScreen => Self::Lock,
212 Action::Screenshot | Action::CaptureRegion => Self::Camera,
213 Action::PlayPause => Self::Play,
214 Action::NextTrack => Self::NextTrack,
215 Action::PrevTrack => Self::PreviousTrack,
216 Action::VolumeUp => Self::Volume,
217 Action::VolumeDown => Self::VolumeDown,
218 Action::MuteVolume => Self::Mute,
219 Action::CycleDpiPresets | Action::SetDpiPreset(_) => Self::Gauge,
220 Action::ToggleSmartShift => Self::Refresh,
221 Action::ScrollUp => Self::ArrowUp,
222 Action::ScrollDown => Self::ArrowDown,
223 Action::HorizontalScrollLeft => Self::ScrollLeft,
224 Action::HorizontalScrollRight => Self::ScrollRight,
225 Action::CustomShortcut(_) | Action::TypeText(_) | Action::Workflow(_) => Self::Keyboard,
226 Action::RunAppleScript(_) | Action::RunShellCommand(_) => Self::Terminal,
227 }
228 }
229
230 #[must_use]
232 pub fn label(self) -> &'static str {
233 match self {
234 Self::Pointer => "Left Click",
235 Self::Mouse => "Middle Click",
236 Self::Copy => "Copy",
237 Self::Paste => "Paste",
238 Self::Cut => "Cut",
239 Self::Search => "Find",
240 Self::Save => "Save",
241 Self::Keyboard => "Custom shortcut",
242 Self::Applications => "Open application or folder",
243 Self::Grid => "Actions Ring",
244 Self::Layers => "App Exposé",
245 Self::Monitor => "Show Desktop",
246 Self::Lock => "Lock Screen",
247 Self::Camera => "Screenshot",
248 Self::Play => "Play / Pause",
249 Self::Volume => "Volume Up",
250 Self::Gauge => "Cycle DPI Presets",
251 Self::Refresh => "Toggle SmartShift",
252 Self::ArrowUp => "Scroll Up",
253 Self::ArrowDown => "Scroll Down",
254 Self::ArrowLeft | Self::ScrollLeft => "Scroll Left",
255 Self::ArrowRight | Self::ScrollRight => "Scroll Right",
256 Self::Undo => "Undo",
257 Self::Redo => "Redo",
258 Self::SelectAll => "Select All",
259 Self::MouseBack => "Back (Button 4)",
260 Self::MouseForward => "Forward (Button 5)",
261 Self::NewTab => "New Tab",
262 Self::CloseTab => "Close Tab",
263 Self::ReopenTab => "Reopen Tab",
264 Self::NextTab => "Next Tab",
265 Self::PreviousTab => "Previous Tab",
266 Self::Reload => "Reload Page",
267 Self::PreviousDesktop => "Previous Desktop",
268 Self::NextDesktop => "Next Desktop",
269 Self::PreviousTrack => "Previous Track",
270 Self::NextTrack => "Next Track",
271 Self::VolumeDown => "Volume Down",
272 Self::Mute => "Mute",
273 Self::Folder => "Folder",
274 Self::File => "File",
275 Self::Globe => "Globe",
276 Self::Terminal => "Terminal",
277 Self::Settings => "Settings",
278 Self::Star => "Star",
279 Self::Heart => "Heart",
280 Self::Calendar => "Calendar",
281 Self::Bell => "Bell",
282 Self::User => "User",
283 Self::Palette => "Palette",
284 Self::Book => "Book",
285 Self::Ban => "Do Nothing",
286 }
287 }
288}