app: delete a recording from its card's menu
The list could only open the review, so a clip that was not worth keeping stayed on disk forever. The dots beside Review open a menu drawn over this window, so it stays inside it, with room for more actions later. Delete asks before the clip and its timeline leave the disk and the row leaves the list.
This commit is contained in:
1 parent
b1cde7e783
commit
6ca825990d
6 files changed
+294
-11
No files matched your search
+39
-3
@@ -133,6 +133,11 @@ pub struct App {
|
||||
/// The timeline the review is waiting for, once a row is opened.
|
||||
pub review_rx: Option<Receiver<Option<Timeline>>>,
|
||||
pub filter: Option<QueueCategory>,
|
||||
/// The row the delete dialog is about, once its menu has asked to delete it.
|
||||
pub confirm_delete: Option<String>,
|
||||
/// The card whose actions menu is open, if any. The card's position, not its recording:
|
||||
/// demo data repeats ids across rows, and a menu opens for one card alone.
|
||||
pub menu_open: Option<usize>,
|
||||
pub review: screens::review::Review,
|
||||
pub portraits: Option<portraits::Portraits>,
|
||||
/// The icons of the processes the audio sources name, decoded from their executables.
|
||||
@@ -183,6 +188,8 @@ impl App {
|
||||
games_next: 0,
|
||||
review_rx: None,
|
||||
filter: None,
|
||||
confirm_delete: None,
|
||||
menu_open: None,
|
||||
review: screens::review::Review::default(),
|
||||
portraits: None,
|
||||
icons: None,
|
||||
@@ -461,6 +468,23 @@ impl App {
|
||||
self.games_next < self.games_paths.len()
|
||||
}
|
||||
|
||||
/// Drop a recording out of the list once it has been deleted from disk, and drop a page
|
||||
/// of rows already on its way: it may still hold the deleted file.
|
||||
pub fn forget_game(&mut self, recording_id: &str) {
|
||||
self.games.retain(|game| game.recording_id != recording_id);
|
||||
if let Some(at) = self
|
||||
.games_paths
|
||||
.iter()
|
||||
.position(|path| path.file_stem().and_then(|s| s.to_str()) == Some(recording_id))
|
||||
{
|
||||
self.games_paths.remove(at);
|
||||
if at < self.games_next {
|
||||
self.games_next -= 1;
|
||||
}
|
||||
}
|
||||
self.games_rx = None;
|
||||
}
|
||||
|
||||
/// The game the review screen is showing, if any.
|
||||
pub fn reviewed(&self) -> Option<&Timeline> {
|
||||
self.review.game.as_ref()
|
||||
@@ -824,10 +848,12 @@ pub fn on_key(app: &mut App, event: &KeyEvent, _tx: &mut Tx) -> bool {
|
||||
let command = event.mods.ctrl || event.mods.cmd;
|
||||
match (&event.key, command) {
|
||||
(Key::Text(t), false) if t == "1" => {
|
||||
app.menu_open = None;
|
||||
app.screen = Screen::History;
|
||||
true
|
||||
}
|
||||
(Key::Text(t), false) if t == "2" => {
|
||||
app.menu_open = None;
|
||||
app.screen = Screen::Settings;
|
||||
true
|
||||
}
|
||||
@@ -835,12 +861,17 @@ pub fn on_key(app: &mut App, event: &KeyEvent, _tx: &mut Tx) -> bool {
|
||||
app.form.close_add();
|
||||
true
|
||||
}
|
||||
(Key::Escape, _) if app.confirm_delete.is_some() => {
|
||||
app.confirm_delete = None;
|
||||
true
|
||||
}
|
||||
(Key::Escape, _) if app.screen == Screen::Review => {
|
||||
screens::review::leave(app);
|
||||
app.screen = Screen::History;
|
||||
true
|
||||
}
|
||||
(Key::Escape, _) if app.screen == Screen::Settings => {
|
||||
app.menu_open = None;
|
||||
app.screen = Screen::History;
|
||||
true
|
||||
}
|
||||
@@ -958,6 +989,7 @@ fn titlebar(p: Paint, app: &App) -> El {
|
||||
"Settings",
|
||||
false,
|
||||
|app: &mut App| {
|
||||
app.menu_open = None;
|
||||
screens::review::leave(app);
|
||||
app.screen = Screen::Settings;
|
||||
},
|
||||
@@ -1011,9 +1043,12 @@ fn notice(p: Paint, notice: &Notice) -> El {
|
||||
|
||||
pub fn view(app: &App, cx: &mut Cx<App>) -> El {
|
||||
let p = Paint::new(app.dark, cx.env().scale);
|
||||
// Menus and dialogs cover the whole window, title bar and status bar included: the
|
||||
// history row menus, the add-application form and the delete confirmation.
|
||||
let mut overlays = Vec::new();
|
||||
let content = match app.screen {
|
||||
Screen::Settings => screens::settings::view(app, p),
|
||||
Screen::History => screens::history::view(app, p),
|
||||
Screen::History => screens::history::view(app, p, &mut overlays),
|
||||
Screen::Review => screens::review::view(app, p),
|
||||
};
|
||||
let mut main = col().key("main").grow(1.0).min_h(0.0).w_full().fill(p.t.bg);
|
||||
@@ -1049,11 +1084,12 @@ pub fn view(app: &App, cx: &mut Cx<App>) -> El {
|
||||
},
|
||||
)),
|
||||
};
|
||||
// The add-application dialog covers the whole window, title bar included.
|
||||
let mut overlays = Vec::new();
|
||||
if app.screen == Screen::Settings && app.form.add_open {
|
||||
screens::settings::add_dialog(app, p, &mut overlays);
|
||||
}
|
||||
if app.confirm_delete.is_some() {
|
||||
screens::history::delete_dialog(app, p, &mut overlays);
|
||||
}
|
||||
rune_kit::root(content, overlays)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user