2021-12-06 21:10:54 +00:00
|
|
|
pragma Singleton
|
|
|
|
|
|
|
|
import QtQuick 2.13
|
2022-03-08 18:49:33 +00:00
|
|
|
import AppLayouts.Chat.popups 1.0
|
2021-12-06 21:10:54 +00:00
|
|
|
|
|
|
|
QtObject {
|
2021-12-07 20:33:12 +00:00
|
|
|
id: root
|
2021-12-21 09:26:13 +00:00
|
|
|
|
2021-12-08 21:20:43 +00:00
|
|
|
property var applicationWindow
|
2022-02-28 20:14:04 +00:00
|
|
|
property var appMain
|
2021-12-08 21:20:43 +00:00
|
|
|
property bool popupOpened: false
|
2022-02-25 13:32:46 +00:00
|
|
|
property int settingsSubsection: Constants.settingsSubsection.profile
|
2022-01-11 23:16:17 +00:00
|
|
|
property var errorSound
|
2021-12-07 20:33:12 +00:00
|
|
|
|
2022-01-11 23:16:17 +00:00
|
|
|
property var mainModuleInst
|
2022-03-04 21:33:48 +00:00
|
|
|
property var privacyModuleInst
|
2021-12-08 21:20:43 +00:00
|
|
|
property bool profilePopupOpened: false
|
2022-01-13 19:25:38 +00:00
|
|
|
property string currentNetworkId: ""
|
2022-05-19 08:53:57 +00:00
|
|
|
property int currentChainId: 0
|
|
|
|
property bool networkGuarded: localAccountSensitiveSettings.isMultiNetworkEnabled || (root.currentNetworkId === Constants.networkMainnet ||
|
|
|
|
(root.currentNetworkId === Constants.networkRopsten && localAccountSensitiveSettings.stickersEnsRopsten))
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2022-02-01 13:10:24 +00:00
|
|
|
signal openImagePopup(var image, var contextMenu)
|
2021-12-06 21:10:54 +00:00
|
|
|
signal openLinkInBrowser(string link)
|
|
|
|
signal openChooseBrowserPopup(string link)
|
2021-12-09 13:28:02 +00:00
|
|
|
signal openDownloadModalRequested()
|
|
|
|
signal settingsLoaded()
|
2021-12-30 12:39:47 +00:00
|
|
|
signal openBackUpSeedPopup()
|
2021-12-09 13:28:02 +00:00
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
signal openProfilePopupRequested(string publicKey, var parentPopup, bool openNicknamePopup)
|
2022-02-04 08:43:55 +00:00
|
|
|
signal openChangeProfilePicPopup()
|
2022-05-05 10:28:54 +00:00
|
|
|
signal displayToastMessage(string title, string subTitle, string icon, bool loading, int ephNotifType, string url)
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2022-03-15 15:55:18 +00:00
|
|
|
function openProfilePopup(publicKey, parentPopup, openNicknamePopup){
|
|
|
|
openProfilePopupRequested(publicKey, parentPopup, openNicknamePopup);
|
2021-12-09 13:28:02 +00:00
|
|
|
}
|
2021-12-07 20:33:12 +00:00
|
|
|
|
|
|
|
function openPopup(popupComponent, params = {}) {
|
2022-04-11 11:39:15 +00:00
|
|
|
const popup = popupComponent.createObject(root.appMain, params);
|
|
|
|
popup.open();
|
|
|
|
return popup;
|
2021-12-07 20:33:12 +00:00
|
|
|
}
|
2021-12-06 21:10:54 +00:00
|
|
|
|
2021-12-08 21:20:43 +00:00
|
|
|
function openDownloadModal(){
|
|
|
|
openDownloadModalRequested();
|
2021-12-21 09:26:13 +00:00
|
|
|
}
|
|
|
|
|
2022-02-25 13:32:46 +00:00
|
|
|
function changeAppSectionBySectionType(sectionType, subsection = 0) {
|
2022-01-11 23:16:17 +00:00
|
|
|
if(!root.mainModuleInst)
|
|
|
|
return
|
|
|
|
|
2021-12-06 21:10:54 +00:00
|
|
|
mainModuleInst.setActiveSectionBySectionType(sectionType)
|
2022-02-25 13:32:46 +00:00
|
|
|
if (sectionType === Constants.appSection.profile) {
|
|
|
|
settingsSubsection = subsection;
|
2021-12-08 21:20:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getProfileImage(pubkey, isCurrentUser, useLargeImage) {
|
|
|
|
if (isCurrentUser || (isCurrentUser === undefined && pubkey === userProfile.pubKey)) {
|
|
|
|
return userProfile.icon;
|
|
|
|
}
|
|
|
|
|
2022-01-05 15:50:03 +00:00
|
|
|
let contactDetails = Utils.getContactDetailsAsJson(pubkey)
|
2022-03-04 21:33:48 +00:00
|
|
|
|
|
|
|
if (root.privacyModuleInst.profilePicturesVisibility !==
|
|
|
|
Constants.profilePicturesVisibility.everyone && !contactDetails.isContact) {
|
2021-12-08 21:20:43 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-31 12:29:51 +00:00
|
|
|
return contactDetails.displayIcon
|
2021-12-06 21:10:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function openLink(link) {
|
|
|
|
if (localAccountSensitiveSettings.showBrowserSelector) {
|
|
|
|
openChooseBrowserPopup(link);
|
|
|
|
} else {
|
|
|
|
if (localAccountSensitiveSettings.openLinksInStatus) {
|
|
|
|
changeAppSectionBySectionType(Constants.appSection.browser);
|
|
|
|
openLinkInBrowser(link);
|
|
|
|
} else {
|
|
|
|
Qt.openUrlExternally(link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function playErrorSound() {
|
2022-01-11 23:16:17 +00:00
|
|
|
if(errorSound)
|
|
|
|
errorSound.play();
|
2021-12-06 21:10:54 +00:00
|
|
|
}
|
2021-12-09 13:28:02 +00:00
|
|
|
|
|
|
|
function settingsHasLoaded() {
|
|
|
|
settingsLoaded()
|
|
|
|
}
|
2022-02-01 13:10:24 +00:00
|
|
|
}
|