diff --git a/src/gui/views/views.rs b/src/gui/views/views.rs index 3e54413..eab2a76 100644 --- a/src/gui/views/views.rs +++ b/src/gui/views/views.rs @@ -23,6 +23,7 @@ use egui::epaint::text::TextWrapping; use egui::os::OperatingSystem; use egui::text::{LayoutJob, TextFormat}; use egui::text_edit::TextEditState; +use crate::AppConfig; use crate::gui::Colors; use crate::gui::icons::{CHECK_SQUARE, CLIPBOARD_TEXT, COPY, EYE, EYE_SLASH, SCAN, SQUARE}; @@ -63,8 +64,11 @@ impl View { ui.ctx().input(|i| { return match i.viewport().inner_rect { None => { - let size = i.viewport().monitor_size.unwrap(); - (size.x, size.y) + if let Some(size) = i.viewport().monitor_size { + (size.x, size.y) + } else { + (AppConfig::DEFAULT_WIDTH, AppConfig::DEFAULT_HEIGHT) + } } Some(rect) => { (rect.width(), rect.height()) diff --git a/src/settings/config.rs b/src/settings/config.rs index bbc4bac..04d1e4c 100644 --- a/src/settings/config.rs +++ b/src/settings/config.rs @@ -47,9 +47,6 @@ pub struct AppConfig { lang: Option } -const DEFAULT_WIDTH: f32 = 1280.0; -const DEFAULT_HEIGHT: f32 = 745.0; - impl Default for AppConfig { fn default() -> Self { Self { @@ -58,8 +55,8 @@ impl Default for AppConfig { android_integrated_node_warning: None, show_wallets_at_dual_panel: false, show_connections_network_panel: false, - width: DEFAULT_WIDTH, - height: DEFAULT_HEIGHT, + width: Self::DEFAULT_WIDTH, + height: Self::DEFAULT_HEIGHT, x: None, y: None, lang: None, @@ -68,6 +65,11 @@ impl Default for AppConfig { } impl AppConfig { + /// Default window width. + pub const DEFAULT_WIDTH: f32 = 1280.0; + /// Default window height. + pub const DEFAULT_HEIGHT: f32 = 745.0; + /// Application configuration file name. pub const FILE_NAME: &'static str = "app.toml";