Skip to content

Commit

Permalink
Remove toolbar box shadow and enhance file list preview.
Browse files Browse the repository at this point in the history
Deleted the box shadow from the toolbar to simplify the UI. Refactored the plugin manager to format file list previews, added new translation strings for file selection messages in English and Chinese.
  • Loading branch information
qianlifeng committed Sep 9, 2024
1 parent b9f55f8 commit 09efcf5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ class WoxQueryToolbarView extends GetView<WoxLauncherController> {
child: Container(
decoration: BoxDecoration(
color: fromCssColor(controller.woxTheme.value.toolbarBackgroundColor),
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
blurRadius: 4,
offset: Offset(0, 2),
),
],
),
child: Padding(
padding: EdgeInsets.only(left: controller.woxTheme.value.toolbarPaddingLeft.toDouble(), right: controller.woxTheme.value.toolbarPaddingRight.toDouble()),
Expand Down
38 changes: 32 additions & 6 deletions Wox/plugin/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/Masterminds/semver/v3"
"github.com/google/uuid"
"github.com/jinzhu/copier"
"github.com/samber/lo"
"github.com/wissance/stringFormatter"
"math"
"os"
"path"
Expand All @@ -23,6 +18,12 @@ import (
"wox/setting"
"wox/share"
"wox/util"

"github.com/Masterminds/semver/v3"
"github.com/google/uuid"
"github.com/jinzhu/copier"
"github.com/samber/lo"
"github.com/wissance/stringFormatter"
)

var managerInstance *Manager
Expand Down Expand Up @@ -476,7 +477,7 @@ func (m *Manager) PolishResult(ctx context.Context, pluginInstance *Instance, qu
if query.Selection.Type == util.SelectionTypeFile {
result.Preview = WoxPreview{
PreviewType: WoxPreviewTypeMarkdown,
PreviewData: strings.Join(query.Selection.FilePaths, "\n"),
PreviewData: m.formatFileListPreview(ctx, query.Selection.FilePaths),
}
}
}
Expand Down Expand Up @@ -582,6 +583,31 @@ func (m *Manager) PolishResult(ctx context.Context, pluginInstance *Instance, qu
return result
}

func (m *Manager) formatFileListPreview(ctx context.Context, filePaths []string) string {
totalFiles := len(filePaths)
if totalFiles == 0 {
return i18n.GetI18nManager().TranslateWox(ctx, "i18n:selection_no_files_selected")
}

var sb strings.Builder
sb.WriteString(fmt.Sprintf(i18n.GetI18nManager().TranslateWox(ctx, "i18n:selection_selected_files_count"), totalFiles))
sb.WriteString("\n\n")

maxDisplayFiles := 10
for i, filePath := range filePaths {
if i < maxDisplayFiles {
sb.WriteString(fmt.Sprintf("- `%s`\n", filePath))
} else {
remainingFiles := totalFiles - maxDisplayFiles
sb.WriteString("\n")
sb.WriteString(fmt.Sprintf(i18n.GetI18nManager().TranslateWox(ctx, "i18n:selection_remaining_files_not_shown"), remainingFiles))
break
}
}

return sb.String()
}

func (m *Manager) calculateResultScore(ctx context.Context, pluginId, title, subTitle string) int64 {
resultHash := setting.NewResultHash(pluginId, title, subTitle)
woxAppData := setting.GetSettingManager().GetWoxAppData(ctx)
Expand Down
5 changes: 4 additions & 1 deletion Wox/resource/lang/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@
"ui_query_hotkeys": "Query Hotkeys",
"ui_query_shortcuts": "Query Shortcuts",
"ui_general": "General",
"ui_ai": "AI"
"ui_ai": "AI",
"selection_no_files_selected": "No files selected",
"selection_selected_files_count": "Selected %d files:",
"selection_remaining_files_not_shown": "... %d more files not shown"
}
5 changes: 4 additions & 1 deletion Wox/resource/lang/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,8 @@
"ui_query_hotkeys": "查询快捷键",
"ui_query_shortcuts": "查询缩写",
"ui_general": "通用",
"ui_ai": "AI"
"ui_ai": "AI",
"selection_no_files_selected": "未选择文件",
"selection_selected_files_count": "已选择 %d 个文件:",
"selection_remaining_files_not_shown": "... 还有 %d 个文件未显示"
}

0 comments on commit 09efcf5

Please sign in to comment.