Add recent file view, implement runtime options
diff --git a/ide/qml/NbWindow.qml b/ide/qml/NbWindow.qml
index 5710c9e..858fb5e 100644
--- a/ide/qml/NbWindow.qml
+++ b/ide/qml/NbWindow.qml
@@ -15,7 +15,8 @@
Material.theme: Material.Light
Material.accent: Material.Orange
- minimumWidth: column.implicitWidth
+ minimumWidth: 600
+ minimumHeight: 400
required property ApplicationWindow welcomeWindow
@@ -92,10 +93,14 @@
Action {
text: qsTr("Run &All")
+
+ onTriggered: notebook.runAll();
}
Action {
text: qsTr("&Reset Runtime State")
+
+ onTriggered: notebook.reset();
}
}
}
@@ -107,6 +112,8 @@
{
console.error(message)
}
+
+ onSaved: welcomeWindow.recentModel.add(notebook.savePath)
}
ColumnLayout {
@@ -137,7 +144,7 @@
ColumnLayout {
Label {
font.pointSize: 18
- text: qsTr("Notebook")
+ text: notebook.savePath != "" ? notebook.savePath.split("/").pop().split(".").slice(0,-1).join('.') : qsTr("Notebook")
}
Label {
diff --git a/ide/qml/RecentNotebook.qml b/ide/qml/RecentNotebook.qml
index d0b1120..194424c 100644
--- a/ide/qml/RecentNotebook.qml
+++ b/ide/qml/RecentNotebook.qml
@@ -8,6 +8,7 @@
property string name: "Hello.refnb"
property alias containsMouse: mouseArea.containsMouse
signal clicked()
+ signal removeClicked()
Image {
id: nbIcon
@@ -27,7 +28,24 @@
anchors.fill: parent
hoverEnabled: true
- onClicked: root.clicked()
+ acceptedButtons: Qt.LeftButton | Qt.RightButton
+
+ onClicked: {
+ if (mouse.button == Qt.LeftButton)
+ root.clicked();
+ else if (mouse.button == Qt.RightButton)
+ contextMenu.popup();
+ }
+ }
+
+ Menu {
+ id: contextMenu
+
+ MenuItem {
+ text: qsTr("Remove")
+
+ onClicked: root.removeClicked()
+ }
}
}
}
diff --git a/ide/qml/main.qml b/ide/qml/main.qml
index 23f8926..210640c 100644
--- a/ide/qml/main.qml
+++ b/ide/qml/main.qml
@@ -2,6 +2,9 @@
import QtQuick.Controls 2.15
import QtQuick.Controls.Material 2.0
import QtQuick.Layouts 1.11
+import Qt.labs.settings 1.0
+
+import sh.swisschili.REFAL 1.0
ApplicationWindow {
id: root
@@ -19,6 +22,8 @@
visible: true
+ property alias recentModel: recents
+
function openNotebook(path=null) {
let NbWindow = Qt.createComponent("qrc:///qml/NbWindow.qml");
let window = NbWindow.createObject(null, {welcomeWindow: root});
@@ -36,6 +41,10 @@
show();
}
+ RecentModel {
+ id: recents
+ }
+
Label {
id: textRefal
text: qsTr("REFAL")
@@ -125,21 +134,20 @@
Layout.fillWidth: true
Layout.fillHeight: false
- model: [
- // "~/Documents/Hello.refnb", "~/Downloads/stuff/Goodbye.refnb", "/home/ch/dev/REFAL/build/test.refnb"
- ]
+ model: recents
delegate: RecentNotebook {
Layout.leftMargin: 8
Layout.rightMargin: 8
- name: modelData.split("/").pop()
+ name: path.split("/").pop()
- ToolTip.text: modelData
+ ToolTip.text: path
ToolTip.visible: containsMouse
ToolTip.delay: 1000
- onClicked: root.openNotebook(modelData)
+ onClicked: root.openNotebook(path)
+ onRemoveClicked: recents.remove(path)
}
}