fix: preserve content when rebuilding appearance drawer
This commit is contained in:
parent
99cf076229
commit
ab5dd5f43a
3 changed files with 18 additions and 1 deletions
|
|
@ -153,6 +153,16 @@ impl Content {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn preserve_from(&mut self, previous: &mut Content) {
|
||||||
|
self.font_config
|
||||||
|
.take_families_from(&mut previous.font_config);
|
||||||
|
|
||||||
|
self.icons_fetched = previous.icons_fetched;
|
||||||
|
self.icon_theme_active = previous.icon_theme_active;
|
||||||
|
self.icon_themes = std::mem::take(&mut previous.icon_themes);
|
||||||
|
self.icon_handles = std::mem::take(&mut previous.icon_handles);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn update_font(
|
pub fn update_font(
|
||||||
&mut self,
|
&mut self,
|
||||||
message: FontMessage,
|
message: FontMessage,
|
||||||
|
|
|
||||||
|
|
@ -94,6 +94,11 @@ impl Model {
|
||||||
self.font_filter.clear();
|
self.font_filter.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn take_families_from(&mut self, other: &mut Model) {
|
||||||
|
self.interface_font_families = std::mem::take(&mut other.interface_font_families);
|
||||||
|
self.monospace_font_families = std::mem::take(&mut other.monospace_font_families);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn font_loaded(
|
pub fn font_loaded(
|
||||||
&mut self,
|
&mut self,
|
||||||
mono: Vec<Arc<str>>,
|
mono: Vec<Arc<str>>,
|
||||||
|
|
|
||||||
|
|
@ -200,7 +200,9 @@ impl Page {
|
||||||
|
|
||||||
Message::DrawerOpen(context_view) => {
|
Message::DrawerOpen(context_view) => {
|
||||||
self.context_view = Some(context_view);
|
self.context_view = Some(context_view);
|
||||||
self.drawer = drawer::Content::from(&self.theme_manager);
|
let mut previous =
|
||||||
|
std::mem::replace(&mut self.drawer, drawer::Content::from(&self.theme_manager));
|
||||||
|
self.drawer.preserve_from(&mut previous);
|
||||||
tasks.push(cosmic::task::message(
|
tasks.push(cosmic::task::message(
|
||||||
crate::app::Message::OpenContextDrawer(self.entity),
|
crate::app::Message::OpenContextDrawer(self.entity),
|
||||||
));
|
));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue