You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

425 lines
9.3 KiB

10 years ago
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Layouts 1.1
import QtQuick.Controls.Styles 1.3
import org.ethereum.qml.InverseMouseArea 1.0
10 years ago
import "js/ErrorLocationFormater.js" as ErrorLocationFormater
import "."
10 years ago
Rectangle {
10 years ago
id: statusHeader
objectName: "statusPane"
property variant webPreview
10 years ago
property alias currentStatus: logPane.currentStatus
function updateStatus(message)
10 years ago
{
if (!message)
10 years ago
{
status.state = "";
status.text = qsTr("Compile successfully.");
debugImg.state = "active";
10 years ago
currentStatus = { "type": "Comp", "date": Qt.formatDateTime(new Date(), "hh:mm:ss"), "content": status.text, "level": "info" }
10 years ago
}
else
{
status.state = "error";
var errorInfo = ErrorLocationFormater.extractErrorInfo(message, true);
10 years ago
status.text = errorInfo.errorLocation + " " + errorInfo.errorDetail;
debugImg.state = "";
10 years ago
currentStatus = { "type": "Comp", "date": Qt.formatDateTime(new Date(), "hh:mm:ss"), "content": status.text, "level": "error" }
10 years ago
}
}
10 years ago
function infoMessage(text, type)
10 years ago
{
status.state = "";
status.text = text
10 years ago
logPane.push("info", type, text);
10 years ago
currentStatus = { "type": type, "date": Qt.formatDateTime(new Date(), "hh:mm:ss"), "content": text, "level": "info" }
10 years ago
}
function warningMessage(text, type)
{
10 years ago
status.state = "warning";
status.text = text
logPane.push("warning", type, text);
10 years ago
currentStatus = { "type": type, "date": Qt.formatDateTime(new Date(), "hh:mm:ss"), "content": text, "level": "warning" }
}
function errorMessage(text, type)
{
status.state = "error";
status.text = text;
logPane.push("error", type, text);
10 years ago
currentStatus = { "type": type, "date": Qt.formatDateTime(new Date(), "hh:mm:ss"), "content": text, "level": "error" }
}
function clear()
{
status.state = "";
status.text = "";
}
StatusPaneStyle {
id: statusPaneStyle
}
Connections {
target: webPreview
10 years ago
onJavaScriptMessage:
{
if (_level === 0)
infoMessage(_content, "JavaScript")
else
{
var message = _sourceId.substring(_sourceId.lastIndexOf("/") + 1) + " - " + qsTr("line") + " " + _lineNb + " - " + _content;
if (_level === 1)
warningMessage(message, "JavaScript")
10 years ago
else
10 years ago
errorMessage(message, "JavaScript")
}
}
}
10 years ago
Connections {
target:clientModel
onRunStarted:
{
logPane.clear()
infoMessage(qsTr("Running transactions..."), "Run");
}
10 years ago
onRunFailed: errorMessage(format(_message), "Run");
onRunComplete: infoMessage(qsTr("Run complete"), "Run");
onNewBlock: infoMessage(qsTr("New block created"), "State");
function format(_message)
{
var formatted = _message.match(/(?:<dev::eth::)(.+)(?:>)/);
if (!formatted)
formatted = _message.match(/(?:<dev::)(.+)(?:>)/);
10 years ago
if (formatted && formatted.length > 1)
formatted = formatted[1];
else
return _message;
var exceptionInfos = _message.match(/(?:tag_)(.+)/g);
if (exceptionInfos !== null && exceptionInfos.length > 0)
formatted += ": "
for (var k in exceptionInfos)
10 years ago
formatted += " " + exceptionInfos[k].replace("*]", "").replace("tag_", "").replace("=", "");
return formatted;
}
10 years ago
}
10 years ago
Connections {
target:projectModel
10 years ago
onDeploymentStarted: infoMessage(qsTr("Running deployment..."), "Deployment");
onDeploymentError: errorMessage(error, "Deployment");
onDeploymentComplete: infoMessage(qsTr("Deployment complete"), "Deployment");
onDeploymentStepChanged: infoMessage(message, "Deployment");
10 years ago
}
Connections {
target: codeModel
10 years ago
onCompilationComplete:
{
goToLine.visible = false;
updateStatus();
}
onCompilationError:
{
goToLine.visible = true
updateStatus(_error);
}
}
10 years ago
color: "transparent"
10 years ago
anchors.fill: parent
10 years ago
Rectangle {
id: statusContainer
10 years ago
anchors.horizontalCenter: parent.horizontalCenter
10 years ago
anchors.verticalCenter: parent.verticalCenter
10 years ago
radius: 3
10 years ago
width: 600
10 years ago
height: 30
color: "#fcfbfc"
Text {
anchors.verticalCenter: parent.verticalCenter
10 years ago
anchors.horizontalCenter: parent.horizontalCenter
font.pointSize: appStyle.absoluteSize(-1)
font.family: "sans serif"
objectName: "status"
wrapMode: Text.WrapAnywhere
elide: Text.ElideRight
maximumLineCount: 1
clip: true
id: status
states: [
State {
name: "error"
PropertyChanges {
target: status
color: "red"
}
PropertyChanges {
target: statusContainer
color: "#fffcd5"
}
10 years ago
},
State {
name: "warning"
PropertyChanges {
target: status
color: "orange"
}
PropertyChanges {
target: statusContainer
color: "#fffcd5"
}
}
]
onTextChanged:
{
updateWidth()
toolTipInfo.tooltip = text;
}
function updateWidth()
{
if (text.length > 80)
width = parent.width - 10
else
width = undefined
}
}
Button
{
anchors.fill: parent
id: toolTip
action: toolTipInfo
text: ""
z: 3;
style:
ButtonStyle {
background:Rectangle {
color: "transparent"
}
}
MouseArea {
anchors.fill: parent
onClicked: {
var globalCoord = goToLineBtn.mapToItem(statusContainer, 0, 0);
if (mouseX > globalCoord.x
&& mouseX < globalCoord.x + goToLineBtn.width
&& mouseY > globalCoord.y
&& mouseY < globalCoord.y + goToLineBtn.height)
goToCompilationError.trigger(goToLineBtn);
else
logsContainer.toggle();
10 years ago
}
}
}
Rectangle
{
visible: false
color: "transparent"
width: 40
height: parent.height
anchors.top: parent.top
anchors.left: status.right
anchors.leftMargin: 15
id: goToLine
RowLayout
{
10 years ago
anchors.fill: parent
Rectangle
{
color: "transparent"
anchors.fill: parent
Button
{
z: 4
anchors.centerIn: parent
id: goToLineBtn
text: ""
width: 30
height: 30
action: goToCompilationError
style: ButtonStyle {
background: Rectangle {
color: "transparent"
Image {
source: "qrc:/qml/img/warningicon.png"
height: 30
width: 30
sourceSize.width: 30
sourceSize.height: 30
anchors.centerIn: parent
}
}
}
}
10 years ago
}
}
10 years ago
}
Action {
id: toolTipInfo
tooltip: ""
}
10 years ago
Rectangle
{
id: logsShadow
width: logsContainer.width + 5
height: 0
opacity: 0.3
clip: true
anchors.top: logsContainer.top
anchors.margins: 4
Rectangle {
color: "gray"
anchors.top: parent.top
radius: 10
id: roundRect
height: 400
width: parent.width
}
}
Rectangle
{
InverseMouseArea
{
id: outsideClick
anchors.fill: parent
active: false
onClickedOutside: {
logsContainer.toggle();
}
}
function toggle()
{
if (logsContainer.state === "opened")
{
statusContainer.visible = true
logsContainer.state = "closed"
}
else
{
statusContainer.visible = false
logsContainer.state = "opened";
10 years ago
logsContainer.focus = true;
forceActiveFocus();
calCoord()
move()
}
}
id: logsContainer
width: 750
anchors.top: statusContainer.bottom
10 years ago
anchors.topMargin: 4
visible: false
10 years ago
radius: 10
function calCoord()
{
if (!logsContainer.parent.parent)
return
var top = logsContainer;
while (top.parent)
top = top.parent
var coordinates = logsContainer.mapToItem(top, 0, 0);
logsContainer.parent = top;
10 years ago
logsShadow.parent = top;
top.onWidthChanged.connect(move)
top.onHeightChanged.connect(move)
}
function move()
{
var statusGlobalCoord = status.mapToItem(null, 0, 0);
logsContainer.x = statusGlobalCoord.x - logPane.contentXPos
logsShadow.x = statusGlobalCoord.x - logPane.contentXPos
10 years ago
logsShadow.z = 1
logsContainer.z = 2
10 years ago
if (Qt.platform.os === "osx")
10 years ago
{
logsContainer.y = statusGlobalCoord.y;
logsShadow.y = statusGlobalCoord.y;
10 years ago
}
}
LogsPaneStyle {
id: logStyle
}
LogsPane
{
id: logPane;
statusPane: statusHeader
onContentXPosChanged:
{
parent.move();
}
}
10 years ago
states: [
State {
name: "opened";
PropertyChanges { target: logsContainer; height: 500; visible: true }
10 years ago
PropertyChanges { target: logsShadow; height: 500; visible: true }
PropertyChanges { target: outsideClick; active: true }
},
State {
name: "closed";
PropertyChanges { target: logsContainer; height: 0; visible: false }
10 years ago
PropertyChanges { target: statusContainer; width: 600; height: 30 }
PropertyChanges { target: outsideClick; active: false }
10 years ago
PropertyChanges { target: logsShadow; height: 0; visible: false }
}
]
transitions: Transition {
NumberAnimation { properties: "height"; easing.type: Easing.InOutQuad; duration: 200 }
10 years ago
NumberAnimation { target: logsContainer; properties: "visible"; easing.type: Easing.InOutQuad; duration: 200 }
}
}
10 years ago
}
10 years ago
Rectangle
{
color: "transparent"
width: 100
height: parent.height
anchors.top: parent.top
anchors.right: parent.right
10 years ago
RowLayout
{
anchors.fill: parent
Rectangle
{
10 years ago
color: "transparent"
anchors.fill: parent
Button
{
anchors.right: parent.right
anchors.rightMargin: 9
10 years ago
anchors.verticalCenter: parent.verticalCenter
id: debugImg
text: ""
10 years ago
iconSource: "qrc:/qml/img/bugiconactive.png"
action: showHideRightPanelAction
10 years ago
}
}
}
}
10 years ago
}