添加qt .ui转css 小工具接口

master
DESKTOP-4RNDQIC\29019 2021-05-08 00:15:04 +08:00
parent f13a1a627a
commit 80180f55f3
3 changed files with 113 additions and 14 deletions

41
main.go
View File

@ -8,6 +8,7 @@ import (
_ "background/docs" _ "background/docs"
"background/logs" "background/logs"
"background/model" "background/model"
"encoding/xml"
"log" "log"
"os" "os"
"strconv" "strconv"
@ -91,9 +92,47 @@ func InitElasticSearch() {
func InitLogs() { func InitLogs() {
logs.Init(config.GetLogConfig().Dir, config.GetLogConfig().File, config.GetLogConfig().Level, config.GetLogConfig().SaveFile) logs.Init(config.GetLogConfig().Dir, config.GetLogConfig().File, config.GetLogConfig().Level, config.GetLogConfig().SaveFile)
} }
func getAttr(name string, attr []xml.Attr) string {
for _, a := range attr {
if a.Name.Local == name {
return a.Value
}
}
return ""
}
func TestUI(){
xmlFile, err := os.Open("process.ui")
if err != nil {
log.Fatal(err)
}
defer xmlFile.Close()
decoder := xml.NewDecoder(xmlFile)
for {
token, _ := decoder.Token()
if token == nil {
break
}
switch startElement := token.(type) {
case xml.StartElement:
log.Print(startElement.Name.Local)
if(startElement.Name.Local == "widget"){
log.Print(getAttr("name",startElement.Attr))
}
break
case xml.EndElement:
log.Print(startElement.Name.Local)
break
}
}
}
func main() { func main() {
log.Print("gid is", os.Getegid()) log.Print("gid is", os.Getegid())
TestUI()
InitConfig() InitConfig()
InitLogs() InitLogs()
InitRedisConfig() InitRedisConfig()

51
process.ui Normal file
View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Process</class>
<widget class="QDialog" name="Process">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>324</width>
<height>88</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QProgressBar" name="progressBar">
<property name="geometry">
<rect>
<x>30</x>
<y>50</y>
<width>281</width>
<height>31</height>
</rect>
</property>
<property name="value">
<number>24</number>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>120</x>
<y>30</y>
<width>121</width>
<height>16</height>
</rect>
</property>
<property name="text">
<string>正在加载数据</string>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -1,6 +1,9 @@
package test package test
import ( import (
"encoding/xml"
"log"
"os"
"testing" "testing"
) )
@ -15,18 +18,24 @@ type Test struct {
} }
func TestXml(t *testing.T) { func TestXml(t *testing.T) {
// x := map[string]interface{}{} xmlFile, err := os.Open("process.ui")
// x["map"] = 1 if err != nil {
// x["ss"] = 2 log.Fatal(err)
// test := Test{A: 1, B: false, C: "hell", D: Sub{A: "aa"}} }
// bytes, e := xml.Marshal(&test) defer xmlFile.Close()
// if nil != e { decoder := xml.NewDecoder(xmlFile)
// t.Error(e.Error()) for {
token, _ := decoder.Token()
// } if token == nil {
// bytes, e = xml.Marshal(&x) break
// if nil != e { }
// t.Error(e.Error()) switch startElement := token.(type) {
case xml.StartElement:
// } t.Log(startElement.Name.Local)
if startElement.Name.Local == "entry" {
// do what you need to do for each entry below
}
}
}
} }