booru: api caller service

This commit is contained in:
end-4
2025-04-28 10:20:27 +02:00
parent c0eff65377
commit 160a55d859
6 changed files with 289 additions and 5 deletions
+1
View File
@@ -83,6 +83,7 @@ Scope {
}
ActiveWindow {
Layout.rightMargin: Appearance.rounding.screenRounding
Layout.fillWidth: true
bar: barRoot
}
@@ -56,6 +56,7 @@ ColumnLayout {
z: 2
anchors.fill: parent
// TODO: make the end point in the moving direction go first
anchors.leftMargin: {
const tabCount = root.tabButtonList.length
const targetWidth = tabBar.contentItem.children[0].children[tabBar.currentIndex].tabContentWidth
@@ -14,7 +14,7 @@ ToolTip {
Connections {
target: parent
onHoveredChanged: {
function onHoveredChanged() {
if (parent.hovered) {
tooltipShowDelay.restart()
} else {
@@ -0,0 +1,85 @@
import "root:/"
import "root:/services"
import "root:/modules/common"
import "root:/modules/common/widgets"
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Quickshell.Io
import Quickshell
import Quickshell.Widgets
import Quickshell.Wayland
import Quickshell.Hyprland
import Qt5Compat.GraphicalEffects
Item {
id: root
onFocusChanged: (focus) => {
if (focus) {
tagInputField.forceActiveFocus()
}
}
ColumnLayout {
anchors.fill: parent
ListView { // Booru responses
id: booruResponseListView
Layout.fillWidth: true
Layout.fillHeight: true
clip: true
model: Booru.responses
delegate: StyledText {
id: booruResponseText
text: JSON.stringify(modelData)
}
}
Rectangle {
Layout.fillWidth: true
radius: Appearance.rounding.small
border.width: 1
border.color: Appearance.m3colors.m3outlineVariant
color: "transparent"
implicitWidth: tagInputField.implicitWidth
implicitHeight: tagInputField.implicitHeight
Behavior on implicitHeight {
NumberAnimation {
duration: Appearance.animation.elementDecel.duration
easing.type: Appearance.animation.elementDecel.type
}
}
TextArea {
id: tagInputField
anchors.fill: parent
wrapMode: TextArea.Wrap
padding: 10
color: activeFocus ? Appearance.m3colors.m3onSurface : Appearance.m3colors.m3onSurfaceVariant
renderType: Text.NativeRendering
selectedTextColor: Appearance.m3colors.m3onPrimary
selectionColor: Appearance.m3colors.m3primary
placeholderText: qsTr("Enter tags")
placeholderTextColor: Appearance.m3colors.m3outline
Keys.onPressed: (event) => {
if ((event.key === Qt.Key_Enter || event.key === Qt.Key_Return)) {
if (event.modifiers & Qt.ShiftModifier) {
// Insert newline
tagInputField.insert(tagInputField.cursorPosition, "\n")
event.accepted = true
} else {
// Submit on Enter or Ctrl+Enter
const tagList = tagInputField.text.split(/\s+/);
Booru.makeRequest(tagList);
tagInputField.clear()
event.accepted = true
}
}
}
}
}
}
}
@@ -16,7 +16,7 @@ Scope { // Scope
id: root
property int sidebarWidth: Appearance.sizes.sidebarWidth
property int sidebarPadding: 15
property var tabButtonList: [{"icon": "neurology", "name": qsTr("Intelligence")}, {"icon": "flare", "name": qsTr("Waifus")}]
property var tabButtonList: [{"icon": "neurology", "name": qsTr("Intelligence")}, {"icon": "bookmark_heart", "name": qsTr("Anime")}]
Variants { // Window repeater
id: sidebarVariants
@@ -88,7 +88,6 @@ Scope { // Scope
sidebarRoot.visible = false;
}
if (event.modifiers === Qt.ControlModifier) {
console.log("Control pressed")
if (event.key === Qt.Key_PageDown) {
sidebarRoot.currentTab = Math.min(sidebarRoot.currentTab + 1, root.tabButtonList.length - 1)
} else if (event.key === Qt.Key_PageUp) {
@@ -133,8 +132,11 @@ Scope { // Scope
}
}
Item {}
Item {}
StyledText {
text: "To be implemented"
horizontalAlignment: Text.AlignHCenter
}
Anime {}
}
}