mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-01-11 22:40:32 +00:00
Command line flag to enable dev tools
This commit is contained in:
parent
76ff6cac5b
commit
a12c7d265a
3 changed files with 8 additions and 1 deletions
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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<WindowStyle>,
|
||||
#[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);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use winapi::um::winuser::{GetClientRect, WM_SETFOCUS};
|
|||
#[derive(Default)]
|
||||
pub struct WebView {
|
||||
pub endpoint: Rc<OnceCell<String>>,
|
||||
pub dev_tools: Rc<OnceCell<bool>>,
|
||||
controller: Rc<OnceCell<Controller>>,
|
||||
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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue