Skip to content

Commit

Permalink
Fix motion data check and opening app on macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrianEddy committed Dec 6, 2023
1 parent 011df7c commit 33d71a8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ ofx = "0.3"
log = "0.4"
itertools = "0.12"
lru = "0.12"
gyroflow-core = { git = "https://github.com/gyroflow/gyroflow.git", default-features = false, rev = "d5df873", features = ["bundle-lens-profiles"] }
gyroflow-core = { git = "https://github.com/gyroflow/gyroflow.git", default-features = false, rev = "00496d1", features = ["bundle-lens-profiles"] }
#gyroflow-core = { path = "../gyroflow/src/core", default-features = false, features = ["bundle-lens-profiles"] }
log-panics = "2.1"
rfd = { version = "0.12", default-features = false, features = ["xdg-portal"] }
Expand Down
53 changes: 36 additions & 17 deletions src/gyroflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -463,26 +463,38 @@ impl InstanceData {
}

pub fn open_gyroflow(&self) {
if let Some(v) = Self::get_gyroflow_location() {
if !v.is_empty() {
if let Ok(project) = self.param_project_path.get_value() {
if !project.is_empty() {
if cfg!(target_os = "macos") {
let _ = std::process::Command::new("open").args(["-a", &v, "--args", "--open", &project]).spawn();
} else {
let _ = std::process::Command::new(v).args(["--open", &project]).spawn();
}
} else {
if cfg!(target_os = "macos") {
let _ = std::process::Command::new("open").args(["-a", &v]).spawn();
if cfg!(target_os = "macos") {
let mut cmd = std::process::Command::new("osascript");
if let Ok(project) = self.param_project_path.get_value() {
if !project.is_empty() {
cmd.args(&["-e", &format!("tell application \"Gyroflow\" to open file \"{}\"", project.replace("/", ":").trim_start_matches(':'))]);
} else {
cmd.args(&["-e", "tell application \"Gyroflow\" to activate"]);
}
}
let _ = cmd.output();
} else {
if let Some(v) = Self::get_gyroflow_location() {
if !v.is_empty() {
if let Ok(project) = self.param_project_path.get_value() {
if !project.is_empty() {
if cfg!(target_os = "macos") {
let _ = std::process::Command::new("open").args(["-a", &v, "--args", "--open", &project]).spawn();
} else {
let _ = std::process::Command::new(v).args(["--open", &project]).spawn();
}
} else {
let _ = std::process::Command::new(v).spawn();
if cfg!(target_os = "macos") {
let _ = std::process::Command::new("open").args(["-a", &v]).spawn();
} else {
let _ = std::process::Command::new(v).spawn();
}
}
}
}
} else {
rfd::MessageDialog::new().set_description("Unable to find Gyroflow app path. Make sure to run Gyroflow app at least once and that version is at least v1.4.3").show();
}
} else {
rfd::MessageDialog::new().set_description("Unable to find Gyroflow app path. Make sure to run Gyroflow app at least once and that version is at least v1.4.3").show();
}
}
fn disable_opencl(&mut self) {
Expand Down Expand Up @@ -886,7 +898,14 @@ impl Execute for GyroflowPlugin {
effect.get_instance_data::<InstanceData>()?.open_gyroflow();
}
if in_args.get_name()? == "OpenRecentProject" {
if let Some(v) = gyroflow_core::util::get_setting("lastProject") {
let last_project = /*if cfg!(target_os = "macos") {
let mut cmd = std::process::Command::new("defaults");
cmd.args(&["read", "com.gyroflow-xyz.Gyroflow", "lastProject"]);
cmd.output().ok().map(|x| String::from_utf8_lossy(&x.stdout).to_string())
} else */{
gyroflow_core::util::get_setting("lastProject")
};
if let Some(v) = last_project {
if !v.is_empty() {
let instance_data: &mut InstanceData = effect.get_instance_data()?;
instance_data.param_project_path.set_value(v)?;
Expand All @@ -906,7 +925,7 @@ impl Execute for GyroflowPlugin {
if instance_data.param_include_project_data.get_value()? {
if path.ends_with(".gyroflow") {
if let Ok(data) = std::fs::read_to_string(&path) {
if !data.contains("\"raw_imu\": null") || !data.contains("\"quaternions\": null") {
if StabilizationManager::project_has_motion_data(data.as_bytes()) {
instance_data.param_project_data.set_value(data.clone())?;
} else {
if let Some((_, stab)) = instance_data.gyrodata.peek_lru() {
Expand Down

0 comments on commit 33d71a8

Please sign in to comment.