Add help button and fix linenumbers with

This commit is contained in:
Michael Zanetti 2020-01-15 23:13:01 +01:00
parent 1ea57cedee
commit f60d20245e
2 changed files with 25 additions and 12 deletions

View File

@ -63,6 +63,14 @@ Page {
placeholderText: qsTr("Script name") placeholderText: qsTr("Script name")
} }
HeaderButton {
imageSource: "../images/question.svg"
text: qsTr("Help")
onClicked: {
Qt.openUrlExternally("https://nymea.io/en/wiki/nymea/master/configuration/scripting")
}
}
HeaderButton { HeaderButton {
imageSource: "../images/save.svg" imageSource: "../images/save.svg"
enabled: d.script && d.script.name !== nameTextField.text || d.oldContent !== scriptEdit.text enabled: d.script && d.script.name !== nameTextField.text || d.oldContent !== scriptEdit.text

View File

@ -10,22 +10,27 @@ Rectangle {
id: fontMetrics id: fontMetrics
font: textArea.font font: textArea.font
} }
TextMetrics {
width: { id: textMetrics
var ret = fontMetrics.maximumCharacterWidth * 2; font: textArea.font
var tmp = textArea.lineCount text: {
while (tmp >= 10) { var digits = 1;
ret += fontMetrics.maximumCharacterWidth; var tmp = textArea.lineCount;
tmp /= 10; while (tmp >= 10) {
digits++;
tmp /= 10;
}
var str = ""
for (var i = 0; i < digits; i++) {
str += "0"
}
return str;
} }
return ret;
} }
width: textMetrics.advanceWidth + app.margins / 2
height: root.textArea.height - 10 height: root.textArea.height - 10
color: (app.backgroundColor.r * 0.2126 + app.backgroundColor.g * 0.7152 + app.backgroundColor.b * 0.0722) * 255 < 128 ? "#202020" : "#e0e0e0" color: (app.backgroundColor.r * 0.2126 + app.backgroundColor.g * 0.7152 + app.backgroundColor.b * 0.0722) * 255 < 128 ? "#202020" : "#e0e0e0"
Component.onCompleted: {
print("..", app.backgroundColor.r)
print("*** background", (app.backgroundColor.r * 0.2126 + app.backgroundColor.g * 0.7152 + app.backgroundColor.b * 0.0722) * 255 < 128 )
}
Column { Column {
id: lineNumbersColumn id: lineNumbersColumn