sidebar: translation widget

This commit is contained in:
end-4
2025-06-02 23:24:10 +02:00
parent c26685b1de
commit 81446091d3
5 changed files with 249 additions and 11 deletions
@@ -14,9 +14,15 @@ import Quickshell.Wayland
import Quickshell.Hyprland
Item {
id: sidebarLeftBackground
id: root
required property var scopeRoot
anchors.fill: parent
property var tabButtonList: [
{"icon": "neurology", "name": qsTr("Intelligence")},
{"icon": "translate", "name": qsTr("Translator")},
{"icon": "bookmark_heart", "name": qsTr("Anime")},
]
property int selectedTab: 0
function focusActiveItem() {
swipeView.currentItem.forceActiveFocus()
@@ -25,19 +31,19 @@ Item {
Keys.onPressed: (event) => {
if (event.modifiers === Qt.ControlModifier) {
if (event.key === Qt.Key_PageDown) {
scopeRoot.selectedTab = Math.min(scopeRoot.selectedTab + 1, scopeRoot.tabButtonList.length - 1)
root.selectedTab = Math.min(root.selectedTab + 1, root.tabButtonList.length - 1)
event.accepted = true;
}
else if (event.key === Qt.Key_PageUp) {
scopeRoot.selectedTab = Math.max(scopeRoot.selectedTab - 1, 0)
root.selectedTab = Math.max(root.selectedTab - 1, 0)
event.accepted = true;
}
else if (event.key === Qt.Key_Tab) {
scopeRoot.selectedTab = (scopeRoot.selectedTab + 1) % scopeRoot.tabButtonList.length;
root.selectedTab = (root.selectedTab + 1) % root.tabButtonList.length;
event.accepted = true;
}
else if (event.key === Qt.Key_Backtab) {
scopeRoot.selectedTab = (scopeRoot.selectedTab - 1 + scopeRoot.tabButtonList.length) % scopeRoot.tabButtonList.length;
root.selectedTab = (root.selectedTab - 1 + root.tabButtonList.length) % root.tabButtonList.length;
event.accepted = true;
}
}
@@ -51,10 +57,10 @@ Item {
PrimaryTabBar { // Tab strip
id: tabBar
tabButtonList: scopeRoot.tabButtonList
externalTrackedTab: scopeRoot.selectedTab
tabButtonList: root.tabButtonList
externalTrackedTab: root.selectedTab
function onCurrentIndexChanged(currentIndex) {
scopeRoot.selectedTab = currentIndex
root.selectedTab = currentIndex
}
}
@@ -68,7 +74,7 @@ Item {
currentIndex: tabBar.externalTrackedTab
onCurrentIndexChanged: {
tabBar.enableIndicatorAnimation = true
scopeRoot.selectedTab = currentIndex
root.selectedTab = currentIndex
}
clip: true
@@ -82,6 +88,7 @@ Item {
}
AiChat {}
Translator {}
Anime {}
}