Skip to content

Commit

Permalink
Default to system theme, set min window size
Browse files Browse the repository at this point in the history
  • Loading branch information
1borgy committed Nov 19, 2023
1 parent 2482c4f commit 5a8321e
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
3 changes: 2 additions & 1 deletion cascade/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cascade"
version = "0.1.3+dev1"
version = "0.1.3"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -10,6 +10,7 @@ anyhow = "1.0.71"
byteorder = "1.4.3"
count-write = "0.1.0"
crc = "3.0.1"
dark-light = "1.0.0"
directories = "5.0.1"
enum-iterator = "1.4.1"
filetime = "0.2.21"
Expand Down
23 changes: 22 additions & 1 deletion cascade/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,15 +320,35 @@ pub struct CascadeTheme {
)]
pub enum CascadeBackground {
Light,
#[default]
Dark,
#[default]
System,
}

impl CascadeBackground {
pub fn get_palette(&self) -> CascadePalette {
match self {
CascadeBackground::Light => CascadePalette::light(),
CascadeBackground::Dark => CascadePalette::dark(),
CascadeBackground::System => {
// autodetect dark/light theme on system
let mode = dark_light::detect();

match mode {
dark_light::Mode::Dark => {
log::info!("autodetected system dark theme");
CascadePalette::dark()
}
dark_light::Mode::Light => {
log::info!("autodetected system light theme");
CascadePalette::light()
}
dark_light::Mode::Default => {
log::warn!("could not autodetect system theme; defaulting to light");
CascadePalette::light()
}
}
}
}
}
}
Expand Down Expand Up @@ -362,6 +382,7 @@ impl Display for CascadeBackground {
match self {
CascadeBackground::Light => "light",
CascadeBackground::Dark => "dark",
CascadeBackground::System => "system",
}
)
}
Expand Down
2 changes: 1 addition & 1 deletion cascade_cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cascade_cli"
version = "0.1.3+dev1"
version = "0.1.3"
edition = "2021"
build = "build.rs"

Expand Down
2 changes: 1 addition & 1 deletion cascade_gui/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cascade_gui"
version = "0.1.3+dev1"
version = "0.1.3"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
1 change: 1 addition & 0 deletions cascade_gui/src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ impl Cascade {
iced::Settings {
window: window::Settings {
size: (720, 520),
min_size: Some((720, 520)),
..Default::default()
},
..Default::default()
Expand Down
15 changes: 10 additions & 5 deletions cascade_gui/src/views/dashboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,16 @@ impl DashboardView {
.clone()
.ok_or(DashboardError::TricksetNotSet)?;

let dialog = FileDialog::new();

if let Some(selected_path) =
dialog.add_filter("SKA", &["SKA"]).pick_file()
{
let dialog =
FileDialog::new().add_filter("SKA", &["SKA"]).set_directory(
self.config
.paths
.saves_dir
.clone()
.ok_or(DashboardError::SavesDirNotSet)?,
);

if let Some(selected_path) = dialog.pick_file() {
fs::copy(selected_path, trickset_path)?;
self.status_text = "successfully set trickset".to_string();
}
Expand Down

0 comments on commit 5a8321e

Please sign in to comment.