diff --git a/nymea-app/ui/magic/ScriptEditor.qml b/nymea-app/ui/magic/ScriptEditor.qml index 69148e46..7913280b 100644 --- a/nymea-app/ui/magic/ScriptEditor.qml +++ b/nymea-app/ui/magic/ScriptEditor.qml @@ -63,6 +63,14 @@ Page { 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 { imageSource: "../images/save.svg" enabled: d.script && d.script.name !== nameTextField.text || d.oldContent !== scriptEdit.text diff --git a/nymea-app/ui/magic/scripting/LineNumbers.qml b/nymea-app/ui/magic/scripting/LineNumbers.qml index 5a27abc2..9b4e183e 100644 --- a/nymea-app/ui/magic/scripting/LineNumbers.qml +++ b/nymea-app/ui/magic/scripting/LineNumbers.qml @@ -10,22 +10,27 @@ Rectangle { id: fontMetrics font: textArea.font } - - width: { - var ret = fontMetrics.maximumCharacterWidth * 2; - var tmp = textArea.lineCount - while (tmp >= 10) { - ret += fontMetrics.maximumCharacterWidth; - tmp /= 10; + TextMetrics { + id: textMetrics + font: textArea.font + text: { + var digits = 1; + var tmp = textArea.lineCount; + 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 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 { id: lineNumbersColumn