11 changed files with 187 additions and 51 deletions
@ -0,0 +1,55 @@ |
|||
use super::{Config, EnvOpt, GenericError}; |
|||
|
|||
use nwd::NwgUi; |
|||
use nwg::{Font, NativeUi}; |
|||
|
|||
#[derive(Default, NwgUi)] |
|||
pub struct APIKeyPrompt { |
|||
#[nwg_control(size: (500, 100), position: (300, 300), title: "API-key prompt", flags: "WINDOW|VISIBLE")] |
|||
#[nwg_events( OnWindowClose: [APIKeyPrompt::say_goodbye] )] |
|||
window: nwg::Window, |
|||
|
|||
#[nwg_layout(parent: window, spacing: 5)] |
|||
grid: nwg::GridLayout, |
|||
|
|||
#[nwg_control(text: "API-key")] |
|||
#[nwg_layout_item(layout: grid, col: 0, row: 0, col_span: 3)] |
|||
label: nwg::Label, |
|||
|
|||
#[nwg_control(text: "", focus: true)] |
|||
#[nwg_layout_item(layout: grid, col: 0, row: 1, col_span: 3)] |
|||
name_edit: nwg::TextInput, |
|||
|
|||
#[nwg_control(text: "Submit")] |
|||
#[nwg_layout_item(layout: grid, col: 1, row: 2)] |
|||
button: nwg::Button, |
|||
} |
|||
|
|||
impl APIKeyPrompt { |
|||
fn say_goodbye(&self) { |
|||
nwg::modal_info_message( |
|||
&self.window, |
|||
"Goodbye", |
|||
&format!("Goodbye {}", self.name_edit.text()), |
|||
); |
|||
nwg::stop_thread_dispatch(); |
|||
} |
|||
} |
|||
|
|||
pub fn start_windows_ui(env: EnvOpt) -> Result<(), GenericError> { |
|||
nwg::init().expect("Failed to init Native Windows GUI"); |
|||
|
|||
let mut font = Font::default(); |
|||
|
|||
Font::builder() |
|||
.family("Segoe UI") |
|||
.size(20) |
|||
.build(&mut font)?; |
|||
|
|||
Font::set_global_default(Some(font)); |
|||
|
|||
let mut _app = APIKeyPrompt::build_ui(Default::default()).expect("Failed to build UI"); |
|||
nwg::dispatch_thread_events(); |
|||
|
|||
Ok(()) |
|||
} |
Loading…
Reference in new issue