harbour-quill 0.2.12: note markdown con sync WebDAV

This commit is contained in:
2026-08-24 14:16:11 +02:00
commit 73acfbd0b4
26 changed files with 2134 additions and 0 deletions
+129
View File
@@ -0,0 +1,129 @@
import QtQuick 2.2
import Sailfish.Silica 1.0
import "../components"
Page {
id: page
property var dav
property string notePath
property string noteName
property string initialContent: ""
property bool skipLoad: false
property bool loaded: false
property bool dirty: false
property string coverText: noteName
onStatusChanged: {
if (status === PageStatus.Active) {
if (!loaded) {
if (skipLoad) {
// New note: content is already known, no GET needed.
loaded = true
editor.text = initialContent
dirty = false
} else {
loadNote()
}
}
} else if (status === PageStatus.Inactive) {
// Auto-save on exit (Obsidian-like: nothing is ever lost).
if (loaded && dirty && !dav.busy) saveNow(false)
}
}
function loadNote() {
loaded = false
dav.readFile(notePath)
}
function saveNow(notify) {
if (!loaded) return
if (dav.busy) {
banner.show(qsTr("Save in progress..."), false)
return
}
dav.writeFile(notePath, editor.text)
if (notify) banner.show(qsTr("Saving..."), false)
}
Connections {
target: dav
onFileReady: {
loaded = true
initialContent = content
editor.text = content
dirty = false
}
onWriteDone: {
initialContent = editor.text
dirty = false
banner.show(qsTr("Saved"), false)
}
onFailed: {
if (loaded) {
banner.show(message, true)
} else {
loaded = true
banner.show(qsTr("Cannot open: %1").arg(message), true)
}
}
}
SilicaFlickable {
anchors.fill: parent
contentHeight: column.height
Column {
id: column
width: parent.width
PageHeader { title: noteName }
TextArea {
id: editor
width: parent.width
focus: true
label: "Markdown"
onTextChanged: {
dirty = editor.text !== initialContent
}
}
}
PullDownMenu {
MenuItem {
text: qsTr("Save")
enabled: page.dirty && page.loaded
onClicked: page.saveNow(true)
}
MenuItem {
text: qsTr("Preview")
onClicked: pageStack.push(Qt.resolvedUrl("PreviewPage.qml"),
{ dav: page.dav, noteName: page.noteName, notePath: page.notePath, markdown: editor.text })
}
MenuItem {
text: qsTr("Delete note")
onClicked: {
var remorse = remorseComponent.createObject(page)
remorse.execute(qsTr("Delete the note?"), function () {
dav.deleteFile(notePath)
pageStack.pop()
})
}
}
}
Component {
id: remorseComponent
RemorsePopup { }
}
BusyIndicator {
anchors.centerIn: parent
running: !page.loaded
}
}
Banner { id: banner }
}