Skip to content

Commit be50a34

Browse files
committed
feat: enhance tooltip descriptions for query hotkeys and add Wox Chrome extension link #4333
1 parent 87232ce commit be50a34

File tree

8 files changed

+103
-80
lines changed

8 files changed

+103
-80
lines changed

wox.core/resource/lang/en_US.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"ui_query_hotkeys_hotkey": "Hotkey",
116116
"ui_query_hotkeys_hotkey_tooltip": "The hotkey to trigger the query.",
117117
"ui_query_hotkeys_query": "Query",
118-
"ui_query_hotkeys_query_tooltip": "The query when the hotkey is triggered. Following variables are supported:\n\n{wox:selected_text} represent the selected text.\n{wox:active_browser_url} represent the url of active browser tab.\n{wox:file_explorer_path} represent the path of the currently open folder in the file explorer (if available).",
118+
"ui_query_hotkeys_query_tooltip": "The query when the hotkey is triggered. Following variables are supported:\n\n - {wox:selected_text} represent the selected text.\n - {wox:active_browser_url} represent the url of active browser tab. To use this, you need to install the Wox Chrome extension [Install Wox Chrome extension](https://chromewebstore.google.com/detail/wox/bjbkdpjdnagiongdfemjhepkkglnailh)\n- {wox:file_explorer_path} represent the path of the currently open folder in the file explorer (if available).",
119119
"ui_query_hotkeys_silent": "Silent",
120120
"ui_query_hotkeys_silent_tooltip": "When selected, if the count of query result is 1, Wox will execute the query directly without showing the result list.\n\nThis is useful when you have a query that always return one result and you want to execute it directly.\nNote: This option is only available when the query result count is 1. Otherwise it will be ignored and notify a warning.",
121121
"ui_disabled": "Disabled",
@@ -865,4 +865,4 @@
865865
"ui_ai_chat_history_history": "History",
866866
"ui_ai_chat_failed_to_chat": "Failed to chat, please try again",
867867
"ui_ai_chat_error": "Error: %s"
868-
}
868+
}

wox.core/resource/lang/pt_BR.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"ui_query_hotkeys_hotkey": "Tecla de atalho",
113113
"ui_query_hotkeys_hotkey_tooltip": "A tecla de atalho para disparar a consulta.",
114114
"ui_query_hotkeys_query": "Consulta",
115-
"ui_query_hotkeys_query_tooltip": "A consulta quando a tecla de atalho acionada. As seguintes variáveis são suportadas:\n\n{wox:selected_text} representa o texto selecionado.\n{wox:active_browser_url} representa o URL da guia do navegador ativo.\n{wox:file_explorer_path} representa o caminho da pasta atualmente aberta no explorador de arquivos (se disponível).",
115+
"ui_query_hotkeys_query_tooltip": "A consulta quando a tecla de atalho acionada. As seguintes variáveis são suportadas:\n\n- {wox:selected_text} representa o texto selecionado.\n- {wox:active_browser_url} representa o URL da guia do navegador ativo. Para usar, instale a extensão Wox para Chrome: [Instalar extensão Wox para Chrome](https://chromewebstore.google.com/detail/wox/bjbkdpjdnagiongdfemjhepkkglnailh)\n- {wox:file_explorer_path} representa o caminho da pasta atualmente aberta no explorador de arquivos (se disponível).",
116116
"ui_query_hotkeys_silent": "Silencioso",
117117
"ui_query_hotkeys_silent_tooltip": "Quando selecionado, se o número de resultados da consulta for 1, o Wox executar a consulta diretamente sem mostrar a lista de resultados.\n\nIssotil quando você tem uma consulta que sempre retorna um resultado e deseja execut-la diretamente.\nNota: Esta opção s est disponível quando o número de resultados da consulta 1. Caso contrário, ser ignorado e notificar um aviso.",
118118
"ui_disabled": "Desativado",
@@ -852,4 +852,4 @@
852852
"ui_ai_chat_history_history": "Histórico",
853853
"ui_ai_chat_failed_to_chat": "Falha ao conversar, tente novamente",
854854
"ui_ai_chat_error": "Erro: %s"
855-
}
855+
}

