qml tests
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.5 KiB

  1. package main
  2. import (
  3. "flag"
  4. "git.openprivacy.ca/openprivacy/libricochet-go/log"
  5. "github.com/therecipe/qt/core"
  6. "github.com/therecipe/qt/gui"
  7. "github.com/therecipe/qt/qml"
  8. "github.com/therecipe/qt/quickcontrols2"
  9. "os"
  10. )
  11. type Thingama struct {
  12. core.QObject
  13. _ string `property:"x"`
  14. _ core.QStringList `property:"mahdahl"`
  15. _ core.QAbstractItemModel `property:"abstracty"`
  16. _ func() `signal:"doTheThing,auto"`
  17. }
  18. func (this *Thingama) doTheThing() {
  19. }
  20. func main() {
  21. flagDebug := flag.Bool("debug", false, "turn on extra logging. WARNING: THIS MAY EXPOSE PRIVATE INFORMATION IN CONSOLE OUTPUT!")
  22. flagLocal := flag.Bool("local", false, "load user interface from the local folder \"qml\" instead of the built-in UI")
  23. flag.Parse()
  24. if *flagDebug {
  25. log.SetLevel(log.LevelDebug)
  26. } else {
  27. log.SetLevel(log.LevelInfo)
  28. }
  29. // this is to load local qml files quickly when developing
  30. var qmlSource *core.QUrl
  31. if *flagLocal {
  32. qmlSource = core.QUrl_FromLocalFile("./qml/main.qml")
  33. } else {
  34. qmlSource = core.NewQUrl3("qrc:/qml/main.qml", 0)
  35. }
  36. core.QCoreApplication_SetAttribute(core.Qt__AA_Use96Dpi, true)
  37. core.QCoreApplication_SetAttribute(core.Qt__AA_EnableHighDpiScaling, false)
  38. app := gui.NewQGuiApplication(len(os.Args), os.Args)
  39. //QApplication::setAttribute(Qt::AA_Use96Dpi);
  40. quickcontrols2.QQuickStyle_SetStyle("Default")
  41. engine := qml.NewQQmlApplicationEngine(nil)
  42. thingama := NewThingama(nil)
  43. thingama.SetX("hello")
  44. engine.RootContext().SetContextProperty("thingama", thingama)
  45. engine.Load(qmlSource)
  46. app.Exec()
  47. }