diff --git a/src/main.rs b/src/main.rs index 97655d5..47a2e31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,8 @@ const STA_ENDPOINT: &str = "https://staging.strem.io/"; #[derive(StructOpt, Debug)] #[structopt(name = "basic")] struct Opt { + #[structopt(long)] + dev_tools: bool, #[structopt(long)] development: bool, #[structopt(long)] @@ -51,6 +53,7 @@ fn main() { nwg::init().expect("Failed to init Native Windows GUI"); let _app = MainWindow::build_ui(MainWindow { webui_url, + dev_tools: opt.development || opt.dev_tools, ..Default::default() }) .expect("Failed to build UI"); diff --git a/src/stremio_app/app.rs b/src/stremio_app/app.rs index 9f39de7..5d42610 100644 --- a/src/stremio_app/app.rs +++ b/src/stremio_app/app.rs @@ -16,6 +16,7 @@ use crate::stremio_app::window_helper::WindowStyle; #[derive(Default, NwgUi)] pub struct MainWindow { pub webui_url: String, + pub dev_tools: bool, pub saved_window_style: RefCell, #[nwg_resource] pub embed: nwg::EmbedResource, @@ -76,6 +77,7 @@ impl MainWindow { } fn on_init(&self) { self.webview.endpoint.set(self.webui_url.clone()).ok(); + self.webview.dev_tools.set(self.dev_tools).ok(); if let Some(hwnd) = self.window.handle.hwnd() { let mut saved_style = self.saved_window_style.borrow_mut(); saved_style.center_window(hwnd, Self::MIN_WIDTH, Self::MIN_HEIGHT); diff --git a/src/stremio_app/stremio_wevbiew/wevbiew.rs b/src/stremio_app/stremio_wevbiew/wevbiew.rs index 83a9c00..5c709f4 100644 --- a/src/stremio_app/stremio_wevbiew/wevbiew.rs +++ b/src/stremio_app/stremio_wevbiew/wevbiew.rs @@ -18,6 +18,7 @@ use winapi::um::winuser::{GetClientRect, WM_SETFOCUS}; #[derive(Default)] pub struct WebView { pub endpoint: Rc>, + pub dev_tools: Rc>, controller: Rc>, pub channel: ipc::Channel, notice: nwg::Notice, @@ -60,6 +61,7 @@ impl PartialUi for WebView { .ok(); let controller_clone = data.controller.clone(); let endpoint = data.endpoint.clone(); + let dev_tools = data.dev_tools.clone(); let result = webview2::EnvironmentBuilder::new() .with_additional_browser_arguments("--disable-gpu --autoplay-policy=no-user-gesture-required") .build(move |env| { @@ -83,7 +85,7 @@ impl PartialUi for WebView { .expect("Cannot obtain webview from controller"); let settings = webview.get_settings().unwrap(); settings.put_is_status_bar_enabled(false).ok(); - settings.put_are_dev_tools_enabled(true).ok(); + settings.put_are_dev_tools_enabled(*dev_tools.get().unwrap()).ok(); settings.put_are_default_context_menus_enabled(false).ok(); settings.put_is_zoom_control_enabled(false).ok(); settings.put_is_built_in_error_page_enabled(false).ok();