callbacks/policycheck_state: update theme, popup
* popup handling update * handling of themes Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -59,7 +59,7 @@ struct Environment {
|
|||||||
rust_log: String,
|
rust_log: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles the requests of the `PolicyCheckView`.
|
/// Handles the requests from `PolicyCheckView`.
|
||||||
#[derive(AsAny, Default)]
|
#[derive(AsAny, Default)]
|
||||||
pub struct PolicyCheckState {
|
pub struct PolicyCheckState {
|
||||||
action: Option<Action>,
|
action: Option<Action>,
|
||||||
@@ -74,7 +74,7 @@ pub struct PolicyCheckState {
|
|||||||
policy_numbers: HashMap<u64, PolicyCode>,
|
policy_numbers: HashMap<u64, PolicyCode>,
|
||||||
progress_bar: Entity,
|
progress_bar: Entity,
|
||||||
progress_count: f64,
|
progress_count: f64,
|
||||||
theme: String
|
theme_name: String
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "light"))]
|
#[cfg(not(feature = "light"))]
|
||||||
@@ -593,19 +593,19 @@ impl State for PolicyCheckState {
|
|||||||
self.set_entry(entity, ctx);
|
self.set_entry(entity, ctx);
|
||||||
}
|
}
|
||||||
Action::ToggleTheme(_entity) => {
|
Action::ToggleTheme(_entity) => {
|
||||||
if self.theme == "light" {
|
if self.theme_name == "light" {
|
||||||
self.theme = "dark_theme".to_string();
|
let theme = dark_theme();
|
||||||
} else {
|
self.theme_name = "dark".to_string();
|
||||||
self.theme = "light_theme".to_string();
|
ctx.switch_theme(theme);
|
||||||
}
|
}
|
||||||
//match &self.theme {
|
|
||||||
// light => { self.theme = "dark_theme".to_string(); }
|
if self.theme_name == "dark" {
|
||||||
// dark => { self.theme = "light_theme".to_string(); }
|
let theme = light_theme();
|
||||||
// _ => { debug!(target: "advotracker", "theme not supported!"); }
|
self.theme_name = "light".to_string();
|
||||||
// }
|
ctx.switch_theme(theme);
|
||||||
println!{"Switch theme to {:?}", self.theme}
|
};
|
||||||
let theme = dark_theme();
|
|
||||||
ctx.switch_theme(theme);
|
println!{"Switch theme to {:?}", self.theme_name};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -632,140 +632,140 @@ impl State for PolicyCheckState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a menu popup
|
/// Create a menu popup
|
||||||
fn create_menu(menu: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
fn create_menu(menu: Entity, ctx: &mut BuildContext<'_>) -> Entity {
|
||||||
Container::new()
|
Container::new()
|
||||||
.style("container_menu")
|
.style("container_menu")
|
||||||
.width(280.0)
|
.width(280.0)
|
||||||
.height(140.0)
|
.height(140.0)
|
||||||
.position((100.0, 100.0))
|
.position((100.0, 100.0))
|
||||||
.child(
|
.child(
|
||||||
Grid::new()
|
Grid::new()
|
||||||
.id(ID_POLICY_CHECK_MENU)
|
.id(ID_POLICY_CHECK_MENU)
|
||||||
.columns(
|
.columns(
|
||||||
Columns::create()
|
Columns::create()
|
||||||
// Menu Button
|
// Menu Button
|
||||||
.push("80")
|
.push("80")
|
||||||
// Seperator
|
// Seperator
|
||||||
.push("1")
|
.push("1")
|
||||||
// Keyboard Shortcut
|
// Keyboard Shortcut
|
||||||
.push("*")
|
.push("*")
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.rows(
|
.rows(
|
||||||
Rows::create()
|
Rows::create()
|
||||||
.push("auto")
|
.push("auto")
|
||||||
.push("auto")
|
.push("auto")
|
||||||
.push("auto")
|
.push("auto")
|
||||||
.build(),
|
.build(),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new()
|
Button::new()
|
||||||
.id(ID_POLICY_CHECK_MENU_LABEL_ACCOUNT)
|
.id(ID_POLICY_CHECK_MENU_LABEL_ACCOUNT)
|
||||||
.style("button_menu")
|
.style("button_menu")
|
||||||
.attach(Grid::row(0))
|
.attach(Grid::row(0))
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::column_span(2))
|
.attach(Grid::column_span(2))
|
||||||
.icon(material_icons_font::MD_PERSON)
|
.icon(material_icons_font::MD_PERSON)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new()
|
Button::new()
|
||||||
.id(ID_POLICY_CHECK_MENU_LABEL_TOGGLE_THEME)
|
.id(ID_POLICY_CHECK_MENU_LABEL_TOGGLE_THEME)
|
||||||
//.style("body")
|
//.style("body")
|
||||||
.style("button_menu")
|
.style("button_menu")
|
||||||
.attach(Grid::row(1))
|
.attach(Grid::row(1))
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::column_span(2))
|
.attach(Grid::column_span(2))
|
||||||
.icon(material_icons_font::MD_EDIT)
|
.icon(material_icons_font::MD_EDIT)
|
||||||
.on_click(move |states, _| {
|
.on_click(move |states, _| {
|
||||||
states.get_mut::<PolicyCheckState>(menu)
|
states.get_mut::<PolicyCheckState>(menu)
|
||||||
.action(Action::ToggleTheme(menu));
|
.action(Action::ToggleTheme(menu));
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
Button::new()
|
Button::new()
|
||||||
.id(ID_POLICY_CHECK_MENU_LABEL_QUIT)
|
.id(ID_POLICY_CHECK_MENU_LABEL_QUIT)
|
||||||
//.style("body")
|
//.style("body")
|
||||||
.style("button_menu")
|
.style("button_menu")
|
||||||
.attach(Grid::row(2))
|
.attach(Grid::row(2))
|
||||||
.attach(Grid::column(0))
|
.attach(Grid::column(0))
|
||||||
.attach(Grid::column_span(2))
|
.attach(Grid::column_span(2))
|
||||||
.icon(material_icons_font::MD_SETTINGS_POWER)
|
.icon(material_icons_font::MD_SETTINGS_POWER)
|
||||||
.on_mouse_down(move |_states, _| {
|
.on_mouse_down(move |_states, _| {
|
||||||
process::exit(0);
|
process::exit(0);
|
||||||
})
|
})
|
||||||
// .on_key_down(move | ctx, "Ctlr+Q"| {
|
// .on_key_down(move | ctx, "Ctlr+Q"| {
|
||||||
// process::exit(0);
|
// process::exit(0);
|
||||||
// })
|
// })
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.id(ID_POLICY_CHECK_MENU_SHORTCUT_QUIT)
|
.id(ID_POLICY_CHECK_MENU_SHORTCUT_QUIT)
|
||||||
.style("button_menu")
|
.style("button_menu")
|
||||||
//.style("body")
|
//.style("body")
|
||||||
.attach(Grid::row(2))
|
.attach(Grid::row(2))
|
||||||
.attach(Grid::column(2))
|
.attach(Grid::column(2))
|
||||||
.margin((0, 0, 16, 0))
|
.margin((0, 0, 16, 0))
|
||||||
.h_align("end")
|
.h_align("end")
|
||||||
.v_align("center")
|
.v_align("center")
|
||||||
.text("CTRL+Q")
|
.text("CTRL+Q")
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx),
|
.build(ctx),
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a progress popup with update status of an onging data import
|
/// Create a progress popup with update status of an onging data import
|
||||||
fn create_popup_progress(target: Entity, text: &str, ctx: &mut BuildContext<'_>) -> Entity {
|
fn create_popup_progress(target: Entity, text: &str, ctx: &mut BuildContext<'_>) -> Entity {
|
||||||
Popup::new()
|
Popup::new()
|
||||||
.id(ID_POLICY_CHECK_POPUP_PROGRESS)
|
.id(ID_POLICY_CHECK_POPUP_PROGRESS)
|
||||||
.target(target)
|
.target(target)
|
||||||
.open(true)
|
.open(true)
|
||||||
//.style("popup_progress")
|
//.style("popup_progress")
|
||||||
.width(280)
|
.width(280)
|
||||||
.height(100)
|
.height(100)
|
||||||
.on_mouse_down(move |ctx, _| {
|
.on_mouse_down(move |ctx, _| {
|
||||||
println!("on_click -> remove_popup_progress()");
|
println!("on_click -> remove_popup_progress()");
|
||||||
ctx.get_mut::<PolicyCheckState>(target)
|
ctx.get_mut::<PolicyCheckState>(target)
|
||||||
.action(Action::RemovePopup(target));
|
.action(Action::RemovePopup(target));
|
||||||
true
|
true
|
||||||
})
|
})
|
||||||
.child(
|
.child(
|
||||||
Container::new()
|
Container::new()
|
||||||
.style("container_progress")
|
.style("container_progress")
|
||||||
.child( Stack::new()
|
.child( Stack::new()
|
||||||
.style("stack_progress")
|
.style("stack_progress")
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.id(ID_POLICY_CHECK_PROGRESS_TEXT)
|
.id(ID_POLICY_CHECK_PROGRESS_TEXT)
|
||||||
//.style("textblock_progress")
|
//.style("textblock_progress")
|
||||||
.font_size(12)
|
.font_size(12)
|
||||||
.text(text)
|
.text(text)
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
ProgressBar::new()
|
ProgressBar::new()
|
||||||
.id(ID_POLICY_CHECK_PROGRESS_BAR)
|
.id(ID_POLICY_CHECK_PROGRESS_BAR)
|
||||||
.val(0)
|
.val(0)
|
||||||
//.width(250)
|
//.width(250)
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
)
|
)
|
||||||
.child(
|
.child(
|
||||||
TextBlock::new()
|
TextBlock::new()
|
||||||
.id(ID_POLICY_CHECK_PROGRESS_TIME)
|
.id(ID_POLICY_CHECK_PROGRESS_TIME)
|
||||||
//.style("textblock_progress")
|
//.style("textblock_progress")
|
||||||
.h_align("end")
|
.h_align("end")
|
||||||
.font_size(12)
|
.font_size(12)
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
)
|
)
|
||||||
.build(ctx)
|
.build(ctx)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user