status-desktop/ui/app/AppLayouts/Chat/components/ContactRequestsPopup.qml
Alexandra Betouni 4ee21ada05 feat(desktop) Added image function in Style
Introduced Style.svg() Style.png() Style.emoji() and
Style.icon() in Style.qml. Those should be used to
set the source in Images instead of using relative
paths. Usage:
Image {
   source: Style.svg("check)
   ....

Also moved all Singletons inside a new "utils"
folder and made it a QML module, to use
import utils 1.0 instead of relative paths

Closes #3678
2021-09-28 15:28:00 -04:00

119 lines
4.0 KiB
QML

import QtQuick 2.13
import QtQuick.Controls 2.13
import QtQuick.Layouts 1.13
import QtGraphicalEffects 1.13
import utils 1.0
import "../../../../shared"
import "../../../../shared/status"
import "../../Profile/Sections/Contacts"
ModalPopup {
id: popup
//% "Contact requests"
title: qsTrId("contact-requests")
ListView {
id: contactList
property Component profilePopupComponent: ProfilePopup {
id: profilePopup
onClosed: destroy()
}
anchors.fill: parent
anchors.leftMargin: -Style.current.halfPadding
anchors.rightMargin: -Style.current.halfPadding
model: profileModel.contacts.contactRequests
clip: true
delegate: ContactRequest {
name: Utils.removeStatusEns(model.name)
address: model.address
localNickname: model.localNickname
identicon: model.thumbnailImage || model.identicon
profileClick: function (showFooter, userName, fromAuthor, identicon, textParam, nickName) {
var popup = profilePopupComponent.createObject(contactList);
popup.openPopup(showFooter, userName, fromAuthor, identicon, textParam, nickName);
}
onBlockContactActionTriggered: {
blockContactConfirmationDialog.contactName = name
blockContactConfirmationDialog.contactAddress = address
blockContactConfirmationDialog.open()
}
}
}
footer: Item {
width: parent.width
height: children[0].height
BlockContactConfirmationDialog {
id: blockContactConfirmationDialog
onBlockButtonClicked: {
profileModel.contacts.blockContact(blockContactConfirmationDialog.contactAddress)
blockContactConfirmationDialog.close()
}
}
ConfirmationDialog {
id: declineAllDialog
//% "Decline all contacts"
header.title: qsTrId("decline-all-contacts")
//% "Are you sure you want to decline all these contact requests"
confirmationText: qsTrId("are-you-sure-you-want-to-decline-all-these-contact-requests")
onConfirmButtonClicked: {
const requests = profileModel.contacts.contactRequests
const pubkeys = []
for (let i = 0; i < requests.count; i++) {
pubkeys.push(requests.rowData(i, "address"))
}
profileModel.contacts.rejectContactRequests(JSON.stringify(pubkeys))
declineAllDialog.close()
}
}
ConfirmationDialog {
id: acceptAllDialog
//% "Accept all contacts"
header.title: qsTrId("accept-all-contacts")
//% "Are you sure you want to accept all these contact requests"
confirmationText: qsTrId("are-you-sure-you-want-to-accept-all-these-contact-requests")
onConfirmButtonClicked: {
const requests = profileModel.contacts.contactRequests
const pubkeys = []
for (let i = 0; i < requests.count; i++) {
pubkeys.push(requests.rowData(i, "address"))
}
profileModel.contacts.acceptContactRequests(JSON.stringify(pubkeys))
acceptAllDialog.close()
}
}
StatusButton {
id: blockBtn
enabled: contactList.count > 0
anchors.right: addToContactsButton.left
anchors.rightMargin: Style.current.padding
anchors.bottom: parent.bottom
type: "warn"
//% "Decline all"
text: qsTrId("decline-all")
onClicked: declineAllDialog.open()
}
StatusButton {
id: addToContactsButton
enabled: contactList.count > 0
anchors.right: parent.right
//% "Accept all"
text: qsTrId("accept-all")
anchors.bottom: parent.bottom
onClicked: acceptAllDialog.open()
}
}
}