2023-02-22 01:48:49 +03:00
// SPDX-FileCopyrightText: Nheko Contributors
2022-08-05 22:44:40 +03:00
//
// SPDX-License-Identifier: GPL-3.0-or-later
import ".."
import "../ui"
import QtQuick 2.15
import QtQuick . Controls 2.3
import QtQuick . Layouts 1.2
import QtQuick . Window 2.13
import im . nheko 1.0
ApplicationWindow {
id: joinRoomRoot
required property RoomSummary summary
2023-06-02 02:29:05 +03:00
color: palette . window
2023-10-31 05:11:03 +03:00
flags: Qt . Dialog | Qt . WindowCloseButtonHint | Qt . WindowTitleHint
2022-08-05 22:44:40 +03:00
height: content . implicitHeight + Nheko . paddingLarge + footer . implicitHeight
2023-10-31 05:11:03 +03:00
modality: Qt . WindowModal
title: summary . isSpace ? qsTr ( "Confirm community join" ) : qsTr ( "Confirm room join" )
width: 350
footer: DialogButtonBox {
id: dbb
standardButtons: DialogButtonBox . Cancel
onAccepted: {
summary . reason = reason . text ;
summary . join ( ) ;
joinRoomRoot . close ( ) ;
}
onRejected: {
joinRoomRoot . close ( ) ;
}
Button {
DialogButtonBox.buttonRole: DialogButtonBox . AcceptRole
enabled: input . text . match ( "#.+?:.{3,}" )
text: summary . isKnockOnly ? qsTr ( "Knock" ) : qsTr ( "Join" )
}
}
2022-08-05 22:44:40 +03:00
Shortcut {
sequence: StandardKey . Cancel
2023-10-31 05:11:03 +03:00
2022-08-05 22:44:40 +03:00
onActivated: dbb . rejected ( )
}
ColumnLayout {
id: content
2023-10-31 05:11:03 +03:00
2022-08-05 22:44:40 +03:00
anchors.fill: parent
2023-10-31 05:11:03 +03:00
anchors.margins: Nheko . paddingMedium
spacing: Nheko . paddingMedium
2022-08-05 22:44:40 +03:00
Avatar {
2023-10-31 05:11:03 +03:00
Layout.alignment: Qt . AlignHCenter
2023-10-26 17:43:09 +03:00
Layout.preferredHeight: 130
Layout.preferredWidth: 130
2023-10-31 05:11:03 +03:00
Layout.topMargin: Nheko . paddingMedium
displayName: summary . roomName
roomid: summary . roomid
url: summary . roomAvatarUrl . replace ( "mxc://" , "image://MxcImage/" )
2022-08-05 22:44:40 +03:00
}
Spinner {
Layout.alignment: Qt . AlignHCenter
2023-06-02 02:29:05 +03:00
foreground: palette . mid
2022-08-05 22:44:40 +03:00
running: ! summary . isLoaded
2023-10-31 05:11:03 +03:00
visible: ! summary . isLoaded
2022-08-05 22:44:40 +03:00
}
TextEdit {
Layout.alignment: Qt . AlignHCenter
Layout.fillWidth: true
2023-10-31 05:11:03 +03:00
color: palette . text
font.pixelSize: fontMetrics . font . pixelSize * 2
2022-08-05 22:44:40 +03:00
horizontalAlignment: TextEdit . AlignHCenter
2023-10-31 05:11:03 +03:00
readOnly: true
2022-08-05 22:44:40 +03:00
selectByMouse: true
2023-10-31 05:11:03 +03:00
text: summary . roomName
textFormat: TextEdit . RichText
wrapMode: TextEdit . Wrap
2022-08-05 22:44:40 +03:00
}
TextEdit {
Layout.alignment: Qt . AlignHCenter
Layout.fillWidth: true
2023-10-31 05:11:03 +03:00
color: palette . text
font.pixelSize: fontMetrics . font . pixelSize * 0.8
2022-08-05 22:44:40 +03:00
horizontalAlignment: TextEdit . AlignHCenter
2023-10-31 05:11:03 +03:00
readOnly: true
2022-08-05 22:44:40 +03:00
selectByMouse: true
2023-10-31 05:11:03 +03:00
text: summary . roomid
textFormat: TextEdit . RichText
wrapMode: TextEdit . Wrap
2022-08-05 22:44:40 +03:00
}
RowLayout {
Layout.alignment: Qt . AlignHCenter
2023-10-31 05:11:03 +03:00
spacing: Nheko . paddingMedium
2022-08-05 22:44:40 +03:00
MatrixText {
text: qsTr ( "%n member(s)" , "" , summary . memberCount )
}
ImageButton {
enabled: false
2023-10-31 05:11:03 +03:00
image: ":/icons/icons/ui/people.svg"
2022-08-05 22:44:40 +03:00
}
}
TextEdit {
Layout.alignment: Qt . AlignHCenter
Layout.fillWidth: true
2023-10-31 05:11:03 +03:00
color: palette . text
2022-08-05 22:44:40 +03:00
horizontalAlignment: TextEdit . AlignHCenter
2023-10-31 05:11:03 +03:00
readOnly: true
2022-08-05 22:44:40 +03:00
selectByMouse: true
2023-10-31 05:11:03 +03:00
text: summary . roomTopic
textFormat: TextEdit . RichText
wrapMode: TextEdit . Wrap
2022-08-05 22:44:40 +03:00
}
Label {
id: promptLabel
Layout.fillWidth: true
2023-10-31 05:11:03 +03:00
color: palette . text
font.bold: true
2022-08-05 22:44:40 +03:00
horizontalAlignment: Text . AlignHCenter
2023-10-31 05:11:03 +03:00
text: summary . isKnockOnly ? qsTr ( "This room can't be joined directly. You can, however, knock on the room and room members can accept or decline this join request. You can additionally provide a reason for them to let you in below:" ) : qsTr ( "Do you want to join this room? You can optionally add a reason below:" )
2022-08-05 22:44:40 +03:00
wrapMode: Text . Wrap
}
MatrixTextField {
id: reason
Layout.fillWidth: true
2023-10-31 05:11:03 +03:00
focus: true
2022-08-05 22:44:40 +03:00
text: joinRoomRoot . summary . reason
}
}
}