diff options
author | Maran <maran.hidskes@gmail.com> | 2014-06-23 22:25:57 +0800 |
---|---|---|
committer | Maran <maran.hidskes@gmail.com> | 2014-06-23 22:25:57 +0800 |
commit | f6aabb7a90903a681eca44976301620756124137 (patch) | |
tree | 0acabc8ce58d13ffa4939e54b36f6a3e45308772 /ethereal/ui | |
parent | 2408e38218d81c567bdaa4671a542a20c55490b9 (diff) | |
download | go-tangerine-f6aabb7a90903a681eca44976301620756124137.tar go-tangerine-f6aabb7a90903a681eca44976301620756124137.tar.gz go-tangerine-f6aabb7a90903a681eca44976301620756124137.tar.bz2 go-tangerine-f6aabb7a90903a681eca44976301620756124137.tar.lz go-tangerine-f6aabb7a90903a681eca44976301620756124137.tar.xz go-tangerine-f6aabb7a90903a681eca44976301620756124137.tar.zst go-tangerine-f6aabb7a90903a681eca44976301620756124137.zip |
Implements QML Apps. Implements #47
You are welcome Stephan.
Diffstat (limited to 'ethereal/ui')
-rw-r--r-- | ethereal/ui/qml_app.go | 59 | ||||
-rw-r--r-- | ethereal/ui/ui_lib.go | 15 |
2 files changed, 63 insertions, 11 deletions
diff --git a/ethereal/ui/qml_app.go b/ethereal/ui/qml_app.go new file mode 100644 index 000000000..d47751616 --- /dev/null +++ b/ethereal/ui/qml_app.go @@ -0,0 +1,59 @@ +package ethui + +import ( + "github.com/ethereum/eth-go/ethchain" + "github.com/ethereum/eth-go/ethpub" + "github.com/ethereum/eth-go/ethutil" + "github.com/go-qml/qml" +) + +type QmlApplication struct { + win *qml.Window + engine *qml.Engine + lib *UiLib + path string +} + +func NewQmlApplication(path string, lib *UiLib) *QmlApplication { + engine := qml.NewEngine() + return &QmlApplication{engine: engine, path: path, lib: lib} +} + +func (app *QmlApplication) Create() error { + component, err := app.engine.LoadFile(app.path) + if err != nil { + ethutil.Config.Log.Debugln(err) + } + app.win = component.CreateWindow(nil) + + return nil +} + +func (app *QmlApplication) Destroy() { + app.engine.Destroy() +} + +func (app *QmlApplication) NewWatcher(quitChan chan bool) { +} + +// Events +func (app *QmlApplication) NewBlock(block *ethchain.Block) { + pblock := ðpub.PBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Hex(block.Hash())} + app.win.Call("onNewBlockCb", pblock) +} + +func (app *QmlApplication) ObjectChanged(stateObject *ethchain.StateObject) { + app.win.Call("onObjectChangeCb", ethpub.NewPStateObject(stateObject)) +} + +func (app *QmlApplication) StorageChanged(storageObject *ethchain.StorageState) { + app.win.Call("onStorageChangeCb", ethpub.NewPStorageState(storageObject)) +} + +// Getters +func (app *QmlApplication) Engine() *qml.Engine { + return app.engine +} +func (app *QmlApplication) Window() *qml.Window { + return app.win +} diff --git a/ethereal/ui/ui_lib.go b/ethereal/ui/ui_lib.go index 791d4fe09..908497be3 100644 --- a/ethereal/ui/ui_lib.go +++ b/ethereal/ui/ui_lib.go @@ -35,18 +35,11 @@ func NewUiLib(engine *qml.Engine, eth *eth.Ethereum, assetPath string) *UiLib { return &UiLib{engine: engine, eth: eth, assetPath: assetPath} } -// Opens a QML file (external application) -func (ui *UiLib) Open(path string) { - component, err := ui.engine.LoadFile(path[7:]) - if err != nil { - ethutil.Config.Log.Debugln(err) - } - win := component.CreateWindow(nil) +func (ui *UiLib) OpenQml(path string) { + container := NewQmlApplication(path[7:], ui) + app := NewExtApplication(container, ui) - go func() { - win.Show() - win.Wait() - }() + go app.run() } func (ui *UiLib) OpenHtml(path string) { |