Move Chat/ dir under Pages/

This commit is contained in:
miruka
2019-12-18 04:53:08 -04:00
parent 2bdf21d528
commit f4d7636df6
30 changed files with 38 additions and 38 deletions

View File

@@ -0,0 +1,93 @@
import QtQuick 2.12
import QtQuick.Layouts 1.12
import "../../../Base"
Rectangle {
id: banner
implicitHeight: childrenRect.height
color: theme.controls.box.background
property alias avatar: bannerAvatar
property alias icon: bannerIcon
property alias labelText: bannerLabel.text
property alias buttonModel: bannerRepeater.model
property var buttonCallbacks: []
HGridLayout {
id: bannerGrid
width: parent.width
flow: bannerAvatarWrapper.width +
bannerIcon.width +
bannerLabel.implicitWidth +
bannerButtons.width >
parent.width ?
GridLayout.TopToBottom : GridLayout.LeftToRight
HRowLayout {
id: bannerRow
Rectangle {
id: bannerAvatarWrapper
color: "black"
Layout.preferredWidth: bannerAvatar.width
Layout.minimumHeight: bannerAvatar.height
Layout.preferredHeight: bannerLabel.height
HUserAvatar {
id: bannerAvatar
anchors.centerIn: parent
}
}
HIcon {
id: bannerIcon
visible: Boolean(svgName)
Layout.leftMargin: theme.spacing / 2
}
HLabel {
id: bannerLabel
textFormat: Text.StyledText
wrapMode: Text.Wrap
Layout.fillWidth: true
Layout.leftMargin: bannerIcon.Layout.leftMargin
Layout.rightMargin: Layout.leftMargin
}
HSpacer {}
}
HRowLayout {
HRowLayout {
id: bannerButtons
Repeater {
id: bannerRepeater
model: []
HButton {
id: button
text: modelData.text
icon.name: modelData.iconName
icon.color: modelData.iconColor || theme.icons.colorize
onClicked: buttonCallbacks[modelData.name](button)
Layout.preferredHeight: theme.baseElementsHeight
}
}
}
Rectangle {
id: buttonsRightPadding
color: theme.controls.button.background
visible: bannerGrid.flow === GridLayout.TopToBottom
Layout.fillWidth: true
Layout.fillHeight: true
}
}
}
}

View File

@@ -0,0 +1,51 @@
import QtQuick 2.12
import "../../../Base"
Banner {
property string inviterId: chat.roomInfo.inviter
property string inviterName: chat.roomInfo.inviter_name
property string inviterAvatar: chat.roomInfo.inviter_avatar
color: theme.chat.inviteBanner.background
avatar.userId: inviterId
avatar.displayName: inviterName
avatar.mxc: inviterAvatar
labelText: qsTr("%1 invited you to this room").arg(
utils.coloredNameHtml(inviterName, inviterId)
)
buttonModel: [
{
name: "accept",
text: qsTr("Join"),
iconName: "invite-accept",
iconColor: theme.colors.positiveBackground
},
{
name: "decline",
text: qsTr("Decline"),
iconName: "invite-decline",
iconColor: theme.colors.negativeBackground
}
]
buttonCallbacks: ({
accept: button => {
button.loading = true
py.callClientCoro(
chat.userId, "join", [chat.roomId], () => {
button.loading = false
})
},
decline: button => {
button.loading = true
py.callClientCoro(
chat.userId, "room_leave", [chat.roomId], () => {
button.loading = false
})
}
})
}

View File

@@ -0,0 +1,39 @@
import QtQuick 2.12
import "../../../Base"
Banner {
color: theme.chat.leftBanner.background
// TODO: avatar func auto
avatar.userId: chat.userId
avatar.displayName: chat.userInfo.display_name
avatar.mxc: chat.userInfo.avatar_url
labelText: qsTr("You are not part of this room anymore")
buttonModel: [
{
name: "forget",
text: qsTr("Forget"),
iconName: "room-forget",
iconColor: theme.colors.negativeBackground
}
]
buttonCallbacks: ({
forget: button => {
utils.makePopup(
"Popups/ForgetRoomPopup.qml",
mainUI, // Must not be destroyed with chat
{
userId: chat.userId,
roomId: chat.roomId,
roomName: chat.roomInfo.display_name,
},
obj => {
obj.onOk.connect(() => { button.loading = true })
},
false,
)
}
})
}

View File

@@ -0,0 +1,24 @@
import QtQuick 2.12
import "../../../Base"
Banner {
color: theme.chat.unknownDevices.background
avatar.visible: false
icon.svgName: "unknown-devices-warning"
labelText: qsTr("Unknown devices are present in this encrypted room")
buttonModel: [
{
name: "inspect",
text: qsTr("Inspect"),
iconName: "unknown-devices-inspect",
}
]
buttonCallbacks: ({
inspect: button => {
print("show")
}
})
}