feat(simple-notes): icon customization, hide widget, IPC toggle, and file export (v1.1.0)#378
feat(simple-notes): icon customization, hide widget, IPC toggle, and file export (v1.1.0)#378fusuyfusuy wants to merge 1 commit intonoctalia-dev:mainfrom
Conversation
spiros132
left a comment
There was a problem hiding this comment.
Some feedback and questions about the PR :)
| id: fileExporter | ||
| path: "" | ||
| watchChanges: false | ||
| } |
There was a problem hiding this comment.
Would it be possible to have some type of error handling so that the user would be able to know what was wrong if the file was weirdly formatted?
| "positionMode": "attached", | ||
| "barIcon": "paperclip", | ||
| "hideBarWidget": false, | ||
| "notesDirectory": "" |
There was a problem hiding this comment.
I'm a bit confused you are including these defaultSettings but not including them anywhere in the code. For example you could do the following:
// Instead of this
readonly property string barIcon: pluginApi?.pluginSettings?.barIcon ?? "paperclip"
// You can have the following instead:
// (NOTE: the following functions aren't needed but you can add them for readabilities sake)
readonly property cfg: pluginApi?.pluginSettings ?? ({})
readonly property defaults: pluginApi?.manifest?.metadata?.defaultSettings ?? ({})
readonly property string barIcon: cfg.barIcon ?? defaults.barIcon ?? "paperclip"
| property real contentPreferredWidth: 700 * Style.uiScaleRatio | ||
| property real contentPreferredHeight: 500 * Style.uiScaleRatio | ||
| readonly property bool allowAttach: true | ||
| readonly property string positionMode: pluginApi?.pluginSettings?.positionMode || "attached" |
There was a problem hiding this comment.
An example of the above comment is here
| if (pluginApi.pluginSettings.notesDirectory === undefined) { | ||
| pluginApi.pluginSettings.notesDirectory = ""; | ||
| pluginApi.saveSettings(); | ||
| } |
There was a problem hiding this comment.
In my opinion you shouldn't depend on the main file to instantiate and save the settings. By using the method before with the default settings you could technically also have the following:
// As a quick example with no fallback value since the value is taken from the defaults
...
readonly property key: cfg.key ?? defaults.key ?? ""| Layout.fillWidth: true | ||
| placeholderText: titleInput.text | ||
| ? root.sanitizeFileName(titleInput.text) | ||
| : (pluginApi?.tr("panel.editor.filename_placeholder") || "auto-generated-from-title.md") |
There was a problem hiding this comment.
When it comes to translations, you don't need to use fallback values anymore. So the following works:
// From:
pluginApi?.tr("key") || "Value"
// To this:
pluginApi?.tr("key")| "positionMode": "attached", | ||
| "barIcon": "paperclip", | ||
| "hideBarWidget": false, | ||
| "notesDirectory": "" |
There was a problem hiding this comment.
Would the ~/Documents folder be a good default for the notesDirectory?
| // 3. Hide Bar Widget | ||
| NToggle { | ||
| label: pluginApi?.tr("settings.hide_bar_widget.label") || "Hide Bar Widget" | ||
| description: pluginApi?.tr("settings.hide_bar_widget.description") || "Hide the bar widget from the status bar" |
There was a problem hiding this comment.
As before you don't need translation fallbacks anymore
|
Thx for the feedback. Working on it |
Automatic Code Quality ReviewFile: simple-notes/BarWidget.qml
property int sectionWidgetIndex: -1
property int sectionWidgetsCount: 0File: simple-notes/Panel.qml
+ root.exportError = pluginApi?.tr("panel.export.error") ?? ("Failed to export note: " + e);File: simple-notes/Settings.qml
+ text: "qs -c noctalia-shell ipc call plugin:simple-notes togglePanel" |
Automatic Code Quality ReviewFile: simple-notes/Panel.qml
+ root.exportError = pluginApi?.tr("panel.export.error") ?? ("Failed to export note: " + e);File: simple-notes/Settings.qml
+ text: "qs -c noctalia-shell ipc call plugin:simple-notes togglePanel" |
Automatic Code Quality ReviewFile: simple-notes/Panel.qml
+ root.exportError = pluginApi?.tr("panel.export.error") ?? ("Failed to export note: " + e);File: simple-notes/Settings.qml
+ text: "qs -c noctalia-shell ipc call plugin:simple-notes togglePanel" |
… export (v1.1.0) Implements: noctalia-dev#212 Changes: - Add customizable bar icon via NIconPicker (pattern: update-count) - Add hide bar widget toggle with smooth opacity/size animation - Add IPC handler for togglePanel with keyboard shortcut display in Settings - Add optional .md file export with directory picker and per-note filenames - Bump version 1.0.3 -> 1.1.0 Review feedback addressed (@spiros132): - Use cfg/defaults pattern throughout: cfg.key ?? defaults.key ?? fallback so defaultSettings in manifest.json are actually used as fallbacks - Remove Component.onCompleted settings initialization from Main.qml - Remove translation fallback strings (|| 'Value') from Panel.qml and Settings.qml - Add error handling for file export: try/catch, exportError state, dismissable error banner in the Panel UI - Change notesDirectory default to ~/Documents in manifest.json Upstream changes incorporated: - Add mandatory sectionWidgetIndex and sectionWidgetsCount props to BarWidget.qml - Fix NButton delete button to use backgroundColor instead of color (704eb32)
Automatic Code Quality ReviewFile: simple-notes/Panel.qml
+ root.exportError = pluginApi?.tr("panel.export.error") ?? ("Failed to export note: " + e);File: simple-notes/Settings.qml
+ text: "qs -c noctalia-shell ipc call plugin:simple-notes togglePanel" |
Implemented this requests: #212
Summary
Changes from review feedback (@spiros132)
cfg.key ?? defaults.key ?? fallbacksodefaultSettingsin manifest.json are actually used as fallbacks|| 'Value') from Panel.qml and Settings.qmlexportNoteToFile(),exportErrorstate property, and a dismissable error banner in the Panel UInotesDirectorydefault to~/Documentsin manifest.json