Minor updates to the UI

This commit is contained in:
obscuren 2014-08-23 11:00:15 +02:00
parent 5ac875b097
commit ded013b7a7
3 changed files with 115 additions and 40 deletions

View File

@ -44,59 +44,104 @@ Rectangle {
gui.setCustomIdentifier(text) gui.setCustomIdentifier(text)
} }
} }
TextArea {
objectName: "statsPane"
width: parent.width
height: 200
selectByMouse: true
readOnly: true
font.family: "Courier"
}
} }
property var addressModel: ListModel { RowLayout {
id: addressModel id: logLayout
}
TableView {
id: addressView
width: parent.width width: parent.width
height: 200 height: 200
anchors.bottom: logLayout.top anchors.bottom: parent.bottom
TableViewColumn{ role: "name"; title: "name" }
TableViewColumn{ role: "address"; title: "address"; width: 300}
model: addressModel TableView {
itemDelegate: Item { id: addressView
Text { width: parent.width
anchors { height: 200
left: parent.left anchors {
right: parent.right left: parent.left
leftMargin: 10 right: logLevelSlider.left
verticalCenter: parent.verticalCenter bottom: parent.bottom
} top: parent.top
color: styleData.textColor }
elide: styleData.elideMode TableViewColumn{ role: "name"; title: "name" }
text: styleData.value TableViewColumn{ role: "address"; title: "address"; width: 300}
font.pixelSize: 11
MouseArea {
acceptedButtons: Qt.LeftButton | Qt.RightButton
propagateComposedEvents: true
anchors.fill: parent
onClicked: {
addressView.selection.clear()
addressView.selection.select(styleData.row)
if(mouse.button == Qt.RightButton) { property var addressModel: ListModel {
contextMenu.row = styleData.row; id: addressModel
contextMenu.popup() }
model: addressModel
itemDelegate: Item {
Text {
anchors {
left: parent.left
right: parent.right
leftMargin: 10
verticalCenter: parent.verticalCenter
}
color: styleData.textColor
elide: styleData.elideMode
text: styleData.value
font.pixelSize: 11
MouseArea {
acceptedButtons: Qt.LeftButton | Qt.RightButton
propagateComposedEvents: true
anchors.fill: parent
onClicked: {
addressView.selection.clear()
addressView.selection.select(styleData.row)
if(mouse.button == Qt.RightButton) {
contextMenu.row = styleData.row;
contextMenu.popup()
}
} }
} }
} }
} }
Menu {
id: contextMenu
property var row;
MenuItem {
text: "Copy"
onTriggered: {
copyToClipboard(addressModel.get(this.row).address)
}
}
}
} }
Menu { Slider {
id: contextMenu id: logLevelSlider
property var row; value: gui.getLogLevelInt()
anchors {
right: parent.right
top: parent.top
bottom: parent.bottom
MenuItem { rightMargin: 5
text: "Copy" leftMargin: 5
onTriggered: { topMargin: 5
copyToClipboard(addressModel.get(this.row).address) bottomMargin: 5
} }
orientation: Qt.Vertical
maximumValue: 5
stepSize: 1
onValueChanged: {
gui.setLogLevel(value)
} }
} }
} }
@ -104,6 +149,8 @@ Rectangle {
property var logModel: ListModel { property var logModel: ListModel {
id: logModel id: logModel
} }
/*
RowLayout { RowLayout {
id: logLayout id: logLayout
width: parent.width width: parent.width
@ -147,6 +194,7 @@ Rectangle {
} }
} }
} }
*/
function addDebugMessage(message){ function addDebugMessage(message){
debuggerLog.append({value: message}) debuggerLog.append({value: message})

View File

@ -6,6 +6,7 @@ import (
"fmt" "fmt"
"math/big" "math/big"
"os" "os"
"runtime"
"strconv" "strconv"
"strings" "strings"
"time" "time"
@ -412,6 +413,7 @@ func (gui *Gui) update() {
peerUpdateTicker := time.NewTicker(5 * time.Second) peerUpdateTicker := time.NewTicker(5 * time.Second)
generalUpdateTicker := time.NewTicker(1 * time.Second) generalUpdateTicker := time.NewTicker(1 * time.Second)
statsUpdateTicker := time.NewTicker(5 * time.Second)
state := gui.eth.StateManager().TransState() state := gui.eth.StateManager().TransState()
@ -488,6 +490,10 @@ func (gui *Gui) update() {
pow := gui.miner.GetPow() pow := gui.miner.GetPow()
miningLabel.Set("text", "Mining @ "+strconv.FormatInt(pow.GetHashrate(), 10)+"Khash") miningLabel.Set("text", "Mining @ "+strconv.FormatInt(pow.GetHashrate(), 10)+"Khash")
} }
case <-statsUpdateTicker.C:
gui.setStatsPane()
} }
} }
}() }()
@ -507,6 +513,28 @@ func (gui *Gui) update() {
reactor.Subscribe("peerList", peerChan) reactor.Subscribe("peerList", peerChan)
} }
func (gui *Gui) setStatsPane() {
var memStats runtime.MemStats
runtime.ReadMemStats(&memStats)
statsPane := gui.getObjectByName("statsPane")
statsPane.Set("text", fmt.Sprintf(`###### Ethereal 0.6.4 (%s) #######
CPU: # %d
Goroutines: # %d
CGoCalls: # %d
Alloc: %d
Heap Alloc: %d
CGNext: %x
NumGC: %d
`, runtime.Version(), runtime.NumCPU, runtime.NumGoroutine(), runtime.NumCgoCall(),
memStats.Alloc, memStats.HeapAlloc,
memStats.NextGC, memStats.NumGC,
))
}
func (gui *Gui) CopyToClipboard(data string) { func (gui *Gui) CopyToClipboard(data string) {
//clipboard.WriteAll("test") //clipboard.WriteAll("test")
fmt.Println("COPY currently BUGGED. Here are the contents:\n", data) fmt.Println("COPY currently BUGGED. Here are the contents:\n", data)

View File

@ -71,7 +71,6 @@ func main() {
// This is a bit of a cheat, but ey! // This is a bit of a cheat, but ey!
os.Setenv("QTWEBKIT_INSPECTOR_SERVER", "127.0.0.1:99999") os.Setenv("QTWEBKIT_INSPECTOR_SERVER", "127.0.0.1:99999")
//qml.Init(nil)
qml.Run(run) qml.Run(run)
var interrupted = false var interrupted = false