really rename all "stickypad" to "notes"

This commit is contained in:
end-4
2025-11-14 14:32:58 +01:00
parent 42f29d47b4
commit c19dd725b8
4 changed files with 45 additions and 45 deletions
@@ -33,7 +33,7 @@ Singleton {
property string shellConfigName: "config.json" property string shellConfigName: "config.json"
property string shellConfigPath: `${Directories.shellConfig}/${Directories.shellConfigName}` property string shellConfigPath: `${Directories.shellConfig}/${Directories.shellConfigName}`
property string todoPath: FileUtils.trimFileProtocol(`${Directories.state}/user/todo.json`) property string todoPath: FileUtils.trimFileProtocol(`${Directories.state}/user/todo.json`)
property string stickypadPath: FileUtils.trimFileProtocol(`${Directories.state}/user/stickypad.txt`) property string notesPath: FileUtils.trimFileProtocol(`${Directories.state}/user/notes.txt`)
property string conflictCachePath: FileUtils.trimFileProtocol(`${Directories.cache}/conflict-killer`) property string conflictCachePath: FileUtils.trimFileProtocol(`${Directories.cache}/conflict-killer`)
property string notificationsPath: FileUtils.trimFileProtocol(`${Directories.cache}/notifications/notifications.json`) property string notificationsPath: FileUtils.trimFileProtocol(`${Directories.cache}/notifications/notifications.json`)
property string generatedMaterialThemePath: FileUtils.trimFileProtocol(`${Directories.state}/user/generated/colors.json`) property string generatedMaterialThemePath: FileUtils.trimFileProtocol(`${Directories.state}/user/generated/colors.json`)
@@ -12,7 +12,7 @@ import qs.modules.ii.overlay.floatingImage
import qs.modules.ii.overlay.fpsLimiter import qs.modules.ii.overlay.fpsLimiter
import qs.modules.ii.overlay.recorder import qs.modules.ii.overlay.recorder
import qs.modules.ii.overlay.resources import qs.modules.ii.overlay.resources
import qs.modules.ii.overlay.stickypad import qs.modules.ii.overlay.notes
DelegateChooser { DelegateChooser {
id: root id: root
@@ -23,6 +23,6 @@ DelegateChooser {
DelegateChoice { roleValue: "fpsLimiter"; FpsLimiter {} } DelegateChoice { roleValue: "fpsLimiter"; FpsLimiter {} }
DelegateChoice { roleValue: "recorder"; Recorder {} } DelegateChoice { roleValue: "recorder"; Recorder {} }
DelegateChoice { roleValue: "resources"; Resources {} } DelegateChoice { roleValue: "resources"; Resources {} }
DelegateChoice { roleValue: "notes"; Stickypad {} } DelegateChoice { roleValue: "notes"; Notes {} }
DelegateChoice { roleValue: "volumeMixer"; VolumeMixer {} } DelegateChoice { roleValue: "volumeMixer"; VolumeMixer {} }
} }
@@ -10,7 +10,7 @@ StyledOverlayWidget {
title: Translation.tr("Notes") title: Translation.tr("Notes")
showCenterButton: true showCenterButton: true
contentItem: StickypadContent { contentItem: NotesContent {
radius: root.contentRadius radius: root.contentRadius
isClickthrough: root.clickthrough isClickthrough: root.clickthrough
} }
@@ -12,7 +12,7 @@ import qs.modules.ii.overlay
OverlayBackground { OverlayBackground {
id: root id: root
property alias stickypadContents: stickypadInput.text property alias content: textInput.text
property bool pendingReload: false property bool pendingReload: false
property var copyListEntries: [] property var copyListEntries: []
property string lastParsedCopylistText: "" property string lastParsedCopylistText: ""
@@ -21,37 +21,37 @@ OverlayBackground {
property real maxCopyButtonSize: 20 property real maxCopyButtonSize: 20
Component.onCompleted: { Component.onCompleted: {
stickypadFile.reload(); noteFile.reload();
updateCopyListEntries(); updateCopyListEntries();
} }
function saveStickypad() { function saveContent() {
if (!stickypadInput) if (!textInput)
return; return;
stickypadFile.setText(root.stickypadContents); noteFile.setText(root.content);
} }
function focusStickypadAtEnd() { function focusAtEnd() {
if (!stickypadInput) if (!textInput)
return; return;
stickypadInput.forceActiveFocus(); textInput.forceActiveFocus();
const endPos = root.stickypadContents.length; const endPos = root.content.length;
applySelection(endPos, endPos); applySelection(endPos, endPos);
} }
function applySelection(cursorPos, anchorPos) { function applySelection(cursorPos, anchorPos) {
if (!stickypadInput) if (!textInput)
return; return;
const textLength = root.stickypadContents.length; const textLength = root.content.length;
const cursor = Math.max(0, Math.min(cursorPos, textLength)); const cursor = Math.max(0, Math.min(cursorPos, textLength));
const anchor = Math.max(0, Math.min(anchorPos, textLength)); const anchor = Math.max(0, Math.min(anchorPos, textLength));
stickypadInput.select(anchor, cursor); textInput.select(anchor, cursor);
if (cursor === anchor) if (cursor === anchor)
stickypadInput.deselect(); textInput.deselect();
} }
function scheduleCopylistUpdate(immediate = false) { function scheduleCopylistUpdate(immediate = false) {
if (!stickypadInput) if (!textInput)
return; return;
if (immediate) { if (immediate) {
copyListDebounce?.stop(); copyListDebounce?.stop();
@@ -62,9 +62,9 @@ OverlayBackground {
} }
function updateCopyListEntries() { function updateCopyListEntries() {
if (!stickypadInput) if (!textInput)
return; return;
const textValue = root.stickypadContents; const textValue = root.content;
if (!textValue || textValue.length === 0) { if (!textValue || textValue.length === 0) {
lastParsedCopylistText = ""; lastParsedCopylistText = "";
parsedCopylistLines = []; parsedCopylistLines = [];
@@ -104,12 +104,12 @@ OverlayBackground {
} }
function updateCopylistPositions() { function updateCopylistPositions() {
if (!stickypadInput || parsedCopylistLines.length === 0) if (!textInput || parsedCopylistLines.length === 0)
return; return;
const rawSelectionStart = stickypadInput.selectionStart; const rawSelectionStart = textInput.selectionStart;
const rawSelectionEnd = stickypadInput.selectionEnd; const rawSelectionEnd = textInput.selectionEnd;
const selectionStart = rawSelectionStart === -1 ? stickypadInput.cursorPosition : rawSelectionStart; const selectionStart = rawSelectionStart === -1 ? textInput.cursorPosition : rawSelectionStart;
const selectionEnd = rawSelectionEnd === -1 ? stickypadInput.cursorPosition : rawSelectionEnd; const selectionEnd = rawSelectionEnd === -1 ? textInput.cursorPosition : rawSelectionEnd;
const rangeStart = Math.min(selectionStart, selectionEnd); const rangeStart = Math.min(selectionStart, selectionEnd);
const rangeEnd = Math.max(selectionStart, selectionEnd); const rangeEnd = Math.max(selectionStart, selectionEnd);
@@ -118,14 +118,14 @@ OverlayBackground {
const caretIntersects = rangeEnd > line.start && rangeStart <= line.end; const caretIntersects = rangeEnd > line.start && rangeStart <= line.end;
if (caretIntersects) if (caretIntersects)
return null; return null;
const startRect = stickypadInput.positionToRectangle(line.start); const startRect = textInput.positionToRectangle(line.start);
let endRect = stickypadInput.positionToRectangle(line.end); let endRect = textInput.positionToRectangle(line.end);
if (!isFinite(startRect.y)) if (!isFinite(startRect.y))
return null; return null;
if (!isFinite(endRect.y)) if (!isFinite(endRect.y))
endRect = startRect; endRect = startRect;
const lineBottom = endRect.y + endRect.height; const lineBottom = endRect.y + endRect.height;
const rectHeight = Math.max(lineBottom - startRect.y, stickypadInput.font.pixelSize + 8); const rectHeight = Math.max(lineBottom - startRect.y, textInput.font.pixelSize + 8);
return { return {
content: line.content, content: line.content,
y: startRect.y, y: startRect.y,
@@ -137,7 +137,7 @@ OverlayBackground {
} }
ColumnLayout { ColumnLayout {
id: stickypadLayout id: contentItem
anchors.fill: parent anchors.fill: parent
spacing: -16 spacing: -16
@@ -150,7 +150,7 @@ OverlayBackground {
onWidthChanged: root.scheduleCopylistUpdate(true) onWidthChanged: root.scheduleCopylistUpdate(true)
StyledTextArea { // This has to be a direct child of ScrollView for proper scrolling StyledTextArea { // This has to be a direct child of ScrollView for proper scrolling
id: stickypadInput id: textInput
anchors { anchors {
left: parent.left left: parent.left
right: parent.right right: parent.right
@@ -165,7 +165,7 @@ OverlayBackground {
rightPadding: root.maxCopyButtonSize + padding rightPadding: root.maxCopyButtonSize + padding
onTextChanged: { onTextChanged: {
if (stickypadInput.activeFocus) { if (textInput.activeFocus) {
saveDebounce.restart(); saveDebounce.restart();
} }
root.scheduleCopylistUpdate(true); root.scheduleCopylistUpdate(true);
@@ -179,7 +179,7 @@ OverlayBackground {
} }
Item { Item {
anchors.fill: stickypadInput anchors.fill: textInput
visible: root.copyListEntries.length > 0 visible: root.copyListEntries.length > 0
clip: true clip: true
@@ -246,7 +246,7 @@ OverlayBackground {
id: saveDebounce id: saveDebounce
interval: 500 interval: 500
repeat: false repeat: false
onTriggered: saveStickypad() onTriggered: saveContent()
} }
Timer { Timer {
@@ -257,33 +257,33 @@ OverlayBackground {
} }
FileView { FileView {
id: stickypadFile id: noteFile
path: Qt.resolvedUrl(Directories.stickypadPath) path: Qt.resolvedUrl(Directories.notesPath)
onLoaded: { onLoaded: {
root.stickypadContents = stickypadFile.text(); root.content = noteFile.text();
if (root.stickypadContents !== root.stickypadContents) { if (root.content !== root.content) {
const previousCursor = stickypadInput.cursorPosition; const previousCursor = textInput.cursorPosition;
const previousAnchor = stickypadInput.selectionStart; const previousAnchor = textInput.selectionStart;
root.stickypadContents = root.stickypadContents; root.content = root.content;
applySelection(previousCursor, previousAnchor); applySelection(previousCursor, previousAnchor);
} }
if (pendingReload) { if (pendingReload) {
pendingReload = false; pendingReload = false;
Qt.callLater(root.focusStickypadAtEnd); Qt.callLater(root.focusAtEnd);
} }
Qt.callLater(root.updateCopyListEntries); Qt.callLater(root.updateCopyListEntries);
} }
onLoadFailed: error => { onLoadFailed: error => {
if (error === FileViewError.FileNotFound) { if (error === FileViewError.FileNotFound) {
root.stickypadContents = ""; root.content = "";
stickypadFile.setText(root.stickypadContents); noteFile.setText(root.content);
if (pendingReload) { if (pendingReload) {
pendingReload = false; pendingReload = false;
Qt.callLater(root.focusStickypadAtEnd); Qt.callLater(root.focusAtEnd);
} }
Qt.callLater(root.updateCopyListEntries); Qt.callLater(root.updateCopyListEntries);
} else { } else {
console.log("[Stickypad] Error loading file: " + error); console.log("[Overlay Notes] Error loading file: " + error);
} }
} }
} }