-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
127 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
use rm_shared::action::Action; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::UserAction; | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] | ||
pub enum GeneralAction { | ||
ShowHelp, | ||
Quit, | ||
Close, | ||
SwitchToTorrents, | ||
SwitchToSearch, | ||
Left, | ||
Right, | ||
Down, | ||
Up, | ||
Search, | ||
SwitchFocus, | ||
Confirm, | ||
Select, | ||
ScrollPageDown, | ||
ScrollPageUp, | ||
GoToBeginning, | ||
GoToEnd, | ||
} | ||
|
||
impl UserAction for GeneralAction { | ||
fn desc(&self) -> &'static str { | ||
match self { | ||
GeneralAction::ShowHelp => "toggle help", | ||
GeneralAction::Quit => "quit Rustmission / a popup", | ||
GeneralAction::Close => "close a popup / task", | ||
GeneralAction::SwitchToTorrents => "switch to torrents tab", | ||
GeneralAction::SwitchToSearch => "switch to search tab", | ||
GeneralAction::Left => "switch to tab left", | ||
GeneralAction::Right => "switch to tab right", | ||
GeneralAction::Down => "move down", | ||
GeneralAction::Up => "move up", | ||
GeneralAction::Search => "search", | ||
GeneralAction::SwitchFocus => "switch focus", | ||
GeneralAction::Confirm => "confirm", | ||
GeneralAction::Select => "select", | ||
GeneralAction::ScrollPageDown => "scroll page down", | ||
GeneralAction::ScrollPageUp => "scroll page up", | ||
GeneralAction::GoToBeginning => "scroll to the beginning", | ||
GeneralAction::GoToEnd => "scroll to the end", | ||
} | ||
} | ||
} | ||
|
||
impl From<GeneralAction> for Action { | ||
fn from(value: GeneralAction) -> Self { | ||
match value { | ||
GeneralAction::ShowHelp => Action::ShowHelp, | ||
GeneralAction::Quit => Action::Quit, | ||
GeneralAction::Close => Action::Close, | ||
GeneralAction::SwitchToTorrents => Action::ChangeTab(1), | ||
GeneralAction::SwitchToSearch => Action::ChangeTab(2), | ||
GeneralAction::Left => Action::Left, | ||
GeneralAction::Right => Action::Right, | ||
GeneralAction::Down => Action::Down, | ||
GeneralAction::Up => Action::Up, | ||
GeneralAction::Search => Action::Search, | ||
GeneralAction::SwitchFocus => Action::ChangeFocus, | ||
GeneralAction::Confirm => Action::Confirm, | ||
GeneralAction::Select => Action::Select, | ||
GeneralAction::ScrollPageDown => Action::ScrollDownPage, | ||
GeneralAction::ScrollPageUp => Action::ScrollUpPage, | ||
GeneralAction::GoToBeginning => Action::Home, | ||
GeneralAction::GoToEnd => Action::End, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
use rm_shared::action::Action; | ||
|
||
pub mod general; | ||
pub mod torrents_tab; | ||
|
||
pub trait UserAction: Into<Action> { | ||
fn desc(&self) -> &'static str; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use rm_shared::action::Action; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::UserAction; | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)] | ||
pub enum TorrentsAction { | ||
AddMagnet, | ||
Pause, | ||
DeleteWithFiles, | ||
DeleteWithoutFiles, | ||
ShowFiles, | ||
ShowStats, | ||
} | ||
|
||
impl UserAction for TorrentsAction { | ||
fn desc(&self) -> &'static str { | ||
match self { | ||
TorrentsAction::AddMagnet => "add a magnet", | ||
TorrentsAction::Pause => "pause/unpause", | ||
TorrentsAction::DeleteWithFiles => "delete with files", | ||
TorrentsAction::DeleteWithoutFiles => "delete without files", | ||
TorrentsAction::ShowFiles => "show files", | ||
TorrentsAction::ShowStats => "show statistics", | ||
} | ||
} | ||
} | ||
|
||
impl From<TorrentsAction> for Action { | ||
fn from(value: TorrentsAction) -> Self { | ||
match value { | ||
TorrentsAction::AddMagnet => Action::AddMagnet, | ||
TorrentsAction::Pause => Action::Pause, | ||
TorrentsAction::DeleteWithFiles => Action::DeleteWithFiles, | ||
TorrentsAction::DeleteWithoutFiles => Action::DeleteWithoutFiles, | ||
TorrentsAction::ShowFiles => Action::ShowFiles, | ||
TorrentsAction::ShowStats => Action::ShowStats, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters