2022-03-07 20:34:59 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtQuick.Layouts 1.13
|
|
|
|
import QtGraphicalEffects 1.13
|
|
|
|
|
|
|
|
import utils 1.0
|
|
|
|
import shared 1.0
|
|
|
|
import shared.panels 1.0
|
|
|
|
import shared.popups 1.0
|
|
|
|
import shared.status 1.0
|
|
|
|
import shared.controls 1.0
|
2022-08-31 08:32:08 +00:00
|
|
|
import shared.stores 1.0
|
2022-03-07 20:34:59 +00:00
|
|
|
|
|
|
|
import StatusQ.Core 0.1
|
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
import StatusQ.Components 0.1
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
import "../stores"
|
|
|
|
import "../controls"
|
|
|
|
import "../popups"
|
|
|
|
import "../panels"
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
SettingsContentBase {
|
2022-03-07 20:34:59 +00:00
|
|
|
id: root
|
|
|
|
|
|
|
|
property MessagingStore messagingStore
|
2022-07-28 22:59:58 +00:00
|
|
|
property AdvancedStore advancedStore
|
2022-06-28 18:11:18 +00:00
|
|
|
property ContactsStore contactsStore
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
ColumnLayout {
|
|
|
|
id: generalColumn
|
2022-05-26 16:02:41 +00:00
|
|
|
spacing: 2 * Constants.settingsSection.itemSpacing
|
2022-05-07 11:45:15 +00:00
|
|
|
width: root.contentWidth
|
2022-03-07 20:34:59 +00:00
|
|
|
|
|
|
|
ButtonGroup {
|
|
|
|
id: showProfilePictureToGroup
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonGroup {
|
|
|
|
id: seeProfilePicturesFromGroup
|
|
|
|
}
|
|
|
|
|
|
|
|
ButtonGroup {
|
|
|
|
id: browserGroup
|
|
|
|
}
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
StatusListItem {
|
|
|
|
id: allowNewContactRequest
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
implicitHeight: 64
|
|
|
|
|
2022-04-04 11:26:30 +00:00
|
|
|
title: qsTr("Allow new contact requests")
|
2022-05-07 11:45:15 +00:00
|
|
|
|
|
|
|
components: [
|
|
|
|
StatusSwitch {
|
|
|
|
id: switch3
|
|
|
|
checked: !root.messagingStore.privacyModule.messagesFromContactsOnly
|
|
|
|
onCheckedChanged: {
|
|
|
|
// messagesFromContactsOnly needs to be accessed from the module (view),
|
|
|
|
// because otherwise doing `messagesFromContactsOnly = value` only changes the bool property on QML
|
|
|
|
if (root.messagingStore.privacyModule.messagesFromContactsOnly === checked) {
|
|
|
|
root.messagingStore.privacyModule.messagesFromContactsOnly = !checked
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
]
|
2022-08-24 14:37:05 +00:00
|
|
|
onClicked: {
|
2022-05-07 11:45:15 +00:00
|
|
|
switch3.checked = !switch3.checked
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
// Open Message Links With
|
|
|
|
StatusBaseText {
|
2022-05-26 16:02:41 +00:00
|
|
|
Layout.topMargin: Constants.settingsSection.itemSpacing
|
2022-05-07 11:45:15 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
|
|
|
text: qsTr("Open Message Links With")
|
|
|
|
font.pixelSize: 15
|
|
|
|
color: Theme.palette.directColor1
|
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
SettingsRadioButton {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
|
|
|
label: qsTr("Status Browser")
|
|
|
|
group: browserGroup
|
|
|
|
checked: localAccountSensitiveSettings.openLinksInStatus
|
|
|
|
onClicked: {
|
|
|
|
localAccountSensitiveSettings.openLinksInStatus = true
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
SettingsRadioButton {
|
2022-05-26 16:02:41 +00:00
|
|
|
Layout.topMargin: Constants.settingsSection.itemSpacing / 2
|
2022-05-07 11:45:15 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
|
|
|
label: qsTr("System Default Browser")
|
|
|
|
group: browserGroup
|
|
|
|
checked: !localAccountSensitiveSettings.openLinksInStatus
|
|
|
|
onClicked: {
|
|
|
|
localAccountSensitiveSettings.openLinksInStatus = false
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Separator {
|
|
|
|
id: separator1
|
2022-05-26 16:02:41 +00:00
|
|
|
Layout.topMargin: Constants.settingsSection.itemSpacing
|
2022-05-07 11:45:15 +00:00
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
// CONTACTS SECTION
|
|
|
|
StatusContactRequestsIndicatorListItem {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
title: qsTr("Contacts, Requests, and Blocked Users")
|
2022-06-28 18:11:18 +00:00
|
|
|
requestsCount: root.contactsStore.receivedContactRequestsModel.count
|
2022-08-22 14:22:28 +00:00
|
|
|
onClicked: Global.changeAppSectionBySectionType(Constants.appSection.profile,
|
2022-05-07 11:45:15 +00:00
|
|
|
Constants.settingsSubsection.contacts)
|
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Separator {
|
|
|
|
id: separator2
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
// MESSAGE LINK PREVIEWS
|
|
|
|
StatusListItem {
|
|
|
|
Layout.fillWidth: true
|
2022-08-12 12:11:57 +00:00
|
|
|
objectName: "displayMessageLinkPreviewsItem"
|
2022-05-07 11:45:15 +00:00
|
|
|
title: qsTr("Display Message Link Previews")
|
|
|
|
implicitHeight: 64
|
|
|
|
components: [
|
|
|
|
StatusSwitch {
|
|
|
|
id: showMessageLinksSwitch
|
2022-11-07 13:43:38 +00:00
|
|
|
function switchOffPreviewableSites() {
|
|
|
|
//update all models
|
|
|
|
localAccountSensitiveSettings.displayChatImages = false
|
|
|
|
for (let i = 0; i < previewableSites.count; i++) {
|
|
|
|
let item = previewableSites.get(i)
|
|
|
|
RootStore.updateWhitelistedUnfurlingSites(item.address, false)
|
|
|
|
}
|
|
|
|
}
|
2022-11-07 15:21:03 +00:00
|
|
|
checked: previewableSites.anyWhitelisted || localAccountSensitiveSettings.displayChatImages
|
|
|
|
onToggled: {
|
2022-05-07 11:45:15 +00:00
|
|
|
if (checked === false) {
|
2022-11-07 13:43:38 +00:00
|
|
|
switchOffPreviewableSites()
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
]
|
2022-08-24 14:37:05 +00:00
|
|
|
onClicked: {
|
2022-11-07 15:21:03 +00:00
|
|
|
showMessageLinksSwitch.toggle()
|
|
|
|
if (showMessageLinksSwitch.checked === false) {
|
|
|
|
showMessageLinksSwitch.switchOffPreviewableSites()
|
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-11-07 13:43:38 +00:00
|
|
|
function buildPreviewablesSitesJSON() {
|
2022-05-07 11:45:15 +00:00
|
|
|
let whitelistAsString = root.messagingStore.getLinkPreviewWhitelist()
|
|
|
|
if(whitelistAsString == "")
|
|
|
|
return
|
2022-11-07 13:43:38 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
if (!localAccountSensitiveSettings.whitelistedUnfurlingSites) {
|
|
|
|
localAccountSensitiveSettings.whitelistedUnfurlingSites = {}
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
2022-11-07 13:43:38 +00:00
|
|
|
|
|
|
|
let anyWhitelisted = false
|
|
|
|
let whitelist = JSON.parse(whitelistAsString)
|
2022-05-07 11:45:15 +00:00
|
|
|
whitelist.forEach(entry => {
|
2022-08-31 08:32:08 +00:00
|
|
|
entry.isWhitelisted = !!localAccountSensitiveSettings.whitelistedUnfurlingSites[entry.address]
|
2022-11-07 13:43:38 +00:00
|
|
|
if(entry.isWhitelisted) anyWhitelisted = true
|
|
|
|
})
|
|
|
|
return [anyWhitelisted, whitelist]
|
|
|
|
}
|
|
|
|
|
|
|
|
function populatePreviewableSites() {
|
|
|
|
const [anyWhitelisted, whitelist] = buildPreviewablesSitesJSON()
|
|
|
|
previewableSites.populateModel(whitelist)
|
2022-11-07 15:21:03 +00:00
|
|
|
previewableSites.anyWhitelisted = anyWhitelisted
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Component.onCompleted: {
|
|
|
|
populatePreviewableSites()
|
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
StatusSectionHeadline {
|
|
|
|
id: labelWebsites
|
|
|
|
visible: showMessageLinksSwitch.checked
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
|
|
|
text: qsTr("Fine tune which sites to allow link previews")
|
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Column {
|
|
|
|
id: siteColumn
|
|
|
|
visible: showMessageLinksSwitch.checked
|
|
|
|
Layout.fillWidth: true
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
ListModel {
|
|
|
|
id: previewableSites
|
2022-11-07 13:43:38 +00:00
|
|
|
function populateModel(jsonModel) {
|
|
|
|
// add/update rows
|
|
|
|
Object.entries(jsonModel)
|
|
|
|
.forEach(([index, newRow]) => {
|
|
|
|
var existingRow = previewableSites.get(index)
|
|
|
|
let isRowIdentical = existingRow != undefined && Object.entries(newRow)
|
|
|
|
.every(([key, value]) => value == existingRow[key])
|
|
|
|
if(!isRowIdentical) {
|
|
|
|
previewableSites.set(index, newRow)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
// remove rows that are not in the new model
|
|
|
|
if(previewableSites.count > jsonModel.length) {
|
|
|
|
let rowsToDelete = previewableSites.count - jsonModel.length
|
|
|
|
previewableSites.remove(jsonModel.length - 1, rowsToDelete)
|
|
|
|
}
|
|
|
|
}
|
2022-11-07 15:21:03 +00:00
|
|
|
|
|
|
|
property bool anyWhitelisted: false
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: Global
|
2022-09-27 21:26:26 +00:00
|
|
|
function onSettingsLoaded() {
|
2022-05-07 11:45:15 +00:00
|
|
|
generalColumn.populatePreviewableSites()
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-08-31 08:32:08 +00:00
|
|
|
Connections {
|
|
|
|
target: localAccountSensitiveSettings
|
|
|
|
onWhitelistedUnfurlingSitesChanged: generalColumn.populatePreviewableSites()
|
|
|
|
}
|
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
// Manually add switch for the image unfurling
|
|
|
|
StatusListItem {
|
2022-08-12 12:11:57 +00:00
|
|
|
objectName: "imageUnfurlingItem"
|
2022-05-07 11:45:15 +00:00
|
|
|
width: parent.width
|
|
|
|
implicitHeight: 64
|
|
|
|
title: qsTr("Image unfurling")
|
|
|
|
subTitle: qsTr("All images (links that contain an image extension) will be downloaded and displayed")
|
|
|
|
// TODO find a better icon for this
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.name: Style.svg('globe')
|
|
|
|
asset.isImage: true
|
2022-05-07 11:45:15 +00:00
|
|
|
components: [
|
|
|
|
StatusSwitch {
|
|
|
|
id: imageSwitch
|
|
|
|
checked: localAccountSensitiveSettings.displayChatImages
|
2022-11-07 13:43:38 +00:00
|
|
|
onToggled: {
|
|
|
|
localAccountSensitiveSettings.displayChatImages = !localAccountSensitiveSettings.displayChatImages
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
]
|
2022-08-24 14:37:05 +00:00
|
|
|
onClicked: {
|
2022-11-07 13:43:38 +00:00
|
|
|
localAccountSensitiveSettings.displayChatImages = !localAccountSensitiveSettings.displayChatImages
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Repeater {
|
|
|
|
id: sitesListView
|
|
|
|
model: previewableSites
|
|
|
|
|
|
|
|
delegate: Component {
|
|
|
|
StatusListItem {
|
2022-09-15 16:32:14 +00:00
|
|
|
objectName: "MessagingView_sitesListView_StatusListItem_" + model.title.replace(/ /g, "_").toLowerCase()
|
2022-05-07 11:45:15 +00:00
|
|
|
width: parent.width
|
|
|
|
implicitHeight: 64
|
|
|
|
title: model.title
|
|
|
|
subTitle: model.address
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.name: {
|
2022-05-07 11:45:15 +00:00
|
|
|
let filename;
|
|
|
|
switch (model.title.toLowerCase()) {
|
|
|
|
case "youtube":
|
|
|
|
case "youtube shortener":
|
|
|
|
filename = "youtube"; break;
|
|
|
|
case "github":
|
|
|
|
filename = "github"; break;
|
|
|
|
case "medium":
|
|
|
|
filename = "medium"; break;
|
2022-08-31 08:32:08 +00:00
|
|
|
case "tenor gifs subdomain":
|
2022-05-07 11:45:15 +00:00
|
|
|
filename = "tenor"; break;
|
|
|
|
case "giphy gifs":
|
|
|
|
case "giphy gifs shortener":
|
|
|
|
case "giphy gifs subdomain":
|
|
|
|
filename = "giphy"; break;
|
|
|
|
case "github":
|
|
|
|
filename = "github"; break;
|
|
|
|
case "status":
|
|
|
|
filename = "status"; break;
|
|
|
|
// TODO get a good default icon
|
|
|
|
default: filename = "../globe"
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
return Style.svg(`linkPreviewThumbnails/${filename}`)
|
|
|
|
}
|
2022-08-11 11:55:08 +00:00
|
|
|
asset.isImage: true
|
2022-05-07 11:45:15 +00:00
|
|
|
components: [
|
|
|
|
StatusSwitch {
|
|
|
|
id: siteSwitch
|
|
|
|
checked: !!model.isWhitelisted
|
2022-11-07 13:43:38 +00:00
|
|
|
onToggled: {
|
|
|
|
RootStore.updateWhitelistedUnfurlingSites(model.address, checked)
|
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
]
|
2022-08-24 14:37:05 +00:00
|
|
|
onClicked: {
|
2022-11-07 13:43:38 +00:00
|
|
|
RootStore.updateWhitelistedUnfurlingSites(model.address, !model.isWhitelisted)
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
} // Site Column
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Separator {
|
|
|
|
id: separator3
|
|
|
|
visible: siteColumn.visible
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
// SYNC WAKU SECTION
|
|
|
|
StatusSectionHeadline {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
|
|
|
text: qsTr("Message syncing")
|
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
StatusListItem {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
title: qsTr("Waku nodes")
|
|
|
|
label: root.messagingStore.getMailserverNameForNodeAddress(root.messagingStore.activeMailserver)
|
|
|
|
components: [
|
|
|
|
StatusIcon {
|
|
|
|
icon: "chevron-down"
|
|
|
|
rotation: 270
|
|
|
|
color: Theme.palette.baseColor1
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
]
|
2022-08-24 14:37:05 +00:00
|
|
|
onClicked: Global.openPopup(wakuNodeModalComponent)
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
2022-03-07 20:34:59 +00:00
|
|
|
|
2022-05-07 11:45:15 +00:00
|
|
|
Component {
|
|
|
|
id: wakuNodeModalComponent
|
|
|
|
WakuNodesModal {
|
|
|
|
messagingStore: root.messagingStore
|
2022-07-28 22:59:58 +00:00
|
|
|
advancedStore: root.advancedStore
|
2022-03-07 20:34:59 +00:00
|
|
|
}
|
2022-05-07 11:45:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StatusSectionHeadline {
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.leftMargin: Style.current.padding
|
|
|
|
Layout.rightMargin: Style.current.padding
|
|
|
|
text: qsTr("For security reasons, private chat history won't be synced.")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|