fix(CreateChatView): hide the Contacts label when no contacts

- hide the TagSelector's `listLabel` and disable the `textEdit` when the
  contacts model is empty
- add forgotten `qsTr()`
- remove some no-op positioniers/anchors/width/height bindings (these are
  handled automatically for QQC2 Control's header and contentItem)
This commit is contained in:
Lukáš Tinkl 2022-07-07 16:16:17 +02:00 committed by Lukáš Tinkl
parent a710558c6b
commit aa804ffaef
2 changed files with 8 additions and 13 deletions

View File

@ -165,7 +165,7 @@ RowLayout {
id: confirmButton id: confirmButton
implicitHeight: 44 implicitHeight: 44
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
text: "Confirm" text: qsTr("Confirm")
onClicked: { onClicked: {
if(root.chatContentModule.chatDetails.id &&((d.addedMembersIds.length > 0) || (d.removedMembersIds.length > 0))) { if(root.chatContentModule.chatDetails.id &&((d.addedMembersIds.length > 0) || (d.removedMembersIds.length > 0))) {
// Add request: // Add request:

View File

@ -81,9 +81,7 @@ Page {
// TODO: Could it be replaced to `GroupChatPanel`? // TODO: Could it be replaced to `GroupChatPanel`?
header: RowLayout { header: RowLayout {
id: headerRow id: headerRow
width: parent.width
height: tagSelector.height height: tagSelector.height
anchors.top: parent.top
anchors.topMargin: 8 anchors.topMargin: 8
clip: true clip: true
StatusTagSelector { StatusTagSelector {
@ -93,7 +91,8 @@ Page {
Layout.leftMargin: 17 Layout.leftMargin: 17
maxHeight: root.height maxHeight: root.height
nameCountLimit: 20 nameCountLimit: 20
listLabel: qsTr("Contacts") listLabel: contactsModel.count ? qsTr("Contacts") : ""
textEdit.enabled: contactsModel.count
toLabelText: qsTr("To: ") toLabelText: qsTr("To: ")
warningText: qsTr("USER LIMIT REACHED") warningText: qsTr("USER LIMIT REACHED")
ringSpecModelGetter: function(pubKey) { ringSpecModelGetter: function(pubKey) {
@ -114,8 +113,8 @@ Page {
id: confirmButton id: confirmButton
implicitHeight: 44 implicitHeight: 44
Layout.alignment: Qt.AlignTop Layout.alignment: Qt.AlignTop
enabled: (tagSelector.namesModel.count > 0) enabled: tagSelector.namesModel.count > 0
text: "Confirm" text: qsTr("Confirm")
onClicked: { onClicked: {
root.rootStore.createChatInitMessage = chatInput.textInput.text; root.rootStore.createChatInitMessage = chatInput.textInput.text;
root.rootStore.createChatFileUrls = chatInput.fileUrls; root.rootStore.createChatFileUrls = chatInput.fileUrls;
@ -138,9 +137,6 @@ Page {
} }
contentItem: Item { contentItem: Item {
anchors.fill: parent
anchors.topMargin: headerRow.height + 32
StatusChatInput { StatusChatInput {
id: chatInput id: chatInput
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
@ -178,17 +174,16 @@ Page {
} }
StatusBaseText { StatusBaseText {
width: parent.width width: parent.width*.66
height: contentHeight
anchors.centerIn: parent anchors.centerIn: parent
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
visible: (contactsModel.count === 0) visible: contactsModel.count === 0
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
font.pixelSize: 15 font.pixelSize: 15
color: Theme.palette.baseColor1 color: Theme.palette.baseColor1
text: qsTr("You can only send direct messages to your Contacts.\n\n text: qsTr("You can only send direct messages to your Contacts.\n\n
Send a contact request to the person you would like to chat with, you will be able to Send a contact request to the person you would like to chat with, you will be able to \
chat with them once they have accepted your contact request.") chat with them once they have accepted your contact request.")
Component.onCompleted: { Component.onCompleted: {
if (visible) { if (visible) {