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.

649 lines
15 KiB

import QtQuick 2.0
import QtQuick.Layouts 1.0
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.3
import org.ethereum.qml.SortFilterProxyModel 1.0
Rectangle
{
property variant statusPane
property variant currentStatus
property int contentXPos: logStyle.generic.layout.dateWidth + logStyle.generic.layout.typeWidth - 70
function clear()
{
logsModel.clear();
statusPane.clear();
currentStatus = undefined;
}
function push(_level, _type, _content)
{
_content = _content.replace(/\n/g, " ")
logsModel.insert(0, { "type": _type, "date": Qt.formatDateTime(new Date(), "hh:mm:ss"), "content": _content, "level": _level });
}
10 years ago
onVisibleChanged:
10 years ago
{
if (currentStatus && visible && (logsModel.count === 0 || logsModel.get(0).content !== currentStatus.content || logsModel.get(0).date !== currentStatus.date))
10 years ago
logsModel.insert(0, { "type": currentStatus.type, "date": currentStatus.date, "content": currentStatus.content, "level": currentStatus.level });
else if (!visible)
{
for (var k = 0; k < logsModel.count; k++)
{
if (logsModel.get(k).type === "Comp") //do not keep compilation logs.
logsModel.remove(k);
}
}
}
anchors.fill: parent
10 years ago
radius: 10
color: "transparent"
id: logsPane
Column {
10 years ago
z: 2
height: parent.height - rowAction.height
width: parent.width
spacing: 0
ListModel {
id: logsModel
}
ScrollView
{
id: scrollView
height: parent.height
width: parent.width
horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
10 years ago
Column
{
id: logsRect
spacing: 0
Repeater {
10 years ago
id: logsRepeater
clip: true
10 years ago
property string frontColor: "transparent"
model: SortFilterProxyModel {
id: proxyModel
source: logsModel
property var roles: ["-", "javascript", "run", "state", "comp", "deployment"]
Component.onCompleted: {
filterType = regEx(proxyModel.roles);
}
function search(_value)
{
filterContent = _value;
}
function toogleFilter(_value)
{
var count = roles.length;
for (var i in roles)
{
if (roles[i] === _value)
{
roles.splice(i, 1);
break;
}
}
if (count === roles.length)
roles.push(_value);
filterType = regEx(proxyModel.roles);
}
function regEx(_value)
{
return "(?:" + roles.join('|') + ")";
}
filterType: "(?:javascript|run|state|comp|deployment)"
filterContent: ""
filterSyntax: SortFilterProxyModel.RegExp
filterCaseSensitivity: Qt.CaseInsensitive
}
Rectangle
{
width: logStyle.generic.layout.dateWidth + logStyle.generic.layout.contentWidth + logStyle.generic.layout.typeWidth
height: 30
color:
{
10 years ago
var cl;
if (level === "warning" || level === "error")
cl = logStyle.generic.layout.errorColor;
else
cl = index % 2 === 0 ? "transparent" : logStyle.generic.layout.logAlternateColor;
10 years ago
if (index === 0)
logsRepeater.frontColor = cl;
return cl;
}
Component.onCompleted:
{
logsPane.contentXPos = logContent.x
}
10 years ago
10 years ago
MouseArea
{
anchors.fill: parent
onClicked:
{
if (logContent.elide === Text.ElideNone)
{
logContent.elide = Text.ElideRight;
logContent.wrapMode = Text.NoWrap
parent.height = 30;
}
else
{
logContent.elide = Text.ElideNone;
logContent.wrapMode = Text.WordWrap;
parent.height = logContent.lineCount * 30;
}
}
}
DefaultLabel {
id: dateLabel
text: date;
font.family: logStyle.generic.layout.logLabelFont
width: logStyle.generic.layout.dateWidth
font.pointSize: appStyle.absoluteSize(-1)
clip: true
elide: Text.ElideRight
anchors.left: parent.left
anchors.leftMargin: 15
anchors.verticalCenter: parent.verticalCenter
color: {
parent.getColor(level);
}
}
DefaultLabel {
text: type;
id: typeLabel
font.family: logStyle.generic.layout.logLabelFont
width: logStyle.generic.layout.typeWidth
clip: true
elide: Text.ElideRight
font.pointSize: appStyle.absoluteSize(-1)
anchors.left: dateLabel.right
anchors.leftMargin: 2
anchors.verticalCenter: parent.verticalCenter
color: {
parent.getColor(level);
}
}
10 years ago
Text {
id: logContent
text: content;
font.family: logStyle.generic.layout.logLabelFont
width: logStyle.generic.layout.contentWidth
font.pointSize: appStyle.absoluteSize(-1)
anchors.verticalCenter: parent.verticalCenter
10 years ago
elide: Text.ElideRight
anchors.left: typeLabel.right
anchors.leftMargin: 2
color: {
parent.getColor(level);
}
}
function getColor()
{
if (level === "error")
return "red";
else if (level === "warning")
return "orange";
else
return "#808080";
}
}
}
}
}
Component {
id: itemDelegate
DefaultLabel {
text: styleData.value;
font.family: logStyle.generic.layout.logLabelFont
font.pointSize: appStyle.absoluteSize(-1)
color: {
if (proxyModel.get(styleData.row).level === "error")
return "red";
else if (proxyModel.get(styleData.row).level === "warning")
return "orange";
else
return "#808080";
}
}
}
}
Rectangle
{
gradient: Gradient {
GradientStop { position: 0.0; color: "#f1f1f1" }
GradientStop { position: 1.0; color: "#d9d7da" }
}
Layout.preferredHeight: logStyle.generic.layout.headerHeight
height: logStyle.generic.layout.headerHeight
width: logsPane.width
anchors.bottom: parent.bottom
Row
{
id: rowAction
anchors.leftMargin: logStyle.generic.layout.leftMargin
anchors.left: parent.left
spacing: logStyle.generic.layout.headerButtonSpacing
height: parent.height
Rectangle
{
color: "transparent"
10 years ago
height: parent.height
width: 40
DefaultLabel
{
width: 40
elide: Text.ElideRight
10 years ago
anchors.verticalCenter: parent.verticalCenter
color: logStyle.generic.layout.logLabelColor
font.pointSize: appStyle.absoluteSize(-3)
font.family: logStyle.generic.layout.logLabelFont
text: qsTr("Show:")
}
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: 1;
height: parent.height
color: logStyle.generic.layout.buttonSeparatorColor1
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
10 years ago
width: 2;
height: parent.height
color: logStyle.generic.layout.buttonSeparatorColor2
}
ToolButton {
id: javascriptButton
checkable: true
height: logStyle.generic.layout.headerButtonHeight
width: 30
anchors.verticalCenter: parent.verticalCenter
checked: true
onCheckedChanged: {
proxyModel.toogleFilter("javascript")
}
tooltip: qsTr("JavaScript")
style:
10 years ago
ButtonStyle {
label:
Item {
Rectangle
{
width: labelJs.width
height: labelJs.height
anchors.centerIn: parent
color: "transparent"
DefaultLabel {
id: labelJs
width: 15
elide: Text.ElideRight
anchors.horizontalCenter: parent.horizontalCenter
font.family: logStyle.generic.layout.logLabelFont
font.pointSize: appStyle.absoluteSize(-3)
color: logStyle.generic.layout.logLabelColor
text: qsTr("JS")
}
}
}
background:
Rectangle {
color: javascriptButton.checked ? logStyle.generic.layout.buttonSelected : "transparent"
}
10 years ago
}
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: 1;
height: parent.height
color: logStyle.generic.layout.buttonSeparatorColor1
10 years ago
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
10 years ago
width: 2;
10 years ago
height: parent.height
color: logStyle.generic.layout.buttonSeparatorColor2
}
10 years ago
ToolButton {
id: runButton
checkable: true
height: logStyle.generic.layout.headerButtonHeight
width: 40
10 years ago
anchors.verticalCenter: parent.verticalCenter
checked: true
onCheckedChanged: {
proxyModel.toogleFilter("run")
}
tooltip: qsTr("Run")
style:
ButtonStyle {
label:
Item {
Rectangle
{
width: labelRun.width
height: labelRun.height
10 years ago
anchors.centerIn: parent
color: "transparent"
DefaultLabel {
id: labelRun
width: 25
anchors.horizontalCenter: parent.horizontalCenter
elide: Text.ElideRight
font.family: logStyle.generic.layout.logLabelFont
font.pointSize: appStyle.absoluteSize(-3)
color: logStyle.generic.layout.logLabelColor
text: qsTr("Run")
}
10 years ago
}
}
background:
Rectangle {
color: runButton.checked ? logStyle.generic.layout.buttonSelected : "transparent"
}
}
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: 1;
height: parent.height
color: logStyle.generic.layout.buttonSeparatorColor1
10 years ago
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
10 years ago
width: 2;
10 years ago
height: parent.height
color: logStyle.generic.layout.buttonSeparatorColor2
}
10 years ago
ToolButton {
id: stateButton
checkable: true
height: logStyle.generic.layout.headerButtonHeight
10 years ago
anchors.verticalCenter: parent.verticalCenter
width: 40
10 years ago
checked: true
onCheckedChanged: {
proxyModel.toogleFilter("state")
}
tooltip: qsTr("State")
style:
ButtonStyle {
label:
Item {
Rectangle
{
width: labelState.width
height: labelState.height
10 years ago
anchors.centerIn: parent
color: "transparent"
DefaultLabel {
id: labelState
width: 30
anchors.horizontalCenter: parent.horizontalCenter
elide: Text.ElideRight
font.family: logStyle.generic.layout.logLabelFont
font.pointSize: appStyle.absoluteSize(-3)
color: logStyle.generic.layout.logLabelColor
text: qsTr("State")
}
10 years ago
}
}
background:
Rectangle {
color: stateButton.checked ? logStyle.generic.layout.buttonSelected : "transparent"
}
}
}
Rectangle {
10 years ago
anchors.verticalCenter: parent.verticalCenter
width: 1;
height: parent.height
color: logStyle.generic.layout.buttonSeparatorColor1
}
10 years ago
Rectangle {
anchors.verticalCenter: parent.verticalCenter
10 years ago
width: 2;
10 years ago
height: parent.height
color: logStyle.generic.layout.buttonSeparatorColor2
}
ToolButton {
id: deloyButton
checkable: true
height: logStyle.generic.layout.headerButtonHeight
width: 50
anchors.verticalCenter: parent.verticalCenter
checked: true
onCheckedChanged: {
proxyModel.toogleFilter("deployment")
}
tooltip: qsTr("Deployment")
style:
ButtonStyle {
label:
Item {
Rectangle
{
width: labelDeploy.width
height: labelDeploy.height
anchors.centerIn: parent
color: "transparent"
DefaultLabel {
width: 40
id: labelDeploy
anchors.horizontalCenter: parent.horizontalCenter
elide: Text.ElideRight
font.family: logStyle.generic.layout.logLabelFont
font.pointSize: appStyle.absoluteSize(-3)
color: logStyle.generic.layout.logLabelColor
text: qsTr("Deploy.")
}
}
}
background:
Rectangle {
color: deloyButton.checked ? logStyle.generic.layout.buttonSelected : "transparent"
}
}
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: 1;
height: parent.height
color: logStyle.generic.layout.buttonSeparatorColor1
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: 2;
height: parent.height
color: logStyle.generic.layout.buttonSeparatorColor2
}
}
Row
{
height: parent.height
anchors.right: parent.right
10 years ago
anchors.rightMargin: 10
spacing: 10
Rectangle
{
height: logStyle.generic.layout.headerButtonHeight
anchors.verticalCenter: parent.verticalCenter
10 years ago
color: "transparent"
width: 20
Button
{
id: clearButton
action: clearAction
anchors.fill: parent
anchors.verticalCenter: parent.verticalCenter
height: 25
style:
ButtonStyle {
background:
Rectangle {
height: logStyle.generic.layout.headerButtonHeight
implicitHeight: logStyle.generic.layout.headerButtonHeight
10 years ago
color: "transparent"
}
}
}
10 years ago
Image {
id: clearImage
source: clearAction.enabled ? "qrc:/qml/img/cleariconactive.png" : "qrc:/qml/img/clearicon.png"
10 years ago
anchors.centerIn: parent
fillMode: Image.PreserveAspectFit
width: 20
10 years ago
height: 25
10 years ago
}
10 years ago
10 years ago
Action {
id: clearAction
enabled: logsModel.count > 0
tooltip: qsTr("Clear")
onTriggered: {
logsPane.clear()
}
10 years ago
}
}
10 years ago
10 years ago
Rectangle
{
height: logStyle.generic.layout.headerButtonHeight
anchors.verticalCenter: parent.verticalCenter
10 years ago
color: "transparent"
width: 20
Button
{
10 years ago
id: copyButton
action: copyAction
anchors.fill: parent
anchors.verticalCenter: parent.verticalCenter
height: 25
style:
ButtonStyle {
background:
Rectangle {
height: logStyle.generic.layout.headerButtonHeight
implicitHeight: logStyle.generic.layout.headerButtonHeight
10 years ago
color: "transparent"
}
}
10 years ago
}
10 years ago
Image {
id: copyImage
source: copyAction.enabled ? "qrc:/qml/img/copyiconactive.png" : "qrc:/qml/img/copyicon.png"
10 years ago
anchors.centerIn: parent
fillMode: Image.PreserveAspectFit
width: 20
10 years ago
height: 25
}
10 years ago
Action {
id: copyAction
enabled: logsModel.count > 0
tooltip: qsTr("Copy to Clipboard")
onTriggered: {
var content = "";
for (var k = 0; k < logsModel.count; k++)
10 years ago
{
10 years ago
var log = logsModel.get(k);
content += log.type + "\t" + log.level + "\t" + log.date + "\t" + log.content + "\n";
10 years ago
}
10 years ago
clipboard.text = content;
}
}
}
Rectangle
10 years ago
{
width: 120
radius: 10
height: 25
color: "white"
10 years ago
anchors.verticalCenter: parent.verticalCenter
Image
10 years ago
{
id: searchImg
source: "qrc:/qml/img/searchicon.png"
fillMode: Image.PreserveAspectFit
width: 20
height: 25
z: 3
10 years ago
}
DefaultTextField
{
id: searchBox
z: 2
width: 100
anchors.left: searchImg.right
anchors.leftMargin: -7
font.family: logStyle.generic.layout.logLabelFont
font.pointSize: appStyle.absoluteSize(-3)
font.italic: true
text: qsTr(" - Search - ")
onFocusChanged:
{
if (!focus && text === "")
text = qsTr(" - Search - ");
else if (focus && text === qsTr(" - Search - "))
text = "";
}
10 years ago
onTextChanged: {
if (text === qsTr(" - Search - "))
proxyModel.search("");
else
proxyModel.search(text);
}
style:
TextFieldStyle {
background: Rectangle {
radius: 10
}
}
}
10 years ago
}
}
}
10 years ago
}