From 51d950de3a8ad92dcd0e584af02fe7719dae9592 Mon Sep 17 00:00:00 2001 From: qianlifeng Date: Sat, 30 Mar 2024 23:19:37 +0800 Subject: [PATCH] Add system settings actions and improved file navigation Added actions to open system settings in the Wox plugin 'sys.go' and updated the ShellOpen function to support both MacOS and Windows. Also, a new feature was included in 'selection.go' to open the containing folder when a single file path is identified, improving file navigation in the system. --- Wox/plugin/system/selection.go | 15 +++++++++++++++ Wox/plugin/system/sys.go | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Wox/plugin/system/selection.go b/Wox/plugin/system/selection.go index e07e9109e..56844f628 100644 --- a/Wox/plugin/system/selection.go +++ b/Wox/plugin/system/selection.go @@ -2,6 +2,7 @@ package system import ( "context" + "path" "strings" "wox/plugin" "wox/util" @@ -97,6 +98,20 @@ func (i *SelectionPlugin) queryForSelectionFile(ctx context.Context, filePaths [ }, }, }) + if len(filePaths) == 1 { + results = append(results, plugin.QueryResult{ + Title: "Open containing folder", + Icon: plugin.NewWoxImageBase64(`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAACXBIWXMAAAsTAAALEwEAmpwYAAABCUlEQVR4nO2VMWrDQBBFp8gRQhoFV5a0pM0Zci/fRAK7CcJd0gXcRfKALxFIZ4OdA+gbxZ1A3nU1A/4Pfv/f7OyuCCGEEDICS3lGJQ1q+UMtSEolC3FTvpZDcnFvErhM/vbyXiRwy9p4lMBQYPUAfGVAVwAabNMVPTazX3w+vaUJDOXb3L64jtLmPT4eX+MCw+Sty+pENrOfuICHtdGpUyj6uIB1Sb0eCoAnELhCV7FeEfASq/2UwWdU7ScNfmTqMxLDuiAooPZTBldI7ScNXmL1GbmHZ/RkXRJT2YZjXGBbrh0LNAkCoYCWe/OyOk55wO5lHhX4l/jOM2h4d7JOp2HyyeUJIYTcFWcLXG7i+rfwxwAAAABJRU5ErkJggg==`), + Actions: []plugin.QueryResultAction{ + { + Name: "Open containing folder", + Action: func(ctx context.Context, actionContext plugin.ActionContext) { + util.ShellOpen(path.Dir(filePaths[0])) + }, + }, + }, + }) + } if util.IsMacOS() { // share with airdrop diff --git a/Wox/plugin/system/sys.go b/Wox/plugin/system/sys.go index 7a06be271..c01d02159 100644 --- a/Wox/plugin/system/sys.go +++ b/Wox/plugin/system/sys.go @@ -102,6 +102,20 @@ func (r *SysPlugin) Init(ctx context.Context, initParams plugin.InitParams) { plugin.GetPluginManager().GetUI().OpenSettingWindow(ctx) }, }, + { + Title: "i18n:plugin_sys_open_system_settings", + SubTitle: "", + PreventHideAfterAction: true, + Icon: sysSettingIcon, + Action: func(ctx context.Context, actionContext plugin.ActionContext) { + if util.IsMacOS() { + util.ShellRun("open", "-a", "System Preferences") + } + if util.IsWindows() { + util.ShellRun("desk.cpl") + } + }, + }, } if util.IsDev() {