wox.core/resource/lang/ru_RU.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
"ui_query_hotkeys_hotkey": "Горячая клавиша",
113113
"ui_query_hotkeys_hotkey_tooltip": "Горячая клавиша для запроса",
114114
"ui_query_hotkeys_query": "Запрос",
115-
"ui_query_hotkeys_query_tooltip": "Запрос при нажатии горячей клавиши. Поддерживаются следующие переменные:\n\n{wox:selected_text} представляет выделенный текст.\n{wox:active_browser_url} представляет URL активной вкладки браузера.\n{wox:file_explorer_path} представляет путь к текущей открытой папке в проводнике (если доступно).",
115+
"ui_query_hotkeys_query_tooltip": "Запрос при нажатии горячей клавиши. Поддерживаются следующие переменные:\n\n- {wox:selected_text} представляет выделенный текст.\n- {wox:active_browser_url} представляет URL активной вкладки браузера. Чтобы использовать, установите расширение Wox для Chrome: [Установить расширение Wox для Chrome](https://chromewebstore.google.com/detail/wox/bjbkdpjdnagiongdfemjhepkkglnailh)\n- {wox:file_explorer_path} представляет путь к текущей открытой папке в проводнике (если доступно).",
116116
"ui_query_hotkeys_silent": "Сильный",
117117
"ui_query_hotkeys_silent_tooltip": "Если выбран, и количество результатов запроса равно 1, Wox выполнит запрос непосредственно без отображения списка результатов.\n\nЭто полезно, когда у вас есть запрос, который всегда возвращает один результат, и вы хотите выполнить его непосредственно.\nПримечание: Эта опция доступна только в том случае, если количество результатов запроса равно 1. В противном случае она будет проигнорирована и будет выведено предупреждение.",
118118
"ui_disabled": "Отключено",
@@ -853,4 +853,4 @@
853853
"ui_ai_chat_history_history": "История",
854854
"ui_ai_chat_failed_to_chat": "Не удалось отправить сообщение, попробуйте еще раз",
855855
"ui_ai_chat_error": "Ошибка: %s"
856-
}
856+
}

wox.core/resource/lang/zh_CN.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@
115115
"ui_query_hotkeys_hotkey": "快捷键",
116116
"ui_query_hotkeys_hotkey_tooltip": "用于触发查询的快捷键",
117117
"ui_query_hotkeys_query": "查询",
118-
"ui_query_hotkeys_query_tooltip": "当快捷键被触发时,查询的内容。支持以下变量:\n\n{wox:selected_text} 代表选中的文本\n{wox:active_browser_url} 代表活动的浏览器标签页的URL\n{wox:file_explorer_path} 代表当前文件管理器中打开的文件夹路径(如果有)",
118+
"ui_query_hotkeys_query_tooltip": "当快捷键被触发时,查询的内容。支持以下变量:\n\n- {wox:selected_text} 代表选中的文本\n- {wox:active_browser_url} 代表活动的浏览器标签页的URL。请安装 Wox Chrome 扩展来使用这个变量:[安装 Wox Chrome 扩展](https://chromewebstore.google.com/detail/wox/bjbkdpjdnagiongdfemjhepkkglnailh)\n- {wox:file_explorer_path} 代表当前文件管理器中打开的文件夹路径(如果有)",
119119
"ui_query_hotkeys_silent": "静默",
120120
"ui_query_hotkeys_silent_tooltip": "当选中时,如果查询结果数量为1,Wox将直接执行查询而不显示结果列表。\n\n这在您有一个总是返回一个结果的查询并且您希望直接执行它时非常有用。\n注意:此选项仅在查询结果数量为1时可用。否则将忽略并通知警告。",
121121
"ui_disabled": "禁用",
@@ -865,4 +865,4 @@
865865
"ui_ai_chat_history_history": "历史",
866866
"ui_ai_chat_failed_to_chat": "对话失败,请重试",
867867
"ui_ai_chat_error": "错误:%s"
868-
}
868+
}

