2023-02-21 20:11:44 +04:00
import QtQuick 2.15
import QtQuick . Controls 2.15
2024-10-02 09:54:35 -04:00
import QtQuick . Layouts 1.15
2023-02-21 20:11:44 +04:00
import QtGraphicalEffects 1.15
2024-10-02 09:54:35 -04:00
import QtQml . Models 2.15
2022-07-13 15:29:38 +03:00
import StatusQ . Controls 0.1
2024-07-12 11:46:43 +02:00
import StatusQ . Core 0.1
import StatusQ . Core . Backpressure 0.1
2023-10-23 13:35:20 +02:00
import StatusQ . Core . Theme 0.1
2024-10-02 09:54:35 -04:00
import StatusQ . Popups . Dialog 0.1
2022-07-13 15:29:38 +03:00
2021-10-28 00:27:49 +03:00
import shared 1.0
2021-12-21 22:52:17 +02:00
import shared . popups 1.0
2022-07-26 17:23:45 +03:00
import shared . views . chat 1.0
2022-07-13 15:29:38 +03:00
import utils 1.0
2021-10-18 12:56:05 +02:00
2024-05-22 11:13:39 +03:00
import AppLayouts . Chat . stores 1.0 as ChatStores
2021-10-01 18:58:36 +03:00
import "../views"
import "../panels"
2022-10-26 20:00:20 +04:00
import "../stores"
2021-09-28 18:04:06 +03:00
2021-05-28 13:35:21 -04:00
Popup {
2022-07-26 17:23:45 +03:00
id: root
2022-10-26 20:00:20 +04:00
property ActivityCenterStore activityCenterStore
2024-05-22 11:13:39 +03:00
property ChatStores . RootStore store
2021-06-10 11:15:38 -04:00
2022-09-15 19:34:41 +03:00
onOpened: {
2023-05-23 14:46:16 +02:00
Global . activityPopupOpened = true
2022-09-15 19:34:41 +03:00
}
onClosed: {
2023-05-23 14:46:16 +02:00
Global . activityPopupOpened = false
2023-04-17 11:09:15 +02:00
Qt . callLater ( activityCenterStore . markAsSeenActivityCenterNotifications )
2022-09-15 19:34:41 +03:00
}
2022-05-19 14:33:17 +02:00
2022-09-19 16:16:48 +03:00
width: 560
padding: 0
2023-04-17 10:29:20 +02:00
modal: true
2021-05-28 13:35:21 -04:00
parent: Overlay . overlay
2021-07-29 15:20:49 -04:00
2023-11-15 15:29:03 +04:00
QtObject {
id: d
readonly property var loadMoreNotificationsIfScrollBelowThreshold: Backpressure . oneInTimeQueued ( root , 100 , function ( ) {
if ( listView . contentY >= listView . contentHeight - listView . height - 1 ) {
root . activityCenterStore . fetchActivityCenterNotifications ( )
}
} )
}
2023-04-17 10:29:20 +02:00
Overlay.modal: MouseArea { // eat every event behind the popup
hoverEnabled: true
onPressed: ( event ) = > {
event . accept ( )
root . close ( )
}
onWheel: ( event ) = > event . accept ( )
}
2021-09-08 05:11:51 +03:00
2021-05-28 13:35:21 -04:00
background: Rectangle {
color: Style . current . background
radius: Style . current . radius
2021-07-29 15:20:49 -04:00
layer.enabled: true
layer.effect: DropShadow {
verticalOffset: 3
radius: Style . current . radius
samples: 15
fast: true
cached: true
color: Style . current . dropShadow
}
2021-05-28 13:35:21 -04:00
}
2022-09-19 16:16:48 +03:00
2021-10-01 18:58:36 +03:00
ActivityCenterPopupTopBarPanel {
2021-05-28 13:35:21 -04:00
id: activityCenterTopBar
2022-09-12 14:06:26 +04:00
width: parent . width
2023-02-22 19:49:44 +04:00
unreadNotificationsCount: activityCenterStore . unreadNotificationsCount
2023-02-23 16:43:28 +04:00
hasAdmin: activityCenterStore . adminCount > 0
hasReplies: activityCenterStore . repliesCount > 0
hasMentions: activityCenterStore . mentionsCount > 0
hasContactRequests: activityCenterStore . contactRequestsCount > 0
2023-03-01 16:23:46 +04:00
hasIdentityVerification: activityCenterStore . identityVerificationCount > 0
2023-02-23 16:43:28 +04:00
hasMembership: activityCenterStore . membershipCount > 0
2023-02-23 15:09:05 +04:00
hideReadNotifications: activityCenterStore . activityCenterReadType === ActivityCenterStore . ActivityCenterReadType . Unread
2023-02-21 20:11:44 +04:00
activeGroup: activityCenterStore . activeNotificationGroup
onGroupTriggered: activityCenterStore . setActiveNotificationGroup ( group )
2023-02-23 16:43:28 +04:00
onMarkAllReadClicked: activityCenterStore . markAllActivityCenterNotificationsRead ( )
2023-02-22 19:49:44 +04:00
onShowHideReadNotifications: activityCenterStore . setActivityCenterReadType ( hideReadNotifications ?
2023-10-23 13:35:20 +02:00
ActivityCenterStore.ActivityCenterReadType.Unread :
ActivityCenterStore . ActivityCenterReadType . All )
2021-05-28 13:35:21 -04:00
}
2022-09-15 19:34:41 +03:00
StatusListView {
id: listView
2023-11-15 15:29:03 +04:00
2022-09-12 14:06:26 +04:00
anchors.left: parent . left
anchors.right: parent . right
2021-05-28 13:35:21 -04:00
anchors.top: activityCenterTopBar . bottom
2021-06-11 13:41:59 -04:00
anchors.bottom: parent . bottom
2022-09-15 19:34:41 +03:00
anchors.margins: Style . current . smallPadding
2023-01-23 13:00:06 +04:00
spacing: 1
2021-05-28 13:35:21 -04:00
2023-02-13 12:51:24 +04:00
model: root . activityCenterStore . activityCenterNotifications
2021-06-11 13:41:59 -04:00
2023-11-15 15:29:03 +04:00
onContentYChanged: d . loadMoreNotificationsIfScrollBelowThreshold ( )
2022-11-30 15:15:29 +04:00
delegate: Loader {
width: listView . availableWidth
property int filteredIndex: index
property var notification: model
sourceComponent: {
switch ( model . notificationType ) {
2023-10-23 13:35:20 +02:00
case ActivityCenterStore.ActivityCenterNotificationType.Mention:
return mentionNotificationComponent
case ActivityCenterStore.ActivityCenterNotificationType.Reply:
return replyNotificationComponent
case ActivityCenterStore.ActivityCenterNotificationType.ContactRequest:
return contactRequestNotificationComponent
case ActivityCenterStore.ActivityCenterNotificationType.ContactVerification:
return verificationRequestNotificationComponent
case ActivityCenterStore.ActivityCenterNotificationType.CommunityInvitation:
return communityInvitationNotificationComponent
case ActivityCenterStore.ActivityCenterNotificationType.CommunityMembershipRequest:
return membershipRequestNotificationComponent
case ActivityCenterStore.ActivityCenterNotificationType.CommunityRequest:
return communityRequestNotificationComponent
case ActivityCenterStore.ActivityCenterNotificationType.CommunityKicked:
return communityKickedNotificationComponent
case ActivityCenterStore.ActivityCenterNotificationType.ContactRemoved:
return contactRemovedComponent
case ActivityCenterStore.ActivityCenterNotificationType.NewKeypairAddedToPairedDevice:
return newKeypairFromPairedDeviceComponent
2024-01-04 13:22:12 +01:00
case ActivityCenterStore.ActivityCenterNotificationType.CommunityTokenReceived:
2024-01-29 14:29:15 +01:00
case ActivityCenterStore.ActivityCenterNotificationType.FirstCommunityTokenReceived:
2024-01-04 13:22:12 +01:00
return communityTokenReceivedComponent
2023-10-23 13:35:20 +02:00
case ActivityCenterStore.ActivityCenterNotificationType.OwnerTokenReceived:
2023-10-23 13:36:33 +02:00
case ActivityCenterStore.ActivityCenterNotificationType.OwnershipReceived:
case ActivityCenterStore.ActivityCenterNotificationType.OwnershipLost:
2023-10-23 13:35:20 +02:00
case ActivityCenterStore.ActivityCenterNotificationType.OwnershipFailed:
2023-10-23 13:36:33 +02:00
case ActivityCenterStore.ActivityCenterNotificationType.OwnershipDeclined:
2023-10-23 13:35:20 +02:00
return ownerTokenReceivedNotificationComponent
2023-11-28 14:41:11 +01:00
case ActivityCenterStore.ActivityCenterNotificationType.ShareAccounts:
return shareAccountsNotificationComponent
2024-02-22 12:01:01 +01:00
case ActivityCenterStore.ActivityCenterNotificationType.CommunityBanned:
return communityBannedNotificationComponent
case ActivityCenterStore.ActivityCenterNotificationType.CommunityUnbanned:
return communityUnbannedNotificationComponent
2024-04-12 18:28:28 +02:00
case ActivityCenterStore.ActivityCenterNotificationType.NewPrivateGroupChat:
return groupChatInvitationNotificationComponent
2024-10-02 09:54:35 -04:00
case ActivityCenterStore.ActivityCenterNotificationType.NewInstallationReceived:
case ActivityCenterStore.ActivityCenterNotificationType.NewInstallationCreated:
return newDeviceDetectedComponent
2023-10-23 13:35:20 +02:00
default:
return null
2022-10-18 23:46:57 +04:00
}
}
2021-06-11 13:41:59 -04:00
}
2021-05-28 13:35:21 -04:00
}
2022-11-30 15:15:29 +04:00
Component {
id: mentionNotificationComponent
ActivityNotificationMention {
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
onCloseActivityCenter: root . close ( )
}
}
Component {
id: replyNotificationComponent
ActivityNotificationReply {
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
onCloseActivityCenter: root . close ( )
}
}
Component {
id: contactRequestNotificationComponent
ActivityNotificationContactRequest {
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
onCloseActivityCenter: root . close ( )
}
}
2022-11-15 13:11:55 +03:00
Component {
id: verificationRequestNotificationComponent
ActivityNotificationContactVerification {
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
onCloseActivityCenter: root . close ( )
}
}
2022-11-30 15:15:29 +04:00
Component {
id: communityInvitationNotificationComponent
ActivityNotificationCommunityInvitation {
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
onCloseActivityCenter: root . close ( )
}
}
Component {
id: membershipRequestNotificationComponent
ActivityNotificationCommunityMembershipRequest {
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
onCloseActivityCenter: root . close ( )
}
}
Component {
id: communityRequestNotificationComponent
ActivityNotificationCommunityRequest {
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
onCloseActivityCenter: root . close ( )
}
}
Component {
id: communityKickedNotificationComponent
ActivityNotificationCommunityKicked {
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
2024-02-22 12:01:01 +01:00
onCloseActivityCenter: root . close ( )
}
}
Component {
id: communityBannedNotificationComponent
ActivityNotificationCommunityBanUnban {
banned: true
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
onCloseActivityCenter: root . close ( )
}
}
Component {
id: communityUnbannedNotificationComponent
ActivityNotificationCommunityBanUnban {
banned: false
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
2022-11-30 15:15:29 +04:00
onCloseActivityCenter: root . close ( )
}
}
2023-06-08 16:52:03 +04:00
Component {
id: contactRemovedComponent
ActivityNotificationContactRemoved {
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
onCloseActivityCenter: root . close ( )
}
}
2023-08-24 15:09:25 +02:00
Component {
id: newKeypairFromPairedDeviceComponent
ActivityNotificationNewKeypairFromPairedDevice {
filteredIndex: parent . filteredIndex
notification: parent . notification
onCloseActivityCenter: root . close ( )
}
}
2023-10-23 13:35:20 +02:00
Component {
id: ownerTokenReceivedNotificationComponent
ActivityNotificationTransferOwnership {
readonly property var community : notification ? root . store . getCommunityDetailsAsJson ( notification . communityId ) : null
type: setType ( notification )
communityName: community ? community.name : ""
communityColor: community ? community.color : Theme . palette . directColor1
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
onCloseActivityCenter: root . close ( )
onFinaliseOwnershipClicked: Global . openFinaliseOwnershipPopup ( notification . communityId )
onNavigateToCommunityClicked: root . store . setActiveCommunity ( notification . communityId )
}
}
2023-11-28 14:41:11 +01:00
2024-10-02 09:54:35 -04:00
Component {
id: newDeviceDetectedComponent
ActivityNotificationNewDevice {
type: setType ( notification )
filteredIndex: parent . filteredIndex
notification: parent . notification
accountName: store . name
store: root . store
activityCenterStore: root . activityCenterStore
onCloseActivityCenter: root . close ( )
onMoreDetailsClicked: {
switch ( type ) {
case ActivityNotificationNewDevice.InstallationType.Received:
Global . openPopup ( pairDeviceDialog , {
name: store . name ,
deviceId: notification . installationId
} ) ;
break ;
case ActivityNotificationNewDevice.InstallationType.Created:
Global . openPopup ( checkOtherDeviceDialog , {
deviceId: notification . installationId
} ) ;
break ;
}
}
}
}
2024-01-04 13:22:12 +01:00
Component {
id: communityTokenReceivedComponent
ActivityNotificationCommunityTokenReceived {
readonly property var community : notification ? root . store . getCommunityDetailsAsJson ( notification . communityId ) : null
2024-01-29 14:29:15 +01:00
communityId: notification . communityId
2024-01-04 13:22:12 +01:00
communityName: community ? community.name : ""
communityImage: community ? community.image : ""
2024-02-19 14:58:20 +01:00
store: root . store
2024-01-04 13:22:12 +01:00
filteredIndex: parent . filteredIndex
notification: parent . notification
onCloseActivityCenter: root . close ( )
}
}
2023-11-28 14:41:11 +01:00
Component {
id: shareAccountsNotificationComponent
ActivityNotificationCommunityShareAddresses {
readonly property var community : notification ? root . store . getCommunityDetailsAsJson ( notification . communityId ) : null
communityName: community ? community.name : ""
2024-01-04 13:22:12 +01:00
communityColor: community ? community.color : "transparent"
2023-11-28 14:41:11 +01:00
communityImage: community ? community.image : ""
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
onCloseActivityCenter: root . close ( )
onOpenShareAccountsClicked: {
Global . communityShareAddressesPopupRequested ( notification . communityId , communityName , communityImage )
}
}
}
2024-04-12 18:28:28 +02:00
Component {
id: groupChatInvitationNotificationComponent
ActivityNotificationUnknownGroupChatInvitation {
filteredIndex: parent . filteredIndex
notification: parent . notification
store: root . store
activityCenterStore: root . activityCenterStore
onCloseActivityCenter: root . close ( )
}
}
2024-10-02 09:54:35 -04:00
function truncateDeviceId ( deviceId ) {
return deviceId . substring ( 0 , 7 ) . toUpperCase ( )
}
Component {
id: pairDeviceDialog
StatusDialog {
property string name
property string deviceId
width: 480
closePolicy: Popup . CloseOnPressOutside
destroyOnClose: true
title: qsTr ( "Pair new device and sync profile" )
contentItem: ColumnLayout {
spacing: 16
StatusBaseText {
Layout.fillWidth: true
text: qsTr ( "New device with %1 profile has been detected. You can see the device ID below and on your other device. Only confirm the request if the device ID matches." )
. arg ( name )
wrapMode: Text . WordWrap
}
StatusBaseText {
Layout.alignment: Qt . AlignHCenter
font.pixelSize: 27
font.weight: Font . Medium
font.letterSpacing: 5
text: truncateDeviceId ( deviceId )
}
}
footer: StatusDialogFooter {
leftButtons: ObjectModel {
StatusFlatButton {
text: qsTr ( "Cancel" )
onClicked: {
close ( )
}
}
}
rightButtons: ObjectModel {
StatusButton {
text: qsTr ( "Pair and Sync" )
onClicked: {
activityCenterStore . enableInstallationAndSync ( deviceId )
close ( )
}
}
}
}
}
}
Component {
id: checkOtherDeviceDialog
StatusDialog {
property string deviceId
width: 480
closePolicy: Popup . CloseOnPressOutside
destroyOnClose: true
title: qsTr ( "Pair this device and sync profile" )
contentItem: ColumnLayout {
spacing: 16
StatusBaseText {
Layout.fillWidth: true
text: qsTr ( "Check your other device for a pairing request. Ensure that the this device ID displayed on your other device. Only proceed with pairing and syncing if the IDs are identical." )
wrapMode: Text . WordWrap
}
StatusBaseText {
Layout.alignment: Qt . AlignHCenter
font.pixelSize: 27
font.weight: Font . Medium
font.letterSpacing: 5
text: truncateDeviceId ( deviceId )
}
Item {
Layout.fillWidth: true
}
}
footer: null
}
}
2021-05-28 13:35:21 -04:00
}