app: pick the recordings folder and cut paths to the row
The folder was a text field, and the path was always cut to its last two folders, so a wide window dropped folders it had room for and a narrow one showed only the tail. The row now shows the path the settings hold, cut in the middle at whatever width the labels and the button leave it, with Select folder opening the system's folder dialog through rune's native-file-dialog feature. Form keeps no copy of the path any more; the draft is the one place it lives. The quick tab's recordings folder and the daemon tab's log file get the same cut, and short_path goes.
This commit is contained in:
1 parent
dbdec05752
commit
1bb2874753
5 files changed
+109
-30
No files matched your search
Generated
+27
@@ -758,6 +758,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38"
|
checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.13.2",
|
"bitflags 2.13.2",
|
||||||
|
"block2 0.6.2",
|
||||||
|
"libc",
|
||||||
"objc2 0.6.5",
|
"objc2 0.6.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -1894,6 +1896,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
|
checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.13.2",
|
"bitflags 2.13.2",
|
||||||
|
"block2 0.6.2",
|
||||||
"objc2 0.6.5",
|
"objc2 0.6.5",
|
||||||
"objc2-core-foundation",
|
"objc2-core-foundation",
|
||||||
"objc2-core-graphics",
|
"objc2-core-graphics",
|
||||||
@@ -2730,6 +2733,29 @@ dependencies = [
|
|||||||
"usvg",
|
"usvg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rfd"
|
||||||
|
version = "0.17.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "20dafead71c16a34e1ff357ddefc8afc11e7d51d6d2b9fbd07eaa48e3e540220"
|
||||||
|
dependencies = [
|
||||||
|
"block2 0.6.2",
|
||||||
|
"dispatch2",
|
||||||
|
"js-sys",
|
||||||
|
"libc",
|
||||||
|
"log",
|
||||||
|
"objc2 0.6.5",
|
||||||
|
"objc2-app-kit 0.3.2",
|
||||||
|
"objc2-core-foundation",
|
||||||
|
"objc2-foundation 0.3.2",
|
||||||
|
"percent-encoding",
|
||||||
|
"raw-window-handle",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-futures",
|
||||||
|
"web-sys",
|
||||||
|
"windows-sys 0.61.2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rgb"
|
name = "rgb"
|
||||||
version = "0.8.53"
|
version = "0.8.53"
|
||||||
@@ -2801,6 +2827,7 @@ dependencies = [
|
|||||||
"png 0.18.1",
|
"png 0.18.1",
|
||||||
"pollster",
|
"pollster",
|
||||||
"raw-window-handle",
|
"raw-window-handle",
|
||||||
|
"rfd",
|
||||||
"rune-core",
|
"rune-core",
|
||||||
"rune-edit",
|
"rune-edit",
|
||||||
"rune-gpu",
|
"rune-gpu",
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ path = "src/main.rs"
|
|||||||
winresource = "0.1"
|
winresource = "0.1"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rune = { path = "vendor/rune/crates/rune" }
|
rune = { path = "vendor/rune/crates/rune", features = ["native-file-dialog"] }
|
||||||
rune-kit = { path = "vendor/rune/crates/rune-kit" }
|
rune-kit = { path = "vendor/rune/crates/rune-kit" }
|
||||||
rune-notify = { path = "vendor/rune/crates/rune-notify" }
|
rune-notify = { path = "vendor/rune/crates/rune-notify" }
|
||||||
|
|
||||||
|
|||||||
+5
-1
@@ -86,7 +86,11 @@ reading (`history::tests`), highlight clipping (`highlight::tests`) and formatti
|
|||||||
are tested against the daemon's serde names.
|
are tested against the daemon's serde names.
|
||||||
3. Settings: done. General, recording, audio and daemon tabs; device and encoder lists come from
|
3. Settings: done. General, recording, audio and daemon tabs; device and encoder lists come from
|
||||||
`getAudioDevices` and `getEncoders`; changes go out through `updateSettings`, and each
|
`getAudioDevices` and `getEncoders`; changes go out through `updateSettings`, and each
|
||||||
application volume slider sends `updateAudioSource` as it moves.
|
application volume slider sends `updateAudioSource` as it moves. The recordings folder is
|
||||||
|
shown, not typed: `Select folder` asks the system for one, through the `native-file-dialog`
|
||||||
|
feature `Cargo.toml` turns on, and headless runs answer it from a script. Every path the
|
||||||
|
settings show is cut in the middle against the row it sits in, so a narrow window elides
|
||||||
|
and a wide one shows the whole thing.
|
||||||
4. Match history: done. Cards read `GameHistory.vue`'s fields (result, champion portrait,
|
4. Match history: done. Cards read `GameHistory.vue`'s fields (result, champion portrait,
|
||||||
queue, KDA, CS/m, gold/m, LP change) from the raw API responses in each timeline, with the
|
queue, KDA, CS/m, gold/m, LP change) from the raw API responses in each timeline, with the
|
||||||
queue filters. Portraits come from Data Dragon and are cached on disk (`src/portraits.rs`).
|
queue filters. Portraits come from Data Dragon and are cached on disk (`src/portraits.rs`).
|
||||||
|
|||||||
+63
-27
@@ -15,7 +15,6 @@ pub struct Form {
|
|||||||
pub dirty: bool,
|
pub dirty: bool,
|
||||||
pub saving: bool,
|
pub saving: bool,
|
||||||
pub open_select: Option<&'static str>,
|
pub open_select: Option<&'static str>,
|
||||||
pub path: TextEdit,
|
|
||||||
pub naming: TextEdit,
|
pub naming: TextEdit,
|
||||||
pub poll_interval: TextEdit,
|
pub poll_interval: TextEdit,
|
||||||
pub bitrate: TextEdit,
|
pub bitrate: TextEdit,
|
||||||
@@ -28,7 +27,6 @@ impl Form {
|
|||||||
pub fn empty() -> Self {
|
pub fn empty() -> Self {
|
||||||
let draft = Settings::default();
|
let draft = Settings::default();
|
||||||
Self {
|
Self {
|
||||||
path: TextEdit::new(&draft.output.path),
|
|
||||||
naming: TextEdit::new(&draft.output.naming_pattern),
|
naming: TextEdit::new(&draft.output.naming_pattern),
|
||||||
poll_interval: TextEdit::new(draft.daemon.poll_interval_ms.to_string()),
|
poll_interval: TextEdit::new(draft.daemon.poll_interval_ms.to_string()),
|
||||||
bitrate: TextEdit::new(draft.audio.bitrate.to_string()),
|
bitrate: TextEdit::new(draft.audio.bitrate.to_string()),
|
||||||
@@ -49,7 +47,6 @@ impl Form {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
self.draft = settings.clone();
|
self.draft = settings.clone();
|
||||||
self.path.replace_text(&settings.output.path);
|
|
||||||
self.naming.replace_text(&settings.output.naming_pattern);
|
self.naming.replace_text(&settings.output.naming_pattern);
|
||||||
self.poll_interval
|
self.poll_interval
|
||||||
.replace_text(settings.daemon.poll_interval_ms.to_string());
|
.replace_text(settings.daemon.poll_interval_ms.to_string());
|
||||||
@@ -63,7 +60,6 @@ impl Form {
|
|||||||
/// Pull the text fields into the draft and hand it to `updateSettings`.
|
/// Pull the text fields into the draft and hand it to `updateSettings`.
|
||||||
pub fn settings(&mut self) -> Settings {
|
pub fn settings(&mut self) -> Settings {
|
||||||
let mut out = self.draft.clone();
|
let mut out = self.draft.clone();
|
||||||
out.output.path = self.path.text.trim().to_string();
|
|
||||||
out.output.naming_pattern = self.naming.text.trim().to_string();
|
out.output.naming_pattern = self.naming.text.trim().to_string();
|
||||||
out.daemon.poll_interval_ms = self
|
out.daemon.poll_interval_ms = self
|
||||||
.poll_interval
|
.poll_interval
|
||||||
@@ -134,6 +130,57 @@ fn text_row(
|
|||||||
ui::setting_row_with(p, key, label, hint, ui::text_field(p, key, label, edit, to))
|
ui::setting_row_with(p, key, label, hint, ui::text_field(p, key, label, edit, to))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The folder recordings land in, as the settings hold it, and the button that replaces it with
|
||||||
|
/// one the system's dialog picks. The path is read back, not typed: a folder is a thing you find.
|
||||||
|
fn path_row(p: Paint, app: &App, key: &'static str, label: &'static str, hint: &'static str) -> El {
|
||||||
|
// The whole path, not the last folders. It gets what the labels and the button leave, and a
|
||||||
|
// middle "…" when that is not enough, so the window's width picks the cut and no character
|
||||||
|
// count does. The margin holds it off the labels once the row is tight.
|
||||||
|
let shown = text(&app.form.draft.output.path)
|
||||||
|
.key("path")
|
||||||
|
.font(body(12.0))
|
||||||
|
.color(p.muted())
|
||||||
|
.ml(space::S2)
|
||||||
|
.truncate_middle();
|
||||||
|
let pick = ui::button_tx(
|
||||||
|
p,
|
||||||
|
"pick-folder",
|
||||||
|
"Select folder",
|
||||||
|
false,
|
||||||
|
move |app: &mut App, tx: &mut rune::Tx| {
|
||||||
|
let options = rune::FileDialogOptions {
|
||||||
|
title: hint.to_string(),
|
||||||
|
directory: Some(app.output_dir()),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
tx.open_folder(options, |app: &mut App, result, _| match result {
|
||||||
|
Ok(Some(path)) => {
|
||||||
|
app.form.draft.output.path = path.display().to_string();
|
||||||
|
app.form.dirty = true;
|
||||||
|
}
|
||||||
|
Ok(None) => {}
|
||||||
|
Err(e) => app.notify_error(format!("No folder dialog: {e}")),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
ui::setting_row_with(
|
||||||
|
p,
|
||||||
|
key,
|
||||||
|
label,
|
||||||
|
hint,
|
||||||
|
// Growing the control and letting itself be small give the text a bounded width to elide
|
||||||
|
// inside; content-sized, the row would run off the card.
|
||||||
|
row()
|
||||||
|
.gap(space::S2)
|
||||||
|
.center_y()
|
||||||
|
.grow(1.0)
|
||||||
|
.min_w(0.0)
|
||||||
|
.justify_end()
|
||||||
|
.child(shown)
|
||||||
|
.child(pick),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(clippy::too_many_arguments)] // the columns of a settings row
|
#[allow(clippy::too_many_arguments)] // the columns of a settings row
|
||||||
fn select_row(
|
fn select_row(
|
||||||
p: Paint,
|
p: Paint,
|
||||||
@@ -395,26 +442,17 @@ fn quick(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content:
|
|||||||
p,
|
p,
|
||||||
"recordings-folder",
|
"recordings-folder",
|
||||||
"Recordings folder",
|
"Recordings folder",
|
||||||
text(short_path(&app.form.draft.output.path))
|
// Cut in the middle against the row's width, so a narrow window elides.
|
||||||
|
text(&app.form.draft.output.path)
|
||||||
.key("path")
|
.key("path")
|
||||||
.font(body(12.0))
|
.font(body(12.0))
|
||||||
.color(p.muted()),
|
.color(p.muted())
|
||||||
|
.ml(space::S2)
|
||||||
|
.truncate_middle(),
|
||||||
)],
|
)],
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A path as it fits on a row: the last two segments, with the rest elided.
|
|
||||||
fn short_path(path: &str) -> String {
|
|
||||||
let sep = std::path::MAIN_SEPARATOR;
|
|
||||||
let normalized = path.replace(sep, "/");
|
|
||||||
let parts: Vec<&str> = normalized.split('/').filter(|p| !p.is_empty()).collect();
|
|
||||||
match parts.len() {
|
|
||||||
0 => path.to_string(),
|
|
||||||
1 | 2 => parts.join(&sep.to_string()),
|
|
||||||
n => format!("…{sep}{}{sep}{}", parts[n - 2], parts[n - 1]),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content: El) -> El {
|
fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, content: El) -> El {
|
||||||
let v = &app.form.draft.video;
|
let v = &app.form.draft.video;
|
||||||
let o = &app.form.draft.output;
|
let o = &app.form.draft.output;
|
||||||
@@ -473,13 +511,12 @@ fn recording(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, cont
|
|||||||
},
|
},
|
||||||
)),
|
)),
|
||||||
vec![
|
vec![
|
||||||
text_row(
|
path_row(
|
||||||
p,
|
p,
|
||||||
|
app,
|
||||||
"output-path",
|
"output-path",
|
||||||
"Folder",
|
"Folder",
|
||||||
"Where finished recordings are written",
|
"Where finished recordings are written",
|
||||||
&app.form.path,
|
|
||||||
|app| &mut app.form.path,
|
|
||||||
),
|
),
|
||||||
text_row(
|
text_row(
|
||||||
p,
|
p,
|
||||||
@@ -913,7 +950,10 @@ fn advanced(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, conte
|
|||||||
text(value)
|
text(value)
|
||||||
.key("value")
|
.key("value")
|
||||||
.font(type_::MONO_CAPTION)
|
.font(type_::MONO_CAPTION)
|
||||||
.color(p.muted()),
|
.color(p.muted())
|
||||||
|
.ml(space::S2)
|
||||||
|
// A long value, the log path most of all, is cut to the row's width.
|
||||||
|
.truncate_middle(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
let recording = if app.status.is_recording { "yes" } else { "no" };
|
let recording = if app.status.is_recording { "yes" } else { "no" };
|
||||||
@@ -951,11 +991,7 @@ fn advanced(app: &App, p: Paint, kit: &rune_kit::Kit, layer: &mut Vec<El>, conte
|
|||||||
.map(|id| id.to_string())
|
.map(|id| id.to_string())
|
||||||
.unwrap_or_else(|| "none".into()),
|
.unwrap_or_else(|| "none".into()),
|
||||||
),
|
),
|
||||||
status_row(
|
status_row("daemon-log", "Log file", crate::daemon::log_path()),
|
||||||
"daemon-log",
|
|
||||||
"Log file",
|
|
||||||
short_path(&crate::daemon::log_path()),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
))
|
))
|
||||||
.child(ui::card(
|
.child(ui::card(
|
||||||
|
|||||||
+13
-1
@@ -412,6 +412,18 @@ pub fn button(
|
|||||||
label: &str,
|
label: &str,
|
||||||
primary: bool,
|
primary: bool,
|
||||||
on_press: impl Fn(&mut App) + Send + Sync + 'static,
|
on_press: impl Fn(&mut App) + Send + Sync + 'static,
|
||||||
|
) -> El {
|
||||||
|
button_tx(p, key, label, primary, move |app, _| on_press(app))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// [`button`] whose press gets the frame's [`Tx`], for a control that asks the window for
|
||||||
|
/// something: a native folder dialog, an open URL, a clipboard read.
|
||||||
|
pub fn button_tx(
|
||||||
|
p: Paint,
|
||||||
|
key: &str,
|
||||||
|
label: &str,
|
||||||
|
primary: bool,
|
||||||
|
on_press: impl Fn(&mut App, &mut rune::Tx) + Send + Sync + 'static,
|
||||||
) -> El {
|
) -> El {
|
||||||
el().key(key)
|
el().key(key)
|
||||||
.role("button")
|
.role("button")
|
||||||
@@ -424,7 +436,7 @@ pub fn button(
|
|||||||
.fill(if primary { p.accent } else { p.t.control_off })
|
.fill(if primary { p.accent } else { p.t.control_off })
|
||||||
.hover(p.t.hover)
|
.hover(p.t.hover)
|
||||||
.press(p.t.press)
|
.press(p.t.press)
|
||||||
.on_press(on_press)
|
.on_press_tx(on_press)
|
||||||
.child(
|
.child(
|
||||||
text(label)
|
text(label)
|
||||||
.key("label")
|
.key("label")
|
||||||
|
|||||||
Reference in new issue
Block a user