Skip to content

Commit

Permalink
feature: 增加字幕文件和目录拖拽功能; 调整资源文件; 更新版本号;
Browse files Browse the repository at this point in the history
  • Loading branch information
speauty committed May 4, 2023
1 parent 0f1061c commit d05183b
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 7 deletions.
7 changes: 2 additions & 5 deletions bootstrap/resource_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,11 @@ package bootstrap

import (
_const "anto/common"
_ "embed"
"anto/resource"
"fmt"
"os"
)

//go:embed favicon.ico
var bytesFav []byte

type ResourceBuilder struct {
}

Expand Down Expand Up @@ -57,7 +54,7 @@ func (customRB *ResourceBuilder) installICO() {
panic(fmt.Errorf("创建图标文件失败, 错误: %s", err))
}

if _, err = fd.Write(bytesFav); err != nil {
if _, err = fd.Write(resource.RFavicon); err != nil {
panic(fmt.Errorf("写入图标文件失败, 错误: %s", err))
}
}
2 changes: 1 addition & 1 deletion common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package common
const (
AppName = "anto"
Author = "speauty"
Version = "v2.9.4"
Version = "v3.0.0"

GoUidLen = 8

Expand Down
30 changes: 29 additions & 1 deletion platform/win/page/subrip_translate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ import (
"anto/platform/win/ui/pack"
"errors"
"fmt"
"os"
"sync"

"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
"sync"
)

var (
Expand Down Expand Up @@ -59,6 +61,8 @@ type SubripTranslate struct {
ptrSrtDir *walk.Label

ptrLog *walk.TextEdit

dropFilesEventId int
}

func (customPage *SubripTranslate) GetId() string {
Expand Down Expand Up @@ -160,6 +164,30 @@ func (customPage *SubripTranslate) Reset() {
if customPage.ptrSrtDir != nil {
_ = customPage.ptrSrtDir.SetText("")
}

if customPage.dropFilesEventId == 0 {
dfEvent := customPage.rootWidget.DropFiles()
customPage.dropFilesEventId = dfEvent.Attach(func(files []string) {
if len(files) < 1 {
return
}
currentFile := files[0]
fsInfo, err := os.Stat(currentFile)
if err != nil {
return
}
if fsInfo.IsDir() {
customPage.ptrSrtDir.SetText(currentFile)
} else {
if util.IsSrtFile(currentFile) {
customPage.ptrSrtFile.SetText(currentFile)
} else {
// @todo 触发两次弹窗提示,暂时注释
// msg.Err(customPage.mainWindow, fmt.Errorf("无效字幕文件(%s)", filepath.Base(currentFile)))
}
}
})
}
}

func (customPage *SubripTranslate) eventEngineOnChange() {
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package resource

import _ "embed"

//go:embed favicon.ico
var RFavicon []byte

//go:embed wxpay.jpg
var RWxPay []byte

Expand Down

0 comments on commit d05183b

Please sign in to comment.