Merge remote-tracking branch 'origin/main' into addon-i18n

This commit is contained in:
月月
2025-07-02 22:21:58 +08:00
79 changed files with 1631 additions and 830 deletions
@@ -50,10 +50,14 @@ Item {
}
},
{
name: "clear",
description: Translation.tr("Clear chat history"),
execute: () => {
Ai.clearMessages();
name: "prompt",
description: Translation.tr("Set the system prompt for the model."),
execute: (args) => {
if (args.length === 0 || args[0] === "get") {
Ai.printPrompt();
return;
}
Ai.loadPrompt(args.join(" ").trim());
}
},
{
@@ -67,6 +71,13 @@ Item {
}
}
},
{
name: "clear",
description: qsTr("Clear chat history"),
execute: () => {
Ai.clearMessages();
}
},
{
name: "temp",
description: Translation.tr("Set temperature (randomness) of the model. Values range between 0 to 2 for Gemini, 0 to 1 for other models. Default is 0.5."),
@@ -250,33 +261,9 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\)
}
}
Item { // Suggestion description
visible: descriptionText.text.length > 0
Layout.fillWidth: true
implicitHeight: descriptionBackground.implicitHeight
Rectangle {
id: descriptionBackground
color: Appearance.colors.colTooltip
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
implicitHeight: descriptionText.implicitHeight + 5 * 2
radius: Appearance.rounding.verysmall
StyledText {
id: descriptionText
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 10
anchors.rightMargin: 10
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: Appearance.font.pixelSize.smaller
color: Appearance.colors.colOnTooltip
wrapMode: Text.Wrap
text: root.suggestionList[suggestions.selectedIndex]?.description ?? ""
}
}
DescriptionBox {
text: root.suggestionList[suggestions.selectedIndex]?.description ?? ""
showArrows: root.suggestionList.length > 1
}
FlowButtonGroup { // Suggestions
@@ -294,7 +281,7 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\)
}
delegate: ApiCommandButton {
id: commandButton
colBackground: suggestions.selectedIndex === index ? Appearance.colors.colLayer2Hover : Appearance.colors.colLayer2
colBackground: suggestions.selectedIndex === index ? Appearance.colors.colSecondaryContainerHover : Appearance.colors.colSecondaryContainer
bounce: false
contentItem: StyledText {
font.pixelSize: Appearance.font.pixelSize.small
@@ -393,6 +380,24 @@ Inline w/ backslash and round brackets \\(e^{i\\pi} + 1 = 0\\)
description: `${Ai.models[model.target].description}`,
}
})
} else if(messageInputField.text.startsWith(`${root.commandPrefix}prompt`)) {
root.suggestionQuery = messageInputField.text.split(" ")[1] ?? ""
const promptFileResults = Fuzzy.go(root.suggestionQuery, Ai.promptFiles.map(file => {
return {
name: Fuzzy.prepare(file),
obj: file,
}
}), {
all: true,
key: "name"
})
root.suggestionList = promptFileResults.map(file => {
return {
name: `${messageInputField.text.trim().split(" ").length == 1 ? (root.commandPrefix + "prompt ") : ""}${file.target}`,
displayName: `${FileUtils.trimFileExt(FileUtils.fileNameForPath(file.target))}`,
description: `Load prompt from ${file.target}`,
}
})
} else if(messageInputField.text.startsWith(root.commandPrefix)) {
root.suggestionQuery = messageInputField.text
root.suggestionList = root.allCommands.filter(cmd => cmd.name.startsWith(messageInputField.text.substring(1))).map(cmd => {
@@ -6,15 +6,11 @@ import "root:/modules/common/functions/fuzzysort.js" as Fuzzy
import "root:/modules/common/functions/string_utils.js" as StringUtils
import "root:/modules/common/functions/file_utils.js" as FileUtils
import "./anime/"
import "root:/services/"
import Qt.labs.platform
import QtQuick
import QtQuick.Controls
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import Quickshell.Io
import Quickshell
import Quickshell.Hyprland
Item {
id: root
@@ -66,14 +62,14 @@ Item {
name: "safe",
description: Translation.tr("Disable NSFW content"),
execute: () => {
PersistentStateManager.setState("booru.allowNsfw", false);
Persistent.states.booru.allowNsfw = false;
}
},
{
name: "lewd",
description: Translation.tr("Allow NSFW content"),
execute: () => {
PersistentStateManager.setState("booru.allowNsfw", true);
Persistent.states.booru.allowNsfw = true;
}
},
]
@@ -107,7 +103,7 @@ Item {
break;
}
}
Booru.makeRequest(tagList, PersistentStates.booru.allowNsfw, ConfigOptions.sidebar.booru.limit, pageIndex);
Booru.makeRequest(tagList, Persistent.states.booru.allowNsfw, Config.options.sidebar.booru.limit, pageIndex);
}
}
@@ -252,33 +248,9 @@ Item {
}
}
Item { // Tag suggestion description
visible: tagDescriptionText.text.length > 0
Layout.fillWidth: true
implicitHeight: tagDescriptionBackground.implicitHeight
Rectangle {
id: tagDescriptionBackground
color: Appearance.colors.colTooltip
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
implicitHeight: tagDescriptionText.implicitHeight + 5 * 2
radius: Appearance.rounding.verysmall
StyledText {
id: tagDescriptionText
anchors.left: parent.left
anchors.right: parent.right
anchors.leftMargin: 10
anchors.rightMargin: 10
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: Appearance.font.pixelSize.smaller
color: Appearance.colors.colOnTooltip
wrapMode: Text.Wrap
text: root.suggestionList[tagSuggestions.selectedIndex]?.description ?? ""
}
}
DescriptionBox { // Tag suggestion description
text: root.suggestionList[tagSuggestions.selectedIndex]?.description ?? ""
showArrows: root.suggestionList.length > 1
}
FlowButtonGroup { // Tag suggestions
@@ -296,7 +268,7 @@ Item {
}
delegate: ApiCommandButton {
id: tagButton
colBackground: tagSuggestions.selectedIndex === index ? Appearance.colors.colLayer2Hover : Appearance.colors.colLayer2
colBackground: tagSuggestions.selectedIndex === index ? Appearance.colors.colSecondaryContainerHover : Appearance.colors.colSecondaryContainer
bounce: false
contentItem: RowLayout {
anchors.centerIn: parent
@@ -304,7 +276,7 @@ Item {
StyledText {
Layout.fillWidth: false
font.pixelSize: Appearance.font.pixelSize.small
color: Appearance.m3colors.m3onSurface
color: Appearance.colors.colOnSecondaryContainer
horizontalAlignment: Text.AlignRight
text: modelData.displayName ?? modelData.name
}
@@ -312,7 +284,7 @@ Item {
Layout.fillWidth: false
visible: modelData.count !== undefined
font.pixelSize: Appearance.font.pixelSize.smaller
color: Appearance.m3colors.m3outline
color: Appearance.colors.colOnSecondaryContainer
horizontalAlignment: Text.AlignLeft
text: modelData.count ?? ""
}
@@ -594,10 +566,10 @@ Item {
enabled: Booru.currentProvider !== "zerochan"
scale: 0.6
Layout.alignment: Qt.AlignVCenter
checked: (PersistentStates.booru.allowNsfw && Booru.currentProvider !== "zerochan")
checked: (Persistent.states.booru.allowNsfw && Booru.currentProvider !== "zerochan")
onCheckedChanged: {
if (!nsfwSwitch.enabled) return;
PersistentStateManager.setState("booru.allowNsfw", checked)
Persistent.states.booru.allowNsfw = checked;
}
}
}
@@ -611,7 +583,6 @@ Item {
id: commandRepeater
model: commandButtonsRow.commandsShown
delegate: ApiCommandButton {
id: tagButton
property string commandRepresentation: `${root.commandPrefix}${modelData.name}`
buttonText: commandRepresentation
colBackground: Appearance.colors.colLayer2
@@ -16,7 +16,7 @@ GroupButton {
baseWidth: contentItem.implicitWidth + horizontalPadding * 2
clickedWidth: baseWidth + 20
baseHeight: contentItem.implicitHeight + verticalPadding * 2
buttonRadius: down ? Appearance.rounding.small : baseHeight / 2
buttonRadius: down ? Appearance.rounding.verysmall : Appearance.rounding.small
colBackground: Appearance.colors.colLayer2
colBackgroundHover: Appearance.colors.colLayer2Hover
@@ -0,0 +1,61 @@
import "root:/services"
import "root:/modules/common"
import "root:/modules/common/widgets"
import QtQuick
import QtQuick.Layouts
Item { // Tag suggestion description
id: root
property alias text: tagDescriptionText.text
property bool showArrows: true
property bool showTab: true
visible: tagDescriptionText.text.length > 0
Layout.fillWidth: true
implicitHeight: tagDescriptionBackground.implicitHeight
Rectangle {
id: tagDescriptionBackground
color: Appearance.colors.colLayer2
anchors.fill: parent
radius: Appearance.rounding.verysmall
implicitHeight: descriptionRow.implicitHeight + 5 * 2
RowLayout {
id: descriptionRow
spacing: 4
anchors {
fill: parent
leftMargin: 10
rightMargin: 10
}
StyledText {
id: tagDescriptionText
Layout.fillWidth: true
font.pixelSize: Appearance.font.pixelSize.smaller
color: Appearance.colors.colOnLayer2
wrapMode: Text.Wrap
}
KeyboardKey {
visible: root.showArrows
key: "↑"
}
KeyboardKey {
visible: root.showArrows
key: "↓"
}
StyledText {
visible: root.showArrows && root.showTab
text: qsTr("or")
font.pixelSize: Appearance.font.pixelSize.smaller
}
KeyboardKey {
id: tagDescriptionKey
visible: root.showTab
key: "Tab"
Layout.alignment: Qt.AlignVCenter
}
}
}
}
@@ -19,9 +19,9 @@ Item {
required property var scopeRoot
anchors.fill: parent
property var tabButtonList: [
...(ConfigOptions.policies.ai !== 0 ? [{"icon": "neurology", "name": Translation.tr("Intelligence")}] : []),
{"icon": "translate", "name": Translation.tr("Translator")},
...(ConfigOptions.policies.weeb === 1 ? [{"icon": "bookmark_heart", "name": Translation.tr("Anime")}] : [])
...(Config.options.policies.ai !== 0 ? [{"icon": "neurology", "name": qsTr("Intelligence")}] : []),
{"icon": "translate", "name": qsTr("Translator")},
...(Config.options.policies.weeb === 1 ? [{"icon": "bookmark_heart", "name": qsTr("Anime")}] : [])
]
property int selectedTab: 0
@@ -89,9 +89,9 @@ Item {
}
contentChildren: [
...(ConfigOptions.policies.ai !== 0 ? [aiChat.createObject()] : []),
...(Config.options.policies.ai !== 0 ? [aiChat.createObject()] : []),
translator.createObject(),
...(ConfigOptions.policies.weeb === 0 ? [] : [anime.createObject()])
...(Config.options.policies.weeb === 0 ? [] : [anime.createObject()])
]
}
@@ -23,8 +23,8 @@ Item {
property string translatedText: ""
property list<string> languages: []
// Options
property string targetLanguage: ConfigOptions.language.translator.targetLanguage
property string sourceLanguage: ConfigOptions.language.translator.sourceLanguage
property string targetLanguage: Config.options.language.translator.targetLanguage
property string sourceLanguage: Config.options.language.translator.sourceLanguage
property string hostLanguage: targetLanguage
property bool showLanguageSelector: false
@@ -43,7 +43,7 @@ Item {
Timer {
id: translateTimer
interval: ConfigOptions.sidebar.translator.delay
interval: Config.options.sidebar.translator.delay
repeat: false
onTriggered: () => {
if (root.inputField.text.trim().length > 0) {
@@ -155,8 +155,8 @@ Item {
color: searchButton.enabled ? Appearance.colors.colOnLayer1 : Appearance.colors.colSubtext
}
onClicked: {
let url = ConfigOptions.search.engineBaseUrl + outputCanvas.displayedText;
for (let site of ConfigOptions.search.excludedSites) {
let url = Config.options.search.engineBaseUrl + outputCanvas.displayedText;
for (let site of Config.options.search.excludedSites) {
url += ` -site:${site}`;
}
Qt.openUrlExternally(url);
@@ -235,10 +235,10 @@ Item {
if (root.languageSelectorTarget) {
root.targetLanguage = result;
ConfigLoader.setConfigValueAndSave("language.translator.targetLanguage", result); // Save to config
Config.options.language.translator.targetLanguage = result; // Save to config
} else {
root.sourceLanguage = result;
ConfigLoader.setConfigValueAndSave("language.translator.sourceLanguage", result); // Save to config
Config.options.language.translator.sourceLanguage = result; // Save to config
}
translateTimer.restart(); // Restart translation after language change