errors.go 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. This file is part of go-ethereum
  3. go-ethereum is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. go-ethereum is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. /**
  15. * @authors
  16. * Jeffrey Wilcke <i@jev.io>
  17. */
  18. package main
  19. import (
  20. "fmt"
  21. "os"
  22. "github.com/obscuren/qml"
  23. )
  24. func ErrorWindow(err error) {
  25. engine := qml.NewEngine()
  26. component, e := engine.LoadString("local", qmlErr)
  27. if e != nil {
  28. fmt.Println("err:", err)
  29. os.Exit(1)
  30. }
  31. win := component.CreateWindow(nil)
  32. win.Root().ObjectByName("label").Set("text", err.Error())
  33. win.Show()
  34. win.Wait()
  35. }
  36. const qmlErr = `
  37. import QtQuick 2.0; import QtQuick.Controls 1.0;
  38. ApplicationWindow {
  39. width: 600; height: 150;
  40. flags: Qt.CustomizeWindowHint | Qt.WindowTitleHint | Qt.WindowCloseButtonHint
  41. title: "Error"
  42. Text {
  43. x: parent.width / 2 - this.width / 2;
  44. y: parent.height / 2 - this.height / 2;
  45. objectName: "label";
  46. }
  47. }
  48. `