feat(bar): Allow custom icon for SidePanelToggle

Adds a feature allowing users to select a custom image file to be used
as the icon for the SidePanelToggle widget.
  - Introduces a "Browse File" button in the widget's settings dialog,
utilizing the `NFilePicker` component.
  - An `NImageCircled` preview of the selected custom icon is now shown
in the settings.
  - The display logic for the widget is updated to prioritize the custom
icon path over the library icon and distro logo.
This commit is contained in:
loner
2025-09-22 11:05:26 +08:00
parent f348eb993c
commit f25bba7c11
3 changed files with 48 additions and 10 deletions
+10 -4
View File
@@ -31,8 +31,10 @@ NIconButton {
readonly property string customIcon: widgetSettings.icon || widgetMetadata.icon
readonly property bool useDistroLogo: (widgetSettings.useDistroLogo !== undefined) ? widgetSettings.useDistroLogo : widgetMetadata.useDistroLogo
readonly property string customIconPath: widgetSettings.customIconPath || ""
icon: useDistroLogo ? "" : customIcon
// If we have a custom path or distro logo, don't use the theme icon.
icon: (customIconPath === "" && !useDistroLogo) ? customIcon : ""
tooltipText: "Open side panel"
baseSize: Style.capsuleHeight
compact: (Settings.data.bar.density === "compact")
@@ -45,12 +47,16 @@ NIconButton {
onRightClicked: PanelService.getPanel("settingsPanel")?.toggle()
IconImage {
id: logo
id: customOrDistroLogo
anchors.centerIn: parent
width: root.width * 0.8
height: width
source: useDistroLogo ? DistroLogoService.osLogo : ""
visible: useDistroLogo && source !== ""
source: {
if (customIconPath !== "") return customIconPath;
if (useDistroLogo) return DistroLogoService.osLogo;
return "";
}
visible: source !== ""
smooth: true
asynchronous: true
}