Skip to content

Commit

Permalink
fix(gui,win): fix silence and layer icon checks (#1072)
Browse files Browse the repository at this point in the history
- Respect the silence if configured on gui reload via tray
- Fix `icon-match-layer-name` not matching by layer name

Fixes some of
#1053 (comment)
  • Loading branch information
eugenesvk authored May 26, 2024
1 parent 8a0c78b commit bb925fb
Showing 1 changed file with 46 additions and 10 deletions.
56 changes: 46 additions & 10 deletions src/gui/win.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,19 @@ fn get_icon_p_impl(
.unwrap_or_else(|| OsStr::new(""))
.to_string_lossy()
.to_string();
let is_icn_ext_valid = if !IMG_EXT.iter().any(|&i| i == icn_ext) && f_ext[i].is_some() {
warn!(
"user icon extension \"{}\" might be invalid (or just not an extension)!",
icn_ext
);
false
let is_icn_ext_valid = if f_ext[i].is_some() {
if IMG_EXT.iter().any(|&i| i == icn_ext) {
trace!("icn_ext={:?}", icn_ext);
true
} else {
warn!(
"user icon extension \"{}\" might be invalid (or just not an extension)!",
icn_ext
);
false
}
} else {
trace!("icn_ext={:?}", icn_ext);
true
false
};
'p: for p_par in parents {
trace!("{}p_par={:?}", " ", p_par);
Expand Down Expand Up @@ -879,6 +883,12 @@ impl SystemTray {
} else {
msg_title += &("🔄 \"".to_owned() + cfg_name + "\" NOT loaded");
flags |= f_tray::ERROR_ICON | f_tray::LARGE_ICON;
{
let app_data = self.app_data.borrow();
if app_data.gui_opts.notify_cfg_reload_silent {
flags |= f_tray::SILENT;
}
}
self.tray.show(
&msg_content,
Some(&msg_title),
Expand All @@ -895,6 +905,12 @@ impl SystemTray {
} else {
msg_title += &("🔄 \"".to_owned() + cfg_name + "\" NOT reloaded");
flags |= f_tray::ERROR_ICON | f_tray::LARGE_ICON;
{
let app_data = self.app_data.borrow();
if app_data.gui_opts.notify_cfg_reload_silent {
flags |= f_tray::SILENT;
}
}
self.tray.show(
&msg_content,
Some(&msg_title),
Expand Down Expand Up @@ -943,6 +959,12 @@ impl SystemTray {
flags |= f_tray::ERROR_ICON;
};
flags |= f_tray::LARGE_ICON; // todo: fails without this, must have SM_CXICON x SM_CYICON?
{
let app_data = self.app_data.borrow();
if app_data.gui_opts.notify_cfg_reload_silent {
flags |= f_tray::SILENT;
}
}
self.tray.show(
&msg_content,
Some(&msg_title),
Expand Down Expand Up @@ -1125,8 +1147,22 @@ impl SystemTray {
*icon_act_key = Some(cfg_layer_pkey);
self.show_tooltip(None);
}
} else if let Some(layer_icon) = layer_icon {
// 1b cfg+layer path hasn't been checked, but layer has an icon configured, so check it
} else if layer_icon.is_some() || app_data.gui_opts.icon_match_layer_name {
let layer_icon = match layer_icon {
Some(layer_icon_inner) => {
trace!("configured layer icon = {}", layer_icon_inner);
layer_icon_inner
}
None => {
trace!(
"no configured layer icon, checking its name = {}",
layer_name
);
layer_name
}
};
// 1b cfg+layer path hasn't been checked, but layer has an icon configured...
// or configured to check its name, so check it
if let Some(ico_p) = get_icon_p(
layer_icon,
layer_name,
Expand Down

0 comments on commit bb925fb

Please sign in to comment.