Adjust shortcut text style

This commit is contained in:
Jeremy Soller 2025-06-27 11:40:59 -06:00
parent 643c7b45ae
commit 9758fe034e
No known key found for this signature in database
GPG key ID: 670FDFB5428E05CA
2 changed files with 136 additions and 124 deletions

View file

@ -1,11 +1,12 @@
// SPDX-License-Identifier: GPL-3.0-only
use cosmic::widget::menu::key_bind::KeyBind;
use cosmic::widget::menu::{items as menu_items, root as menu_root, Item as MenuItem};
use cosmic::widget::menu::Item as MenuItem;
use cosmic::{
app::Core,
iced::{widget::column, Background, Length},
iced::{advanced::widget::text::Style as TextStyle, widget::column, Background, Length},
iced_core::Border,
theme,
widget::{
self, divider, horizontal_space,
menu::{menu_button, ItemHeight, ItemWidth, MenuBar, Tree as MenuTree},
@ -24,6 +25,14 @@ pub fn context_menu<'a>(
key_binds: &HashMap<KeyBind, Action>,
entity: segmented_button::Entity,
) -> Element<'a, Message> {
fn key_style(theme: &cosmic::Theme) -> TextStyle {
let mut color = theme.cosmic().background.component.on;
color.alpha *= 0.75;
TextStyle {
color: Some(color.into()),
}
}
let menu_item = |menu_label, menu_action| {
let mut key = String::new();
for (key_bind, key_action) in key_binds.iter() {
@ -35,7 +44,9 @@ pub fn context_menu<'a>(
menu_button(vec![
widget::text(menu_label).into(),
horizontal_space().into(),
widget::text(key).into(),
widget::text(key)
.class(theme::Text::Custom(key_style))
.into(),
])
.on_press(Message::TabContextAction(entity, menu_action))
};