diff --git a/.config/quickshell/modules/sidebarLeft/Anime.qml b/.config/quickshell/modules/sidebarLeft/Anime.qml index f126dd3b6..0911fed4b 100644 --- a/.config/quickshell/modules/sidebarLeft/Anime.qml +++ b/.config/quickshell/modules/sidebarLeft/Anime.qml @@ -226,22 +226,54 @@ Item { } } } + + Item { // Queries awaiting response + anchors.left: parent.left + anchors.right: parent.right + anchors.bottom: parent.bottom + anchors.margins: 10 + implicitHeight: pendingBackground.implicitHeight + opacity: Booru.runningRequests > 0 ? 1 : 0 + visible: opacity > 0 + + Behavior on opacity { + NumberAnimation { + duration: Appearance.animation.elementMove.duration + easing.type: Appearance.animation.elementMove.type + easing.bezierCurve: Appearance.animation.elementMove.bezierCurve + } + } + + Rectangle { + id: pendingBackground + color: Appearance.m3colors.m3inverseSurface + anchors.left: parent.left + anchors.right: parent.right + anchors.verticalCenter: parent.verticalCenter + implicitHeight: pendingText.implicitHeight + 12 * 2 + radius: Appearance.rounding.verysmall + + StyledText { + id: pendingText + anchors.left: parent.left + anchors.right: parent.right + anchors.leftMargin: 12 + anchors.rightMargin: 12 + anchors.verticalCenter: parent.verticalCenter + font.pixelSize: Appearance.font.pixelSize.smaller + color: Appearance.m3colors.m3inverseOnSurface + wrapMode: Text.Wrap + text: StringUtils.format(qsTr("{0} queries pending"), Booru.runningRequests) + } + } + } } Item { // Tag suggestion description - opacity: tagDescriptionText.text.length > 0 ? 1 : 0 - visible: opacity > 0 + visible: tagDescriptionText.text.length > 0 Layout.fillWidth: true implicitHeight: tagDescriptionBackground.implicitHeight - Behavior on opacity { - NumberAnimation { - duration: Appearance.animation.elementMoveFast.duration - easing.type: Appearance.animation.elementMoveFast.type - easing.bezierCurve: Appearance.animation.elementMoveFast.bezierCurve - } - } - Rectangle { id: tagDescriptionBackground color: Appearance.colors.colTooltip diff --git a/.config/quickshell/services/Booru.qml b/.config/quickshell/services/Booru.qml index 3762d6793..2276b0945 100644 --- a/.config/quickshell/services/Booru.qml +++ b/.config/quickshell/services/Booru.qml @@ -22,6 +22,7 @@ Singleton { property string failMessage: qsTr("That didn't work. Tips:\n- Check your tags and NSFW settings\n- If you don't have a tag in mind, type a page number") property var responses: [] + property int runningRequests: 0 property var getWorkingImageSource: (url) => { if (url.includes('pximg.net')) { return `https://www.pixiv.net/en/artworks/${url.substring(url.lastIndexOf('/') + 1).replace(/_p\d+\.(png|jpg|jpeg|gif)$/, '')}`; @@ -315,7 +316,6 @@ Singleton { "images": [], "message": "" }) - root.responses = [...root.responses, newResponse] var xhr = new XMLHttpRequest() xhr.open("GET", url) @@ -332,6 +332,9 @@ Singleton { } catch (e) { console.log("[Booru] Failed to parse response: " + e) newResponse.message = root.failMessage + } finally { + root.runningRequests--; + root.responses = [...root.responses, newResponse] } } else if (xhr.readyState === XMLHttpRequest.DONE) { @@ -348,6 +351,7 @@ Singleton { const userAgent = ConfigOptions.sidebar.booru.zerochan.username ? `Desktop sidebar booru viewer - ${ConfigOptions.sidebar.booru.zerochan.username}` : defaultUserAgent xhr.setRequestHeader("User-Agent", userAgent) } + root.runningRequests++; xhr.send() } catch (error) { console.log("Could not set User-Agent:", error)