2023-04-09 13:35:35 +08:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-12-18 12:52:52 +08:00
|
|
|
import QtQuick
|
2023-05-19 23:03:39 +08:00
|
|
|
import QtQuick.Controls
|
2022-12-18 12:52:52 +08:00
|
|
|
import QtQuick.Layouts
|
2023-05-19 23:03:39 +08:00
|
|
|
import Fk.Pages
|
2022-12-18 12:52:52 +08:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
property bool isLobby: false
|
|
|
|
|
|
|
|
function append(chatter) {
|
|
|
|
chatLogBox.append(chatter)
|
|
|
|
}
|
|
|
|
|
2023-07-02 13:21:13 +08:00
|
|
|
/*
|
|
|
|
function loadSkills(pid) {
|
|
|
|
if (isLobby) return;
|
|
|
|
let gender = 0;
|
|
|
|
// let g = false;
|
|
|
|
// if (g) {
|
|
|
|
// const data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [g]));
|
|
|
|
// const extension = data.extension;
|
|
|
|
// gender = data.gender;
|
|
|
|
// data.skill.forEach(t => {
|
|
|
|
// for (let i = 0; i < 999; i++) {
|
|
|
|
// const fname = AppPath + "/packages/" + extension + "/audio/skill/" +
|
|
|
|
// t.name + (i !== 0 ? i.toString() : "") + ".mp3";
|
|
|
|
|
|
|
|
// if (Backend.exists(fname)) {
|
|
|
|
// skills.append({ name: t.name, idx: i });
|
|
|
|
// } else {
|
|
|
|
// if (i > 0) break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// data.related_skill.forEach(t => {
|
|
|
|
// for (let i = 0; i < 999; i++) {
|
|
|
|
// const fname = AppPath + "/packages/" + extension + "/audio/skill/" +
|
|
|
|
// t.name + (i !== 0 ? i.toString() : "") + ".mp3";
|
|
|
|
|
|
|
|
// if (Backend.exists(fname)) {
|
|
|
|
// skills.append({ name: t.name, idx: i });
|
|
|
|
// } else {
|
|
|
|
// if (i > 0) break;
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// }
|
|
|
|
for (let i = 0; i < 999; i++) {
|
|
|
|
const name = "fastchat_" + (gender == 1 ? "f" : "m")
|
|
|
|
const fname = AppPath + "/packages/standard/audio/skill/" +
|
|
|
|
name + (i !== 0 ? i.toString() : "") + ".mp3";
|
|
|
|
|
|
|
|
if (Backend.exists(fname)) {
|
|
|
|
skills.append({ name: name, idx: i });
|
|
|
|
} else {
|
|
|
|
if (i > 0) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
function loadSkills() {
|
|
|
|
for (let i = 1; i <= 16; i++) {
|
|
|
|
skills.append({ name: "fastchat_m", idx: i });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Timer {
|
|
|
|
id: opTimer
|
|
|
|
interval: 1500
|
|
|
|
}
|
|
|
|
|
2022-12-18 12:52:52 +08:00
|
|
|
ColumnLayout {
|
|
|
|
anchors.fill: parent
|
|
|
|
spacing: 0
|
|
|
|
|
|
|
|
Item {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
|
|
|
|
LogEdit {
|
|
|
|
id: chatLogBox
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 10
|
2023-05-13 14:16:09 +08:00
|
|
|
//font.pixelSize: 14
|
2022-12-18 12:52:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-19 23:03:39 +08:00
|
|
|
GridView {
|
|
|
|
id: emojiSelector
|
2022-12-18 12:52:52 +08:00
|
|
|
Layout.fillWidth: true
|
2023-05-19 23:03:39 +08:00
|
|
|
Layout.preferredHeight: 120
|
|
|
|
cellHeight: 48
|
|
|
|
cellWidth: 48
|
2023-08-13 16:36:11 +08:00
|
|
|
model: 59
|
2023-05-19 23:03:39 +08:00
|
|
|
visible: false
|
2023-06-16 23:53:44 +08:00
|
|
|
clip: true
|
2023-05-19 23:03:39 +08:00
|
|
|
delegate: ItemDelegate {
|
|
|
|
Image {
|
|
|
|
height: 32; width: 32
|
|
|
|
anchors.centerIn: parent
|
|
|
|
source: "../../image/emoji/" + index
|
|
|
|
}
|
|
|
|
onClicked: chatEdit.insert(chatEdit.cursorPosition, "{emoji" + index + "}");
|
|
|
|
}
|
|
|
|
}
|
2022-12-18 12:52:52 +08:00
|
|
|
|
2023-07-02 13:21:13 +08:00
|
|
|
ListView {
|
|
|
|
id: soundSelector
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 180
|
|
|
|
visible: false
|
|
|
|
clip: true
|
|
|
|
ScrollBar.vertical: ScrollBar {}
|
|
|
|
model: ListModel {
|
|
|
|
id: skills
|
|
|
|
}
|
|
|
|
// onVisibleChanged: {skills.clear(); loadSkills();}
|
|
|
|
|
|
|
|
delegate: ItemDelegate {
|
|
|
|
width: soundSelector.width
|
|
|
|
height: 30
|
|
|
|
text: Backend.translate("$" + name + (idx ? idx.toString() : ""))
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
opTimer.start();
|
|
|
|
const general = roomScene.getPhoto(Self.id).general;
|
|
|
|
let skill = "fastchat_m";
|
|
|
|
if (general !== "") {
|
|
|
|
const data = JSON.parse(Backend.callLuaFunction("GetGeneralDetail", [general]));
|
|
|
|
const gender = data.gender;
|
|
|
|
if (gender !== 1) {
|
|
|
|
skill = "fastchat_f";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ClientInstance.notifyServer(
|
|
|
|
"Chat",
|
|
|
|
JSON.stringify({
|
|
|
|
type: isLobby ? 1 : 2,
|
|
|
|
msg: "$" + skill + ":" + idx
|
|
|
|
})
|
|
|
|
);
|
|
|
|
soundSelector.visible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-19 23:03:39 +08:00
|
|
|
RowLayout {
|
|
|
|
Rectangle {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.preferredHeight: 28
|
|
|
|
color: "#040403"
|
|
|
|
radius: 3
|
|
|
|
border.width: 1
|
|
|
|
border.color: "#A6967A"
|
|
|
|
|
|
|
|
TextInput {
|
|
|
|
id: chatEdit
|
|
|
|
anchors.fill: parent
|
|
|
|
anchors.margins: 6
|
|
|
|
color: "white"
|
|
|
|
clip: true
|
|
|
|
font.pixelSize: 14
|
|
|
|
|
|
|
|
onAccepted: {
|
|
|
|
if (text != "") {
|
|
|
|
ClientInstance.notifyServer(
|
|
|
|
"Chat",
|
|
|
|
JSON.stringify({
|
|
|
|
type: isLobby ? 1 : 2,
|
|
|
|
msg: text
|
|
|
|
})
|
|
|
|
);
|
|
|
|
text = "";
|
|
|
|
}
|
2022-12-18 12:52:52 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-05-19 23:03:39 +08:00
|
|
|
|
2023-07-02 13:21:13 +08:00
|
|
|
MetroButton {
|
|
|
|
id: soundBtn
|
|
|
|
text: "🗨️"
|
|
|
|
visible: !isLobby
|
|
|
|
enabled: !opTimer.running;
|
|
|
|
onClicked: {
|
|
|
|
emojiSelector.visible = false;
|
|
|
|
soundSelector.visible = !soundSelector.visible;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-19 23:03:39 +08:00
|
|
|
MetroButton {
|
|
|
|
id: emojiBtn
|
|
|
|
text: "😃"
|
2023-07-02 13:21:13 +08:00
|
|
|
onClicked: {
|
|
|
|
soundSelector.visible = false;
|
|
|
|
emojiSelector.visible = !emojiSelector.visible;
|
|
|
|
}
|
2023-05-19 23:03:39 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
MetroButton {
|
|
|
|
text: "✔️"
|
2023-07-02 13:21:13 +08:00
|
|
|
enabled: !opTimer.running;
|
|
|
|
onClicked: {
|
|
|
|
opTimer.start();
|
|
|
|
chatEdit.accepted();
|
|
|
|
}
|
2023-05-19 23:03:39 +08:00
|
|
|
}
|
2022-12-18 12:52:52 +08:00
|
|
|
}
|
|
|
|
}
|
2023-07-02 13:21:13 +08:00
|
|
|
|
|
|
|
Component.onCompleted: {
|
|
|
|
loadSkills();
|
|
|
|
}
|
2022-12-18 12:52:52 +08:00
|
|
|
}
|