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