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
|
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
|
2022-05-10 16:04:25 +00:00
|
|
|
property var toastMessage
|
|
|
|
property var pinnedMessagesPopup
|
|
|
|
property var communityProfilePopup
|
|
|
|
property var inviteFriendsToCommunityPopup
|
2021-12-08 21:20:43 +00:00
|
|
|
property bool profilePopupOpened: false
|
|
|
|
|
2022-07-26 14:23:45 +00:00
|
|
|
property bool activityCenterPopupOpened: false
|
|
|
|
|
2022-05-10 16:04:25 +00:00
|
|
|
property var sendMessageSound
|
|
|
|
property var notificationSound
|
|
|
|
property var errorSound
|
|
|
|
|
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)
|
2022-03-03 21:00:52 +00:00
|
|
|
signal openPopupRequested(var popupComponent, var params)
|
|
|
|
signal openDownloadModalRequested(bool available, string version, string url)
|
2021-12-09 13:28:02 +00:00
|
|
|
signal settingsLoaded()
|
2021-12-30 12:39:47 +00:00
|
|
|
signal openBackUpSeedPopup()
|
2022-05-13 15:27:26 +00:00
|
|
|
signal openCreateChatView()
|
|
|
|
signal closeCreateChatView()
|
2021-12-09 13:28:02 +00:00
|
|
|
|
2022-06-20 14:48:38 +00:00
|
|
|
signal openProfilePopupRequested(string publicKey, var parentPopup, string state)
|
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)
|
2022-06-28 18:11:18 +00:00
|
|
|
signal openEditDisplayNamePopup()
|
2022-07-26 14:23:45 +00:00
|
|
|
signal openActivityCenterPopupRequested
|
2021-12-08 21:20:43 +00:00
|
|
|
|
2022-06-20 14:48:38 +00:00
|
|
|
function openProfilePopup(publicKey, parentPopup, state = "") {
|
|
|
|
openProfilePopupRequested(publicKey, parentPopup, state);
|
2021-12-09 13:28:02 +00:00
|
|
|
}
|
2021-12-07 20:33:12 +00:00
|
|
|
|
2022-07-26 14:23:45 +00:00
|
|
|
function openActivityCenterPopup() {
|
|
|
|
openActivityCenterPopupRequested()
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
2022-03-03 21:00:52 +00:00
|
|
|
function openDownloadModal(available, version, url){
|
|
|
|
openDownloadModalRequested(available, version, url);
|
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 !==
|
2022-07-06 16:51:56 +00:00
|
|
|
Constants.profilePicturesVisibility.everyone && !contactDetails.isAdded) {
|
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) {
|
2022-08-30 14:49:12 +00:00
|
|
|
// Qt sometimes inserts random HTML tags; and this will break on invalid URL inside QDesktopServices::openUrl(link)
|
|
|
|
link = globalUtils.plainText(link);
|
2021-12-06 21:10:54 +00:00
|
|
|
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
|
|
|
}
|