qs: better notes
This commit is contained in:
@@ -23,8 +23,7 @@ Item {
|
|||||||
readonly property real viewportHeight: outputHeight > 0 ? outputHeight : height
|
readonly property real viewportHeight: outputHeight > 0 ? outputHeight : height
|
||||||
readonly property real scrollProgress: {
|
readonly property real scrollProgress: {
|
||||||
if (workspaceCount <= 1 || focusedIndex < 0)
|
if (workspaceCount <= 1 || focusedIndex < 0)
|
||||||
return 0;
|
return 0.5; // Center
|
||||||
|
|
||||||
return Math.max(0, Math.min(1, (focusedIndex - 1) / (workspaceCount - 1)));
|
return Math.max(0, Math.min(1, (focusedIndex - 1) / (workspaceCount - 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -107,14 +107,6 @@ Rectangle {
|
|||||||
onClicked: NotesService.openNote(model.notePath)
|
onClicked: NotesService.openNote(model.notePath)
|
||||||
}
|
}
|
||||||
|
|
||||||
FileView {
|
|
||||||
id: fileView
|
|
||||||
|
|
||||||
path: model.notePath
|
|
||||||
watchChanges: true
|
|
||||||
onFileChanged: reload()
|
|
||||||
}
|
|
||||||
|
|
||||||
RowLayout {
|
RowLayout {
|
||||||
id: noteLayout
|
id: noteLayout
|
||||||
|
|
||||||
@@ -124,13 +116,7 @@ Rectangle {
|
|||||||
|
|
||||||
UText {
|
UText {
|
||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
text: {
|
text: model.contentPreview
|
||||||
var t = fileView.text();
|
|
||||||
if (!t)
|
|
||||||
return "(empty note)";
|
|
||||||
|
|
||||||
return t.trim().split('\n').slice(0, 5).join('\n');
|
|
||||||
}
|
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
maximumLineCount: 5
|
maximumLineCount: 5
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import QtQml
|
||||||
import QtQuick
|
import QtQuick
|
||||||
import Quickshell
|
import Quickshell
|
||||||
import Quickshell.Io
|
import Quickshell.Io
|
||||||
@@ -20,7 +21,8 @@ Singleton {
|
|||||||
const path = Paths.notesDir + "/" + fileName;
|
const path = Paths.notesDir + "/" + fileName;
|
||||||
createProcess.currentNote = {
|
createProcess.currentNote = {
|
||||||
"notePath": path,
|
"notePath": path,
|
||||||
"colorIdx": strToColor(fileName)
|
"colorIdx": strToColor(fileName),
|
||||||
|
"contentPreview": ""
|
||||||
};
|
};
|
||||||
createProcess.command = ["touch", path];
|
createProcess.command = ["touch", path];
|
||||||
createProcess.running = true;
|
createProcess.running = true;
|
||||||
@@ -124,7 +126,8 @@ Singleton {
|
|||||||
|
|
||||||
root.notesModel.append({
|
root.notesModel.append({
|
||||||
"notePath": Paths.notesDir + "/" + fileName,
|
"notePath": Paths.notesDir + "/" + fileName,
|
||||||
"colorIdx": strToColor(fileName)
|
"colorIdx": strToColor(fileName),
|
||||||
|
"contentPreview": ""
|
||||||
});
|
});
|
||||||
Logger.d("Notes", "Loaded note: " + fileName);
|
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 {
|
notesModel: ListModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user