Skip to content

Commit

Permalink
update: 移除状态栏和对UI进行分包处理;
Browse files Browse the repository at this point in the history
  • Loading branch information
speauty committed Apr 14, 2023
1 parent 5348f86 commit 49e0dd3
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 90 deletions.
6 changes: 3 additions & 3 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"anto/bootstrap"
"anto/cfg"
_const "anto/common"
"anto/common"
"anto/dependency/repository"
"anto/dependency/service/translator/ali_cloud_mt"
"anto/dependency/service/translator/baidu"
Expand All @@ -26,8 +26,8 @@ func main() {
if err := cfg.Singleton().Load(""); err != nil {
panic(err)
}
cfg.Singleton().App.Author = _const.Author
cfg.Singleton().App.Version = _const.Version
cfg.Singleton().App.Author = common.Author
cfg.Singleton().App.Version = common.Version
log.Singleton()

cfg.Singleton().UI.Title = cfg.Singleton().NewUITitle()
Expand Down
6 changes: 3 additions & 3 deletions cron/detector/data.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package detector

import (
_type "anto/common"
"anto/common"
"anto/cron/reader"
"anto/cron/translate"
"anto/dependency/service/translator"
Expand All @@ -11,8 +11,8 @@ type StrDetectorData struct {
Translator translator.InterfaceTranslator
FromLang string
ToLang string
TranslateMode _type.TranslateMode
MainTrackReport _type.LangDirection
TranslateMode common.TranslateMode
MainTrackReport common.LangDirection
SrtFile string
SrtDir string
FlagTrackExport int
Expand Down
4 changes: 2 additions & 2 deletions cron/translate/srt_translator.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package translate

import (
_type "anto/common"
"anto/common"
"anto/cron"
"anto/cron/writer"
"anto/dependency/service/translator"
Expand Down Expand Up @@ -88,7 +88,7 @@ func (customCron *SrtTranslator) jobTranslator() {
var blockChunked []string
tmpBlockStr := ""
for _, block := range currentData.PrtSrt.Blocks {
if block.SubTrack != "" && currentData.PtrOpts.TranslateMode == _type.ModeDelta {
if block.SubTrack != "" && currentData.PtrOpts.TranslateMode == common.ModeDelta {
continue
}

Expand Down
9 changes: 9 additions & 0 deletions platform/win/ui/event.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package ui

import "github.com/lxn/walk"

func (customG *Gui) eventCustomClose(canceled *bool, reason walk.CloseReason) {
reason = walk.CloseReasonUser
*canceled = false
customG.ctxCancelFn()
}
25 changes: 25 additions & 0 deletions platform/win/ui/sets.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package ui

import (
"github.com/lxn/walk"
"github.com/lxn/win"
)

func (customG *Gui) setWindowFlag() {
win.SetWindowLong(customG.GetWindow().Handle(), win.GWL_STYLE,
win.GetWindowLong(customG.GetWindow().Handle(), win.GWL_STYLE) & ^win.WS_MAXIMIZEBOX & ^win.WS_THICKFRAME)
}

func (customG *Gui) setWindowCenter() {
scrWidth := win.GetSystemMetrics(win.SM_CXSCREEN)
scrHeight := win.GetSystemMetrics(win.SM_CYSCREEN)
_ = customG.GetWindow().SetBounds(walk.Rectangle{
X: int((scrWidth - width) / 2), Y: int((scrHeight - height) / 2),
Width: width, Height: height,
})
}

func (customG *Gui) setWindowMinAndMaxSize() {
minMaxSize := walk.Size{Width: width, Height: height}
_ = customG.GetWindow().SetMinMaxSize(minMaxSize, minMaxSize)
}
44 changes: 0 additions & 44 deletions platform/win/ui/status_bar.go

This file was deleted.

46 changes: 8 additions & 38 deletions platform/win/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"github.com/lxn/walk"
. "github.com/lxn/walk/declarative"
"github.com/lxn/win"
"sync"
)

Expand Down Expand Up @@ -37,7 +36,7 @@ type Gui struct {
func (customG *Gui) Init(cfg *Cfg) error {
customG.cfg = cfg

if err := customG.genMainWindow(); err != nil {
if err := customG.initMainWindow(); err != nil {
return err
}

Expand Down Expand Up @@ -67,12 +66,6 @@ func (customG *Gui) Close() {
_ = customG.win.Close()
}

func (customG *Gui) eventCustomClose(canceled *bool, reason walk.CloseReason) {
reason = walk.CloseReasonUser
*canceled = false
customG.ctxCancelFn()
}

func (customG *Gui) GetWindow() *walk.MainWindow {
return customG.win
}
Expand All @@ -91,40 +84,17 @@ func (customG *Gui) RegisterMenus(menus []MenuItem) {
return
}

func (customG *Gui) genMainWindow() error {
func (customG *Gui) initMainWindow() error {
return MainWindow{
AssignTo: &customG.win,
Title: customG.cfg.Title,
Icon: "./favicon.ico",
Visible: false,
Persistent: true,
Layout: VBox{MarginsZero: true},
MenuItems: customG.menus,
Children: customG.pageCtl.GetWidgets(),
AssignTo: &customG.win,
Title: customG.cfg.Title, Icon: "./favicon.ico",
Visible: false, Persistent: true,
Layout: VBox{MarginsZero: true},
MenuItems: customG.menus,
Children: customG.pageCtl.GetWidgets(),
}.Create()
}

func (customG *Gui) setWindowFlag() {
win.SetWindowLong(customG.GetWindow().Handle(), win.GWL_STYLE,
win.GetWindowLong(customG.GetWindow().Handle(), win.GWL_STYLE) & ^win.WS_MAXIMIZEBOX & ^win.WS_THICKFRAME)
}

func (customG *Gui) setWindowCenter() {
scrWidth := win.GetSystemMetrics(win.SM_CXSCREEN)
scrHeight := win.GetSystemMetrics(win.SM_CYSCREEN)
_ = customG.GetWindow().SetBounds(walk.Rectangle{
X: int((scrWidth - width) / 2),
Y: int((scrHeight - height) / 2),
Width: width,
Height: height,
})
}

func (customG *Gui) setWindowMinAndMaxSize() {
minMaxSize := walk.Size{Width: width, Height: height}
_ = customG.GetWindow().SetMinMaxSize(minMaxSize, minMaxSize)
}

func (customG *Gui) log() *log.Log {
return log.Singleton()
}
2 changes: 2 additions & 0 deletions platform/win/win.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"anto/cron/reader"
"anto/cron/translate"
"anto/cron/writer"
"anto/lib/log"
"anto/lib/nohup"
"anto/platform/win/page"
"anto/platform/win/ui"
Expand All @@ -18,6 +19,7 @@ func Run(ctx context.Context) {
ui.Singleton().RegisterPages(page.GetSettings(), page.GetSubripTranslate())

if err := ui.Singleton().Init(cfg.Singleton().UI); err != nil {
log.Singleton().ErrorF("UI启动崩溃, 错误: %s", err)
panic(err)
}

Expand Down

0 comments on commit 49e0dd3

Please sign in to comment.