2020-06-17 19:18:31 +00:00
import QtQuick 2.13
import QtQuick . Controls 2.13
import QtQuick . Layouts 1.13
2021-10-27 09:37:58 +00:00
import StatusQ . Core 0.1
import StatusQ . Core . Theme 0.1
2022-04-04 11:09:23 +00:00
import StatusQ . Controls 0.1
import StatusQ . Components 0.1
import StatusQ . Popups 0.1
2021-09-28 15:04:06 +00:00
import utils 1.0
2021-10-27 21:27:49 +00:00
import shared . panels 1.0
import shared . controls 1.0
2020-05-27 21:28:25 +00:00
2021-12-30 12:39:47 +00:00
import "../stores"
2022-04-04 11:09:23 +00:00
import "../controls"
2021-10-06 09:16:39 +00:00
import "../panels"
2022-04-04 11:09:23 +00:00
import "../popups"
2021-10-06 09:16:39 +00:00
2022-05-07 11:45:15 +00:00
SettingsContentBase {
2021-10-06 09:16:39 +00:00
id: root
2023-04-04 14:05:50 +00:00
2021-12-30 12:39:47 +00:00
property NotificationsStore notificationsStore
2021-12-28 14:43:25 +00:00
2024-08-22 18:48:04 +00:00
Component.onCompleted: root . notificationsStore . loadExemptions ( )
2023-02-06 18:08:55 +00:00
content: ColumnLayout {
2022-04-04 11:09:23 +00:00
id: contentColumn
2020-09-18 12:24:16 +00:00
2023-02-06 18:08:55 +00:00
spacing: Constants . settingsSection . itemSpacing
2022-04-04 11:09:23 +00:00
2023-02-06 18:08:55 +00:00
ButtonGroup {
id: messageSetting
}
2020-09-18 12:24:16 +00:00
2023-02-06 18:08:55 +00:00
Loader {
id: exemptionNotificationsModal
active: false
2022-04-04 11:09:23 +00:00
2023-02-06 18:08:55 +00:00
function open ( item ) {
active = true
exemptionNotificationsModal . item . item = item
exemptionNotificationsModal . item . open ( )
}
function close ( ) {
active = false
2020-09-18 12:24:16 +00:00
}
2023-02-06 18:08:55 +00:00
sourceComponent: ExemptionNotificationsModal {
anchors.centerIn: parent
notificationsStore: root . notificationsStore
2022-04-04 11:09:23 +00:00
2023-02-06 18:08:55 +00:00
onClosed: {
exemptionNotificationsModal . close ( ) ;
2020-12-07 17:37:39 +00:00
}
}
2023-02-06 18:08:55 +00:00
}
Component {
id: exemptionDelegateComponent
StatusListItem {
property string lowerCaseSearchString: searchBox . text . toLowerCase ( )
width: ListView . view . width
height: visible ? implicitHeight : 0
visible: lowerCaseSearchString === "" ||
model . itemId . toLowerCase ( ) . includes ( lowerCaseSearchString ) ||
model . name . toLowerCase ( ) . includes ( lowerCaseSearchString )
title: model . name
subTitle: {
if ( model . type === Constants . settingsSection . exemptions . community )
return qsTr ( "Community" )
else if ( model . type === Constants . settingsSection . exemptions . oneToOneChat )
return qsTr ( "1:1 Chat" )
else if ( model . type === Constants . settingsSection . exemptions . groupChat )
return qsTr ( "Group Chat" )
else
return ""
}
label: {
if ( ! model . customized )
return ""
let l = ""
if ( model . muteAllMessages )
l += qsTr ( "Muted" )
else {
let nbOfChanges = 0
if ( model . personalMentions !== Constants . settingsSection . notifications . sendAlertsValue )
{
nbOfChanges ++
let valueText = model . personalMentions === Constants . settingsSection . notifications . turnOffValue ?
qsTr ( "Off" ) :
qsTr ( "Quiet" )
l = qsTr ( "Personal @ Mentions %1" ) . arg ( valueText )
2020-11-17 19:02:56 +00:00
}
2022-04-04 11:09:23 +00:00
2023-02-06 18:08:55 +00:00
if ( model . globalMentions !== Constants . settingsSection . notifications . sendAlertsValue )
{
nbOfChanges ++
let valueText = model . globalMentions === Constants . settingsSection . notifications . turnOffValue ?
qsTr ( "Off" ) :
qsTr ( "Quiet" )
l = qsTr ( "Global @ Mentions %1" ) . arg ( valueText )
2020-11-17 19:02:56 +00:00
}
2020-09-18 12:24:16 +00:00
2023-02-06 18:08:55 +00:00
if ( model . otherMessages !== Constants . settingsSection . notifications . turnOffValue )
{
nbOfChanges ++
let valueText = model . otherMessages === Constants . settingsSection . notifications . sendAlertsValue ?
qsTr ( "Alerts" ) :
qsTr ( "Quiet" )
l = qsTr ( "Other Messages %1" ) . arg ( valueText )
2020-11-17 19:02:56 +00:00
}
2021-01-19 19:26:59 +00:00
2023-02-06 18:08:55 +00:00
if ( nbOfChanges > 1 )
l = qsTr ( "Multiple Exemptions" )
2021-01-29 10:12:45 +00:00
}
2022-04-04 11:09:23 +00:00
2023-02-06 18:08:55 +00:00
return l
}
2022-04-04 11:09:23 +00:00
2023-02-06 18:08:55 +00:00
// Maybe we need to redo `StatusListItem` to display identicon ring, but that's not in Figma design for now.
ringSettings.ringSpecModel: model . type === Constants . settingsSection . exemptions . oneToOneChat ? Utils . getColorHashAsJson ( model . itemId ) : undefined
asset: StatusAssetSettings {
name: model . image
isImage: ! ! model . image && model . image !== ""
color: model . type === Constants . settingsSection . exemptions . oneToOneChat ?
Utils . colorForPubkey ( model . itemId ) :
model . color
charactersLen: model . type === Constants . settingsSection . exemptions . oneToOneChat ? 2 : 1
isLetterIdenticon: ! model . image || model . image === ""
height: 40
width: 40
}
2020-09-18 12:24:16 +00:00
2023-02-06 18:08:55 +00:00
components: [
StatusIcon {
visible: model . customized
icon: "next"
2022-04-04 11:09:23 +00:00
color: Theme . palette . baseColor1
2023-02-06 18:08:55 +00:00
MouseArea {
anchors.fill: parent
cursorShape: Qt . PointingHandCursor
onClicked: {
exemptionNotificationsModal . open ( model )
2022-04-04 11:09:23 +00:00
}
}
2023-02-06 18:08:55 +00:00
} ,
StatusIcon {
visible: ! model . customized
icon: "add"
color: Theme . palette . primaryColor1
MouseArea {
anchors.fill: parent
cursorShape: Qt . PointingHandCursor
onClicked: {
exemptionNotificationsModal . open ( model )
2022-04-04 11:09:23 +00:00
}
}
2023-02-06 18:08:55 +00:00
} ]
}
}
Rectangle {
Layout.preferredWidth: root . contentWidth
implicitHeight: col1 . height + 2 * Style . current . padding
2023-04-04 14:05:50 +00:00
visible: Qt . platform . os == Constants . mac
2023-02-06 18:08:55 +00:00
radius: Constants . settingsSection . radius
color: Theme . palette . primaryColor3
ColumnLayout {
id: col1
anchors.margins: Style . current . padding
anchors.left: parent . left
anchors.right: parent . right
anchors.verticalCenter: parent . verticalCenter
spacing: Constants . settingsSection . infoSpacing
StatusBaseText {
Layout.preferredWidth: parent . width
text: qsTr ( "Enable Notifications in macOS Settings" )
font.pixelSize: Constants . settingsSection . infoFontSize
lineHeight: Constants . settingsSection . infoLineHeight
lineHeightMode: Text . FixedHeight
color: Theme . palette . primaryColor1
}
2022-04-04 11:09:23 +00:00
2023-02-06 18:08:55 +00:00
StatusBaseText {
Layout.preferredWidth: parent . width
text: qsTr ( "To receive Status notifications, make sure you've enabled them in your computer's settings under <b>System Preferences > Notifications</b>" )
font.pixelSize: Constants . settingsSection . infoFontSize
lineHeight: Constants . settingsSection . infoLineHeight
lineHeightMode: Text . FixedHeight
color: Theme . palette . baseColor1
wrapMode: Text . WordWrap
}
}
}
StatusListItem {
Layout.preferredWidth: root . contentWidth
2023-03-15 15:50:04 +00:00
title: qsTr ( "Allow Notification Bubbles" )
2023-02-06 18:08:55 +00:00
components: [
StatusSwitch {
id: allowNotifSwitch
checked: appSettings . notifSettingAllowNotifications
onClicked: {
appSettings . notifSettingAllowNotifications = ! appSettings . notifSettingAllowNotifications
2022-04-04 11:09:23 +00:00
}
2023-02-06 18:08:55 +00:00
}
]
onClicked: {
allowNotifSwitch . clicked ( )
}
}
StatusBaseText {
Layout.preferredWidth: root . contentWidth
Layout.leftMargin: Style . current . padding
text: qsTr ( "Messages" )
font.pixelSize: Constants . settingsSection . subHeaderFontSize
color: Theme . palette . baseColor1
}
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "1:1 Chats" )
components: [
NotificationSelect {
selected: appSettings . notifSettingOneToOneChats
onSendAlertsClicked: appSettings . notifSettingOneToOneChats = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingOneToOneChats = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingOneToOneChats = Constants . settingsSection . notifications . turnOffValue
}
]
}
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "Group Chats" )
components: [
NotificationSelect {
selected: appSettings . notifSettingGroupChats
onSendAlertsClicked: appSettings . notifSettingGroupChats = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingGroupChats = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingGroupChats = Constants . settingsSection . notifications . turnOffValue
}
]
}
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "Personal @ Mentions" )
tertiaryTitle: qsTr ( "Messages containing @%1" ) . arg ( userProfile . name )
components: [
NotificationSelect {
selected: appSettings . notifSettingPersonalMentions
onSendAlertsClicked: appSettings . notifSettingPersonalMentions = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingPersonalMentions = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingPersonalMentions = Constants . settingsSection . notifications . turnOffValue
}
]
}
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "Global @ Mentions" )
2023-03-14 10:50:34 +00:00
tertiaryTitle: qsTr ( "Messages containing @everyone" )
2023-02-06 18:08:55 +00:00
components: [
NotificationSelect {
selected: appSettings . notifSettingGlobalMentions
onSendAlertsClicked: appSettings . notifSettingGlobalMentions = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingGlobalMentions = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingGlobalMentions = Constants . settingsSection . notifications . turnOffValue
}
]
}
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "All Messages" )
components: [
NotificationSelect {
selected: appSettings . notifSettingAllMessages
onSendAlertsClicked: appSettings . notifSettingAllMessages = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingAllMessages = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingAllMessages = Constants . settingsSection . notifications . turnOffValue
}
]
}
StatusBaseText {
Layout.preferredWidth: root . contentWidth
Layout.leftMargin: Style . current . padding
text: qsTr ( "Others" )
font.pixelSize: Constants . settingsSection . subHeaderFontSize
color: Theme . palette . baseColor1
}
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "Contact Requests" )
components: [
NotificationSelect {
selected: appSettings . notifSettingContactRequests
onSendAlertsClicked: appSettings . notifSettingContactRequests = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingContactRequests = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingContactRequests = Constants . settingsSection . notifications . turnOffValue
}
]
}
StatusListItem {
2024-07-18 20:10:24 +00:00
// Hidden since 2.29 since it's not mature enough
visible: false
2023-02-06 18:08:55 +00:00
Layout.preferredWidth: root . contentWidth
title: qsTr ( "Identity Verification Requests" )
components: [
NotificationSelect {
selected: appSettings . notifSettingIdentityVerificationRequests
onSendAlertsClicked: appSettings . notifSettingIdentityVerificationRequests = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingIdentityVerificationRequests = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingIdentityVerificationRequests = Constants . settingsSection . notifications . turnOffValue
}
]
}
Separator {
Layout.preferredWidth: root . contentWidth
Layout.preferredHeight: Style . current . bigPadding
}
StatusBaseText {
Layout.preferredWidth: root . contentWidth
Layout.leftMargin: Style . current . padding
text: qsTr ( "Notification Content" )
font.pixelSize: Constants . settingsSection . subHeaderFontSize
color: Theme . palette . directColor1
}
NotificationAppearancePreviewPanel {
id: notifNameAndMsg
Layout.preferredWidth: root . contentWidth
Layout.leftMargin: Style . current . padding
name: qsTr ( "Show Name and Message" )
notificationTitle: "Vitalik Buterin"
notificationMessage: qsTr ( "Hi there! So EIP-1559 will defini..." )
buttonGroup: messageSetting
checked: appSettings . notificationMessagePreview === Constants . settingsSection . notificationsBubble . previewNameAndMessage
onRadioCheckedChanged: {
if ( checked ) {
appSettings . notificationMessagePreview = Constants . settingsSection . notificationsBubble . previewNameAndMessage
}
}
}
NotificationAppearancePreviewPanel {
Layout.preferredWidth: root . contentWidth
Layout.leftMargin: Style . current . padding
name: qsTr ( "Name Only" )
notificationTitle: "Vitalik Buterin"
notificationMessage: qsTr ( "You have a new message" )
buttonGroup: messageSetting
checked: appSettings . notificationMessagePreview === Constants . settingsSection . notificationsBubble . previewNameOnly
onRadioCheckedChanged: {
if ( checked ) {
appSettings . notificationMessagePreview = Constants . settingsSection . notificationsBubble . previewNameOnly
}
}
}
NotificationAppearancePreviewPanel {
Layout.preferredWidth: root . contentWidth
Layout.leftMargin: Style . current . padding
name: qsTr ( "Anonymous" )
notificationTitle: "Status"
notificationMessage: qsTr ( "You have a new message" )
buttonGroup: messageSetting
checked: appSettings . notificationMessagePreview === Constants . settingsSection . notificationsBubble . previewAnonymous
onRadioCheckedChanged: {
if ( checked ) {
appSettings . notificationMessagePreview = Constants . settingsSection . notificationsBubble . previewAnonymous
}
}
}
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "Play a Sound When Receiving a Notification" )
components: [
StatusSwitch {
id: soundSwitch
checked: appSettings . notificationSoundsEnabled
onClicked: {
appSettings . notificationSoundsEnabled = ! appSettings . notificationSoundsEnabled
2022-04-04 11:09:23 +00:00
}
2023-02-06 18:08:55 +00:00
}
]
onClicked: {
soundSwitch . clicked ( )
}
}
StatusBaseText {
Layout.preferredWidth: root . contentWidth
Layout.leftMargin: Style . current . padding
text: qsTr ( "Volume" )
font.pixelSize: Constants . settingsSection . subHeaderFontSize
color: Theme . palette . directColor1
}
Item {
Layout.preferredWidth: root . contentWidth
Layout.preferredHeight: Constants . settingsSection . itemHeight + Style . current . padding
StatusSlider {
id: volumeSlider
anchors.top: parent . top
anchors.left: parent . left
anchors.right: parent . right
anchors.topMargin: Style . current . bigPadding
anchors.leftMargin: Style . current . padding
anchors.rightMargin: Style . current . padding
from: 0
to: 100
stepSize: 1
onValueChanged: {
appSettings . volume = value
}
2022-04-04 11:09:23 +00:00
2023-02-06 18:08:55 +00:00
Component.onCompleted: {
value = appSettings . volume
volumeSlider . valueChanged . connect ( ( ) = > {
// play a sound preview, but not on startup
2023-02-07 14:21:32 +00:00
Global . playNotificationSound ( )
2023-02-06 18:08:55 +00:00
} ) ;
}
}
2022-04-04 11:09:23 +00:00
2023-02-06 18:08:55 +00:00
RowLayout {
anchors.top: volumeSlider . bottom
anchors.left: volumeSlider . left
anchors.topMargin: Style . current . halfPadding
width: volumeSlider . width
StatusBaseText {
font.pixelSize: 15
text: volumeSlider . from
Layout.preferredWidth: volumeSlider . width / 2
color: Theme . palette . baseColor1
}
2022-04-04 11:09:23 +00:00
2023-02-06 18:08:55 +00:00
StatusBaseText {
font.pixelSize: 15
text: volumeSlider . to
Layout.alignment: Qt . AlignRight
color: Theme . palette . baseColor1
2022-04-04 11:09:23 +00:00
}
2023-02-06 18:08:55 +00:00
}
}
StatusButton {
Layout.leftMargin: Style . current . padding
text: qsTr ( "Send a Test Notification" )
onClicked: {
root . notificationsStore . sendTestNotification ( notifNameAndMsg . notificationTitle ,
notifNameAndMsg . notificationMessage )
}
}
Separator {
Layout.preferredWidth: root . contentWidth
Layout.preferredHeight: Style . current . bigPadding
}
StatusBaseText {
Layout.preferredWidth: root . contentWidth
Layout.leftMargin: Style . current . padding
text: qsTr ( "Exemptions" )
font.pixelSize: Constants . settingsSection . subHeaderFontSize
color: Theme . palette . directColor1
}
SearchBox {
id: searchBox
Layout.preferredWidth: root . contentWidth - 2 * Style . current . padding
Layout.leftMargin: Style . current . padding
Layout.rightMargin: Style . current . padding
placeholderText: qsTr ( "Search Communities, Group Chats and 1:1 Chats" )
}
StatusBaseText {
Layout.preferredWidth: root . contentWidth
Layout.leftMargin: Style . current . padding
text: qsTr ( "Most recent" )
font.pixelSize: Constants . settingsSection . subHeaderFontSize
color: Theme . palette . baseColor1
}
StatusListView {
Layout.preferredWidth: root . contentWidth
Layout.preferredHeight: this . contentHeight
visible: root . notificationsStore . exemptionsModel . count > 0
model: root . notificationsStore . exemptionsModel
delegate: exemptionDelegateComponent
}
}
2020-05-27 21:28:25 +00:00
}