Browse Source

qml: Initial QML to test QObject property binding, ListModels, Camera

patch-4
Sander van Grieken 4 years ago
parent
commit
3dce09328e
  1. 41
      electrum/gui/qml/components/EButton.qml
  2. 60
      electrum/gui/qml/components/landing.qml
  3. 35
      electrum/gui/qml/components/main.qml
  4. 58
      electrum/gui/qml/components/scan.qml
  5. 14
      electrum/gui/qml/components/splash.qml
  6. 39
      electrum/gui/qml/components/tx.qml

41
electrum/gui/qml/components/EButton.qml

@ -0,0 +1,41 @@
import QtQuick 2.6
Item {
id: rootItem
width: visbut.width + 10
height: visbut.height + 10
signal clicked
property string text
Rectangle {
id: visbut
border {
color: '#444444'
width: 2
}
color: '#dddddd'
radius: 4
anchors.centerIn: parent
width: buttonText.width
height: buttonText.height
MouseArea {
anchors.fill: parent
onClicked: rootItem.clicked()
}
}
Text {
id: buttonText
leftPadding: 30
rightPadding: 30
topPadding: 20
bottomPadding: 20
verticalAlignment: Text.AlignVCenter
text: rootItem.text
color: 'red'
}
}

60
electrum/gui/qml/components/landing.qml

@ -0,0 +1,60 @@
import QtQuick 2.6
import QtQuick.Controls 1.4
import QtQml 2.6
Item {
Column {
width: parent.width
Row {
Text { text: "Server: " }
Text { text: Network.server }
}
Row {
Text { text: "Local Height: " }
Text { text: Network.height }
}
Row {
Text { text: "Status: " }
Text { text: Network.status }
}
Row {
Text { text: "Wallet: " }
Text { text: Daemon.walletName }
}
EButton {
text: 'Scan QR Code'
onClicked: app.stack.push(Qt.resolvedUrl('scan.qml'))
}
EButton {
text: 'Show TXen'
onClicked: app.stack.push(Qt.resolvedUrl('tx.qml'))
}
ListView {
width: parent.width
height: 200
model: Daemon.activeWallets
delegate: Item {
width: parent.width
Row {
Rectangle {
width: 10
height: parent.height
color: 'red'
}
Text {
leftPadding: 20
text: model.display
}
}
}
}
}
}

35
electrum/gui/qml/components/main.qml

@ -0,0 +1,35 @@
import QtQuick 2.6
import QtQuick.Controls 1.4
import QtQml 2.6
import QtMultimedia 5.6
ApplicationWindow
{
id: app
visible: true
width: 480
height: 800
color: '#dddddd'
property alias stack: mainStackView
StackView {
id: mainStackView
anchors.fill: parent
initialItem: Qt.resolvedUrl('splash.qml')
}
Timer {
id: splashTimer
interval: 400
onTriggered: {
mainStackView.push(Qt.resolvedUrl('landing.qml'))
}
}
Component.onCompleted: {
Daemon.load_wallet()
splashTimer.start()
}
}

58
electrum/gui/qml/components/scan.qml

@ -0,0 +1,58 @@
import QtQuick 2.6
import QtMultimedia 5.6
Item {
Column {
width: parent.width
Item {
id: voc
width: parent.width
height: parent.width
VideoOutput {
id: vo
anchors.fill: parent
source: camera
//fillMode: VideoOutput.PreserveAspectCrop
}
MouseArea {
anchors.fill: parent
onClicked: {
vo.grabToImage(function(result) {
console.log("grab: image=" + (result.image !== undefined) + " url=" + result.url)
if (result.image !== undefined) {
console.log('scanning image for QR')
QR.scanImage(result.image)
}
})
}
}
}
EButton {
text: 'Exit'
onClicked: app.stack.pop()
}
}
Camera {
id: camera
deviceId: QtMultimedia.defaultCamera.deviceId
viewfinder.resolution: "640x480"
function dumpstats() {
console.log(camera.viewfinder.resolution)
console.log(camera.viewfinder.minimumFrameRate)
console.log(camera.viewfinder.maximumFrameRate)
var resolutions = camera.supportedViewfinderResolutions()
resolutions.forEach(function(item, i) {
console.log('' + item.width + 'x' + item.height)
})
}
}
}

14
electrum/gui/qml/components/splash.qml

@ -0,0 +1,14 @@
import QtQuick 2.0
Item {
Rectangle {
anchors.fill: parent
color: '#111111'
}
Image {
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
source: "../../icons/electrum.png"
}
}

39
electrum/gui/qml/components/tx.qml

@ -0,0 +1,39 @@
import QtQuick 2.6
Item {
id: rootItem
// height: 800
Column {
width: parent.width
// height: parent.height
Text {
text: "Transactions"
}
ListView {
width: parent.width
height: 200
// anchors.bottom: rootItem.bottom
model: Daemon.currentWallet.historyModel
delegate: Item {
width: parent.width
height: line.height
Row {
id: line
Rectangle {
width: 10
height: parent.height
color: 'blue'
}
Text {
leftPadding: 20
text: model.display
}
}
}
}
}
}
Loading…
Cancel
Save