Merge branch 'next' of https://gitea.networkx.de:50443/rzerres/advotracker into wip_toggle_theme_menu

Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
2020-11-02 09:43:32 +01:00

View File

@@ -8,10 +8,7 @@ use std::time::{Duration, SystemTime};
use tracing::{error, info, trace}; use tracing::{error, info, trace};
use crate::{ use crate::{
widgets::{ widgets::global_state::GlobalState,
global_state::GlobalState,
policycheck::policycheck_view::PolicycheckView,
},
data::{ data::{
structures::{PolicyCode, PolicyDataList, PolicyList}, structures::{PolicyCode, PolicyDataList, PolicyList},
constants::*, constants::*,
@@ -39,7 +36,7 @@ pub enum PolicycheckAction {
SetEntry(Entity), SetEntry(Entity),
SetVisibility(Entity), SetVisibility(Entity),
TextChanged(Entity, usize), TextChanged(Entity, usize),
ToggleTheme(Entity), ToggleTheme(Entity)
} }
/// define valid environment variables provided via .env files /// define valid environment variables provided via .env files
@@ -62,6 +59,7 @@ pub struct PolicycheckState {
button_menu: Entity, button_menu: Entity,
policy_data_count: u64, policy_data_count: u64,
policy_numbers: HashMap<u64, PolicyCode>, policy_numbers: HashMap<u64, PolicyCode>,
popup_menu: Entity,
progress_bar: Entity, progress_bar: Entity,
progress_count: f64, progress_count: f64,
progress_popup: Entity progress_popup: Entity
@@ -176,8 +174,7 @@ impl PolicycheckState {
pub fn open_menu(&mut self, _entity: Entity, ctx: &mut Context<'_>) { pub fn open_menu(&mut self, _entity: Entity, ctx: &mut Context<'_>) {
//let menu_string = ctx.get_widget(entity).get::<String16>("text"); //let menu_string = ctx.get_widget(entity).get::<String16>("text");
//.child(policycheck_menu); //.child(policycheck_menu);
//self.set_popup_menu(ctx); self.set_popup_menu(ctx);
self.set_menu(ctx);
} }
/// Parse validity of the given policy number. /// Parse validity of the given policy number.
@@ -356,7 +353,7 @@ impl PolicycheckState {
} }
/// Set a menu /// Set a menu
fn set_menu(&mut self, ctx: &mut Context<'_>) { fn set_popup_menu(&mut self, ctx: &mut Context<'_>) {
let stack = ctx let stack = ctx
.entity_of_child(ID_POLICY_CHECK_BUTTON_MENU) .entity_of_child(ID_POLICY_CHECK_BUTTON_MENU)
.expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_POPUP_MENU'."); .expect("PolicycheckState: Can't find entity of resource 'ID_POLICY_CHECK_POPUP_MENU'.");
@@ -555,7 +552,7 @@ impl State for PolicycheckState {
self.set_entry(policy_check_policy_number, ctx); self.set_entry(policy_check_policy_number, ctx);
} }
PolicycheckAction::SetMenu(_entity) => { PolicycheckAction::SetMenu(_entity) => {
self.set_menu(ctx); self.set_popup_menu(ctx);
} }
PolicycheckAction::SetProgress(value) => { PolicycheckAction::SetProgress(value) => {
if value >= 0. || value <= 1. { if value >= 0. || value <= 1. {
@@ -572,6 +569,10 @@ impl State for PolicycheckState {
PolicycheckAction::TextChanged(entity, _index) => { PolicycheckAction::TextChanged(entity, _index) => {
self.set_entry(entity, ctx); self.set_entry(entity, ctx);
} }
PolicycheckAction::ToggleTheme(_entity) => {
println!("TODO: toggle active theme");
//self.toggle_theme(entity, ctx);
}
} }
} }
// Reset action // Reset action