mirror of
https://github.com/mappu/miqt.git
synced 2025-02-08 22:10:23 +00:00
uic: add -Qt6 argument
This commit is contained in:
parent
8b20ff1070
commit
7bacd37161
@ -9,9 +9,14 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultIsQt6 = false
|
||||||
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
inFile := flag.String("InFile", "", "Input .ui file")
|
inFile := flag.String("InFile", "", "Input .ui file")
|
||||||
outFile := flag.String("OutFile", "-", "Output .go file, or - for stdout")
|
outFile := flag.String("OutFile", "-", "Output .go file, or - for stdout")
|
||||||
|
useQt6 := flag.Bool("Qt6", DefaultIsQt6, "Use Qt 6 instead of Qt 5")
|
||||||
packageName := flag.String("Package", "main", "Custom package name")
|
packageName := flag.String("Package", "main", "Custom package name")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@ -31,7 +36,7 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
gosrc, err := generate(*packageName, strings.Join(os.Args[1:], " "), parsed)
|
gosrc, err := generate(*packageName, strings.Join(os.Args[1:], " "), parsed, *useQt6)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
@ -490,7 +490,7 @@ func generateWidget(w UiWidget, parentName string, parentClass string) (string,
|
|||||||
return ret.String(), nil
|
return ret.String(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func generate(packageName string, goGenerateArgs string, u UiFile) ([]byte, error) {
|
func generate(packageName string, goGenerateArgs string, u UiFile, useQt6 bool) ([]byte, error) {
|
||||||
|
|
||||||
ret := strings.Builder{}
|
ret := strings.Builder{}
|
||||||
|
|
||||||
@ -507,6 +507,11 @@ func generate(packageName string, goGenerateArgs string, u UiFile) ([]byte, erro
|
|||||||
|
|
||||||
// Header
|
// Header
|
||||||
|
|
||||||
|
importPackage := `"github.com/mappu/miqt/qt"`
|
||||||
|
if useQt6 {
|
||||||
|
importPackage = `qt "github.com/mappu/miqt/qt6"`
|
||||||
|
}
|
||||||
|
|
||||||
ret.WriteString(`// Generated by miqt-uic. To update this file, edit the .ui file in
|
ret.WriteString(`// Generated by miqt-uic. To update this file, edit the .ui file in
|
||||||
// Qt Designer, and then run 'go generate'.
|
// Qt Designer, and then run 'go generate'.
|
||||||
//
|
//
|
||||||
@ -515,7 +520,7 @@ func generate(packageName string, goGenerateArgs string, u UiFile) ([]byte, erro
|
|||||||
package ` + packageName + `
|
package ` + packageName + `
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/mappu/miqt/qt"
|
` + importPackage + `
|
||||||
)
|
)
|
||||||
|
|
||||||
type ` + u.Class + `Ui struct {
|
type ` + u.Class + `Ui struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user