swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 1 | import QtQuick 2.0 |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 2 | import QtQuick.Controls 2.15 |
| 3 | import QtQuick.Controls.Material 2.0 |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 4 | import QtQuick.Layouts 1.11 |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 5 | |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 6 | ApplicationWindow { |
| 7 | id: root |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 8 | |
| 9 | title: "REFAL Studio" |
| 10 | |
| 11 | width: 680 |
| 12 | height: 360 |
| 13 | |
| 14 | minimumWidth: 680 |
| 15 | minimumHeight: 360 |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 16 | |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 17 | Material.theme: Material.Light |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 18 | Material.accent: Material.Orange |
| 19 | |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 20 | visible: true |
swissChili | 505de41 | 2022-03-24 12:35:08 -0700 | [diff] [blame] | 21 | |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 22 | function openNotebook(path=null) { |
| 23 | let NbWindow = Qt.createComponent("qrc:///qml/NbWindow.qml"); |
| 24 | let window = NbWindow.createObject(null, {welcomeWindow: root}); |
swissChili | 505de41 | 2022-03-24 12:35:08 -0700 | [diff] [blame] | 25 | |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 26 | if (path !== null) |
swissChili | 505de41 | 2022-03-24 12:35:08 -0700 | [diff] [blame] | 27 | { |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 28 | window.openNotebook(path) |
swissChili | 505de41 | 2022-03-24 12:35:08 -0700 | [diff] [blame] | 29 | } |
swissChili | 4b3105a | 2022-02-22 16:34:39 -0800 | [diff] [blame] | 30 | } |
| 31 | |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 32 | function toggleVisible() { |
| 33 | if (visible) |
| 34 | hide(); |
| 35 | else |
| 36 | show(); |
| 37 | } |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 38 | |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 39 | Label { |
| 40 | id: textRefal |
| 41 | text: qsTr("REFAL") |
| 42 | anchors.left: parent.left |
| 43 | anchors.top: parent.top |
| 44 | font.pixelSize: 36 |
| 45 | anchors.leftMargin: 36 |
| 46 | anchors.topMargin: 29 |
| 47 | font.weight: Font.Black |
| 48 | font.bold: true |
| 49 | font.italic: false |
| 50 | } |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 51 | |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 52 | Label { |
| 53 | id: textStudio |
| 54 | y: 29 |
| 55 | text: qsTr("Studio") |
| 56 | anchors.verticalCenter: textRefal.verticalCenter |
| 57 | anchors.left: textRefal.right |
| 58 | font.pixelSize: 36 |
| 59 | anchors.leftMargin: 6 |
| 60 | font.bold: false |
| 61 | font.italic: false |
| 62 | font.weight: Font.Medium |
| 63 | color: Material.color(Material.Orange) |
| 64 | } |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 65 | |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 66 | Rectangle { |
| 67 | id: sepRect |
| 68 | x: 364 |
| 69 | width: 1 |
| 70 | color: "#cecece" |
| 71 | anchors.top: parent.top |
| 72 | anchors.bottom: parent.bottom |
| 73 | anchors.bottomMargin: 14 |
| 74 | anchors.topMargin: 78 |
| 75 | anchors.horizontalCenter: parent.horizontalCenter |
| 76 | } |
| 77 | |
| 78 | Flickable { |
| 79 | id: notebooksFlick |
| 80 | anchors.left: textRefal.left |
| 81 | anchors.right: sepRect.left |
| 82 | anchors.top: textRefal.bottom |
| 83 | anchors.bottom: parent.bottom |
| 84 | anchors.leftMargin: -8 |
| 85 | anchors.rightMargin: 16 |
| 86 | anchors.bottomMargin: 16 |
| 87 | anchors.topMargin: 6 |
| 88 | clip: true |
| 89 | flickableDirection: Flickable.VerticalFlick |
| 90 | |
| 91 | ColumnLayout { |
| 92 | id: notebooksCol |
| 93 | spacing: 12 |
| 94 | |
| 95 | RowLayout { |
| 96 | id: nbBtnsRow |
| 97 | spacing: 12 |
| 98 | Layout.alignment: Qt.AlignLeft | Qt.AlignTop |
| 99 | Layout.fillWidth: true |
| 100 | Layout.fillHeight: false |
| 101 | Layout.leftMargin: 8 |
| 102 | Layout.rightMargin: 8 |
| 103 | |
| 104 | Button { |
| 105 | id: newNotebookBtn |
| 106 | text: qsTr("New Notebook") |
| 107 | font.bold: true |
| 108 | highlighted: true |
| 109 | |
| 110 | onClicked: { |
| 111 | root.openNotebook(); |
| 112 | } |
| 113 | } |
| 114 | |
| 115 | Button { |
| 116 | id: openNotebookBtn |
| 117 | text: qsTr("Open Existing") |
| 118 | } |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 119 | } |
| 120 | |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 121 | Repeater { |
| 122 | id: notebooksList |
| 123 | |
| 124 | Layout.alignment: Qt.AlignLeft | Qt.AlignTop |
| 125 | Layout.fillWidth: true |
| 126 | Layout.fillHeight: false |
| 127 | |
| 128 | model: [ |
| 129 | // "~/Documents/Hello.refnb", "~/Downloads/stuff/Goodbye.refnb", "/home/ch/dev/REFAL/build/test.refnb" |
| 130 | ] |
| 131 | |
| 132 | delegate: RecentNotebook { |
| 133 | Layout.leftMargin: 8 |
| 134 | Layout.rightMargin: 8 |
| 135 | |
| 136 | name: modelData.split("/").pop() |
| 137 | |
| 138 | ToolTip.text: modelData |
| 139 | ToolTip.visible: containsMouse |
| 140 | ToolTip.delay: 1000 |
| 141 | |
| 142 | onClicked: root.openNotebook(modelData) |
| 143 | } |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 144 | } |
| 145 | |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 146 | Label { |
| 147 | Layout.leftMargin: 8 |
| 148 | Layout.rightMargin: 8 |
| 149 | |
| 150 | visible: notebooksList.count == 0 |
| 151 | text: qsTr("Your recent notebooks will appear here") |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 152 | } |
| 153 | } |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 154 | } |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 155 | |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 156 | ListView { |
| 157 | id: tipsList |
| 158 | anchors.left: sepRect.right |
| 159 | anchors.right: parent.right |
| 160 | anchors.top: textRefal.bottom |
| 161 | anchors.bottom: parent.bottom |
| 162 | anchors.bottomMargin: 16 |
| 163 | anchors.topMargin: 6 |
| 164 | anchors.leftMargin: 16 |
| 165 | anchors.rightMargin: 36 |
| 166 | spacing: 12 |
| 167 | |
| 168 | model: [ |
| 169 | {url: "https://wiki.swisschili.sh/wiki/REFAL", title: "REFAL Studio Wiki"}, |
| 170 | {url: "https://wiki.swisschili.sh/wiki/REFAL/Cookbook", title: "REFAL Cookbook"}, |
| 171 | {url: "http://refal.botik.ru/book/html/", title: "REFAL-5 Programming Guide (en)"}, |
| 172 | {url: "http://refal.net/rf5_frm.htm", title: "REFAL-5 Programming Guide (ru)"} |
| 173 | ] |
| 174 | |
| 175 | delegate: Tip { |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 176 | Layout.fillWidth: true |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 177 | |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 178 | url: modelData.url |
| 179 | title: modelData.title |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 180 | |
swissChili | d2af6ad | 2022-04-16 14:42:17 -0700 | [diff] [blame^] | 181 | ToolTip.text: modelData.url |
| 182 | ToolTip.visible: containsMouse |
| 183 | ToolTip.delay: 1000 |
swissChili | 23958ca | 2022-02-21 19:23:34 -0800 | [diff] [blame] | 184 | } |
| 185 | } |
| 186 | } |