wox.ui.flutter/wox/lib/components/plugin/wox_setting_plugin_table_update_view.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import 'package:wox/components/wox_image_view.dart';
1414
import 'package:wox/components/wox_textfield.dart';
1515
import 'package:wox/components/wox_checkbox.dart';
1616
import 'package:wox/components/wox_checkbox_tile.dart';
17+
import 'package:wox/components/wox_markdown.dart';
1718
import 'package:wox/components/wox_path_finder.dart';
1819
import 'package:wox/controllers/wox_setting_controller.dart';
1920
import 'package:wox/entity/setting/wox_plugin_setting_table.dart';
@@ -683,7 +684,14 @@ class _WoxSettingPluginTableUpdateState extends State<WoxSettingPluginTableUpdat
683684
if (column.tooltip != "")
684685
Padding(
685686
padding: EdgeInsets.only(top: 4, left: maxLabelWidth + 10),
686-
child: Text(tr(column.tooltip), style: TextStyle(color: textColor.withOpacity(0.6), fontSize: 12)),
687+
child: WoxMarkdownView(
688+
data: tr(column.tooltip),
689+
fontColor: textColor.withOpacity(0.6),
690+
fontSize: 12,
691+
linkColor: accentColor,
692+
linkHoverColor: accentColor.withOpacity(0.8),
693+
selectable: true,
694+
),
687695
),
688696
],
689697
),

wox.ui.flutter/wox/lib/components/wox_markdown.dart

Lines changed: 73 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,30 @@ import 'package:gpt_markdown/custom_widgets/custom_error_image.dart';
55
import 'package:gpt_markdown/custom_widgets/markdown_config.dart';
66
import 'package:gpt_markdown/custom_widgets/unordered_ordered_list.dart';
77
import 'package:gpt_markdown/gpt_markdown.dart';
8+
import 'package:url_launcher/url_launcher.dart';
89
import 'package:wox/utils/colors.dart';
910

