From fe7dcb389e0df86aadbe481646ca9202dfcca9dc Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 16 Oct 2026 20:39:40 +0200 Subject: notes: drawer tile with count and the note list The module resolves notes.sh's own paths by sourcing its rc, so a changed BASEDIR moves the page with it, and notes.sh's git test is the same one the page uses. A Module is a plain QtObject with no default property, so the config Process and the db.json FileView are typed properties, the shape UpdatesModule uses for its own Process. db.json is watched rather than read on open: the tile's count has to move when a note is added from either side, the CLI included, which is the same call mail makes for its unread count. The list reads db.json.notes rather than walking notes/, because that is where the titles are; entries sort newest first on the file timestamp and a title search filters them. --- desktop/modules/notes/NotesPage.qml | 121 ++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 desktop/modules/notes/NotesPage.qml (limited to 'desktop/modules/notes/NotesPage.qml') diff --git a/desktop/modules/notes/NotesPage.qml b/desktop/modules/notes/NotesPage.qml new file mode 100644 index 0000000..d73bea2 --- /dev/null +++ b/desktop/modules/notes/NotesPage.qml @@ -0,0 +1,121 @@ +// Copyright (C) 2026 Danilo M. +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2 as +// published by the Free Software Foundation. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +import QtQuick +import QtQuick.Controls +import "../.." +import "Notes.js" as Notes + +// The notes list, newest first, with a title search. Reads the module's parsed +// db.json; nothing here touches the store or git. +Item { + id: page + + // The notes module: the store, the resolved paths and the writes. + required property QtObject owner + + Row { + id: bar + anchors { top: parent.top; left: parent.left; right: parent.right } + spacing: 8 + + TextField { + id: search + width: parent.width + height: 32 + placeholderText: "Search" + color: Theme.text + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 } + background: Rectangle { + radius: 6 + color: Qt.alpha(Theme.surface, 0.9) + border.width: 1 + border.color: Qt.alpha(Theme.text, 0.15) + } + Component.onCompleted: forceActiveFocus() + onTextChanged: list.currentIndex = 0 + } + } + + ListView { + id: list + anchors { + top: bar.bottom; topMargin: 10 + left: parent.left; right: parent.right + bottom: errorLine.top; bottomMargin: 6 + } + clip: true + spacing: 4 + model: Notes.filter(page.owner.notes, search.text) + boundsBehavior: Flickable.StopAtBounds + ScrollBar.vertical: ScrollBar {} + + Text { + anchors.centerIn: parent + visible: list.count === 0 + text: page.owner.ready ? "No notes" : "Loading…" + color: Theme.subtext + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 } + } + + delegate: Rectangle { + id: row + required property var modelData + required property int index + + width: list.width + height: 36 + radius: 8 + color: rowArea.containsMouse || ListView.isCurrentItem + ? Qt.alpha(Theme.accent, 0.18) : Qt.alpha(Theme.surface, 0.35) + + MouseArea { + id: rowArea + anchors.fill: parent + hoverEnabled: true + cursorShape: Qt.PointingHandCursor + } + + Text { + anchors { + left: parent.left; leftMargin: 10 + right: when.left; rightMargin: 8 + verticalCenter: parent.verticalCenter + } + elide: Text.ElideRight + maximumLineCount: 1 + textFormat: Text.PlainText + text: row.modelData.title + color: Theme.text + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2 } + } + + Text { + id: when + anchors { right: parent.right; rightMargin: 10; verticalCenter: parent.verticalCenter } + text: Notes.formatDate(row.modelData.file) + color: Theme.overlay + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 } + } + } + } + + Text { + id: errorLine + anchors { left: parent.left; right: parent.right; bottom: parent.bottom } + height: visible ? implicitHeight : 0 + visible: page.owner.lastError !== "" + text: page.owner.lastError + wrapMode: Text.WordWrap + color: Theme.red + font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 } + } +} -- cgit v1.2.3