mirror of
https://github.com/Stremio/stremio-shell-ng.git
synced 2026-04-21 16:01:56 +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)]
|
#[derive(StructOpt, Debug)]
|
||||||
#[structopt(name = "basic")]
|
#[structopt(name = "basic")]
|
||||||
struct Opt {
|
struct Opt {
|
||||||
|
#[structopt(long)]
|
||||||
|
dev_tools: bool,
|
||||||
#[structopt(long)]
|
#[structopt(long)]
|
||||||
development: bool,
|
development: bool,
|
||||||
#[structopt(long)]
|
#[structopt(long)]
|
||||||
|
|
@ -51,6 +53,7 @@ fn main() {
|
||||||
nwg::init().expect("Failed to init Native Windows GUI");
|
nwg::init().expect("Failed to init Native Windows GUI");
|
||||||
let _app = MainWindow::build_ui(MainWindow {
|
let _app = MainWindow::build_ui(MainWindow {
|
||||||
webui_url,
|
webui_url,
|
||||||
|
dev_tools: opt.development || opt.dev_tools,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
})
|
})
|
||||||
.expect("Failed to build UI");
|
.expect("Failed to build UI");
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ use crate::stremio_app::window_helper::WindowStyle;
|
||||||
#[derive(Default, NwgUi)]
|
#[derive(Default, NwgUi)]
|
||||||
pub struct MainWindow {
|
pub struct MainWindow {
|
||||||
pub webui_url: String,
|
pub webui_url: String,
|
||||||
|
pub dev_tools: bool,
|
||||||
pub saved_window_style: RefCell<WindowStyle>,
|
pub saved_window_style: RefCell<WindowStyle>,
|
||||||
#[nwg_resource]
|
#[nwg_resource]
|
||||||
pub embed: nwg::EmbedResource,
|
pub embed: nwg::EmbedResource,
|
||||||
|
|
@ -76,6 +77,7 @@ impl MainWindow {
|
||||||
}
|
}
|
||||||
fn on_init(&self) {
|
fn on_init(&self) {
|
||||||
self.webview.endpoint.set(self.webui_url.clone()).ok();
|
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() {
|
if let Some(hwnd) = self.window.handle.hwnd() {
|
||||||
let mut saved_style = self.saved_window_style.borrow_mut();
|
let mut saved_style = self.saved_window_style.borrow_mut();
|
||||||
saved_style.center_window(hwnd, Self::MIN_WIDTH, Self::MIN_HEIGHT);
|
saved_style.center_window(hwnd, Self::MIN_WIDTH, Self::MIN_HEIGHT);
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ use winapi::um::winuser::{GetClientRect, WM_SETFOCUS};
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct WebView {
|
pub struct WebView {
|
||||||
pub endpoint: Rc<OnceCell<String>>,
|
pub endpoint: Rc<OnceCell<String>>,
|
||||||
|
pub dev_tools: Rc<OnceCell<bool>>,
|
||||||
controller: Rc<OnceCell<Controller>>,
|
controller: Rc<OnceCell<Controller>>,
|
||||||
pub channel: ipc::Channel,
|
pub channel: ipc::Channel,
|
||||||
notice: nwg::Notice,
|
notice: nwg::Notice,
|
||||||
|
|
@ -60,6 +61,7 @@ impl PartialUi for WebView {
|
||||||
.ok();
|
.ok();
|
||||||
let controller_clone = data.controller.clone();
|
let controller_clone = data.controller.clone();
|
||||||
let endpoint = data.endpoint.clone();
|
let endpoint = data.endpoint.clone();
|
||||||
|
let dev_tools = data.dev_tools.clone();
|
||||||
let result = webview2::EnvironmentBuilder::new()
|
let result = webview2::EnvironmentBuilder::new()
|
||||||
.with_additional_browser_arguments("--disable-gpu --autoplay-policy=no-user-gesture-required")
|
.with_additional_browser_arguments("--disable-gpu --autoplay-policy=no-user-gesture-required")
|
||||||
.build(move |env| {
|
.build(move |env| {
|
||||||
|
|
@ -83,7 +85,7 @@ impl PartialUi for WebView {
|
||||||
.expect("Cannot obtain webview from controller");
|
.expect("Cannot obtain webview from controller");
|
||||||
let settings = webview.get_settings().unwrap();
|
let settings = webview.get_settings().unwrap();
|
||||||
settings.put_is_status_bar_enabled(false).ok();
|
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_are_default_context_menus_enabled(false).ok();
|
||||||
settings.put_is_zoom_control_enabled(false).ok();
|
settings.put_is_zoom_control_enabled(false).ok();
|
||||||
settings.put_is_built_in_error_page_enabled(false).ok();
|
settings.put_is_built_in_error_page_enabled(false).ok();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue