diff --git a/Cargo.lock b/Cargo.lock index e176962..4769996 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1077,7 +1077,7 @@ dependencies = [ [[package]] name = "cosmic-config" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "atomicwrites 0.4.2", "cosmic-config-derive", @@ -1096,7 +1096,7 @@ dependencies = [ [[package]] name = "cosmic-config-derive" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "quote", "syn 1.0.109", @@ -1128,7 +1128,7 @@ dependencies = [ [[package]] name = "cosmic-theme" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "almost", "cosmic-config", @@ -2493,7 +2493,7 @@ dependencies = [ [[package]] name = "iced" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "dnd", "iced_accessibility", @@ -2511,7 +2511,7 @@ dependencies = [ [[package]] name = "iced_accessibility" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "accesskit", "accesskit_winit", @@ -2520,7 +2520,7 @@ dependencies = [ [[package]] name = "iced_core" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "bitflags 2.6.0", "bytes", @@ -2543,7 +2543,7 @@ dependencies = [ [[package]] name = "iced_futures" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "futures", "iced_core", @@ -2569,7 +2569,7 @@ dependencies = [ [[package]] name = "iced_graphics" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "bitflags 2.6.0", "bytemuck", @@ -2591,7 +2591,7 @@ dependencies = [ [[package]] name = "iced_renderer" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "iced_graphics", "iced_tiny_skia", @@ -2603,7 +2603,7 @@ dependencies = [ [[package]] name = "iced_runtime" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "bytes", "dnd", @@ -2617,7 +2617,7 @@ dependencies = [ [[package]] name = "iced_tiny_skia" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "bytemuck", "cosmic-text", @@ -2633,7 +2633,7 @@ dependencies = [ [[package]] name = "iced_wgpu" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "as-raw-xcb-connection", "bitflags 2.6.0", @@ -2664,7 +2664,7 @@ dependencies = [ [[package]] name = "iced_widget" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "dnd", "iced_renderer", @@ -2681,7 +2681,7 @@ dependencies = [ [[package]] name = "iced_winit" version = "0.14.0-dev" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "dnd", "iced_futures", @@ -3001,7 +3001,7 @@ checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libcosmic" version = "0.1.0" -source = "git+https://github.com/pop-os/libcosmic.git#a355a049d917823dafcd6669cad6afa6983bc6c6" +source = "git+https://github.com/pop-os/libcosmic.git#62b0c8a401c175ab956229b2901f2fdb8b96aeab" dependencies = [ "apply", "ashpd 0.9.1", diff --git a/res/icons/bundled/cross-small-square-filled-symbolic.svg b/res/icons/bundled/cross-small-square-filled-symbolic.svg new file mode 100644 index 0000000..4f83c5d --- /dev/null +++ b/res/icons/bundled/cross-small-square-filled-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/res/icons/bundled/edit-symbolic.svg b/res/icons/bundled/edit-symbolic.svg new file mode 100644 index 0000000..51090b9 --- /dev/null +++ b/res/icons/bundled/edit-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/res/icons/bundled/face-smile-big-symbolic.svg b/res/icons/bundled/face-smile-big-symbolic.svg new file mode 100644 index 0000000..986286d --- /dev/null +++ b/res/icons/bundled/face-smile-big-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/res/icons/bundled/plus-square-filled-symbolic.svg b/res/icons/bundled/plus-square-filled-symbolic.svg new file mode 100644 index 0000000..c15fccf --- /dev/null +++ b/res/icons/bundled/plus-square-filled-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/res/icons/bundled/settings-symbolic.svg b/res/icons/bundled/settings-symbolic.svg new file mode 100644 index 0000000..408d7e5 --- /dev/null +++ b/res/icons/bundled/settings-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/res/icons/bundled/tabs-stack-symbolic.svg b/res/icons/bundled/tabs-stack-symbolic.svg new file mode 100644 index 0000000..387d854 --- /dev/null +++ b/res/icons/bundled/tabs-stack-symbolic.svg @@ -0,0 +1,2 @@ + + diff --git a/src/app.rs b/src/app.rs index b9f9fa9..7a941a6 100644 --- a/src/app.rs +++ b/src/app.rs @@ -30,7 +30,7 @@ use crate::details::Details; use crate::{content, details, fl, todo}; pub mod config; -pub mod icon_cache; +pub mod icons; mod key_bind; pub mod localize; pub mod markdown; @@ -306,9 +306,21 @@ impl Application for Tasks { Some(cosmic::widget::menu::items( &HashMap::new(), vec![ - cosmic::widget::menu::Item::Button(fl!("rename"), NavMenuAction::Rename(id)), - cosmic::widget::menu::Item::Button(fl!("icon"), NavMenuAction::SetIcon(id)), - cosmic::widget::menu::Item::Button(fl!("delete"), NavMenuAction::Delete(id)), + cosmic::widget::menu::Item::Button( + fl!("rename"), + Some(icons::get_handle("edit-symbolic", 14)), + NavMenuAction::Rename(id), + ), + cosmic::widget::menu::Item::Button( + fl!("icon"), + Some(icons::get_handle("face-smile-big-symbolic", 14)), + NavMenuAction::SetIcon(id), + ), + cosmic::widget::menu::Item::Button( + fl!("delete"), + Some(icons::get_handle("user-trash-full-symbolic", 14)), + NavMenuAction::Delete(id), + ), ], )) } diff --git a/src/app/icon_cache.rs b/src/app/icons.rs similarity index 71% rename from src/app/icon_cache.rs rename to src/app/icons.rs index a46d8b2..e2dfa0d 100644 --- a/src/app/icon_cache.rs +++ b/src/app/icons.rs @@ -34,6 +34,16 @@ impl IconCache { }; } + // Menu icons + bundle!("edit-symbolic", 14); + bundle!("settings-symbolic", 14); + bundle!("tabs-stack-symbolic", 14); + bundle!("info-outline-symbolic", 14); + bundle!("plus-square-filled-symbolic", 14); + bundle!("cross-small-square-filled-symbolic", 14); + bundle!("face-smile-big-symbolic", 14); + bundle!("user-trash-full-symbolic", 14); + bundle!("edit-clear-symbolic", 18); bundle!("folder-open-symbolic", 18); bundle!("go-down-symbolic", 18); @@ -68,18 +78,18 @@ impl IconCache { .clone(); icon::icon(handle).size(size) } +} - pub fn get(name: &'static str, size: u16) -> icon::Icon { - let mut icon_cache = ICON_CACHE.get().unwrap().lock().unwrap(); - icon_cache.get_icon(name, size) - } +pub fn get_icon(name: &'static str, size: u16) -> icon::Icon { + let mut icon_cache = ICON_CACHE.get().unwrap().lock().unwrap(); + icon_cache.get_icon(name, size) +} - pub fn get_handle(name: &'static str, size: u16) -> icon::Handle { - let mut icon_cache = ICON_CACHE.get().unwrap().lock().unwrap(); - icon_cache - .cache - .entry(IconCacheKey { name, size }) - .or_insert_with(|| icon::from_name(name).size(size).handle()) - .clone() - } +pub fn get_handle(name: &'static str, size: u16) -> icon::Handle { + let mut icon_cache = ICON_CACHE.get().unwrap().lock().unwrap(); + icon_cache + .cache + .entry(IconCacheKey { name, size }) + .or_insert_with(|| icon::from_name(name).size(size).handle()) + .clone() } diff --git a/src/app/menu.rs b/src/app/menu.rs index 612604d..c714f7d 100644 --- a/src/app/menu.rs +++ b/src/app/menu.rs @@ -13,6 +13,8 @@ use crate::{ fl, }; +use super::icons; + pub fn menu_bar<'a>(key_binds: &HashMap) -> Element<'a, Message> { MenuBar::new(vec![ Tree::with_children( @@ -20,11 +22,23 @@ pub fn menu_bar<'a>(key_binds: &HashMap) -> Element<'a, Message items( key_binds, vec![ - Item::Button(fl!("new-window"), Action::WindowNew), + Item::Button( + fl!("new-window"), + Some(icons::get_handle("tabs-stack-symbolic", 14)), + Action::WindowNew, + ), Item::Divider, - Item::Button(fl!("new-list"), Action::NewList), + Item::Button( + fl!("new-list"), + Some(icons::get_handle("plus-square-filled-symbolic", 14)), + Action::NewList, + ), Item::Divider, - Item::Button(fl!("quit"), Action::WindowClose), + Item::Button( + fl!("quit"), + Some(icons::get_handle("cross-small-square-filled-symbolic", 14)), + Action::WindowClose, + ), ], ), ), @@ -33,11 +47,23 @@ pub fn menu_bar<'a>(key_binds: &HashMap) -> Element<'a, Message items( key_binds, vec![ - Item::Button(fl!("rename"), Action::RenameList), + Item::Button( + fl!("rename"), + Some(icons::get_handle("edit-symbolic", 14)), + Action::RenameList, + ), Item::Divider, - Item::Button(fl!("icon"), Action::Icon), + Item::Button( + fl!("icon"), + Some(icons::get_handle("face-smile-big-symbolic", 14)), + Action::Icon, + ), Item::Divider, - Item::Button(fl!("delete"), Action::DeleteList), + Item::Button( + fl!("delete"), + Some(icons::get_handle("user-trash-full-symbolic", 14)), + Action::DeleteList, + ), ], ), ), @@ -46,9 +72,17 @@ pub fn menu_bar<'a>(key_binds: &HashMap) -> Element<'a, Message items( key_binds, vec![ - Item::Button(fl!("menu-settings"), Action::Settings), + Item::Button( + fl!("menu-settings"), + Some(icons::get_handle("settings-symbolic", 14)), + Action::Settings, + ), Item::Divider, - Item::Button(fl!("menu-about"), Action::About), + Item::Button( + fl!("menu-about"), + Some(icons::get_handle("info-outline-symbolic", 14)), + Action::About, + ), ], ), ), diff --git a/src/app/settings.rs b/src/app/settings.rs index ab4b04f..57784d4 100644 --- a/src/app/settings.rs +++ b/src/app/settings.rs @@ -1,4 +1,4 @@ -use crate::app::icon_cache::{IconCache, ICON_CACHE}; +use crate::app::icons::{IconCache, ICON_CACHE}; use crate::app::Flags; use cosmic::app::Settings; use cosmic::iced::{Limits, Size}; diff --git a/src/content.rs b/src/content.rs index 5dbf733..85c455c 100644 --- a/src/content.rs +++ b/src/content.rs @@ -1,4 +1,4 @@ -use crate::app::icon_cache::IconCache; +use crate::app::icons; use crate::core::models::{self, List, Status}; use cosmic::iced::alignment::{Horizontal, Vertical}; use cosmic::iced::{Alignment, Length, Subscription}; @@ -55,7 +55,7 @@ impl Content { fn list_header<'a>(&'a self, list: &'a List) -> Element<'a, Message> { let spacing = theme::active().cosmic().spacing; - let export_button = widget::button::icon(IconCache::get_handle("share-symbolic", 18)) + let export_button = widget::button::icon(icons::get_handle("share-symbolic", 18)) .class(cosmic::style::Button::Suggested) .padding(spacing.space_xxs) .on_press(Message::Export(self.tasks.values().cloned().collect())); @@ -89,13 +89,13 @@ impl Content { .on_toggle(move |value| Message::Complete(id, value)); let delete_button = - widget::button::icon(IconCache::get_handle("user-trash-full-symbolic", 18)) + widget::button::icon(icons::get_handle("user-trash-full-symbolic", 18)) .padding(spacing.space_xxs) .class(cosmic::style::Button::Destructive) .on_press(Message::Delete(id)); let details_button = - widget::button::icon(IconCache::get_handle("info-outline-symbolic", 18)) + widget::button::icon(icons::get_handle("info-outline-symbolic", 18)) .padding(spacing.space_xxs) .class(cosmic::style::Button::Standard) .on_press(Message::Select(item.clone())); @@ -138,7 +138,7 @@ impl Content { let container = widget::container( widget::column::with_children(vec![ - IconCache::get("task-past-due-symbolic", 56).into(), + icons::get_icon("task-past-due-symbolic", 56).into(), widget::text::title1(fl!("no-tasks")).into(), widget::text(fl!("no-tasks-suggestion")).into(), ]) @@ -165,7 +165,7 @@ impl Content { .on_submit(Message::AddTask) .width(Length::Fill) .into(), - widget::button::icon(IconCache::get_handle("mail-send-symbolic", 18)) + widget::button::icon(icons::get_handle("mail-send-symbolic", 18)) .padding(spacing.space_xxs) .class(cosmic::style::Button::Suggested) .on_press(Message::AddTask) @@ -276,7 +276,7 @@ impl Content { let Some(ref list) = self.list else { return widget::container( widget::column::with_children(vec![ - IconCache::get("applications-office-symbolic", 56).into(), + icons::get_icon("applications-office-symbolic", 56).into(), widget::text::title1(fl!("no-list-selected")).into(), widget::text(fl!("no-list-suggestion")).into(), ]) diff --git a/src/details.rs b/src/details.rs index d5c436d..da9d8d1 100644 --- a/src/details.rs +++ b/src/details.rs @@ -1,4 +1,4 @@ -use crate::app::icon_cache::IconCache; +use crate::app::icons; use crate::core::models::{self, Priority, Status}; use chrono::{NaiveDate, TimeZone, Utc}; use cosmic::iced::{Alignment, Length}; @@ -48,17 +48,17 @@ impl Details { let priority_model = segmented_button::ModelBuilder::default() .insert(|entity| { entity - .icon(IconCache::get("flag-outline-thin-symbolic", 16)) + .icon(icons::get_icon("flag-outline-thin-symbolic", 16)) .data(Priority::Low) }) .insert(|entity| { entity - .icon(IconCache::get("flag-outline-thick-symbolic", 16)) + .icon(icons::get_icon("flag-outline-thick-symbolic", 16)) .data(Priority::Normal) }) .insert(|entity| { entity - .icon(IconCache::get("flag-filled-symbolic", 16)) + .icon(icons::get_icon("flag-filled-symbolic", 16)) .data(Priority::High) }) .build(); @@ -187,7 +187,7 @@ impl Details { .on_submit(Message::SubTaskEditDone); let delete_button = - widget::button::icon(IconCache::get_handle("user-trash-full-symbolic", 18)) + widget::button::icon(icons::get_handle("user-trash-full-symbolic", 18)) .padding(spacing.space_xxs) .on_press(Message::DeleteSubTask(id)); @@ -288,7 +288,7 @@ impl Details { .on_submit(Message::AddTask) .width(Length::Fill) .into(), - widget::button::icon(IconCache::get_handle("mail-send-symbolic", 18)) + widget::button::icon(icons::get_handle("mail-send-symbolic", 18)) .padding(spacing.space_xxs) .on_press(Message::AddTask) .into(),