From aeefd8d79f372dd8cb0ecd5c2dd7760136151b93 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Sat, 9 Jan 2021 17:31:52 +0100 Subject: [PATCH] Allow resizing the console/error panel in the scripteditor --- nymea-app/ui/magic/ScriptEditor.qml | 30 +++++++++++++++------ nymea-app/ui/magic/scripting/EditorPane.qml | 4 ++- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/nymea-app/ui/magic/ScriptEditor.qml b/nymea-app/ui/magic/ScriptEditor.qml index 6550d1bf..4e5dedd6 100644 --- a/nymea-app/ui/magic/ScriptEditor.qml +++ b/nymea-app/ui/magic/ScriptEditor.qml @@ -28,7 +28,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -import QtQuick 2.4 +import QtQuick 2.9 import QtQuick.Controls 2.2 import Nymea 1.0 import QtQuick.Layouts 1.2 @@ -49,7 +49,7 @@ Page { scriptEdit.text = "import QtQuick 2.0\nimport nymea 1.0\n\nItem {\n \n}\n" } - if ((Qt.platform.os == "android" || Qt.platform.os == "ios") && !popupCache.shown) { + if ((Qt.platform.os == "android" || Qt.platform.os == "ios") && !editorSettings.popupWasShown) { var component = Qt.createComponent(Qt.resolvedUrl("../components/MeaDialog.qml")); var infoPopup = component.createObject(root, { @@ -58,13 +58,14 @@ Page { text: qsTr("nymea:app is available for all kinds of devices. In order to edit scripts we recommend to use nymea:app on your personal computer or connect a keyboard to your tablet.") }) infoPopup.open(); - popupCache.shown = true + editorSettings.popupWasShown = true } } Settings { - id: popupCache - property bool shown: false + id: editorSettings + property bool popupWasShown: false + property int preferredPaneHeight: Math.min(200, root.height / 4) } header: NymeaHeader { @@ -227,7 +228,6 @@ Page { clip: true interactive: !completionBox.visible boundsBehavior: Flickable.StopAtBounds - ScrollBar.vertical: ScrollBar { policy: ScrollBar.AlwaysOn } ScrollBar.horizontal: ScrollBar { policy: ScrollBar.AlwaysOn } @@ -367,9 +367,23 @@ Page { } } - EditorPane { + MouseArea { Layout.fillWidth: true - Layout.preferredHeight: Math.min(implicitHeight, root.height / 4) + Layout.preferredHeight: app.margins / 4 + property int offset: 0 + enabled: editorPane.shown + onPressed: offset = height - mouseY + cursorShape: enabled ? Qt.SplitVCursor : Qt.ArrowCursor + onMouseYChanged: { + var newSize = content.height - mapToItem(content, mouseX, mouseY).y - offset + editorSettings.preferredPaneHeight = Math.min(Math.max(editorPane.collapsedHeight + 50, newSize), root.height - infoPane.height) + } + } + + EditorPane { + id: editorPane + Layout.fillWidth: true + Layout.preferredHeight: shown ? editorSettings.preferredPaneHeight : collapsedHeight ScrollView { id: errorsPane diff --git a/nymea-app/ui/magic/scripting/EditorPane.qml b/nymea-app/ui/magic/scripting/EditorPane.qml index 601906d1..a7bf5192 100644 --- a/nymea-app/ui/magic/scripting/EditorPane.qml +++ b/nymea-app/ui/magic/scripting/EditorPane.qml @@ -36,7 +36,9 @@ import Nymea 1.0 Item { id: pane - implicitHeight: shown ? 40 + 10 * app.smallFont : 25 + implicitHeight: shown ? 40 + 10 * app.smallFont : collapsedHeight + + readonly property int collapsedHeight: 25 readonly property bool shown: (shownOverride === "auto" && autoWouldShow) || shownOverride == "shown"