Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
f6aabb7a
Commit
f6aabb7a
authored
Jun 23, 2014
by
Maran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implements QML Apps. Implements #47
You are welcome Stephan.
parent
2408e382
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
152 additions
and
35 deletions
+152
-35
QmlApp.qml
ethereal/assets/qml/QmlApp.qml
+22
-0
test_app.qml
ethereal/assets/qml/test_app.qml
+58
-23
wallet.qml
ethereal/assets/qml/wallet.qml
+9
-1
qml_app.go
ethereal/ui/qml_app.go
+59
-0
ui_lib.go
ethereal/ui/ui_lib.go
+4
-11
No files found.
ethereal/assets/qml/QmlApp.qml
0 → 100644
View file @
f6aabb7a
import
QtQuick
2.0
import
QtQuick
.
Controls
1.0
;
import
QtQuick
.
Layouts
1.0
;
import
Ethereum
1.0
ApplicationWindow
{
minimumWidth
:
500
maximumWidth
:
500
maximumHeight
:
400
minimumHeight
:
400
function
onNewBlockCb
(
block
)
{
console
.
log
(
"Please overwrite onNewBlock(block):"
,
block
)
}
function
onObjectChangeCb
(
stateObject
)
{
console
.
log
(
"Please overwrite onObjectChangeCb(object)"
,
stateObject
)
}
function
onStorageChangeCb
(
storageObject
)
{
var
ev
=
[
"storage"
,
storageObject
.
stateAddress
,
storageObject
.
address
].
join
(
":"
);
console
.
log
(
"Please overwrite onStorageChangeCb(object)"
,
ev
)
}
}
ethereal/assets/qml/test_app.qml
View file @
f6aabb7a
...
...
@@ -3,33 +3,68 @@ import QtQuick.Controls 1.0;
import
QtQuick
.
Layouts
1.0
;
import
Ethereum
1.0
ApplicationWindow
{
minimumWidth
:
50
0
maximumWidth
:
50
0
maximumHeight
:
10
0
minimumHeight
:
10
0
QmlApp
{
minimumWidth
:
35
0
maximumWidth
:
35
0
maximumHeight
:
8
0
minimumHeight
:
8
0
title
:
"
Ethereum Dice
"
title
:
"
Generic Coin
"
TextField
{
id
:
textField
anchors.verticalCenter
:
parent
.
verticalCenter
anchors.horizontalCenter
:
parent
.
horizontalCenter
placeholderText
:
"Amount"
property
string
contractAddr
:
"f299f6c74515620e4c4cd8fe3d205b5c4f2e25c8"
property
string
addr
:
"2ef47100e0787b915105fd5e3f4ff6752079d5cb"
Component.onCompleted
:
{
eth
.
watch
(
contractAddr
,
addr
)
eth
.
watch
(
addr
,
contractAddr
)
setAmount
()
}
function
onStorageChangeCb
(
storageObject
)
{
setAmount
()
}
Label
{
id
:
txHash
anchors.bottom
:
textField
.
top
anchors.bottomMargin
:
5
a
nchors.horizontalCenter
:
parent
.
horizontalCenter
function
setAmount
(){
var
state
=
eth
.
getStateObject
(
contractAddr
)
var
storage
=
state
.
getStorage
(
addr
)
a
mountLabel
.
text
=
storage
}
Button
{
anchors.top
:
textField
.
bottom
anchors.horizontalCenter
:
parent
.
horizontalCenter
anchors.topMargin
:
5
text
:
"Place bet"
onClicked
:
{
txHash
.
text
=
eth
.
createTx
(
"e6716f9544a56c530d868e4bfbacb172315bdead"
,
textField
.
text
)
Column
{
spacing
:
5
Row
{
spacing
:
20
Label
{
id
:
genLabel
text
:
"Generic coin balance:"
}
Label
{
id
:
amountLabel
}
}
Row
{
spacing
:
20
TextField
{
id
:
address
placeholderText
:
"Address"
}
TextField
{
id
:
amount
placeholderText
:
"Amount"
}
}
Button
{
text
:
"Send coins"
onClicked
:
{
var
privKey
=
eth
.
getKey
().
privateKey
if
(
privKey
){
var
result
=
eth
.
transact
(
privKey
,
contractAddr
,
0
,
"100000"
,
"250"
,
"0x"
+
address
.
text
+
"
\n
"
+
amount
.
text
)
resultTx
.
text
=
result
.
hash
}
}
}
Label
{
id
:
resultTx
}
}
}
ethereal/assets/qml/wallet.qml
View file @
f6aabb7a
...
...
@@ -372,7 +372,15 @@ ApplicationWindow {
onAccepted
:
{
//ui.open(openAppDialog.fileUrl.toString())
//ui.openHtml(Qt.resolvedUrl(ui.assetPath("test.html")))
ui
.
openHtml
(
openAppDialog
.
fileUrl
.
toString
())
var
path
=
openAppDialog
.
fileUrl
.
toString
()
console
.
log
(
path
)
var
ext
=
path
.
split
(
'.'
).
pop
()
console
.
log
(
ext
)
if
(
ext
==
"html"
||
ext
==
"htm"
)
{
ui
.
openHtml
(
path
)
}
else
if
(
ext
==
"qml"
){
ui
.
openQml
(
path
)
}
}
}
...
...
ethereal/ui/qml_app.go
0 → 100644
View file @
f6aabb7a
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
:=
&
ethpub
.
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
}
ethereal/ui/ui_lib.go
View file @
f6aabb7a
...
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment