Wallpaper: improved over conditional wallpaper management

- hide all wallpaper settings if feature is disabled
- hide wallpaper selector if feature is disabled
- hide quick access wallpaper if feature is disabled
This commit is contained in:
LemmyCook 2025-09-01 19:58:05 -04:00
parent fac72b257c
commit cb7b1d92c6
3 changed files with 96 additions and 68 deletions

View file

@ -46,6 +46,18 @@ NPanel {
property int requestedTab: SettingsPanel.Tab.General property int requestedTab: SettingsPanel.Tab.General
property int currentTabIndex: 0 property int currentTabIndex: 0
property var tabsModel: []
Connections {
target: Settings.data.wallpaper
function onEnabledChanged() {
updateTabsModel()
}
}
Component.onCompleted: {
updateTabsModel()
}
Component { Component {
id: generalTab id: generalTab
@ -102,7 +114,8 @@ NPanel {
} }
// Order *DOES* matter // Order *DOES* matter
property var tabsModel: [{ function updateTabsModel() {
let newTabs = [{
"id": SettingsPanel.Tab.General, "id": SettingsPanel.Tab.General,
"label": "General", "label": "General",
"icon": "tune", "icon": "tune",
@ -152,12 +165,19 @@ NPanel {
"label": "Wallpaper", "label": "Wallpaper",
"icon": "image", "icon": "image",
"source": wallpaperTab "source": wallpaperTab
}, { }]
// Only add the Wallpaper Selector tab if the feature is enabled
if (Settings.data.wallpaper.enabled) {
newTabs.push({
"id": SettingsPanel.Tab.WallpaperSelector, "id": SettingsPanel.Tab.WallpaperSelector,
"label": "Wallpaper Selector", "label": "Wallpaper Selector",
"icon": "wallpaper_slideshow", "icon": "wallpaper_slideshow",
"source": wallpaperSelectorTab "source": wallpaperSelectorTab
}, { })
}
newTabs.push({
"id": SettingsPanel.Tab.ScreenRecorder, "id": SettingsPanel.Tab.ScreenRecorder,
"label": "Screen Recorder", "label": "Screen Recorder",
"icon": "videocam", "icon": "videocam",
@ -167,10 +187,14 @@ NPanel {
"label": "About", "label": "About",
"icon": "info", "icon": "info",
"source": aboutTab "source": aboutTab
}] })
root.tabsModel = newTabs // Assign the generated list to the model
}
// When the panel opens, choose the appropriate tab // When the panel opens, choose the appropriate tab
onOpened: { onOpened: {
updateTabsModel()
var initialIndex = SettingsPanel.Tab.General var initialIndex = SettingsPanel.Tab.General
if (root.requestedTab !== null) { if (root.requestedTab !== null) {
for (var i = 0; i < root.tabsModel.length; i++) { for (var i = 0; i < root.tabsModel.length; i++) {

View file

@ -12,13 +12,14 @@ ColumnLayout {
NToggle { NToggle {
label: "Enable Wallpaper Management" label: "Enable Wallpaper Management"
description: "Let Quickshell manage your wallpaper. Disable this if you use an external wallpaper daemon like swww." description: "Manage wallpapers with Noctalia. (Uncheck if you prefer using another application)."
checked: Settings.data.wallpaper.enabled checked: Settings.data.wallpaper.enabled
onToggled: checked => Settings.data.wallpaper.enabled = checked onToggled: checked => Settings.data.wallpaper.enabled = checked
Layout.bottomMargin: Style.marginL * scaling
} }
ColumnLayout { ColumnLayout {
enabled: Settings.data.wallpaper.enabled visible: Settings.data.wallpaper.enabled
spacing: Style.marginL * scaling spacing: Style.marginL * scaling
Layout.fillWidth: true Layout.fillWidth: true
NTextInput { NTextInput {
@ -77,12 +78,14 @@ ColumnLayout {
} }
NDivider { NDivider {
visible: Settings.data.wallpaper.enabled
Layout.fillWidth: true Layout.fillWidth: true
Layout.topMargin: Style.marginXL * scaling Layout.topMargin: Style.marginXL * scaling
Layout.bottomMargin: Style.marginXL * scaling Layout.bottomMargin: Style.marginXL * scaling
} }
ColumnLayout { ColumnLayout {
visible: Settings.data.wallpaper.enabled
spacing: Style.marginL * scaling spacing: Style.marginL * scaling
Layout.fillWidth: true Layout.fillWidth: true

View file

@ -47,6 +47,7 @@ NBox {
// Wallpaper // Wallpaper
NIconButton { NIconButton {
visible: Settings.data.wallpaper.enabled
icon: "image" icon: "image"
tooltipText: "Left click: Open wallpaper selector\nRight click: Set random wallpaper" tooltipText: "Left click: Open wallpaper selector\nRight click: Set random wallpaper"
onClicked: { onClicked: {