forked from Shinonome/dots-hyprland
prevent empty sidebar
This commit is contained in:
@@ -144,41 +144,13 @@ ContentPage {
|
|||||||
title: Translation.tr("Policies")
|
title: Translation.tr("Policies")
|
||||||
|
|
||||||
ConfigRow {
|
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 {
|
ColumnLayout {
|
||||||
// AI policy
|
|
||||||
ContentSubsectionLabel {
|
ContentSubsectionLabel {
|
||||||
text: Translation.tr("AI")
|
text: Translation.tr("AI")
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigSelectionArray {
|
ConfigSelectionArray {
|
||||||
currentValue: Config.options.policies.ai
|
currentValue: Config.options.policies.ai
|
||||||
onSelected: newValue => {
|
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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,17 @@ Item {
|
|||||||
id: root
|
id: root
|
||||||
required property var scopeRoot
|
required property var scopeRoot
|
||||||
anchors.fill: parent
|
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: [
|
property var tabButtonList: [
|
||||||
...(Config.options.policies.ai !== 0 ? [{"icon": "neurology", "name": Translation.tr("Intelligence")}] : []),
|
...(root.aiChatEnabled ? [{"icon": "neurology", "name": Translation.tr("Intelligence")}] : []),
|
||||||
...(Config.options.sidebar.translator.enable ? [{"icon": "translate", "name": Translation.tr("Translator")}] : []),
|
...(root.translatorEnabled ? [{"icon": "translate", "name": Translation.tr("Translator")}] : []),
|
||||||
...(Config.options.policies.weeb === 1 ? [{"icon": "bookmark_heart", "name": Translation.tr("Anime")}] : [])
|
...((root.animeEnabled && !root.animeCloset) ? [{"icon": "bookmark_heart", "name": Translation.tr("Anime")}] : [])
|
||||||
]
|
]
|
||||||
property int selectedTab: 0
|
property int selectedTab: 0
|
||||||
|
property int tabCount: swipeView.count
|
||||||
|
|
||||||
function focusActiveItem() {
|
function focusActiveItem() {
|
||||||
swipeView.currentItem.forceActiveFocus()
|
swipeView.currentItem.forceActiveFocus()
|
||||||
@@ -26,7 +31,7 @@ Item {
|
|||||||
Keys.onPressed: (event) => {
|
Keys.onPressed: (event) => {
|
||||||
if (event.modifiers === Qt.ControlModifier) {
|
if (event.modifiers === Qt.ControlModifier) {
|
||||||
if (event.key === Qt.Key_PageDown) {
|
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;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
else if (event.key === Qt.Key_PageUp) {
|
else if (event.key === Qt.Key_PageUp) {
|
||||||
@@ -34,11 +39,11 @@ Item {
|
|||||||
event.accepted = true;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
else if (event.key === Qt.Key_Tab) {
|
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;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
else if (event.key === Qt.Key_Backtab) {
|
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;
|
event.accepted = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -52,6 +57,7 @@ Item {
|
|||||||
|
|
||||||
PrimaryTabBar { // Tab strip
|
PrimaryTabBar { // Tab strip
|
||||||
id: tabBar
|
id: tabBar
|
||||||
|
visible: root.tabButtonList.length > 1
|
||||||
tabButtonList: root.tabButtonList
|
tabButtonList: root.tabButtonList
|
||||||
externalTrackedTab: root.selectedTab
|
externalTrackedTab: root.selectedTab
|
||||||
function onCurrentIndexChanged(currentIndex) {
|
function onCurrentIndexChanged(currentIndex) {
|
||||||
@@ -83,9 +89,9 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
contentChildren: [
|
contentChildren: [
|
||||||
...(Config.options.policies.ai !== 0 ? [aiChat.createObject()] : []),
|
...((root.aiChatEnabled || (!root.translatorEnabled && !root.animeEnabled)) ? [aiChat.createObject()] : []),
|
||||||
...(Config.options.sidebar.translator.enable ? [translator.createObject()] : []),
|
...(root.translatorEnabled ? [translator.createObject()] : []),
|
||||||
...(Config.options.policies.weeb === 0 ? [] : [anime.createObject()])
|
...(root.animeEnabled ? [anime.createObject()] : [])
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user