Browse Source

ui changes

cl-refactor
yann300 10 years ago
parent
commit
b4e869acfa
  1. 55
      mix/qml/LogsPane.qml
  2. 2
      mix/qml/LogsPaneStyle.qml
  3. 27
      mix/qml/StatusPane.qml

55
mix/qml/LogsPane.qml

@ -7,19 +7,29 @@ import "."
Rectangle Rectangle
{ {
property variant currentStatus;
function push(_level, _type, _content) function push(_level, _type, _content)
{ {
_content = _content.replace(/\n/g, " ") _content = _content.replace(/\n/g, " ")
logsModel.insert(0, { "type": _type, "date": Qt.formatDateTime(new Date(), "hh:mm:ss"), "content": _content, "level": _level }); logsModel.insert(0, { "type": _type, "date": Qt.formatDateTime(new Date(), "hh:mm:ss"), "content": _content, "level": _level });
} }
Keys.onEscapePressed: onVisibleChanged:
{ {
parent.toggle(); if (visible && (logsModel.count === 0 || (logsModel.get(0).date !== currentStatus.date && logsModel.get(0).content !== currentStatus.content)))
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 anchors.fill: parent
radius: 5 radius: 10
color: "transparent" color: "transparent"
id: logsPane id: logsPane
Column { Column {
@ -43,11 +53,13 @@ Rectangle
id: logsRect id: logsRect
spacing: 0 spacing: 0
Repeater { Repeater {
id: logsRepeater
clip: true clip: true
property string frontColor: "transparent"
model: SortFilterProxyModel { model: SortFilterProxyModel {
id: proxyModel id: proxyModel
source: logsModel source: logsModel
property var roles: ["-", "javascript", "run", "state"] property var roles: ["-", "javascript", "run", "state", "comp"]
Component.onCompleted: { Component.onCompleted: {
filterType = regEx(proxyModel.roles); filterType = regEx(proxyModel.roles);
@ -80,7 +92,7 @@ Rectangle
return "(?:" + roles.join('|') + ")"; return "(?:" + roles.join('|') + ")";
} }
filterType: "(?:javascript|run|state)" filterType: "(?:javascript|run|state|comp)"
filterContent: "" filterContent: ""
filterSyntax: SortFilterProxyModel.RegExp filterSyntax: SortFilterProxyModel.RegExp
filterCaseSensitivity: Qt.CaseInsensitive filterCaseSensitivity: Qt.CaseInsensitive
@ -92,12 +104,17 @@ Rectangle
height: 30 height: 30
color: color:
{ {
var cl;
if (level === "warning" || level === "error") if (level === "warning" || level === "error")
return "#fffcd5"; cl = "#fffcd5";
else else
return index % 2 === 0 ? "transparent" : LogsPaneStyle.generic.layout.logAlternateColor; cl = index % 2 === 0 ? "transparent" : LogsPaneStyle.generic.layout.logAlternateColor;
if (index === 0)
logsRepeater.frontColor = cl;
return cl;
} }
MouseArea MouseArea
{ {
anchors.fill: parent anchors.fill: parent
@ -148,13 +165,11 @@ Rectangle
Text { Text {
id: logContent id: logContent
text: content; text: content;
font.family: LogsPaneStyle.generic.layout.logLabelFont font.family: "sans serif"
width: LogsPaneStyle.generic.layout.contentWidth width: LogsPaneStyle.generic.layout.contentWidth
font.pointSize: Style.absoluteSize(-1) font.pointSize: Style.absoluteSize(-1)
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
elide: Text.ElideRight elide: Text.ElideRight
maximumLineCount: 10
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 190 anchors.leftMargin: 190
color: { color: {
@ -230,7 +245,14 @@ Rectangle
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: 1; width: 1;
height: parent.height height: parent.height
color : "transparent" color : "#d3d0d0"
}
Rectangle {
anchors.verticalCenter: parent.verticalCenter
width: 2;
height: parent.height
color : "#f2f1f2"
} }
ToolButton { ToolButton {
@ -272,7 +294,7 @@ Rectangle
Rectangle { Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: 1; width: 2;
height: parent.height height: parent.height
color : "#f2f1f2" color : "#f2f1f2"
} }
@ -311,14 +333,14 @@ Rectangle
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: 1; width: 1;
height: parent.height height: parent.height
color : "#d3d0d0" color: "#d3d0d0"
} }
Rectangle { Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: 1; width: 2;
height: parent.height height: parent.height
color : "#f2f1f2" color: "#f2f1f2"
} }
ToolButton { ToolButton {
@ -360,7 +382,7 @@ Rectangle
Rectangle { Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
width: 1; width: 2;
height: parent.height height: parent.height
color : "#f2f1f2" color : "#f2f1f2"
} }
@ -541,4 +563,5 @@ Rectangle
} }
} }
} }
} }

2
mix/qml/LogsPaneStyle.qml

@ -15,7 +15,7 @@ QtObject {
property int headerButtonSpacing: 0 property int headerButtonSpacing: 0
property int leftMargin: 10 property int leftMargin: 10
property int headerButtonHeight: 30 property int headerButtonHeight: 30
property string logLabelColor: "#808080" property string logLabelColor: "#4a4a4a"
property string logLabelFont: "sans serif" property string logLabelFont: "sans serif"
property int headerInputWidth: 200 property int headerInputWidth: 200
property int dateWidth: 70 property int dateWidth: 70

27
mix/qml/StatusPane.qml

@ -9,7 +9,7 @@ Rectangle {
id: statusHeader id: statusHeader
objectName: "statusPane" objectName: "statusPane"
property variant webPreview property variant webPreview
property alias currentStatus: logPane.currentStatus
function updateStatus(message) function updateStatus(message)
{ {
if (!message) if (!message)
@ -17,6 +17,7 @@ Rectangle {
status.state = ""; status.state = "";
status.text = qsTr("Compile successfully."); status.text = qsTr("Compile successfully.");
debugImg.state = "active"; debugImg.state = "active";
currentStatus = { "type": "Comp", "date": Qt.formatDateTime(new Date(), "hh:mm:ss"), "content": status.text, "level": "info" }
} }
else else
{ {
@ -24,6 +25,7 @@ Rectangle {
var errorInfo = ErrorLocationFormater.extractErrorInfo(message, true); var errorInfo = ErrorLocationFormater.extractErrorInfo(message, true);
status.text = errorInfo.errorLocation + " " + errorInfo.errorDetail; status.text = errorInfo.errorLocation + " " + errorInfo.errorDetail;
debugImg.state = ""; debugImg.state = "";
currentStatus = { "type": "Comp", "date": Qt.formatDateTime(new Date(), "hh:mm:ss"), "content": status.text, "level": "error" }
} }
debugRunActionIcon.enabled = codeModel.hasContract; debugRunActionIcon.enabled = codeModel.hasContract;
} }
@ -33,6 +35,7 @@ Rectangle {
status.state = ""; status.state = "";
status.text = text status.text = text
logPane.push("info", type, text); logPane.push("info", type, text);
currentStatus = { "type": type, "date": Qt.formatDateTime(new Date(), "hh:mm:ss"), "content": text, "level": "info" }
} }
function warningMessage(text, type) function warningMessage(text, type)
@ -40,6 +43,7 @@ Rectangle {
status.state = "warning"; status.state = "warning";
status.text = text status.text = text
logPane.push("warning", type, text); logPane.push("warning", type, text);
currentStatus = { "type": type, "date": Qt.formatDateTime(new Date(), "hh:mm:ss"), "content": text, "level": "warning" }
} }
function errorMessage(text, type) function errorMessage(text, type)
@ -47,6 +51,7 @@ Rectangle {
status.state = "error"; status.state = "error";
status.text = text; status.text = text;
logPane.push("error", type, text); logPane.push("error", type, text);
currentStatus = { "type": type, "date": Qt.formatDateTime(new Date(), "hh:mm:ss"), "content": text, "level": "error" }
} }
Connections { Connections {
@ -118,7 +123,7 @@ Rectangle {
Text { Text {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
font.pointSize: StatusPaneStyle.general.statusFontSize font.pointSize: Style.absoluteSize(-1)
height: 15 height: 15
font.family: "sans serif" font.family: "sans serif"
objectName: "status" objectName: "status"
@ -196,7 +201,9 @@ Rectangle {
function toggle() function toggle()
{ {
if (logsContainer.state === "opened") if (logsContainer.state === "opened")
{
logsContainer.state = "closed" logsContainer.state = "closed"
}
else else
{ {
logsContainer.state = "opened"; logsContainer.state = "opened";
@ -208,11 +215,10 @@ Rectangle {
id: logsContainer id: logsContainer
width: 750 width: 750
anchors.topMargin: -30
anchors.top: statusContainer.bottom anchors.top: statusContainer.bottom
anchors.horizontalCenter: parent.horizontalCenter anchors.topMargin: 4
visible: false visible: false
radius: 5 radius: 10
function calCoord() function calCoord()
{ {
@ -221,28 +227,31 @@ Rectangle {
top = top.parent top = top.parent
var coordinates = logsContainer.mapToItem(top, 0, 0); var coordinates = logsContainer.mapToItem(top, 0, 0);
logsContainer.parent = top; logsContainer.parent = top;
logsContainer.x = coordinates.x; logsContainer.x = status.x + statusContainer.x - LogsPaneStyle.generic.layout.dateWidth - LogsPaneStyle.generic.layout.typeWidth - 30
logsContainer.y = coordinates.y;
} }
LogsPane LogsPane
{ {
id: logPane; id: logPane;
} }
states: [ states: [
State { State {
name: "opened"; name: "opened";
PropertyChanges { target: logsContainer; height: 500; visible: true } PropertyChanges { target: logsContainer; height: 500; visible: true }
PropertyChanges { target: statusContainer; width: 100; height: 25 }
}, },
State { State {
name: "closed"; name: "closed";
PropertyChanges { target: logsContainer; height: 0; visible: false } PropertyChanges { target: logsContainer; height: 0; visible: false }
PropertyChanges { target: statusContainer; width: 600; height: 30 }
} }
] ]
transitions: Transition { transitions: Transition {
NumberAnimation { properties: "height"; easing.type: Easing.InOutQuad; duration: 200 } NumberAnimation { properties: "height"; easing.type: Easing.InOutQuad; duration: 200 }
NumberAnimation { properties: "visible"; easing.type: Easing.InOutQuad; duration: 200 } NumberAnimation { target: logsContainer; properties: "visible"; easing.type: Easing.InOutQuad; duration: 200 }
} NumberAnimation { target: statusContainer; properties: "width"; easing.type: Easing.InOutQuad; duration: 500 }
}
} }
} }

Loading…
Cancel
Save