forked from Shinonome/dots-hyprland
booru: images, clear, provider setting
This commit is contained in:
@@ -5,15 +5,16 @@ import "root:/modules/common/widgets"
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import QtQuick.Layouts
|
||||
import Qt5Compat.GraphicalEffects
|
||||
import Quickshell.Io
|
||||
import Quickshell
|
||||
import Quickshell.Widgets
|
||||
import Quickshell.Wayland
|
||||
import Quickshell.Hyprland
|
||||
import Qt5Compat.GraphicalEffects
|
||||
|
||||
Item {
|
||||
id: root
|
||||
property var panelWindow
|
||||
property var inputField: tagInputField
|
||||
|
||||
onFocusChanged: (focus) => {
|
||||
if (focus) {
|
||||
tagInputField.forceActiveFocus()
|
||||
@@ -21,6 +22,7 @@ Item {
|
||||
}
|
||||
|
||||
ColumnLayout {
|
||||
id: columnLayout
|
||||
anchors.fill: parent
|
||||
|
||||
ListView { // Booru responses
|
||||
@@ -28,21 +30,33 @@ Item {
|
||||
Layout.fillWidth: true
|
||||
Layout.fillHeight: true
|
||||
clip: true
|
||||
model: Booru.responses
|
||||
delegate: StyledText {
|
||||
id: booruResponseText
|
||||
text: JSON.stringify(modelData)
|
||||
layer.enabled: true
|
||||
layer.effect: OpacityMask {
|
||||
maskSource: Rectangle {
|
||||
width: swipeView.width
|
||||
height: swipeView.height
|
||||
radius: Appearance.rounding.small
|
||||
}
|
||||
}
|
||||
|
||||
spacing: 10
|
||||
model: ScriptModel {
|
||||
values: Booru.responses
|
||||
}
|
||||
delegate: BooruResponse {
|
||||
responseData: modelData
|
||||
tagInputField: root.inputField
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
id: tagInputFieldContainer
|
||||
Layout.fillWidth: true
|
||||
radius: Appearance.rounding.small
|
||||
border.width: 1
|
||||
border.color: Appearance.m3colors.m3outlineVariant
|
||||
color: "transparent"
|
||||
color: Appearance.colors.colLayer1
|
||||
implicitWidth: tagInputField.implicitWidth
|
||||
implicitHeight: tagInputField.implicitHeight
|
||||
implicitHeight: Math.max(tagInputField.implicitHeight, 45)
|
||||
clip: true
|
||||
|
||||
Behavior on implicitHeight {
|
||||
NumberAnimation {
|
||||
@@ -53,7 +67,9 @@ Item {
|
||||
|
||||
TextArea {
|
||||
id: tagInputField
|
||||
anchors.fill: parent
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
wrapMode: TextArea.Wrap
|
||||
|
||||
padding: 10
|
||||
@@ -71,9 +87,32 @@ Item {
|
||||
tagInputField.insert(tagInputField.cursorPosition, "\n")
|
||||
event.accepted = true
|
||||
} else {
|
||||
// Submit on Enter or Ctrl+Enter
|
||||
const tagList = tagInputField.text.split(/\s+/);
|
||||
Booru.makeRequest(tagList);
|
||||
const inputText = tagInputField.text
|
||||
if (inputText.startsWith("/")) {
|
||||
// Handle special commands
|
||||
const command = inputText.split(" ")[0].substring(1);
|
||||
if (command === "clear") {
|
||||
Booru.clearResponses();
|
||||
}
|
||||
else if (command === "mode") {
|
||||
const newProvider = inputText.split(" ")[1];
|
||||
Booru.setProvider(newProvider);
|
||||
Booru.addSystemMessage(`Provider set to ${Booru.providers[newProvider].name}`);
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Create tag list
|
||||
const tagList = inputText.split(/\s+/);
|
||||
let pageIndex = 1;
|
||||
for (let i = 0; i < tagList.length; ++i) { // Detect page number
|
||||
if (/^\d+$/.test(tagList[i])) {
|
||||
pageIndex = parseInt(tagList[i], 10);
|
||||
tagList.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Booru.makeRequest(tagList, ConfigOptions.sidebar.booru.allowNsfw, ConfigOptions.sidebar.booru.limit, pageIndex);
|
||||
}
|
||||
tagInputField.clear()
|
||||
event.accepted = true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user