blob: 210640c9fb6305d2eb3e1170288fea0d0b36cda1 [file] [log] [blame]
swissChilid2af6ad2022-04-16 14:42:17 -07001import QtQuick 2.0
swissChili23958ca2022-02-21 19:23:34 -08002import QtQuick.Controls 2.15
3import QtQuick.Controls.Material 2.0
swissChilid2af6ad2022-04-16 14:42:17 -07004import QtQuick.Layouts 1.11
swissChilia44bf722022-04-16 18:41:54 -07005import Qt.labs.settings 1.0
6
7import sh.swisschili.REFAL 1.0
swissChili4b3105a2022-02-22 16:34:39 -08008
swissChili23958ca2022-02-21 19:23:34 -08009ApplicationWindow {
10 id: root
swissChilid2af6ad2022-04-16 14:42:17 -070011
12 title: "REFAL Studio"
13
14 width: 680
15 height: 360
16
17 minimumWidth: 680
18 minimumHeight: 360
swissChili23958ca2022-02-21 19:23:34 -080019
swissChili4b3105a2022-02-22 16:34:39 -080020 Material.theme: Material.Light
swissChili23958ca2022-02-21 19:23:34 -080021 Material.accent: Material.Orange
22
swissChilid2af6ad2022-04-16 14:42:17 -070023 visible: true
swissChili505de412022-03-24 12:35:08 -070024
swissChilia44bf722022-04-16 18:41:54 -070025 property alias recentModel: recents
26
swissChilid2af6ad2022-04-16 14:42:17 -070027 function openNotebook(path=null) {
28 let NbWindow = Qt.createComponent("qrc:///qml/NbWindow.qml");
29 let window = NbWindow.createObject(null, {welcomeWindow: root});
swissChili505de412022-03-24 12:35:08 -070030
swissChilid2af6ad2022-04-16 14:42:17 -070031 if (path !== null)
swissChili505de412022-03-24 12:35:08 -070032 {
swissChilid2af6ad2022-04-16 14:42:17 -070033 window.openNotebook(path)
swissChili505de412022-03-24 12:35:08 -070034 }
swissChili4b3105a2022-02-22 16:34:39 -080035 }
36
swissChilid2af6ad2022-04-16 14:42:17 -070037 function toggleVisible() {
38 if (visible)
39 hide();
40 else
41 show();
42 }
swissChili23958ca2022-02-21 19:23:34 -080043
swissChilia44bf722022-04-16 18:41:54 -070044 RecentModel {
45 id: recents
46 }
47
swissChilid2af6ad2022-04-16 14:42:17 -070048 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 }
swissChili23958ca2022-02-21 19:23:34 -080060
swissChilid2af6ad2022-04-16 14:42:17 -070061 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 }
swissChili23958ca2022-02-21 19:23:34 -080074
swissChilid2af6ad2022-04-16 14:42:17 -070075 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 }
swissChili23958ca2022-02-21 19:23:34 -0800128 }
129
swissChilid2af6ad2022-04-16 14:42:17 -0700130 Repeater {
131 id: notebooksList
132
133 Layout.alignment: Qt.AlignLeft | Qt.AlignTop
134 Layout.fillWidth: true
135 Layout.fillHeight: false
136
swissChilia44bf722022-04-16 18:41:54 -0700137 model: recents
swissChilid2af6ad2022-04-16 14:42:17 -0700138
139 delegate: RecentNotebook {
140 Layout.leftMargin: 8
141 Layout.rightMargin: 8
142
swissChilia44bf722022-04-16 18:41:54 -0700143 name: path.split("/").pop()
swissChilid2af6ad2022-04-16 14:42:17 -0700144
swissChilia44bf722022-04-16 18:41:54 -0700145 ToolTip.text: path
swissChilid2af6ad2022-04-16 14:42:17 -0700146 ToolTip.visible: containsMouse
147 ToolTip.delay: 1000
148
swissChilia44bf722022-04-16 18:41:54 -0700149 onClicked: root.openNotebook(path)
150 onRemoveClicked: recents.remove(path)
swissChilid2af6ad2022-04-16 14:42:17 -0700151 }
swissChili23958ca2022-02-21 19:23:34 -0800152 }
153
swissChilid2af6ad2022-04-16 14:42:17 -0700154 Label {
155 Layout.leftMargin: 8
156 Layout.rightMargin: 8
157
158 visible: notebooksList.count == 0
159 text: qsTr("Your recent notebooks will appear here")
swissChili23958ca2022-02-21 19:23:34 -0800160 }
161 }
swissChilid2af6ad2022-04-16 14:42:17 -0700162 }
swissChili23958ca2022-02-21 19:23:34 -0800163
swissChilid2af6ad2022-04-16 14:42:17 -0700164 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 {
swissChili23958ca2022-02-21 19:23:34 -0800184 Layout.fillWidth: true
swissChili23958ca2022-02-21 19:23:34 -0800185
swissChilid2af6ad2022-04-16 14:42:17 -0700186 url: modelData.url
187 title: modelData.title
swissChili23958ca2022-02-21 19:23:34 -0800188
swissChilid2af6ad2022-04-16 14:42:17 -0700189 ToolTip.text: modelData.url
190 ToolTip.visible: containsMouse
191 ToolTip.delay: 1000
swissChili23958ca2022-02-21 19:23:34 -0800192 }
193 }
194}