1011
class WoxMarkdownView extends StatelessWidget {
1112
final String data;
1213
final Color fontColor;
14+
final double fontSize;
15+
final Color? linkColor;
16+
final Color? linkHoverColor;
17+
final bool selectable;
1318

14-
const WoxMarkdownView({super.key, required this.fontColor, required this.data});
19+
const WoxMarkdownView({super.key, required this.fontColor, required this.data, this.fontSize = 14, this.linkColor, this.linkHoverColor, this.selectable = true});
1520

1621
@override
1722
Widget build(BuildContext context) {
18-
const baseTextStyle = TextStyle(fontSize: 14);
23+
final baseTextStyle = TextStyle(fontSize: fontSize);
1924
final fontTextStyle = baseTextStyle.copyWith(color: fontColor);
2025
final bool isDarkFont = fontColor.computeLuminance() < 0.5;
2126
final codeBackgroundColor = isDarkFont ? Colors.black.withValues(alpha: 0.06) : Colors.white.withValues(alpha: 0.08);
2227
final codeTextStyle = fontTextStyle.copyWith(fontSize: 13, color: fontColor);
2328
final dividerColor = getThemeDividerColor();
29+
final effectiveLinkColor = linkColor ?? fontColor;
30+
final effectiveLinkHoverColor = linkHoverColor ?? fontColor.withValues(alpha: 0.85);
31+
2432
final themeData = GptMarkdownThemeData(
2533
brightness: isDarkFont ? Brightness.light : Brightness.dark,
2634
highlightColor: codeBackgroundColor,
@@ -32,68 +40,75 @@ class WoxMarkdownView extends StatelessWidget {
3240
h6: baseTextStyle,
3341
hrLineThickness: 1.5,
3442
hrLineColor: dividerColor,
35-
linkColor: fontColor,
36-
linkHoverColor: fontColor.withValues(alpha: 0.85),
43+
linkColor: effectiveLinkColor,
44+
linkHoverColor: effectiveLinkHoverColor,
3745
);
3846

3947
final normalizedData = normalizeMarkdownImages(data);
4048

41-
return DefaultTextStyle.merge(
42-
style: fontTextStyle,
43-
child: SelectionArea(
44-
child: GptMarkdownTheme(
45-
gptThemeData: themeData,
46-
child: GptMarkdown(
47-
normalizedData,
48-
style: baseTextStyle,
49-
textDirection: Directionality.of(context),
50-
imageBuilder: (context, url) => buildImage(context, url),
51-
inlineComponents: [
52-
ATagMd(),
53-
WoxImageMd(),
54-
TableMd(),
55-
StrikeMd(),
56-
BoldMd(),
57-
ItalicMd(),
58-
UnderLineMd(),
59-
LatexMath(),
60-
LatexMathMultiLine(),
61-
HighlightedText(),
62-
SourceTag(),
63-
],
64-
unOrderedListBuilder: (context, child, config) {
65-
final itemText = child is MdWidget ? child.exp.trimLeft() : '';
66-
if (RegExp(r'^\[(?:x|X| )\]\s+').hasMatch(itemText)) {
67-
return UnorderedListView(padding: 0, spacing: 0, bulletSize: 0, textDirection: config.textDirection, child: child);
68-
}
69-
final bulletColor = config.style?.color ?? DefaultTextStyle.of(context).style.color;
70-
final fontSize = config.style?.fontSize ?? DefaultTextStyle.of(context).style.fontSize ?? 14;
71-
return UnorderedListView(bulletColor: bulletColor, padding: 7, spacing: 10, bulletSize: 0.3 * fontSize, textDirection: config.textDirection, child: child);
72-
},
73-
codeBuilder: (context, name, code, closed) {
74-
final trimmedName = name.trim();
75-
final borderRadius = BorderRadius.circular(closed ? 4 : 0);
76-
return Container(
77-
margin: const EdgeInsets.symmetric(vertical: 6),
78-
decoration: BoxDecoration(color: codeBackgroundColor, borderRadius: borderRadius),
79-
child: Column(
80-
crossAxisAlignment: CrossAxisAlignment.stretch,
81-
children: [
82-
if (trimmedName.isNotEmpty)
83-
Padding(
84-
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
85-
child: Text(trimmedName, style: codeTextStyle.copyWith(fontSize: 12, fontWeight: FontWeight.w600)),
86-
),
87-
if (trimmedName.isNotEmpty) Divider(height: 1, color: dividerColor.withValues(alpha: 0.4)),
88-
SingleChildScrollView(scrollDirection: Axis.horizontal, padding: const EdgeInsets.all(8), child: Text(code, style: codeTextStyle)),
89-
],
90-
),
91-
);
92-
},
93-
),
94-
),
49+
final markdownBody = GptMarkdownTheme(
50+
gptThemeData: themeData,
51+
child: GptMarkdown(
52+
normalizedData,
53+
style: baseTextStyle,
54+
textDirection: Directionality.of(context),
55+
linkBuilder: (context, text, url, style) {
56+
TextSpan? span;
57+
if (text is TextSpan) {
58+
span = TextSpan(
59+
text: text.text,
60+
children: text.children,
61+
style: (text.style ?? style).copyWith(decoration: TextDecoration.underline, decorationColor: (text.style?.color ?? style.color)),
62+
);
63+
}
64+
final linkText = Text.rich(span ?? text, style: style);
65+
final linkWidget = MouseRegion(cursor: SystemMouseCursors.click, child: linkText);
66+
if (!selectable) {
67+
return linkWidget;
68+
}
69+
return SelectionContainer.disabled(child: linkWidget);
70+
},
71+
onLinkTap: (String url, String title) {
72+
final uri = Uri.tryParse(url);
73+
if (uri != null) {
74+
launchUrl(uri);
75+
}
76+
},
77+
imageBuilder: (context, url) => buildImage(context, url),
78+
inlineComponents: [ATagMd(), WoxImageMd(), TableMd(), StrikeMd(), BoldMd(), ItalicMd(), UnderLineMd(), LatexMath(), LatexMathMultiLine(), HighlightedText(), SourceTag()],
79+
unOrderedListBuilder: (context, child, config) {
80+
final itemText = child is MdWidget ? child.exp.trimLeft() : '';
81+
if (RegExp(r'^\[(?:x|X| )\]\s+').hasMatch(itemText)) {
82+
return UnorderedListView(padding: 0, spacing: 0, bulletSize: 0, textDirection: config.textDirection, child: child);
83+
}
84+
final bulletColor = config.style?.color ?? DefaultTextStyle.of(context).style.color;
85+
final fontSize = config.style?.fontSize ?? DefaultTextStyle.of(context).style.fontSize ?? 14;
86+
return UnorderedListView(bulletColor: bulletColor, padding: 7, spacing: 10, bulletSize: 0.3 * fontSize, textDirection: config.textDirection, child: child);
87+
},
88+
codeBuilder: (context, name, code, closed) {
89+
final trimmedName = name.trim();
90+
final borderRadius = BorderRadius.circular(closed ? 4 : 0);
91+
return Container(
92+
margin: const EdgeInsets.symmetric(vertical: 6),
93+
decoration: BoxDecoration(color: codeBackgroundColor, borderRadius: borderRadius),
94+
child: Column(
95+
crossAxisAlignment: CrossAxisAlignment.stretch,
96+
children: [
97+
if (trimmedName.isNotEmpty)
98+
Padding(
99+
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
100+
child: Text(trimmedName, style: codeTextStyle.copyWith(fontSize: 12, fontWeight: FontWeight.w600)),
101+
),
102+
if (trimmedName.isNotEmpty) Divider(height: 1, color: dividerColor.withValues(alpha: 0.4)),
103+
SingleChildScrollView(scrollDirection: Axis.horizontal, padding: const EdgeInsets.all(8), child: Text(code, style: codeTextStyle)),
104+
],
105+
),
106+
);
107+
},
95108
),
96109
);
110+
111+
return DefaultTextStyle.merge(style: fontTextStyle, child: selectable ? SelectionArea(child: markdownBody) : markdownBody);
97112
}
98113

99114
String normalizeMarkdownImages(String input) {

wox.ui.flutter/wox/lib/modules/setting/views/wox_setting_general_view.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class WoxSettingGeneralView extends WoxSettingBaseView {
227227
],
228228
},
229229
{"Key": "IsSilentExecution", "Label": "i18n:ui_query_hotkeys_silent", "Tooltip": "i18n:ui_query_hotkeys_silent_tooltip", "Width": 40, "Type": "checkbox"},
230-
{"Key": "Disabled", "Label": "i18n:ui_disabled", "Tooltip": "i18n:ui_disabled_tooltip", "Width": 50, "Type": "checkbox"},
230+
{"Key": "Disabled", "Label": "i18n:ui_disabled", "Tooltip": "i18n:ui_disabled_tooltip", "Width": 60, "Type": "checkbox"},
231231
],
232232
"SortColumnKey": "Query",
233233
}),
@@ -267,7 +267,7 @@ class WoxSettingGeneralView extends WoxSettingBaseView {
267267
{"Type": "not_empty"},
268268
],
269269
},
270-
{"Key": "Disabled", "Label": "i18n:ui_disabled", "Tooltip": "i18n:ui_disabled_tooltip", "Width": 50, "Type": "checkbox"},
270+
{"Key": "Disabled", "Label": "i18n:ui_disabled", "Tooltip": "i18n:ui_disabled_tooltip", "Width": 60, "Type": "checkbox"},
271271
],
272272
"SortColumnKey": "Query",
273273
}),
@@ -298,7 +298,7 @@ class WoxSettingGeneralView extends WoxSettingBaseView {
298298
],
299299
},
300300
{"Key": "Width", "Label": "i18n:ui_tray_queries_width", "Tooltip": "i18n:ui_tray_queries_width_tooltip", "Type": "text", "Width": 90, "TextMaxLines": 1},
301-
{"Key": "Disabled", "Label": "i18n:ui_disabled", "Tooltip": "i18n:ui_disabled_tooltip", "Width": 50, "Type": "checkbox"},
301+
{"Key": "Disabled", "Label": "i18n:ui_disabled", "Tooltip": "i18n:ui_disabled_tooltip", "Width": 60, "Type": "checkbox"},
302302
],
303303
"SortColumnKey": "",
304304
}),

0 commit comments

Comments
 (0)