swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 1 | import QtQuick 2.5 |
| 2 | import QtQuick.Controls 2.15 |
| 3 | import QtQuick.Controls.Material 2.0 |
| 4 | import QtQuick.Layouts 1.3 |
| 5 | |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 6 | import sh.swisschili.REFAL 1.0 |
| 7 | |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 8 | ApplicationWindow { |
| 9 | id: root |
| 10 | width: 1080 |
| 11 | height: 720 |
| 12 | title: "Notebook" |
| 13 | visible: true |
| 14 | |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 15 | Material.theme: Material.Light |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 16 | Material.accent: Material.Orange |
| 17 | |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame^] | 18 | Notebook { |
| 19 | id: notebook |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 20 | } |
| 21 | |
| 22 | Component.onCompleted: { |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame^] | 23 | notebook.cellModel.addCell("Refal { = Hi!; }", ""); |
| 24 | notebook.cellModel.addCell("<Refal>", "Hi!"); |
| 25 | notebook.cellModel.addCell("Hello there", "Hello there"); |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 26 | } |
| 27 | |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 28 | ColumnLayout { |
| 29 | id: column |
| 30 | anchors.fill: parent |
| 31 | |
| 32 | TabBar { |
| 33 | id: bar |
| 34 | |
| 35 | Layout.fillWidth: true |
| 36 | |
| 37 | TabButton { |
| 38 | text: "Example Workspace" |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame^] | 39 | width: implicitWidth |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | TabButton { |
| 43 | text: "Another Workspace" |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame^] | 44 | width: implicitWidth |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | TabButton { |
| 48 | text: "Testing" |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame^] | 49 | width: implicitWidth |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 50 | } |
| 51 | } |
| 52 | |
| 53 | SplitView { |
| 54 | id: split |
| 55 | Layout.fillHeight: true |
| 56 | Layout.fillWidth: true |
| 57 | orientation: Qt.Horizontal |
| 58 | |
| 59 | ListView { |
| 60 | id: codeEditor |
| 61 | SplitView.fillWidth: true |
| 62 | SplitView.minimumWidth: 400 |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame^] | 63 | model: notebook.cellModel |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 64 | clip: true |
| 65 | |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 66 | delegate: NotebookCell { |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame^] | 67 | id: notebookCell |
| 68 | |
| 69 | required property var model |
| 70 | required property var index |
| 71 | |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 72 | width: codeEditor.width - 5 |
swissChili | 25620b0 | 2022-02-23 17:15:16 -0800 | [diff] [blame^] | 73 | |
| 74 | code: model.code |
| 75 | result: model.result |
| 76 | |
| 77 | onCodeEditingFinished: model.code = code |
| 78 | |
| 79 | onInsertBelowClicked: { |
| 80 | console.info(index) |
| 81 | cellModel.insertRows(cellModel.index(0, index), 1) |
| 82 | } |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 83 | } |
| 84 | } |
| 85 | |
| 86 | Item { |
| 87 | id: variables |
| 88 | SplitView.minimumWidth: 240 |
| 89 | |
| 90 | Label { |
| 91 | anchors.centerIn: parent |
| 92 | text: "Vars" |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | } |