Merge pull request #335 from lonerOrz/sidepanel

feat(bar): Allow custom icon for SidePanelToggle
This commit is contained in:
Lemmy
2025-09-22 11:49:00 -04:00
committed by GitHub
3 changed files with 48 additions and 10 deletions
@@ -16,18 +16,34 @@ ColumnLayout {
// Local state
property string valueIcon: widgetData.icon !== undefined ? widgetData.icon : widgetMetadata.icon
property bool valueUseDistroLogo: widgetData.useDistroLogo !== undefined ? widgetData.useDistroLogo : widgetMetadata.useDistroLogo
property string valueCustomIconPath: widgetData.customIconPath !== undefined ? widgetData.customIconPath : ""
function saveSettings() {
var settings = Object.assign({}, widgetData || {})
settings.icon = valueIcon
settings.useDistroLogo = valueUseDistroLogo
settings.customIconPath = valueCustomIconPath
return settings
}
NToggle {
label: "Use distro logo instead of icon"
checked: valueUseDistroLogo
onToggled: checked => valueUseDistroLogo = checked
onToggled: {
valueUseDistroLogo = checked
if (checked) {
valueCustomIconPath = ""
valueIcon = ""
}
}
}
NFilePicker {
id: filePicker
title: "Select a custom icon"
onFileSelected: function (filePath) {
valueCustomIconPath = "file://" + filePath
}
}
RowLayout {
@@ -35,21 +51,35 @@ ColumnLayout {
NLabel {
label: "Icon"
description: "Select an icon from the library."
description: "Select an icon from the library or a custom file."
}
NImageCircled {
Layout.alignment: Qt.AlignVCenter
imagePath: valueCustomIconPath
visible: valueCustomIconPath !== ""
width: Style.fontSizeXL * 2 * scaling
height: Style.fontSizeXL * 2 * scaling
}
NIcon {
Layout.alignment: Qt.AlignVCenter
icon: valueIcon
font.pointSize: Style.fontSizeXL * scaling
visible: valueIcon !== ""
visible: valueIcon !== "" && valueCustomIconPath === ""
}
NButton {
enabled: !valueUseDistroLogo
text: "Browse"
text: "Browse Library"
onClicked: iconPicker.open()
}
NButton {
enabled: !valueUseDistroLogo
text: "Browse File"
onClicked: filePicker.open()
}
}
NIconPicker {
@@ -57,6 +87,7 @@ ColumnLayout {
initialIcon: valueIcon
onIconSelected: function (iconName) {
valueIcon = iconName
valueCustomIconPath = ""
}
}
}
}