From 40fe0bebcf7c4b328b64325dc8a06192b9a40640 Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Sun, 12 Oct 2025 20:17:31 +0200 Subject: [PATCH] prevent empty sidebar --- .../ii/modules/settings/GeneralConfig.qml | 64 ++++++++++--------- .../sidebarLeft/SidebarLeftContent.qml | 24 ++++--- 2 files changed, 49 insertions(+), 39 deletions(-) diff --git a/.config/quickshell/ii/modules/settings/GeneralConfig.qml b/.config/quickshell/ii/modules/settings/GeneralConfig.qml index 2dcc39a2e..74ed1cdf2 100644 --- a/.config/quickshell/ii/modules/settings/GeneralConfig.qml +++ b/.config/quickshell/ii/modules/settings/GeneralConfig.qml @@ -144,41 +144,13 @@ ContentPage { title: Translation.tr("Policies") ConfigRow { - ColumnLayout { - // Weeb policy - ContentSubsectionLabel { - text: Translation.tr("Weeb") - } - ConfigSelectionArray { - currentValue: Config.options.policies.weeb - onSelected: newValue => { - Config.options.policies.weeb = newValue; - } - options: [ - { - displayName: Translation.tr("No"), - icon: "close", - value: 0 - }, - { - displayName: Translation.tr("Yes"), - icon: "check", - value: 1 - }, - { - displayName: Translation.tr("Closet"), - icon: "ev_shadow", - value: 2 - } - ] - } - } + // AI policy ColumnLayout { - // AI policy ContentSubsectionLabel { text: Translation.tr("AI") } + ConfigSelectionArray { currentValue: Config.options.policies.ai onSelected: newValue => { @@ -203,6 +175,38 @@ ContentPage { ] } } + + // Weeb policy + ColumnLayout { + + ContentSubsectionLabel { + text: Translation.tr("Weeb") + } + + ConfigSelectionArray { + currentValue: Config.options.policies.weeb + onSelected: newValue => { + Config.options.policies.weeb = newValue; + } + options: [ + { + displayName: Translation.tr("No"), + icon: "close", + value: 0 + }, + { + displayName: Translation.tr("Yes"), + icon: "check", + value: 1 + }, + { + displayName: Translation.tr("Closet"), + icon: "ev_shadow", + value: 2 + } + ] + } + } } } diff --git a/.config/quickshell/ii/modules/sidebarLeft/SidebarLeftContent.qml b/.config/quickshell/ii/modules/sidebarLeft/SidebarLeftContent.qml index ee5e1cccb..341e73e64 100644 --- a/.config/quickshell/ii/modules/sidebarLeft/SidebarLeftContent.qml +++ b/.config/quickshell/ii/modules/sidebarLeft/SidebarLeftContent.qml @@ -12,12 +12,17 @@ Item { id: root required property var scopeRoot anchors.fill: parent + property bool aiChatEnabled: Config.options.policies.ai !== 0 + property bool translatorEnabled: Config.options.sidebar.translator.enable + property bool animeEnabled: Config.options.policies.weeb !== 0 + property bool animeCloset: Config.options.policies.weeb === 2 property var tabButtonList: [ - ...(Config.options.policies.ai !== 0 ? [{"icon": "neurology", "name": Translation.tr("Intelligence")}] : []), - ...(Config.options.sidebar.translator.enable ? [{"icon": "translate", "name": Translation.tr("Translator")}] : []), - ...(Config.options.policies.weeb === 1 ? [{"icon": "bookmark_heart", "name": Translation.tr("Anime")}] : []) + ...(root.aiChatEnabled ? [{"icon": "neurology", "name": Translation.tr("Intelligence")}] : []), + ...(root.translatorEnabled ? [{"icon": "translate", "name": Translation.tr("Translator")}] : []), + ...((root.animeEnabled && !root.animeCloset) ? [{"icon": "bookmark_heart", "name": Translation.tr("Anime")}] : []) ] property int selectedTab: 0 + property int tabCount: swipeView.count function focusActiveItem() { swipeView.currentItem.forceActiveFocus() @@ -26,7 +31,7 @@ Item { Keys.onPressed: (event) => { if (event.modifiers === Qt.ControlModifier) { if (event.key === Qt.Key_PageDown) { - root.selectedTab = Math.min(root.selectedTab + 1, root.tabButtonList.length - 1) + root.selectedTab = Math.min(root.selectedTab + 1, root.tabCount - 1) event.accepted = true; } else if (event.key === Qt.Key_PageUp) { @@ -34,11 +39,11 @@ Item { event.accepted = true; } else if (event.key === Qt.Key_Tab) { - root.selectedTab = (root.selectedTab + 1) % root.tabButtonList.length; + root.selectedTab = (root.selectedTab + 1) % root.tabCount; event.accepted = true; } else if (event.key === Qt.Key_Backtab) { - root.selectedTab = (root.selectedTab - 1 + root.tabButtonList.length) % root.tabButtonList.length; + root.selectedTab = (root.selectedTab - 1 + root.tabCount) % root.tabCount; event.accepted = true; } } @@ -52,6 +57,7 @@ Item { PrimaryTabBar { // Tab strip id: tabBar + visible: root.tabButtonList.length > 1 tabButtonList: root.tabButtonList externalTrackedTab: root.selectedTab function onCurrentIndexChanged(currentIndex) { @@ -83,9 +89,9 @@ Item { } contentChildren: [ - ...(Config.options.policies.ai !== 0 ? [aiChat.createObject()] : []), - ...(Config.options.sidebar.translator.enable ? [translator.createObject()] : []), - ...(Config.options.policies.weeb === 0 ? [] : [anime.createObject()]) + ...((root.aiChatEnabled || (!root.translatorEnabled && !root.animeEnabled)) ? [aiChat.createObject()] : []), + ...(root.translatorEnabled ? [translator.createObject()] : []), + ...(root.animeEnabled ? [anime.createObject()] : []) ] }