use serde::{Deserialize, Serialize};
use super::super::Action;
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum ActionRingIcon {
Pointer,
Mouse,
Copy,
Paste,
Cut,
Search,
Save,
Keyboard,
Applications,
Grid,
Layers,
Monitor,
Lock,
Camera,
Play,
Volume,
Gauge,
Refresh,
ArrowUp,
ArrowDown,
ArrowLeft,
ArrowRight,
Undo,
Redo,
SelectAll,
MouseBack,
MouseForward,
NewTab,
CloseTab,
ReopenTab,
NextTab,
PreviousTab,
Reload,
PreviousDesktop,
NextDesktop,
PreviousTrack,
NextTrack,
VolumeDown,
Mute,
ScrollLeft,
ScrollRight,
Folder,
File,
Globe,
Terminal,
Settings,
Star,
Heart,
Calendar,
Bell,
User,
Palette,
Book,
Ban,
}
impl ActionRingIcon {
pub const ALL: [Self; 54] = [
Self::Pointer,
Self::Mouse,
Self::Copy,
Self::Paste,
Self::Cut,
Self::Search,
Self::Save,
Self::Keyboard,
Self::Applications,
Self::Grid,
Self::Layers,
Self::Monitor,
Self::Lock,
Self::Camera,
Self::Play,
Self::Volume,
Self::Gauge,
Self::Refresh,
Self::ArrowUp,
Self::ArrowDown,
Self::ArrowLeft,
Self::ArrowRight,
Self::Undo,
Self::Redo,
Self::SelectAll,
Self::MouseBack,
Self::MouseForward,
Self::NewTab,
Self::CloseTab,
Self::ReopenTab,
Self::NextTab,
Self::PreviousTab,
Self::Reload,
Self::PreviousDesktop,
Self::NextDesktop,
Self::PreviousTrack,
Self::NextTrack,
Self::VolumeDown,
Self::Mute,
Self::ScrollLeft,
Self::ScrollRight,
Self::Folder,
Self::File,
Self::Globe,
Self::Terminal,
Self::Settings,
Self::Star,
Self::Heart,
Self::Calendar,
Self::Bell,
Self::User,
Self::Palette,
Self::Book,
Self::Ban,
];
#[must_use]
pub fn label(self) -> &'static str {
match self {
Self::Pointer => "Left Click",
Self::Mouse => "Middle Click",
Self::Copy => "Copy",
Self::Paste => "Paste",
Self::Cut => "Cut",
Self::Search => "Find",
Self::Save => "Save",
Self::Keyboard => "Custom shortcut",
Self::Applications => "Open application or folder",
Self::Grid => "Actions Ring",
Self::Layers => "App Exposé",
Self::Monitor => "Show Desktop",
Self::Lock => "Lock Screen",
Self::Camera => "Screenshot",
Self::Play => "Play / Pause",
Self::Volume => "Volume Up",
Self::Gauge => "Cycle DPI Presets",
Self::Refresh => "Toggle SmartShift",
Self::ArrowUp => "Scroll Up",
Self::ArrowDown => "Scroll Down",
Self::ArrowLeft | Self::ScrollLeft => "Scroll Left",
Self::ArrowRight | Self::ScrollRight => "Scroll Right",
Self::Undo => "Undo",
Self::Redo => "Redo",
Self::SelectAll => "Select All",
Self::MouseBack => "Back (Button 4)",
Self::MouseForward => "Forward (Button 5)",
Self::NewTab => "New Tab",
Self::CloseTab => "Close Tab",
Self::ReopenTab => "Reopen Tab",
Self::NextTab => "Next Tab",
Self::PreviousTab => "Previous Tab",
Self::Reload => "Reload Page",
Self::PreviousDesktop => "Previous Desktop",
Self::NextDesktop => "Next Desktop",
Self::PreviousTrack => "Previous Track",
Self::NextTrack => "Next Track",
Self::VolumeDown => "Volume Down",
Self::Mute => "Mute",
Self::Folder => "Folder",
Self::File => "File",
Self::Globe => "Globe",
Self::Terminal => "Terminal",
Self::Settings => "Settings",
Self::Star => "Star",
Self::Heart => "Heart",
Self::Calendar => "Calendar",
Self::Bell => "Bell",
Self::User => "User",
Self::Palette => "Palette",
Self::Book => "Book",
Self::Ban => "Do Nothing",
}
}
}
macro_rules! derive_action_icon {
( $( $variant:ident $label:literal $category:ident $icon:ident $( $tag:ident )? ),* $(,)? ) => {
impl ActionRingIcon {
#[must_use]
pub fn for_action(action: &Action) -> Self {
match action {
$( Action::$variant => Self::$icon, )*
Action::SetDpiPreset(_) => Self::Gauge,
Action::CustomShortcut(_) | Action::TypeText(_) | Action::Workflow(_) => {
Self::Keyboard
}
Action::RunAppleScript(_) | Action::RunShellCommand(_) => Self::Terminal,
Action::OpenApplication(_) => Self::Applications,
}
}
}
};
}
super::super::action::for_each_unit_action!(derive_action_icon);