Merge PR #1194: fix(ui): ribbon tooltips show each platform's shortcuts (Ctrl+B on Windows, ⌘B on macOS) (#1191)

crates/ui-egui/src/widgets.rs: both test modules kept.
This commit is contained in:
aiongg
2026-10-22 02:37:51 +00:00
12 changed files with 118 additions and 98 deletions
+4 -6
View File
@@ -194,12 +194,11 @@ const JAPANESE: &[(&str, &str)] = &[
("Insert Copied Cells…", "コピーしたセルの挿入…"),
("Insert Cut Cells", "切り取ったセルの挿入"),
("Insert Paste", "挿入貼り付け"),
("Cut (⌘X)", "切り取り (⌘X)"),
("Copy (⌘C)", "コピー (⌘C)"),
("Cut", "切り取り"),
("Copy", "コピー"),
("Format Painter (double-click to keep it on)", "書式のコピー/貼り付け (ダブルクリックで固定)"),
("Bold (⌘B)", "太字 (⌘B)"),
("Italic (⌘I)", "斜体 (⌘I)"),
("Underline (⌘U)", "下線 (⌘U)"),
("Bold", "太字"),
("Italic", "斜体"),
("Double Underline", "二重下線"),
("Strikethrough", "取り消し線"),
("Underline", "下線"),
@@ -268,7 +267,6 @@ const JAPANESE: &[(&str, &str)] = &[
("Clear Comments and Notes", "コメントとメモのクリア"),
("Clear Hyperlinks", "ハイパーリンクのクリア"),
("AutoSum", "オート SUM"),
("AutoSum (⌘⇧T)", "オート SUM (⌘⇧T)"),
("Flash\nFill", "フラッシュ フィル"),
("Flash Fill", "フラッシュ フィル"),
("Fill", "フィル"),
+6 -15
View File
@@ -9,12 +9,9 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Transpose" => "Transponovat",
"Paste Link" => "Vložit propojení",
"Paste Special…" => "Vložit jinak…",
"Cut (⌘X)" => "Vyjmout (⌘X)",
"Copy (⌘C)" => "Kopírovat (⌘C)",
"Format Painter (double-click to keep it on)" => "Štětec formátu (dvojklikem zůstane zapnutý)",
"Bold (⌘B)" => "Tučné (⌘B)",
"Italic (⌘I)" => "Kurzíva (⌘I)",
"Underline (⌘U)" => "Podtržení (⌘U)",
"Bold" => "Tučné",
"Italic" => "Kurzíva",
"Double Underline" => "Dvojité podtržení",
"Strikethrough" => "Přeškrtnutí",
"Underline" => "Podtržení",
@@ -83,7 +80,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Clear Comments and Notes" => "Vymazat komentáře a poznámky",
"Clear Hyperlinks" => "Vymazat hypertextové odkazy",
"AutoSum" => "Automatický\nsoučet",
"AutoSum (⌘⇧T)" => "Automatický součet (⌘⇧T)",
"Flash\nFill" => "Dynamické\ndoplňování",
"Flash Fill" => "Dynamické doplňování",
"Fill" => "Vyplnit",
@@ -451,9 +447,7 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Edit chart title" => "Upravit název grafu",
"Erase ink strokes" => "Vymazat tahy rukopisu",
"Every command run in this session (replayable)" => "Všechny příkazy spuštěné v této relaci (lze znovu přehrát)",
"Filter (⌘⇧F)" => "Filtr (⌘⇧F)",
"Find & Select" => "Najít a vybrat",
"Flash Fill (⌘E)" => "Dynamické doplňování (⌘E)",
"Forecast Sheet" => "List prognózy",
"Format Chart pane" => "Podokno formátu grafu",
"Format as Table" => "Formátovat jako tabulku",
@@ -464,7 +458,7 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Import a text or CSV file" => "Importovat textový soubor nebo CSV",
"Insert\nSlicer" => "Vložit\nprůřez",
"Insert Function (⇧F3)" => "Vložit funkci (⇧F3)",
"Insert Link (⌘K)" => "Vložit odkaz (⌘K)",
"Insert Link" => "Vložit odkaz",
"Insert Sheet" => "Vložit list",
"Insert Slicer" => "Vložit průřez",
"Insert a picture" => "Vložit obrázek",
@@ -479,7 +473,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Name Manager" => "Správce názvů",
"Page Breaks" => "Konce stránek",
"Paper Size" => "Velikost papíru",
"Paste (⌘V)" => "Vložit (⌘V)",
"Pen\nBlack" => "Pero\nčerné",
"Pen\nBlue" => "Pero\nmodré",
"Pen\nRed" => "Pero\nčervené",
@@ -490,13 +483,12 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Protect Sheet" => "Zamknout list",
"Protect Workbook structure" => "Zamknout strukturu sešitu",
"Recommended Charts" => "Doporučené grafy",
"Redo (⌘Y)" => "Znovu (⌘Y)",
"Redo" => "Znovu",
"Remove Duplicates" => "Odebrat duplicity",
"Rename Sheet" => "Přejmenovat list",
"Save (⌘S)" => "Uložit (⌘S)",
"Scatter or Bubble" => "Bodový nebo bublinový graf",
"Search and run any command" => "Vyhledat a spustit libovolný příkaz",
"Search commands (⌘⇧Space)" => "Vyhledat příkazy (⌘⇧Space)",
"Search commands" => "Vyhledat příkazy",
"Select Data" => "Vybrat data",
"Select and move ink and shapes" => "Vybrat a přesunout rukopis a obrazce",
"Series…" => "Řady…",
@@ -507,12 +499,11 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Spelling (F7)" => "Pravopis (F7)",
"Statistic" => "Statistické grafy",
"Switch Row/Column" => "Prohodit řádky/sloupce",
"Table (⌘T)" => "Tabulka (⌘T)",
"Table Styles" => "Styly tabulky",
"Text Box" => "Textové pole",
"Text to Columns" => "Text do sloupců",
"Top Align" => "Zarovnat nahoru",
"Undo (⌘Z)" => "Zpět (⌘Z)",
"Undo" => "Zpět",
"Undo list" => "Seznam akcí k vrácení",
"Unhide Sheet…" => "Zobrazit list…",
"Up" => "Nahoru",
+4 -6
View File
@@ -10,12 +10,11 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Transpose" => "Transponieren",
"Paste Link" => "Verknüpfung einfügen",
"Paste Special…" => "Inhalte einfügen…",
"Cut (⌘X)" => "Ausschneiden (⌘X)",
"Copy (⌘C)" => "Kopieren (⌘C)",
"Cut" => "Ausschneiden",
"Copy" => "Kopieren",
"Format Painter (double-click to keep it on)" => "Format übertragen (Doppelklick zum Beibehalten)",
"Bold (⌘B)" => "Fett (⌘B)",
"Italic (⌘I)" => "Kursiv (⌘I)",
"Underline (⌘U)" => "Unterstrichen (⌘U)",
"Bold" => "Fett",
"Italic" => "Kursiv",
"Double Underline" => "Doppelt unterstrichen",
"Strikethrough" => "Durchgestrichen",
"Underline" => "Unterstrichen",
@@ -83,7 +82,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Clear Comments and Notes" => "Kommentare und Notizen löschen",
"Clear Hyperlinks" => "Hyperlinks löschen",
"AutoSum" => "AutoSumme",
"AutoSum (⌘⇧T)" => "AutoSumme (⌘⇧T)",
"Flash\nFill" => "Blitz-\nvorschau",
"Flash Fill" => "Blitzvorschau",
"Fill" => "Ausfüllen",
+4 -6
View File
@@ -11,12 +11,11 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Transpose" => "Transponer",
"Paste Link" => "Pegar vínculo",
"Paste Special…" => "Pegado especial…",
"Cut (⌘X)" => "Cortar (⌘X)",
"Copy (⌘C)" => "Copiar (⌘C)",
"Cut" => "Cortar",
"Copy" => "Copiar",
"Format Painter (double-click to keep it on)" => "Copiar formato (doble clic para mantenerlo activo)",
"Bold (⌘B)" => "Negrita (⌘B)",
"Italic (⌘I)" => "Cursiva (⌘I)",
"Underline (⌘U)" => "Subrayado (⌘U)",
"Bold" => "Negrita",
"Italic" => "Cursiva",
"Double Underline" => "Subrayado doble",
"Strikethrough" => "Tachado",
"Underline" => "Subrayado",
@@ -84,7 +83,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Clear Comments and Notes" => "Borrar comentarios y notas",
"Clear Hyperlinks" => "Borrar hipervínculos",
"AutoSum" => "Autosuma",
"AutoSum (⌘⇧T)" => "Autosuma (⌘⇧T)",
"Flash\nFill" => "Relleno\nrápido",
"Flash Fill" => "Relleno rápido",
"Fill" => "Rellenar",
+4 -6
View File
@@ -15,12 +15,11 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Insert Copied Cells…" => "Insérer les cellules copiées…",
"Insert Cut Cells" => "Insérer les cellules coupées",
"Insert Paste" => "Insérer en collant",
"Cut (⌘X)" => "Couper (⌘X)",
"Copy (⌘C)" => "Copier (⌘C)",
"Cut" => "Couper",
"Copy" => "Copier",
"Format Painter (double-click to keep it on)" => "Reproduire la mise en forme (double-clic pour la conserver)",
"Bold (⌘B)" => "Gras (⌘B)",
"Italic (⌘I)" => "Italique (⌘I)",
"Underline (⌘U)" => "Souligné (⌘U)",
"Bold" => "Gras",
"Italic" => "Italique",
"Double Underline" => "Double soulignement",
"Strikethrough" => "Barré",
"Underline" => "Souligné",
@@ -89,7 +88,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Clear Comments and Notes" => "Effacer les commentaires et les notes",
"Clear Hyperlinks" => "Effacer les liens hypertexte",
"AutoSum" => "Somme automatique",
"AutoSum (⌘⇧T)" => "Somme automatique (⌘⇧T)",
"Flash\nFill" => "Remplissage\ninstantané",
"Flash Fill" => "Remplissage instantané",
"Fill" => "Remplir",
+4 -6
View File
@@ -13,12 +13,11 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Insert Copied Cells…" => "복사한 셀 삽입…",
"Insert Cut Cells" => "잘라낸 셀 삽입",
"Insert Paste" => "삽입 붙여넣기",
"Cut (⌘X)" => "잘라내기 (⌘X)",
"Copy (⌘C)" => "복사 (⌘C)",
"Cut" => "잘라내기",
"Copy" => "복사",
"Format Painter (double-click to keep it on)" => "서식 복사 (두 번 클릭하여 유지)",
"Bold (⌘B)" => "굵게 (⌘B)",
"Italic (⌘I)" => "기울임꼴 (⌘I)",
"Underline (⌘U)" => "밑줄 (⌘U)",
"Bold" => "굵게",
"Italic" => "기울임꼴",
"Double Underline" => "이중 밑줄",
"Strikethrough" => "취소선",
"Underline" => "밑줄",
@@ -86,7 +85,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Clear Comments and Notes" => "댓글 및 메모 지우기",
"Clear Hyperlinks" => "하이퍼링크 지우기",
"AutoSum" => "자동 합계",
"AutoSum (⌘⇧T)" => "자동 합계 (⌘⇧T)",
"Flash\nFill" => "빠른\n채우기",
"Flash Fill" => "빠른 채우기",
"Fill" => "채우기",
+4 -15
View File
@@ -14,12 +14,7 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Insert Copied Cells…" => "Inserir Células Copiadas…",
"Insert Cut Cells" => "Inserir Células Recortadas",
"Insert Paste" => "Inserir Colagem",
"Cut (⌘X)" => "Recortar (⌘X)",
"Copy (⌘C)" => "Copiar (⌘C)",
"Format Painter (double-click to keep it on)" => "Pincel de Formatação (clique duas vezes para mantê-lo ativo)",
"Bold (⌘B)" => "Negrito (⌘B)",
"Italic (⌘I)" => "Itálico (⌘I)",
"Underline (⌘U)" => "Sublinhado (⌘U)",
"Double Underline" => "Sublinhado Duplo",
"Strikethrough" => "Riscado",
"Underline" => "Sublinhado",
@@ -87,7 +82,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Clear Comments and Notes" => "Limpar Comentários e Notas",
"Clear Hyperlinks" => "Limpar Hiperlinks",
"AutoSum" => "Soma Automática",
"AutoSum (⌘⇧T)" => "Soma Automática (⌘⇧T)",
"Flash\nFill" => "Preenchimento\nRelâmpago",
"Flash Fill" => "Preenchimento Relâmpago",
"Fill" => "Preencher",
@@ -874,10 +868,8 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Erase ink strokes" => "Apagar traços de tinta",
"Every command run in this session (replayable)" => "Todos os comandos executados nesta sessão (podem ser repetidos)",
"Expand formula bar" => "Expandir barra de fórmulas",
"Filter (⌘⇧F)" => "Filtro (⌘⇧F)",
"Filter by Selected Cell's Value" => "Filtrar pelo Valor da Célula Selecionada",
"Find & Select" => "Localizar e Selecionar",
"Flash Fill (⌘E)" => "Preenchimento Relâmpago (⌘E)",
"Forecast Sheet" => "Planilha de Previsão",
"Forecast end (date or number; blank: a third of the history):" => "Fim da previsão (data ou número; em branco: um terço do histórico):",
"Format Chart pane" => "Painel Formatar Gráfico",
@@ -890,7 +882,7 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Import a text or CSV file" => "Importar um arquivo de texto ou CSV",
"Insert Function" => "Inserir Função",
"Insert Function (⇧F3)" => "Inserir Função (⇧F3)",
"Insert Link (⌘K)" => "Inserir Link (⌘K)",
"Insert Link" => "Inserir Link",
"Insert Sheet" => "Inserir Planilha",
"Insert Slicer" => "Inserir Segmentação de Dados",
"Insert a picture" => "Inserir uma imagem",
@@ -907,18 +899,16 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Next sheet" => "Próxima planilha",
"Page Breaks" => "Quebras",
"Paper Size" => "Tamanho",
"Paste (⌘V)" => "Colar (⌘V)",
"Pick From Drop-down List…" => "Escolher na Lista Suspensa…",
"Pie or Doughnut" => "Pizza ou Rosca",
"Previous sheet" => "Planilha anterior",
"Print Area" => "Área de Impressão",
"Print Titles" => "Imprimir Títulos",
"Protect Workbook structure" => "Proteger estrutura da pasta de trabalho",
"Redo (⌘Y)" => "Refazer (⌘Y)",
"Save (⌘S)" => "Salvar (⌘S)",
"Redo" => "Refazer",
"Scatter or Bubble" => "Dispersão ou Bolhas",
"Search and run any command" => "Pesquisar e executar qualquer comando",
"Search commands (⌘⇧Space)" => "Pesquisar comandos (⌘⇧Space)",
"Search commands" => "Pesquisar comandos",
"Select and move ink and shapes" => "Selecionar e mover tinta e formas",
"Series…" => "Série…",
"Share: export or save a copy" => "Compartilhar: exportar ou salvar uma cópia",
@@ -928,12 +918,11 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Spelling (F7)" => "Ortografia (F7)",
"Statistic" => "Estatístico",
"Switch Row/Column" => "Alternar Linha/Coluna",
"Table (⌘T)" => "Tabela (⌘T)",
"Table Styles" => "Estilos de Tabela",
"Text to Columns" => "Texto para Colunas",
"The output range already holds data. Replace it with the report?" => "O intervalo de saída já contém dados. Substituí-los pelo relatório?",
"Top Align" => "Alinhar em Cima",
"Undo (⌘Z)" => "Desfazer (⌘Z)",
"Undo" => "Desfazer",
"Undo list" => "Lista de desfazer",
"Unhide Sheet…" => "Reexibir Planilha…",
"Up" => "Para Cima",
+4 -6
View File
@@ -13,12 +13,11 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Insert Copied Cells…" => "Вставить скопированные ячейки…",
"Insert Cut Cells" => "Вставить вырезанные ячейки",
"Insert Paste" => "Вставка со сдвигом",
"Cut (⌘X)" => "Вырезать (⌘X)",
"Copy (⌘C)" => "Копировать (⌘C)",
"Cut" => "Вырезать",
"Copy" => "Копировать",
"Format Painter (double-click to keep it on)" => "Формат по образцу (дважды щёлкните, чтобы закрепить)",
"Bold (⌘B)" => "Полужирный (⌘B)",
"Italic (⌘I)" => "Курсив (⌘I)",
"Underline (⌘U)" => "Подчёркивание (⌘U)",
"Bold" => "Полужирный",
"Italic" => "Курсив",
"Double Underline" => "Двойное подчёркивание",
"Strikethrough" => "Зачёркивание",
"Underline" => "Подчёркивание",
@@ -86,7 +85,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Clear Comments and Notes" => "Удалить комментарии и заметки",
"Clear Hyperlinks" => "Удалить гиперссылки",
"AutoSum" => "Автосумма",
"AutoSum (⌘⇧T)" => "Автосумма (⌘⇧T)",
"Flash\nFill" => "Мгновенное\nзаполнение",
"Flash Fill" => "Мгновенное заполнение",
"Fill" => "Заполнить",
+4 -6
View File
@@ -13,12 +13,11 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Insert Copied Cells…" => "Umetni kopirane ćelije…",
"Insert Cut Cells" => "Umetni isečene ćelije",
"Insert Paste" => "Umetni lepljenje",
"Cut (⌘X)" => "Iseci (⌘X)",
"Copy (⌘C)" => "Kopiraj (⌘C)",
"Cut" => "Iseci",
"Copy" => "Kopiraj",
"Format Painter (double-click to keep it on)" => "Kopiraj oblikovanje (dupli klik da ostane uključeno)",
"Bold (⌘B)" => "Podebljano (⌘B)",
"Italic (⌘I)" => "Kurziv (⌘I)",
"Underline (⌘U)" => "Podvučeno (⌘U)",
"Bold" => "Podebljano",
"Italic" => "Kurziv",
"Double Underline" => "Dvostruko podvlačenje",
"Strikethrough" => "Precrtano",
"Underline" => "Podvučeno",
@@ -87,7 +86,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Clear Comments and Notes" => "Obriši komentare i beleške",
"Clear Hyperlinks" => "Obriši hiperveze",
"AutoSum" => "Automatski zbir",
"AutoSum (⌘⇧T)" => "Automatski zbir (⌘⇧T)",
"Flash\nFill" => "Brzo\npopunjavanje",
"Flash Fill" => "Brzo popunjavanje",
"Fill" => "Popuni",
+4 -6
View File
@@ -13,12 +13,11 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Insert Copied Cells…" => "插入复制的单元格…",
"Insert Cut Cells" => "插入剪切的单元格",
"Insert Paste" => "插入粘贴",
"Cut (⌘X)" => "剪切 (⌘X)",
"Copy (⌘C)" => "复制 (⌘C)",
"Cut" => "剪切",
"Copy" => "复制",
"Format Painter (double-click to keep it on)" => "格式刷(双击可持续使用)",
"Bold (⌘B)" => "粗体 (⌘B)",
"Italic (⌘I)" => "斜体 (⌘I)",
"Underline (⌘U)" => "下划线 (⌘U)",
"Bold" => "粗体",
"Italic" => "斜体",
"Double Underline" => "双下划线",
"Strikethrough" => "删除线",
"Underline" => "下划线",
@@ -86,7 +85,6 @@ pub(super) fn translate(text: &str) -> Option<&'static str> {
"Clear Comments and Notes" => "清除批注和备注",
"Clear Hyperlinks" => "清除超链接",
"AutoSum" => "自动求和",
"AutoSum (⌘⇧T)" => "自动求和 (⌘⇧T)",
"Flash\nFill" => "快速\n填充",
"Flash Fill" => "快速填充",
"Fill" => "填充",
+15 -15
View File
@@ -68,7 +68,7 @@ pub fn title_bar(app: &mut SheetApp, ui: &mut Ui) {
if __k.clicked() {
app.open_dialog("start", json!({}));
}
if icon_button(ui, Icon::Save, t.text_dim, "Save (⌘S)", vec2(26.0, ch)).clicked()
if icon_button(ui, Icon::Save, t.text_dim, "Save", vec2(26.0, ch)).clicked()
// File operations must include the cell the user is still editing (as the File > Save menu item already does).
&& app.commit_edit(0, 0, false, false)
{
@@ -76,7 +76,7 @@ pub fn title_bar(app: &mut SheetApp, ui: &mut Ui) {
}
let can_undo = app.session.active().is_some_and(|d| !d.undo.is_empty());
let can_redo = app.session.active().is_some_and(|d| !d.redo.is_empty());
if icon_button(ui, Icon::Undo, if can_undo { t.text_dim } else { t.text_disabled }, "Undo (⌘Z)", vec2(26.0, ch)).clicked() && can_undo {
if icon_button(ui, Icon::Undo, if can_undo { t.text_dim } else { t.text_disabled }, "Undo", vec2(26.0, ch)).clicked() && can_undo {
app.run_or_alert("edit.undo", json!({}));
}
let undo_list = icon_button(ui, Icon::Chevron, t.text_dim, "Undo list", vec2(14.0, ch));
@@ -92,7 +92,7 @@ pub fn title_bar(app: &mut SheetApp, ui: &mut Ui) {
}
}
});
if icon_button(ui, Icon::Redo, if can_redo { t.text_dim } else { t.text_disabled }, "Redo (⌘Y)", vec2(26.0, ch)).clicked() && can_redo {
if icon_button(ui, Icon::Redo, if can_redo { t.text_dim } else { t.text_disabled }, "Redo", vec2(26.0, ch)).clicked() && can_redo {
app.run_or_alert("edit.redo", json!({}));
}
let more = icon_button(ui, Icon::More, t.text_dim, "More commands", vec2(26.0, ch));
@@ -124,7 +124,7 @@ pub fn title_bar(app: &mut SheetApp, ui: &mut Ui) {
);
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
ui.add_space(8.0);
let __k = icon_button(ui, Icon::Search, t.text_dim, "Search commands (⌘⇧Space)", vec2(28.0, ch));
let __k = icon_button(ui, Icon::Search, t.text_dim, "Search commands", vec2(28.0, ch));
control_keytip(app, ui, &__k, "commandSearch");
if __k.clicked() {
app.open_dialog("commandSearch", json!({}));
@@ -512,7 +512,7 @@ fn home(app: &mut SheetApp, ui: &mut Ui) {
let t = Tokens::get(ui.ctx());
let st = active_style(app);
// Clipboard
let paste = big_button(ui, Icon::Paste, "Paste", "Paste (⌘V)", true);
let paste = big_button(ui, Icon::Paste, "Paste", "Paste", true);
paste.widget_info(|| egui::WidgetInfo::labeled(egui::WidgetType::Button, ui.is_enabled(), "Paste"));
for sequence in
keytip_table::group_extension(app.keytips.prefix().unwrap_or_default(), &["edit.paste", "edit.pasteSpecial", "dialog:pasteSpecial"])
@@ -564,12 +564,12 @@ fn home(app: &mut SheetApp, ui: &mut Ui) {
);
});
ui.vertical(|ui| {
let __k = icon_button(ui, Icon::Cut, t.text, "Cut (⌘X)", vec2(26.0, 23.0));
let __k = icon_button(ui, Icon::Cut, t.text, "Cut", vec2(26.0, 23.0));
control_keytip(app, ui, &__k, "edit.cut");
if __k.clicked() {
app.copy_to_clipboard(ui.ctx(), "edit.cut");
}
let __k = icon_button(ui, Icon::Copy, t.text, "Copy (⌘C)", vec2(26.0, 23.0));
let __k = icon_button(ui, Icon::Copy, t.text, "Copy", vec2(26.0, 23.0));
control_keytip(app, ui, &__k, "edit.copy");
if __k.clicked() {
app.copy_to_clipboard(ui.ctx(), "edit.copy");
@@ -605,17 +605,17 @@ fn home(app: &mut SheetApp, ui: &mut Ui) {
}
});
ui.horizontal(|ui| {
let __k = toggle_button(ui, Icon::Bold, st.font.bold, "Bold (⌘B)");
let __k = toggle_button(ui, Icon::Bold, st.font.bold, "Bold");
control_keytip(app, ui, &__k, "home.bold");
if __k.clicked() {
act(app, "home.bold", json!({}));
}
let __k = toggle_button(ui, Icon::Italic, st.font.italic, "Italic (⌘I)");
let __k = toggle_button(ui, Icon::Italic, st.font.italic, "Italic");
control_keytip(app, ui, &__k, "home.italic");
if __k.clicked() {
act(app, "home.italic", json!({}));
}
let (u, ua) = split_button(ui, Icon::Underline, None, "Underline (⌘U)");
let (u, ua) = split_button(ui, Icon::Underline, None, "Underline");
control_keytip(app, ui, &ua, "home.underline");
if u {
act(app, "home.underline", json!({}));
@@ -966,7 +966,7 @@ fn home(app: &mut SheetApp, ui: &mut Ui) {
// Editing
ui.vertical(|ui| {
ui.horizontal(|ui| {
let (s, sa) = split_button(ui, Icon::Sum, None, "AutoSum (⌘⇧T)");
let (s, sa) = split_button(ui, Icon::Sum, None, "AutoSum");
control_keytip(app, ui, &sa, "formulas.autoSum");
if s {
act(app, "formulas.autoSum", json!({}));
@@ -1388,7 +1388,7 @@ fn insert(app: &mut SheetApp, ui: &mut Ui) {
if __k.clicked() {
act(app, "insert.pivotTable", json!({}));
}
let __k = big_button(ui, Icon::Table, "Table", "Table (⌘T)", false);
let __k = big_button(ui, Icon::Table, "Table", "Table", false);
control_keytip(app, ui, &__k, "insert.table");
if __k.clicked() {
act(app, "insert.table", json!({}));
@@ -1553,7 +1553,7 @@ fn insert(app: &mut SheetApp, ui: &mut Ui) {
act(app, "insert.checkbox", json!({}));
}
sep(ui);
let __k = big_button(ui, Icon::Link, "Link", "Insert Link (⌘K)", false);
let __k = big_button(ui, Icon::Link, "Link", "Insert Link", false);
control_keytip(app, ui, &__k, "dialog:insertLink");
if __k.clicked() {
app.open_dialog("insertLink", json!({}));
@@ -1922,7 +1922,7 @@ fn data(app: &mut SheetApp, ui: &mut Ui) {
if __k.clicked() {
app.open_dialog("sort", json!({}));
}
let __k = big_button(ui, Icon::Filter, "Filter", "Filter (⌘⇧F)", false);
let __k = big_button(ui, Icon::Filter, "Filter", "Filter", false);
control_keytip(app, ui, &__k, "data.filter");
if __k.clicked() {
act(app, "data.filter", json!({}));
@@ -1945,7 +1945,7 @@ fn data(app: &mut SheetApp, ui: &mut Ui) {
if __k.clicked() {
app.open_dialog("textToColumns", json!({}));
}
let __k = big_button(ui, Icon::FillDown, "Flash\nFill", "Flash Fill (⌘E)", false);
let __k = big_button(ui, Icon::FillDown, "Flash\nFill", "Flash Fill", false);
control_keytip(app, ui, &__k, "edit.flashFill");
if __k.clicked() {
act(app, "edit.flashFill", json!({}));
+61 -5
View File
@@ -14,6 +14,41 @@ fn tr<'a>(ui: &Ui, text: &'a str) -> &'a str {
i18n::current(ui.ctx()).tr(text)
}
/// Keyboard shortcuts shown after a ribbon tooltip's command name: Excel for Mac's on macOS,
/// Excel for Windows' elsewhere (each one GridCraft binds). Only the name is translated.
const TOOLTIP_SHORTCUTS: &[(&str, &str, &str)] = &[
("Save", "⌘S", "Ctrl+S"),
("Undo", "⌘Z", "Ctrl+Z"),
("Redo", "⌘Y", "Ctrl+Y"),
("Paste", "⌘V", "Ctrl+V"),
("Cut", "⌘X", "Ctrl+X"),
("Copy", "⌘C", "Ctrl+C"),
("Bold", "⌘B", "Ctrl+B"),
("Italic", "⌘I", "Ctrl+I"),
("Underline", "⌘U", "Ctrl+U"),
("AutoSum", "⌘⇧T", "Alt+="),
("Table", "⌘T", "Ctrl+T"),
("Insert Link", "⌘K", "Ctrl+K"),
("Filter", "⌘⇧F", "Ctrl+Shift+L"),
("Flash Fill", "⌘E", "Ctrl+E"),
];
/// The shortcut a ribbon tooltip shows after `tip`, for this platform (`mac`).
pub fn tooltip_shortcut(tip: &str, mac: bool) -> Option<&'static str> {
TOOLTIP_SHORTCUTS.iter().find(|(name, _, _)| *name == tip).map(|(_, m, other)| if mac { *m } else { *other })
}
/// A ribbon tooltip: the translated command name, then its shortcut for this platform, as Excel
/// shows them ("Bold (Ctrl+B)" on Windows, "Bold (⌘B)" on macOS).
fn tip_text(ui: &Ui, tip: &str) -> String {
// A name shared with a two-line ribbon label (Czech "Automatický\nsoučet") reads as one line.
let name = tr(ui, tip).replace('\n', " ");
match tooltip_shortcut(tip, cfg!(target_os = "macos")) {
Some(keys) => format!("{name} ({keys})"),
None => name.to_string(),
}
}
/// A flat square icon button with hover highlight and tooltip.
pub fn icon_button(ui: &mut Ui, icon: Icon, color: Color32, tip: &str, size: egui::Vec2) -> Response {
let (rect, resp) = ui.allocate_exact_size(size, Sense::click());
@@ -24,7 +59,7 @@ pub fn icon_button(ui: &mut Ui, icon: Icon, color: Color32, tip: &str, size: egu
ui.painter().rect_filled(rect, 4.0, t.hover);
}
icons::paint(ui.painter(), Rect::from_center_size(rect.center(), vec2(16.0, 16.0)), icon, color);
resp.on_hover_text(tr(ui, tip))
resp.on_hover_text(tip_text(ui, tip))
}
/// A toggle-able small button (e.g. Bold) showing a checked state.
@@ -38,7 +73,7 @@ pub fn toggle_button(ui: &mut Ui, icon: Icon, on: bool, tip: &str) -> Response {
ui.painter().rect_filled(rect, 4.0, t.hover);
}
icons::paint(ui.painter(), Rect::from_center_size(rect.center(), vec2(16.0, 16.0)), icon, t.text);
resp.on_hover_text(tr(ui, tip))
resp.on_hover_text(tip_text(ui, tip))
}
/// Large ribbon button: 32px icon over a one- or two-line label.
@@ -73,7 +108,7 @@ pub fn big_button(ui: &mut Ui, icon: Icon, label: &str, tip: &str, dropdown: boo
);
}
}
resp.on_hover_text(tr(ui, tip))
resp.on_hover_text(tip_text(ui, tip))
}
/// Small ribbon button: 16px icon with optional label to the right.
@@ -101,7 +136,7 @@ pub fn small_button(ui: &mut Ui, icon: Icon, label: &str, tip: &str, dropdown: b
t.text_dim,
);
}
resp.on_hover_text(tr(ui, tip))
resp.on_hover_text(tip_text(ui, tip))
}
/// A split button: main part runs the default action, the arrow opens a menu.
@@ -122,7 +157,7 @@ pub fn split_button(ui: &mut Ui, icon: Icon, accent: Option<Color32>, tip: &str)
ui.painter().rect_filled(Rect::from_min_size(pos2(main.left() + 4.0, main.bottom() - 5.0), vec2(17.0, 3.0)), 0.0, c);
}
icons::paint(ui.painter(), Rect::from_center_size(arrow.center(), vec2(10.0, 10.0)), Icon::Chevron, t.text_dim);
(m.on_hover_text(tr(ui, tip)).clicked(), a)
(m.on_hover_text(tip_text(ui, tip)).clicked(), a)
}
/// A one-line text field for a value stored in the workbook, which callers reload every frame. The text being typed is
@@ -521,3 +556,24 @@ mod color_tests {
assert_eq!(r.len(), RECENT_COLORS);
}
}
#[cfg(test)]
mod tooltip_shortcut_tests {
use super::tooltip_shortcut;
#[test]
fn tooltips_show_each_platforms_own_shortcut() {
// #1191: Windows and Linux show Excel for Windows' shortcuts, never the Mac ⌘ ones.
assert_eq!(tooltip_shortcut("Bold", false), Some("Ctrl+B"));
assert_eq!(tooltip_shortcut("AutoSum", false), Some("Alt+="));
assert_eq!(tooltip_shortcut("Filter", false), Some("Ctrl+Shift+L"));
assert_eq!(tooltip_shortcut("Bold", true), Some("⌘B"));
assert_eq!(tooltip_shortcut("Filter", true), Some("⌘⇧F"));
// Search commands has no shortcut of its own (Ctrl+Shift+Space selects all).
assert_eq!(tooltip_shortcut("Search commands", false), None);
for (name, mac, other) in super::TOOLTIP_SHORTCUTS {
assert!(!other.contains(['⌘', '⇧', '⌥']), "{name}: {other}");
assert!(mac.starts_with('⌘'), "{name}: {mac}");
}
}
}