aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/assets/qml/webapp.qml
blob: 4695903e8e8cc06fed7288304ed9313e822da42a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import QtQuick 2.0
import QtWebKit 3.0
import QtWebKit.experimental 1.0
import QtQuick.Controls 1.0;
import QtQuick.Layouts 1.0;
import QtQuick.Window 2.1;
import Ethereum 1.0

ApplicationWindow {
  id: window
  title: "Webapp"
  width: 900
  height: 600
  minimumHeight: 300
  property alias url: webview.url

  Item {
    id: root
    anchors.fill: parent
    state: "inspectorShown"

    WebView {
      id: webview
      anchors {
        left: parent.left
        right: parent.right
        bottom: sizeGrip.top
        top: parent.top
      }
      onTitleChanged: { window.title = title }
      experimental.preferences.javascriptEnabled: true
      experimental.preferences.navigatorQtObjectEnabled: true
      experimental.preferences.developerExtrasEnabled: true
      experimental.userScripts: [ui.assetPath("ethereum.js")]
      experimental.onMessageReceived: {
        console.log("[onMessageReceived]: ", message.data)
        var data = JSON.parse(message.data)

        webview.experimental.postMessage(JSON.stringify({data: {message: data.message}, _seed: data._seed}))
      }
    }

    Rectangle {
      id: sizeGrip
      color: "gray"
      visible: true
      height: 10
      anchors {
        left: root.left
        right: root.right
      }
      y: Math.round(root.height * 2 / 3)

      MouseArea {
        anchors.fill: parent
        drag.target: sizeGrip
        drag.minimumY: 0
        drag.maximumY: root.height
        drag.axis: Drag.YAxis
      }
    }

    WebView {
      id: inspector
      visible: true
      url: webview.experimental.remoteInspectorUrl
      anchors {
        left: root.left
        right: root.right
        top: sizeGrip.bottom
        bottom: root.bottom
      }
    }

    states: [
      State {
        name: "inspectorShown"
        PropertyChanges {
          target: inspector
          url: webview.experimental.remoteInspectorUrl
        }
      }
    ]
  }
}