-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
202 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package ui | ||
|
||
import ( | ||
"fyne.io/fyne/v2" | ||
"fyne.io/fyne/v2/container" | ||
"fyne.io/fyne/v2/widget" | ||
"github.com/Ericwyn/EzeTranslate/conf" | ||
"github.com/Ericwyn/EzeTranslate/log" | ||
"github.com/Ericwyn/EzeTranslate/ui/resource/cusWidget" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func buildFormatCheckBox() *fyne.Container { | ||
return container.NewHBox( | ||
widget.NewLabel("输入优化 "), | ||
cusWidget.CreateCheckGroup( | ||
[]cusWidget.LabelAndInit{ | ||
{"注释", viper.GetBool(conf.ConfigKeyFormatAnnotation)}, | ||
{"空格", viper.GetBool(conf.ConfigKeyFormatSpace)}, | ||
{"回车", viper.GetBool(conf.ConfigKeyFormatCarriageReturn)}, | ||
{"驼峰", viper.GetBool(conf.ConfigKeyFormatCamelCase)}, | ||
}, | ||
true, // 横向 | ||
false, // 单选 | ||
func(label string, checked bool) { | ||
if label == "注释" { | ||
viper.Set(conf.ConfigKeyFormatAnnotation, checked) | ||
} else if label == "空格" { | ||
viper.Set(conf.ConfigKeyFormatSpace, checked) | ||
} else if label == "回车" { | ||
viper.Set(conf.ConfigKeyFormatCarriageReturn, checked) | ||
} else if label == "驼峰" { | ||
viper.Set(conf.ConfigKeyFormatCamelCase, checked) | ||
} | ||
conf.SaveConfig() | ||
}, | ||
), | ||
) | ||
} | ||
|
||
func buildTransApiCheckBox() *fyne.Container { | ||
return container.NewHBox( | ||
widget.NewLabel("翻译结果 "), | ||
cusWidget.CreateCheckGroup( | ||
[]cusWidget.LabelAndInit{ | ||
{"Google", viper.GetString(conf.ConfigKeyTranslateSelect) == "google"}, | ||
{"Baidu", viper.GetString(conf.ConfigKeyTranslateSelect) == "baidu"}, | ||
{"Youdao", viper.GetString(conf.ConfigKeyTranslateSelect) == "youdao"}, | ||
}, | ||
true, // 横向 | ||
true, // 单选 | ||
func(label string, checked bool) { | ||
if label == "Google" { | ||
viper.Set(conf.ConfigKeyTranslateSelect, "google") | ||
} else if label == "Baidu" { | ||
viper.Set(conf.ConfigKeyTranslateSelect, "baidu") | ||
} else if label == "Youdao" { | ||
viper.Set(conf.ConfigKeyTranslateSelect, "youdao") | ||
} | ||
e := viper.WriteConfig() | ||
if e != nil { | ||
log.E("配置文件保存失败") | ||
log.E(e) | ||
} | ||
}, | ||
), | ||
) | ||
} |
Oops, something went wrong.