qs: better notes
This commit is contained in:
@@ -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)));
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user