2021-12-06 23:10:54 +02:00
|
|
|
pragma Singleton
|
|
|
|
|
|
|
|
import QtQuick 2.13
|
2022-03-08 13:49:33 -05:00
|
|
|
import AppLayouts.Chat.popups 1.0
|
2021-12-06 23:10:54 +02:00
|
|
|
|
|
|
|
QtObject {
|
2021-12-07 22:33:12 +02:00
|
|
|
id: root
|
2021-12-21 10:26:13 +01:00
|
|
|
|
2021-12-08 23:20:43 +02:00
|
|
|
property var applicationWindow
|
2022-02-28 15:14:04 -05:00
|
|
|
property var appMain
|
2021-12-08 23:20:43 +02:00
|
|
|
property bool popupOpened: false
|
2022-02-25 14:32:46 +01:00
|
|
|
property int settingsSubsection: Constants.settingsSubsection.profile
|
2021-12-07 22:33:12 +02:00
|
|
|
|
2022-01-12 00:16:17 +01:00
|
|
|
property var mainModuleInst
|
2022-03-04 16:33:48 -05:00
|
|
|
property var privacyModuleInst
|
2022-05-10 19:04:25 +03:00
|
|
|
property var toastMessage
|
|
|
|
property var pinnedMessagesPopup
|
|
|
|
property var communityProfilePopup
|
|
|
|
property var inviteFriendsToCommunityPopup
|
2021-12-08 23:20:43 +02:00
|
|
|
property bool profilePopupOpened: false
|
|
|
|
|
2022-07-26 17:23:45 +03:00
|
|
|
property bool activityCenterPopupOpened: false
|
|
|
|
|
2022-05-10 19:04:25 +03:00
|
|
|
property var sendMessageSound
|
|
|
|
property var notificationSound
|
|
|
|
property var errorSound
|
|
|
|
|
2022-02-01 14:10:24 +01:00
|
|
|
signal openImagePopup(var image, var contextMenu)
|
2021-12-06 23:10:54 +02:00
|
|
|
signal openLinkInBrowser(string link)
|
|
|
|
signal openChooseBrowserPopup(string link)
|
2022-03-03 17:00:52 -04:00
|
|
|
signal openPopupRequested(var popupComponent, var params)
|
|
|
|
signal openDownloadModalRequested(bool available, string version, string url)
|
2021-12-09 14:28:02 +01:00
|
|
|
signal settingsLoaded()
|
2021-12-30 13:39:47 +01:00
|
|
|
signal openBackUpSeedPopup()
|
2022-05-13 11:27:26 -04:00
|
|
|
signal openCreateChatView()
|
|
|
|
signal closeCreateChatView()
|
2021-12-09 14:28:02 +01:00
|
|
|
|
2022-06-20 17:48:38 +03:00
|
|
|
signal openProfilePopupRequested(string publicKey, var parentPopup, string state)
|
2022-02-04 09:43:55 +01:00
|
|
|
signal openChangeProfilePicPopup()
|
2022-05-05 12:28:54 +02:00
|
|
|
signal displayToastMessage(string title, string subTitle, string icon, bool loading, int ephNotifType, string url)
|
2022-06-28 14:11:18 -04:00
|
|
|
signal openEditDisplayNamePopup()
|
2022-07-26 17:23:45 +03:00
|
|
|
signal openActivityCenterPopupRequested
|
2021-12-08 23:20:43 +02:00
|
|
|
|
2022-06-20 17:48:38 +03:00
|
|
|
function openProfilePopup(publicKey, parentPopup, state = "") {
|
|
|
|
openProfilePopupRequested(publicKey, parentPopup, state);
|
2021-12-09 14:28:02 +01:00
|
|
|
}
|
2021-12-07 22:33:12 +02:00
|
|
|
|
2022-07-26 17:23:45 +03:00
|
|
|
function openActivityCenterPopup() {
|
|
|
|
openActivityCenterPopupRequested()
|
|
|
|
}
|
|
|
|
|
2021-12-07 22:33:12 +02:00
|
|
|
function openPopup(popupComponent, params = {}) {
|
2022-04-11 13:39:15 +02:00
|
|
|
const popup = popupComponent.createObject(root.appMain, params);
|
|
|
|
popup.open();
|
|
|
|
return popup;
|
2021-12-07 22:33:12 +02:00
|
|
|
}
|
2021-12-06 23:10:54 +02:00
|
|
|
|
2022-03-03 17:00:52 -04:00
|
|
|
function openDownloadModal(available, version, url){
|
|
|
|
openDownloadModalRequested(available, version, url);
|
2021-12-21 10:26:13 +01:00
|
|
|
}
|
|
|
|
|
2022-02-25 14:32:46 +01:00
|
|
|
function changeAppSectionBySectionType(sectionType, subsection = 0) {
|
2022-01-12 00:16:17 +01:00
|
|
|
if(!root.mainModuleInst)
|
|
|
|
return
|
|
|
|
|
2021-12-06 23:10:54 +02:00
|
|
|
mainModuleInst.setActiveSectionBySectionType(sectionType)
|
2022-02-25 14:32:46 +01:00
|
|
|
if (sectionType === Constants.appSection.profile) {
|
|
|
|
settingsSubsection = subsection;
|
2021-12-08 23:20:43 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function getProfileImage(pubkey, isCurrentUser, useLargeImage) {
|
|
|
|
if (isCurrentUser || (isCurrentUser === undefined && pubkey === userProfile.pubKey)) {
|
|
|
|
return userProfile.icon;
|
|
|
|
}
|
|
|
|
|
2022-01-05 16:50:03 +01:00
|
|
|
let contactDetails = Utils.getContactDetailsAsJson(pubkey)
|
2022-03-04 16:33:48 -05:00
|
|
|
|
|
|
|
if (root.privacyModuleInst.profilePicturesVisibility !==
|
2022-07-06 12:51:56 -04:00
|
|
|
Constants.profilePicturesVisibility.everyone && !contactDetails.isAdded) {
|
2021-12-08 23:20:43 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-12-31 13:29:51 +01:00
|
|
|
return contactDetails.displayIcon
|
2021-12-06 23:10:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function openLink(link) {
|
2022-08-30 16:49:12 +02: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 23:10:54 +02:00
|
|
|
if (localAccountSensitiveSettings.showBrowserSelector) {
|
|
|
|
openChooseBrowserPopup(link);
|
|
|
|
} else {
|
|
|
|
if (localAccountSensitiveSettings.openLinksInStatus) {
|
|
|
|
changeAppSectionBySectionType(Constants.appSection.browser);
|
|
|
|
openLinkInBrowser(link);
|
|
|
|
} else {
|
|
|
|
Qt.openUrlExternally(link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function playErrorSound() {
|
2022-01-12 00:16:17 +01:00
|
|
|
if(errorSound)
|
|
|
|
errorSound.play();
|
2021-12-06 23:10:54 +02:00
|
|
|
}
|
2021-12-09 14:28:02 +01:00
|
|
|
|
|
|
|
function settingsHasLoaded() {
|
|
|
|
settingsLoaded()
|
|
|
|
}
|
2022-02-01 14:10:24 +01:00
|
|
|
}
|