mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-08-12 17:21:17 +00:00
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.
64 lines
2.1 KiB
QML
64 lines
2.1 KiB
QML
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Widgets
|
|
import QtQuick.Effects
|
|
import qs.Commons
|
|
import qs.Widgets
|
|
import qs.Services
|
|
|
|
NIconButton {
|
|
id: root
|
|
|
|
property ShellScreen screen
|
|
property real scaling: 1.0
|
|
|
|
// Widget properties passed from Bar.qml for per-instance settings
|
|
property string widgetId: ""
|
|
property string section: ""
|
|
property int sectionWidgetIndex: -1
|
|
property int sectionWidgetsCount: 0
|
|
|
|
property var widgetMetadata: BarWidgetRegistry.widgetMetadata[widgetId]
|
|
property var widgetSettings: {
|
|
if (section && sectionWidgetIndex >= 0) {
|
|
var widgets = Settings.data.bar.widgets[section]
|
|
if (widgets && sectionWidgetIndex < widgets.length) {
|
|
return widgets[sectionWidgetIndex]
|
|
}
|
|
}
|
|
return {}
|
|
}
|
|
|
|
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 || ""
|
|
|
|
// 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")
|
|
colorBg: (Settings.data.bar.showCapsule ? Color.mSurfaceVariant : Color.transparent)
|
|
colorFg: Color.mOnSurface
|
|
colorBgHover: useDistroLogo ? Color.mSurfaceVariant : Color.mTertiary
|
|
colorBorder: Color.transparent
|
|
colorBorderHover: useDistroLogo ? Color.mTertiary : Color.transparent
|
|
onClicked: PanelService.getPanel("sidePanel")?.toggle(this)
|
|
onRightClicked: PanelService.getPanel("settingsPanel")?.toggle()
|
|
|
|
IconImage {
|
|
id: customOrDistroLogo
|
|
anchors.centerIn: parent
|
|
width: root.width * 0.8
|
|
height: width
|
|
source: {
|
|
if (customIconPath !== "") return customIconPath;
|
|
if (useDistroLogo) return DistroLogoService.osLogo;
|
|
return "";
|
|
}
|
|
visible: source !== ""
|
|
smooth: true
|
|
asynchronous: true
|
|
}
|
|
}
|