Browse Source

Scenario Panel: UI changes

cl-refactor
yann300 9 years ago
parent
commit
8ec447166f
  1. 43
      mix/qml/Block.qml
  2. 46
      mix/qml/BlockChain.qml
  3. 41
      mix/qml/ScenarioButton.qml
  4. 13
      mix/qml/ScenarioExecution.qml
  5. 290
      mix/qml/ScenarioLoader.qml

43
mix/qml/Block.qml

@ -21,6 +21,7 @@ ColumnLayout
property int openedTr: 0 property int openedTr: 0
property int blockIndex property int blockIndex
property variant scenario property variant scenario
property string labelColor: "#414141"
function calculateHeight() function calculateHeight()
{ {
@ -41,18 +42,17 @@ ColumnLayout
height = calculateHeight() height = calculateHeight()
} }
RowLayout RowLayout
{ {
Layout.preferredHeight: trHeight Layout.preferredHeight: trHeight
Layout.preferredWidth: blockWidth Layout.preferredWidth: blockWidth
id: rowHeader id: rowHeader
Rectangle Rectangle
{ {
color: "#DEDCDC"
Layout.preferredWidth: blockWidth Layout.preferredWidth: blockWidth
Layout.preferredHeight: trHeight Layout.preferredHeight: trHeight
color: "#DEDCDC"
radius: 4 radius: 4
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: statusWidth + 5 anchors.leftMargin: statusWidth + 5
@ -60,12 +60,32 @@ ColumnLayout
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: horizontalMargin anchors.leftMargin: horizontalMargin
color: "#adadad"
text: text:
{ {
if (status === "mined") if (number === -2)
return qsTr("STARTING PARAMETERS")
else if (status === "mined")
return qsTr("BLOCK") + " " + number return qsTr("BLOCK") + " " + number
else else
return qsTr("BLOCK") + " pending" return qsTr("PENDING TRANSACTIONS")
}
}
Label
{
text: qsTr("EDIT")
color: "#1397da"
anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right
anchors.rightMargin: 14
MouseArea
{
anchors.fill: parent
onClicked:
{
// load edit block panel
}
} }
} }
} }
@ -75,7 +95,6 @@ ColumnLayout
{ {
id: transactionRepeater id: transactionRepeater
model: transactions model: transactions
RowLayout RowLayout
{ {
id: rowTransaction id: rowTransaction
@ -99,7 +118,7 @@ ColumnLayout
var p = log.param.get(i) var p = log.param.get(i)
logsText.text += p.name + " = " + p.value + " - indexed:" + p.indexed + "\n" logsText.text += p.name + " = " + p.value + " - indexed:" + p.indexed + "\n"
} }
else{ else {
logsText.text += "From : " + log.address + "\n" logsText.text += "From : " + log.address + "\n"
} }
} }
@ -112,18 +131,18 @@ ColumnLayout
{ {
id: trSaveStatus id: trSaveStatus
Layout.preferredWidth: statusWidth Layout.preferredWidth: statusWidth
Layout.preferredHeight: trHeight Layout.preferredHeight: parent.height
color: "transparent" color: "transparent"
anchors.top: parent.top anchors.top: parent.top
property bool saveStatus property bool saveStatus
Image { Image {
anchors.top: parent.top
anchors.topMargin: -7
id: saveStatusImage id: saveStatusImage
source: "qrc:/qml/img/recyclediscard@2x.png" source: "qrc:/qml/img/recyclediscard@2x.png"
width: statusWidth width: statusWidth
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
} }
Component.onCompleted: Component.onCompleted:
@ -177,6 +196,7 @@ ColumnLayout
Layout.preferredWidth: fromWidth Layout.preferredWidth: fromWidth
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: 1 maximumLineCount: 1
color: labelColor
text: { text: {
if (index >= 0) if (index >= 0)
return transactions.get(index).sender return transactions.get(index).sender
@ -195,6 +215,7 @@ ColumnLayout
return "" return ""
} }
elide: Text.ElideRight elide: Text.ElideRight
color: labelColor
maximumLineCount: 1 maximumLineCount: 1
Layout.preferredWidth: toWidth Layout.preferredWidth: toWidth
} }
@ -217,6 +238,7 @@ ColumnLayout
id: returnValue id: returnValue
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: 1 maximumLineCount: 1
color: labelColor
Layout.preferredWidth: valueWidth Layout.preferredWidth: valueWidth
text: { text: {
if (index >= 0 && transactions.get(index).returned) if (index >= 0 && transactions.get(index).returned)
@ -237,6 +259,7 @@ ColumnLayout
id: logs id: logs
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 10 anchors.leftMargin: 10
color: labelColor
text: { text: {
if (index >= 0 && transactions.get(index).logs && transactions.get(index).logs.count) if (index >= 0 && transactions.get(index).logs && transactions.get(index).logs.count)
return transactions.get(index).logs.count return transactions.get(index).logs.count

46
mix/qml/BlockChain.qml

@ -20,7 +20,7 @@ ColumnLayout {
signal chainChanged signal chainChanged
onChainChanged: { onChainChanged: {
reBuildNeeded.start() rebuild.startBlinking()
} }
onWidthChanged: onWidthChanged:
@ -55,12 +55,12 @@ ColumnLayout {
previousWidth = width previousWidth = width
} }
property int statusWidth: 30 property int statusWidth: 40
property int fromWidth: 100 property int fromWidth: 100
property int toWidth: 100 property int toWidth: 100
property int valueWidth: 200 property int valueWidth: 200
property int logsWidth: 50 property int logsWidth: 40
property int debugActionWidth: 50 property int debugActionWidth: 40
property int horizontalMargin: 10 property int horizontalMargin: 10
property int cellSpacing: 10 property int cellSpacing: 10
@ -68,12 +68,12 @@ ColumnLayout {
{ {
id: header id: header
spacing: 0 spacing: 0
Layout.preferredHeight: 25 Layout.preferredHeight: 30
Image { Image {
id: debugImage id: debugImage
source: "qrc:/qml/img/recycleicon@2x.png" source: "qrc:/qml/img/recycleicon@2x.png"
Layout.preferredWidth: statusWidth Layout.preferredWidth: statusWidth
Layout.preferredHeight: 25 Layout.preferredHeight: parent.height
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
} }
Rectangle Rectangle
@ -126,6 +126,19 @@ ColumnLayout {
id: blockChainLayout id: blockChainLayout
width: parent.width width: parent.width
spacing: 10 spacing: 10
Block
{
scenario: blockChainPanel.model
Layout.preferredWidth: blockChainScrollView.width
Layout.preferredHeight: 60
blockIndex: -1
transactions: []
status: ""
number: -2
trHeight: 60
}
Repeater // List of blocks Repeater // List of blocks
{ {
id: blockChainRepeater id: blockChainRepeater
@ -229,7 +242,7 @@ ColumnLayout {
{ {
if (ensureNotFuturetime.running) if (ensureNotFuturetime.running)
return; return;
reBuildNeeded.stop() stopBlinking()
var retBlocks = []; var retBlocks = [];
var bAdded = 0; var bAdded = 0;
for (var j = 0; j < model.blocks.length; j++) for (var j = 0; j < model.blocks.length; j++)
@ -282,23 +295,8 @@ ColumnLayout {
Layout.preferredHeight: 30 Layout.preferredHeight: 30
buttonShortcut: "" buttonShortcut: ""
sourceImg: "qrc:/qml/img/recycleicon@2x.png" sourceImg: "qrc:/qml/img/recycleicon@2x.png"
Timer
{
id: reBuildNeeded
repeat: true
interval: 1000
running: false
onTriggered: {
if (!parent.fillColor || parent.fillColor === "white")
parent.fillColor = "orange"
else
parent.fillColor = "white"
}
onRunningChanged: {
if (!running)
parent.fillColor = "white"
}
}
} }
ScenarioButton { ScenarioButton {

41
mix/qml/ScenarioButton.qml

@ -11,13 +11,52 @@ Rectangle {
property string fillColor property string fillColor
signal clicked signal clicked
function startBlinking()
{
blinkTimer.start()
}
function stopBlinking()
{
blinkTimer.stop()
}
Rectangle { Rectangle {
id: contentRectangle id: contentRectangle
anchors.fill: parent anchors.fill: parent
border.color: "#cccccc" border.color: "#cccccc"
border.width: 1 border.width: 1
radius: 4 radius: 4
color: parent.fillColor ? parent.fillColor : "white" color: "white"
property variant colorGradient: ["#FFFFFF", "#FFFEFC", "#FFFDF9", "#FFFCF7", "#FFFBF4", "#FFFAF2", "#FFF9EF", "#FFF8EC", "#FFF7EA", "#FFF6E7", "#FFF5E5", "#FFF5E2", "#FFF4E0", "#FFF3DD", "#FFF2DA", "#FFF1D8", "#FFF0D5", "#FFEFD3", "#FFEED0", "#FFEDCE", "#FFECCB", "#FFEBC8", "#FFEBC6", "#FFEAC3", "#FFE9C1", "#FFE8BE", "#FFE7BC", "#FFE6B9", "#FFE5B6", "#FFE4B4", "#FFE3B1", "#FFE2AF", "#FFE1AC", "#FFE1AA", "#FFE0A7", "#FFDFA4", "#FFDEA2", "#FFDD9F", "#FFDC9D", "#FFDB9A", "#FFDA97", "#FFD995", "#FFD892", "#FFD790", "#FFD78D", "#FFD68B", "#FFD588", "#FFD485", "#FFD383", "#FFD280", "#FFD17E", "#FFD07B", "#FFCF79", "#FFCE76", "#FFCD73", "#FFCD71", "#FFCC6E", "#FFCB6C", "#FFCA69", "#FFC967", "#FFC864", "#FFC761", "#FFC65F", "#FFC55C", "#FFC45A", "#FFC357", "#FFC355", "#FFC252", "#FFC14F", "#FFC04D", "#FFBF4A", "#FFBE48", "#FFBD45", "#FFBC42", "#FFBB40", "#FFBA3D", "#FFB93B", "#FFB938", "#FFB836", "#FFB733", "#FFB630", "#FFB52E", "#FFB42B", "#FFB329", "#FFB226", "#FFB124", "#FFB021", "#FFAF1E", "#FFAF1C", "#FFAE19", "#FFAD17", "#FFAC14", "#FFAB12", "#FFAA0F", "#FFA90C", "#FFA80A", "#FFA707", "#FFA605", "#FFA502", "#FFA500"]
Timer
{
id: blinkTimer
repeat: true
interval: 40
running: false
property int index: 0
property int direction: 1
onTriggered: {
index = index + direction
parent.color = parent.colorGradient[index]
if (index >= parent.colorGradient.length - 1)
direction = -1
else if (index <= 0)
direction = 1
}
onRunningChanged: {
if (!running)
{
parent.color = "white"
index = 0
direction = 1
}
}
}
Image { Image {
id: debugImage id: debugImage
anchors { anchors {

13
mix/qml/ScenarioExecution.qml

@ -28,14 +28,23 @@ Rectangle {
spacing: 10 spacing: 10
ScenarioLoader ScenarioLoader
{ {
height: 70 height: 100
width: parent.width width: parent.width
id: loader id: loader
} }
Connections
{
target: blockChain
onChainChanged:
{
loader.needSaveOrReload()
}
}
Rectangle Rectangle
{ {
width: parent.width width: parent.parent.width
height: 1 height: 1
color: "#cccccc" color: "#cccccc"
} }

290
mix/qml/ScenarioLoader.qml

@ -10,8 +10,9 @@ import "js/Debugger.js" as Debugger
import "js/ErrorLocationFormater.js" as ErrorLocationFormater import "js/ErrorLocationFormater.js" as ErrorLocationFormater
import "." import "."
RowLayout ColumnLayout
{ {
id: blockChainSelector
signal restored(variant scenario) signal restored(variant scenario)
signal saved(variant scenario) signal saved(variant scenario)
signal duplicated(variant scenario) signal duplicated(variant scenario)
@ -22,154 +23,209 @@ RowLayout
scenarioList.load() scenarioList.load()
} }
id: blockChainSelector function needSaveOrReload()
{
Dialog { editStatus.visible = true
id: newStateWin }
modality: Qt.ApplicationModal
title: qsTr("New Project");
width: 320
height: 120
visible: false //anchors.margins: 10
//width: parent.width
Rectangle
{
Layout.fillWidth: true
Layout.preferredHeight: 30
color: "transparent"
Rectangle
{
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
color: "transparent"
Text
{
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
id: scenarioName
}
contentItem: Rectangle { TextInput
anchors.fill: parent {
anchors.margins: 10 id: scenarioNameEdit
RowLayout { visible: false
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
Text { anchors.horizontalCenter: parent.horizontalCenter
text: qsTr("Name:") Keys.onEnterPressed:
{
save()
} }
Rectangle function edit()
{ {
Layout.preferredWidth: 250 editIconRect.anchors.left = scenarioNameEdit.right
Layout.preferredHeight: parent.height editStatus.parent.anchors.left = scenarioNameEdit.right
border.width: 1 scenarioNameEdit.forceActiveFocus()
border.color: "#cccccc" }
TextInput
{ function save()
anchors.fill: parent {
id: stateName editIconRect.anchors.left = scenarioName.right
} editStatus.parent.anchors.left = scenarioName.right
scenarioName.text = scenarioNameEdit.text
scenarioName.visible = true
scenarioNameEdit.visible = false
projectModel.stateListModel.getState(scenarioList.currentIndex).title = scenarioName.text
projectModel.saveProjectFile()
saved(state)
} }
} }
RowLayout
Connections
{ {
anchors.bottom: parent.bottom target: blockChainSelector
anchors.right: parent.right; onLoaded:
function acceptAndClose()
{ {
var item = projectModel.stateListModel.createDefaultState(); scenarioName.text = scenario.title
item.title = stateName.text scenarioNameEdit.text = scenario.title
projectModel.stateListModel.appendState(item)
projectModel.stateListModel.save()
close()
scenarioList.currentIndex = projectModel.stateListModel.count - 1
} }
}
function close() Rectangle
{ {
newStateWin.close() anchors.left: scenarioName.right
stateName.text = "" anchors.top: scenarioName.top
anchors.leftMargin: 2
Layout.preferredWidth: 20
Text {
id: editStatus
text: "*"
visible: false
} }
}
Button { Rectangle
id: okButton; {
enabled: stateName.text !== "" id: editIconRect
text: qsTr("OK"); anchors.left: scenarioName.right
onClicked: { anchors.leftMargin: 15
parent.acceptAndClose(); Image {
source: "qrc:/qml/img/edit.png"
width: 10
fillMode: Image.PreserveAspectFit
anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter
MouseArea
{
anchors.fill: parent
onClicked:
{
scenarioName.visible = !scenarioName.visible
scenarioNameEdit.visible = !scenarioNameEdit.visible
if (!scenarioNameEdit.visible)
scenarioNameEdit.save()
else
scenarioNameEdit.edit()
}
} }
} }
Button {
text: qsTr("Cancel");
onClicked: parent.close();
}
} }
} }
} }
ComboBox RowLayout
{ {
id: scenarioList Layout.fillWidth: true
model: projectModel.stateListModel Layout.preferredHeight: 50
textRole: "title" spacing: 0
onCurrentIndexChanged:
{
restoreScenario.restore()
}
function load() Row
{ {
var state = projectModel.stateListModel.getState(currentIndex) Layout.preferredWidth: 100 * 5
loaded(state) Layout.preferredHeight: 50
} spacing: 0
}
Row ComboBox
{
Layout.preferredWidth: 100 * 4
Layout.preferredHeight: 30
spacing: 0
ScenarioButton {
id: restoreScenario
width: 100
height: 30
buttonShortcut: ""
sourceImg: "qrc:/qml/img/restoreicon@2x.png"
onClicked: {
restore()
}
text: qsTr("Restore")
function restore()
{ {
var state = projectModel.stateListModel.reloadStateFromFromProject(scenarioList.currentIndex) id: scenarioList
restored(state) model: projectModel.stateListModel
loaded(state) textRole: "title"
height: 30
onCurrentIndexChanged:
{
restoreScenario.restore()
}
function load()
{
var state = projectModel.stateListModel.getState(currentIndex)
loaded(state)
}
}
ScenarioButton {
id: restoreScenario
width: 100
height: 30
buttonShortcut: ""
sourceImg: "qrc:/qml/img/restoreicon@2x.png"
onClicked: {
restore()
}
text: qsTr("Restore")
function restore()
{
var state = projectModel.stateListModel.reloadStateFromFromProject(scenarioList.currentIndex)
if (state)
{
editStatus.visible = false
restored(state)
loaded(state)
}
}
} }
}
ScenarioButton { ScenarioButton {
id: saveScenario id: saveScenario
text: qsTr("Save") text: qsTr("Save")
onClicked: { onClicked: {
projectModel.saveProjectFile() projectModel.saveProjectFile()
saved(state) saved(state)
}
width: 100
height: 30
buttonShortcut: ""
sourceImg: "qrc:/qml/img/saveicon@2x.png"
} }
width: 100
height: 30
buttonShortcut: ""
sourceImg: "qrc:/qml/img/saveicon@2x.png"
}
ScenarioButton ScenarioButton
{ {
id: duplicateScenario id: duplicateScenario
text: qsTr("Duplicate") text: qsTr("Duplicate")
onClicked: { onClicked: {
projectModel.stateListModel.duplicateState(scenarioList.currentIndex) projectModel.stateListModel.duplicateState(scenarioList.currentIndex)
duplicated(state) duplicated(state)
}
width: 100
height: 30
buttonShortcut: ""
sourceImg: "qrc:/qml/img/duplicateicon@2x.png"
} }
width: 100
height: 30
buttonShortcut: ""
sourceImg: "qrc:/qml/img/duplicateicon@2x.png"
}
ScenarioButton { ScenarioButton {
id: addScenario id: addScenario
width: 100 width: 100
height: 30 height: 30
buttonShortcut: "" buttonShortcut: ""
sourceImg: "qrc:/qml/img/plus.png" sourceImg: "qrc:/qml/img/plus.png"
onClicked: { onClicked: {
newStateWin.open() var item = projectModel.stateListModel.createDefaultState();
item.title = qsTr("New Scenario")
projectModel.stateListModel.appendState(item)
projectModel.stateListModel.save()
scenarioList.currentIndex = projectModel.stateListModel.count - 1
scenarioNameEdit.edit()
}
text: qsTr("New")
} }
text: qsTr("New")
} }
} }
} }

Loading…
Cancel
Save