diff --git a/config/quickshell/.config/quickshell/Modules/Background/ScrollBackground.qml b/config/quickshell/.config/quickshell/Modules/Background/ScrollBackground.qml index 8193e78..5c6d455 100644 --- a/config/quickshell/.config/quickshell/Modules/Background/ScrollBackground.qml +++ b/config/quickshell/.config/quickshell/Modules/Background/ScrollBackground.qml @@ -23,8 +23,7 @@ Item { readonly property real viewportHeight: outputHeight > 0 ? outputHeight : height readonly property real scrollProgress: { if (workspaceCount <= 1 || focusedIndex < 0) - return 0; - + return 0.5; // Center return Math.max(0, Math.min(1, (focusedIndex - 1) / (workspaceCount - 1))); } diff --git a/config/quickshell/.config/quickshell/Modules/Sidebar/Modules/NoteCard.qml b/config/quickshell/.config/quickshell/Modules/Sidebar/Modules/NoteCard.qml index 9ae86ad..1225f64 100644 --- a/config/quickshell/.config/quickshell/Modules/Sidebar/Modules/NoteCard.qml +++ b/config/quickshell/.config/quickshell/Modules/Sidebar/Modules/NoteCard.qml @@ -107,14 +107,6 @@ Rectangle { onClicked: NotesService.openNote(model.notePath) } - FileView { - id: fileView - - path: model.notePath - watchChanges: true - onFileChanged: reload() - } - RowLayout { id: noteLayout @@ -124,13 +116,7 @@ Rectangle { UText { Layout.fillWidth: true - text: { - var t = fileView.text(); - if (!t) - return "(empty note)"; - - return t.trim().split('\n').slice(0, 5).join('\n'); - } + text: model.contentPreview wrapMode: Text.Wrap elide: Text.ElideRight maximumLineCount: 5 diff --git a/config/quickshell/.config/quickshell/Services/NotesService.qml b/config/quickshell/.config/quickshell/Services/NotesService.qml index 9f726dd..0e90858 100644 --- a/config/quickshell/.config/quickshell/Services/NotesService.qml +++ b/config/quickshell/.config/quickshell/Services/NotesService.qml @@ -1,3 +1,4 @@ +import QtQml import QtQuick import Quickshell import Quickshell.Io @@ -20,7 +21,8 @@ Singleton { const path = Paths.notesDir + "/" + fileName; createProcess.currentNote = { "notePath": path, - "colorIdx": strToColor(fileName) + "colorIdx": strToColor(fileName), + "contentPreview": "" }; createProcess.command = ["touch", path]; createProcess.running = true; @@ -124,7 +126,8 @@ Singleton { root.notesModel.append({ "notePath": Paths.notesDir + "/" + fileName, - "colorIdx": strToColor(fileName) + "colorIdx": strToColor(fileName), + "contentPreview": "" }); Logger.d("Notes", "Loaded note: " + fileName); } @@ -136,6 +139,24 @@ Singleton { } + Instantiator { + model: notesModel + + delegate: FileView { + path: model.notePath + watchChanges: true + onFileChanged: reload() + onLoaded: { + const content = text(); + if (!content) + model.contentPreview = "(empty note)"; + else + model.contentPreview = content.trim().split('\n').slice(0, 5).join('\n'); + } + } + + } + notesModel: ListModel { }