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
2021-12-30 12:39:47 +00:00
property NotificationsStore notificationsStore
2022-04-04 11:09:23 +00:00
property DevicesStore devicesStore
2021-12-28 14:43:25 +00:00
2022-04-04 11:09:23 +00:00
ColumnLayout {
id: contentColumn
spacing: Constants . settingsSection . itemSpacing
ButtonGroup {
id: messageSetting
2020-09-18 12:24:16 +00:00
}
2022-04-04 11:09:23 +00:00
Loader {
id: exemptionNotificationsModal
active: false
function open ( item ) {
active = true
exemptionNotificationsModal . item . item = item
exemptionNotificationsModal . item . open ( )
}
function close ( ) {
active = false
2020-09-18 12:24:16 +00:00
}
2022-04-04 11:09:23 +00:00
sourceComponent: ExemptionNotificationsModal {
anchors.centerIn: parent
notificationsStore: root . notificationsStore
onClosed: {
exemptionNotificationsModal . close ( ) ;
2020-10-15 11:53:27 +00:00
}
2020-09-18 12:24:16 +00:00
}
}
2022-04-04 11:09:23 +00:00
Component {
id: exemptionDelegateComponent
StatusListItem {
property string lowerCaseSearchString: searchBox . text . toLowerCase ( )
2020-09-18 12:24:16 +00:00
2022-09-27 21:26:26 +00:00
width: ListView . view . width
2022-04-04 11:09:23 +00:00
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 )
}
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 )
}
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 )
}
if ( nbOfChanges > 1 )
l = qsTr ( "Multiple Exemptions" )
}
return l
}
// Maybe we need to redo `StatusListItem` to display identicon ring, but that's not in Figma design for now.
2022-05-17 18:58:34 +00:00
ringSettings.ringSpecModel: model . type === Constants . settingsSection . exemptions . oneToOneChat ? Utils . getColorHashAsJson ( model . itemId ) : undefined
2022-08-11 11:55:08 +00:00
asset: StatusAssetSettings {
name: model . image
isImage: ! ! model . image && model . image !== ""
2022-04-04 11:09:23 +00:00
color: model . type === Constants . settingsSection . exemptions . oneToOneChat ?
2022-08-19 10:01:54 +00:00
Utils . colorForPubkey ( model . itemId ) :
2022-04-04 11:09:23 +00:00
model . color
charactersLen: model . type === Constants . settingsSection . exemptions . oneToOneChat ? 2 : 1
2022-08-11 11:55:08 +00:00
isLetterIdenticon: ! model . image || model . image === ""
2022-10-13 11:08:43 +00:00
height: 40
width: 40
2022-04-04 11:09:23 +00:00
}
components: [
StatusIcon {
visible: model . customized
2022-10-13 11:08:43 +00:00
icon: "next"
2022-04-04 11:09:23 +00:00
color: Theme . palette . baseColor1
MouseArea {
anchors.fill: parent
cursorShape: Qt . PointingHandCursor
onClicked: {
exemptionNotificationsModal . open ( model )
}
}
} ,
StatusIcon {
visible: ! model . customized
icon: "add"
color: Theme . palette . primaryColor1
MouseArea {
anchors.fill: parent
cursorShape: Qt . PointingHandCursor
onClicked: {
exemptionNotificationsModal . open ( model )
}
}
} ]
2020-12-07 17:37:39 +00:00
}
}
2020-09-18 12:24:16 +00:00
2022-04-04 11:09:23 +00:00
Rectangle {
Layout.preferredWidth: root . contentWidth
implicitHeight: col1 . height + 2 * Style . current . padding
visible: Qt . platform . os == "osx"
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
}
StatusBaseText {
Layout.preferredWidth: parent . width
2022-10-13 11:08:43 +00:00
text: qsTr ( "To receive Status notifications, make sure you've enabled them in your computer's settings under <b>System Preferences > Notifications</b>" )
2022-04-04 11:09:23 +00:00
font.pixelSize: Constants . settingsSection . infoFontSize
lineHeight: Constants . settingsSection . infoLineHeight
lineHeightMode: Text . FixedHeight
color: Theme . palette . baseColor1
wrapMode: Text . WordWrap
}
2020-11-17 19:02:56 +00:00
}
}
2022-04-04 11:09:23 +00:00
Rectangle {
Layout.preferredWidth: root . contentWidth
implicitHeight: row1 . height + 2 * Style . current . padding
radius: Constants . settingsSection . radius
color: Theme . palette . pinColor2
RowLayout {
id: row1
anchors.margins: Style . current . padding
anchors.left: parent . left
anchors.right: parent . right
anchors.verticalCenter: parent . verticalCenter
visible: root . devicesStore . devicesModel . count > 0
StatusBaseText {
Layout.fillWidth: true
text: qsTr ( "Sync your devices to share notifications preferences" )
font.pixelSize: Constants . settingsSection . infoFontSize
lineHeight: Constants . settingsSection . infoLineHeight
lineHeightMode: Text . FixedHeight
color: Theme . palette . pinColor1
}
StatusBaseText {
text: qsTr ( "Syncing >" )
font.pixelSize: Constants . settingsSection . infoFontSize
lineHeight: Constants . settingsSection . infoLineHeight
lineHeightMode: Text . FixedHeight
color: Theme . palette . pinColor1
MouseArea {
anchors.fill: parent
cursorShape: Qt . PointingHandCursor
onClicked: {
root . devicesStore . syncAll ( )
}
}
}
2020-11-17 19:02:56 +00:00
}
}
2020-09-18 12:24:16 +00:00
2022-04-04 11:09:23 +00:00
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "Allow Notifications" )
components: [
StatusSwitch {
id: allowNotifSwitch
2022-05-10 13:15:56 +00:00
checked: appSettings . notifSettingAllowNotifications
2022-04-04 11:09:23 +00:00
onClicked: {
2022-05-10 13:15:56 +00:00
appSettings . notifSettingAllowNotifications = ! appSettings . notifSettingAllowNotifications
2022-04-04 11:09:23 +00:00
}
}
]
2022-08-24 14:37:05 +00:00
onClicked: {
2022-04-04 11:09:23 +00:00
allowNotifSwitch . clicked ( )
2020-11-17 19:02:56 +00:00
}
}
2020-09-18 12:24:16 +00:00
2022-04-04 11:09:23 +00:00
StatusBaseText {
Layout.preferredWidth: root . contentWidth
Layout.leftMargin: Style . current . padding
text: qsTr ( "Messages" )
font.pixelSize: Constants . settingsSection . subHeaderFontSize
color: Theme . palette . baseColor1
}
2020-09-18 12:24:16 +00:00
2022-04-04 11:09:23 +00:00
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "1:1 Chats" )
components: [
NotificationSelect {
2022-05-10 13:15:56 +00:00
selected: appSettings . notifSettingOneToOneChats
onSendAlertsClicked: appSettings . notifSettingOneToOneChats = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingOneToOneChats = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingOneToOneChats = Constants . settingsSection . notifications . turnOffValue
2022-04-04 11:09:23 +00:00
}
]
}
2020-09-18 12:24:16 +00:00
2022-04-04 11:09:23 +00:00
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "Group Chats" )
components: [
NotificationSelect {
2022-05-10 13:15:56 +00:00
selected: appSettings . notifSettingGroupChats
onSendAlertsClicked: appSettings . notifSettingGroupChats = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingGroupChats = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingGroupChats = Constants . settingsSection . notifications . turnOffValue
2022-04-04 11:09:23 +00:00
}
]
}
2021-01-19 19:26:59 +00:00
2022-04-04 11:09:23 +00:00
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "Personal @ Mentions" )
tertiaryTitle: qsTr ( "Messages containing @%1" ) . arg ( userProfile . name )
components: [
NotificationSelect {
2022-05-10 13:15:56 +00:00
selected: appSettings . notifSettingPersonalMentions
onSendAlertsClicked: appSettings . notifSettingPersonalMentions = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingPersonalMentions = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingPersonalMentions = Constants . settingsSection . notifications . turnOffValue
2022-04-04 11:09:23 +00:00
}
]
2021-01-29 10:12:45 +00:00
}
2022-04-04 11:09:23 +00:00
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "Global @ Mentions" )
tertiaryTitle: qsTr ( "Messages containing @here and @channel" )
components: [
NotificationSelect {
2022-05-10 13:15:56 +00:00
selected: appSettings . notifSettingGlobalMentions
onSendAlertsClicked: appSettings . notifSettingGlobalMentions = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingGlobalMentions = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingGlobalMentions = Constants . settingsSection . notifications . turnOffValue
2022-04-04 11:09:23 +00:00
}
]
2021-01-29 10:12:45 +00:00
}
2022-04-04 11:09:23 +00:00
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "All Messages" )
components: [
NotificationSelect {
2022-05-10 13:15:56 +00:00
selected: appSettings . notifSettingAllMessages
onSendAlertsClicked: appSettings . notifSettingAllMessages = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingAllMessages = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingAllMessages = Constants . settingsSection . notifications . turnOffValue
2022-04-04 11:09:23 +00:00
}
]
2021-01-29 10:12:45 +00:00
}
2020-09-18 12:24:16 +00:00
2022-04-04 11:09:23 +00:00
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 {
2022-05-10 13:15:56 +00:00
selected: appSettings . notifSettingContactRequests
onSendAlertsClicked: appSettings . notifSettingContactRequests = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingContactRequests = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingContactRequests = Constants . settingsSection . notifications . turnOffValue
2022-04-04 11:09:23 +00:00
}
]
}
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "Identity Verification Requests" )
components: [
NotificationSelect {
2022-05-10 13:15:56 +00:00
selected: appSettings . notifSettingIdentityVerificationRequests
onSendAlertsClicked: appSettings . notifSettingIdentityVerificationRequests = Constants . settingsSection . notifications . sendAlertsValue
onDeliverQuietlyClicked: appSettings . notifSettingIdentityVerificationRequests = Constants . settingsSection . notifications . deliverQuietlyValue
onTurnOffClicked: appSettings . notifSettingIdentityVerificationRequests = Constants . settingsSection . notifications . turnOffValue
2022-04-04 11:09:23 +00:00
}
]
}
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
2022-05-10 13:15:56 +00:00
checked: appSettings . notificationMessagePreview === Constants . settingsSection . notificationsBubble . previewNameAndMessage
2022-04-04 11:09:23 +00:00
onRadioCheckedChanged: {
if ( checked ) {
2022-05-10 13:15:56 +00:00
appSettings . notificationMessagePreview = Constants . settingsSection . notificationsBubble . previewNameAndMessage
2022-04-04 11:09:23 +00:00
}
}
}
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
2022-05-10 13:15:56 +00:00
checked: appSettings . notificationMessagePreview === Constants . settingsSection . notificationsBubble . previewNameOnly
2022-04-04 11:09:23 +00:00
onRadioCheckedChanged: {
if ( checked ) {
2022-05-10 13:15:56 +00:00
appSettings . notificationMessagePreview = Constants . settingsSection . notificationsBubble . previewNameOnly
2022-04-04 11:09:23 +00:00
}
}
}
NotificationAppearancePreviewPanel {
Layout.preferredWidth: root . contentWidth
Layout.leftMargin: Style . current . padding
name: qsTr ( "Anonymous" )
notificationTitle: "Status"
notificationMessage: qsTr ( "You have a new message" )
buttonGroup: messageSetting
2022-05-10 13:15:56 +00:00
checked: appSettings . notificationMessagePreview === Constants . settingsSection . notificationsBubble . previewAnonymous
2022-04-04 11:09:23 +00:00
onRadioCheckedChanged: {
if ( checked ) {
2022-05-10 13:15:56 +00:00
appSettings . notificationMessagePreview = Constants . settingsSection . notificationsBubble . previewAnonymous
2022-04-04 11:09:23 +00:00
}
}
}
StatusListItem {
Layout.preferredWidth: root . contentWidth
title: qsTr ( "Play a Sound When Receiving a Notification" )
components: [
StatusSwitch {
id: soundSwitch
2022-05-10 13:15:56 +00:00
checked: appSettings . notificationSoundsEnabled
2022-04-04 11:09:23 +00:00
onClicked: {
2022-05-10 13:15:56 +00:00
appSettings . notificationSoundsEnabled = ! appSettings . notificationSoundsEnabled
2022-04-04 11:09:23 +00:00
}
}
]
2022-08-24 14:37:05 +00:00
onClicked: {
2022-04-04 11:09:23 +00:00
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: {
2022-05-10 13:15:56 +00:00
appSettings . volume = value
2022-04-04 11:09:23 +00:00
}
Component.onCompleted: {
2022-05-10 13:15:56 +00:00
value = appSettings . volume
2022-12-09 15:17:56 +00:00
volumeSlider . valueChanged . connect ( ( ) = > {
// play a sound preview, but not on startup
Global . notificationSound . stop ( )
Global . notificationSound . play ( )
} ) ;
2022-04-04 11:09:23 +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
}
StatusBaseText {
font.pixelSize: 15
text: volumeSlider . to
Layout.alignment: Qt . AlignRight
color: Theme . palette . baseColor1
}
}
}
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
2022-07-22 10:28:04 +00:00
placeholderText: qsTr ( "Search Communities, Group Chats and 1:1 Chats" )
2022-04-04 11:09:23 +00:00
}
StatusBaseText {
Layout.preferredWidth: root . contentWidth
Layout.leftMargin: Style . current . padding
text: qsTr ( "Most recent" )
font.pixelSize: Constants . settingsSection . subHeaderFontSize
color: Theme . palette . baseColor1
}
2022-07-14 11:03:36 +00:00
StatusListView {
2022-04-04 11:09:23 +00:00
Layout.preferredWidth: root . contentWidth
Layout.preferredHeight: 400
visible: root . notificationsStore . exemptionsModel . count > 0
model: root . notificationsStore . exemptionsModel
delegate: exemptionDelegateComponent
}
}
//}
// }
//}
2020-05-27 21:28:25 +00:00
}