2022-12-05 09:56:44 +00:00
|
|
|
pragma Singleton
|
|
|
|
|
|
|
|
import QtQml 2.14
|
|
|
|
|
2023-03-08 01:56:41 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
|
|
|
|
2022-12-05 09:56:44 +00:00
|
|
|
QtObject {
|
2024-02-23 07:14:55 +00:00
|
|
|
|
|
|
|
readonly property int defaultDelegateHeight: 76
|
|
|
|
|
2022-12-05 09:56:44 +00:00
|
|
|
function displayName(nickName, ensName, displayName, aliasName)
|
|
|
|
{
|
|
|
|
return nickName || ensName || displayName || aliasName
|
|
|
|
}
|
2023-03-08 01:56:41 +00:00
|
|
|
|
|
|
|
// social links utils
|
|
|
|
function addSocialLinkPrefix(link, type) {
|
|
|
|
const prefix = Constants.socialLinkPrefixesByType[type]
|
|
|
|
if (link.startsWith(prefix))
|
|
|
|
return link
|
|
|
|
return prefix + link
|
|
|
|
}
|
|
|
|
|
|
|
|
function stripSocialLinkPrefix(link, type) {
|
|
|
|
return link.replace(Constants.socialLinkPrefixesByType[type], "")
|
|
|
|
}
|
|
|
|
|
|
|
|
function linkTypeToText(linkType) {
|
2024-03-03 12:06:52 +00:00
|
|
|
if (linkType === Constants.socialLinkType.twitter) return qsTr("X (Twitter)")
|
2023-06-06 11:59:50 +00:00
|
|
|
if (linkType === Constants.socialLinkType.personalSite) return qsTr("Personal site")
|
2023-03-08 01:56:41 +00:00
|
|
|
if (linkType === Constants.socialLinkType.github) return qsTr("Github")
|
2023-06-06 11:59:50 +00:00
|
|
|
if (linkType === Constants.socialLinkType.youtube) return qsTr("YouTube channel")
|
|
|
|
if (linkType === Constants.socialLinkType.discord) return qsTr("Discord handle")
|
|
|
|
if (linkType === Constants.socialLinkType.telegram) return qsTr("Telegram handle")
|
2023-03-08 01:56:41 +00:00
|
|
|
return "" // "custom" link type allows for user defined text
|
|
|
|
}
|
|
|
|
|
2024-03-03 12:06:52 +00:00
|
|
|
function linkTypeToShortText(linkType) {
|
|
|
|
if (linkType === Constants.socialLinkType.twitter) return qsTr("X (Twitter)")
|
|
|
|
if (linkType === Constants.socialLinkType.personalSite) return qsTr("Personal")
|
|
|
|
if (linkType === Constants.socialLinkType.github) return qsTr("Github")
|
|
|
|
if (linkType === Constants.socialLinkType.youtube) return qsTr("YouTube")
|
|
|
|
if (linkType === Constants.socialLinkType.discord) return qsTr("Discord")
|
|
|
|
if (linkType === Constants.socialLinkType.telegram) return qsTr("Telegram")
|
|
|
|
return "" // "custom" link type allows for user defined text
|
|
|
|
}
|
|
|
|
|
2023-03-08 01:56:41 +00:00
|
|
|
function linkTypeColor(linkType) {
|
2024-03-03 12:06:52 +00:00
|
|
|
if (linkType === Constants.socialLinkType.twitter) return "#000000"
|
2023-03-08 01:56:41 +00:00
|
|
|
if (linkType === Constants.socialLinkType.github) return "#000000"
|
|
|
|
if (linkType === Constants.socialLinkType.youtube) return "#FF3000"
|
|
|
|
if (linkType === Constants.socialLinkType.discord) return "#7289DA"
|
|
|
|
if (linkType === Constants.socialLinkType.telegram) return "#0088CC"
|
|
|
|
return Theme.palette.primaryColor1
|
|
|
|
}
|
|
|
|
|
2024-03-03 12:06:52 +00:00
|
|
|
function linkTypeBgColor(linkType) {
|
|
|
|
return Theme.palette.getColor(linkTypeColor(linkType), 0.1)
|
|
|
|
}
|
|
|
|
|
2023-03-08 01:56:41 +00:00
|
|
|
function linkTypeToDescription(linkType) {
|
2023-06-06 11:59:50 +00:00
|
|
|
if (linkType === Constants.socialLinkType.twitter) return qsTr("Twitter username")
|
|
|
|
if (linkType === Constants.socialLinkType.personalSite) return qsTr("Personal site")
|
2023-03-08 01:56:41 +00:00
|
|
|
if (linkType === Constants.socialLinkType.github) return qsTr("Github")
|
2023-06-06 11:59:50 +00:00
|
|
|
if (linkType === Constants.socialLinkType.youtube) return qsTr("YouTube channel")
|
|
|
|
if (linkType === Constants.socialLinkType.discord) return qsTr("Discord handle")
|
|
|
|
if (linkType === Constants.socialLinkType.telegram) return qsTr("Telegram handle")
|
2023-03-08 01:56:41 +00:00
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
function linkTextToType(text) {
|
|
|
|
if (text === "__twitter") return Constants.socialLinkType.twitter
|
|
|
|
if (text === "__personal_site") return Constants.socialLinkType.personalSite
|
|
|
|
if (text === "__github") return Constants.socialLinkType.github
|
|
|
|
if (text === "__youtube") return Constants.socialLinkType.youtube
|
|
|
|
if (text === "__discord") return Constants.socialLinkType.discord
|
|
|
|
if (text === "__telegram") return Constants.socialLinkType.telegram
|
|
|
|
return Constants.socialLinkType.custom
|
|
|
|
}
|
2023-03-20 12:29:05 +00:00
|
|
|
|
2024-03-08 09:27:45 +00:00
|
|
|
function linkTypeToIcon(linkType) {
|
|
|
|
if (linkType === Constants.socialLinkType.twitter) return "twitter"
|
|
|
|
if (linkType === Constants.socialLinkType.personalSite) return "language"
|
|
|
|
if (linkType === Constants.socialLinkType.github) return "github"
|
|
|
|
if (linkType === Constants.socialLinkType.youtube) return "youtube"
|
|
|
|
if (linkType === Constants.socialLinkType.discord) return "discord"
|
|
|
|
if (linkType === Constants.socialLinkType.telegram) return "telegram"
|
|
|
|
return "link"
|
|
|
|
}
|
|
|
|
|
2023-03-20 12:29:05 +00:00
|
|
|
// showcase
|
|
|
|
function visibilityIcon(showcaseVisibility) {
|
|
|
|
switch (showcaseVisibility) {
|
|
|
|
case Constants.ShowcaseVisibility.IdVerifiedContacts:
|
|
|
|
return "checkmark-circle"
|
|
|
|
case Constants.ShowcaseVisibility.Contacts:
|
|
|
|
return "profile"
|
|
|
|
case Constants.ShowcaseVisibility.Everyone:
|
|
|
|
return "language"
|
|
|
|
case Constants.ShowcaseVisibility.NoOne:
|
|
|
|
default:
|
|
|
|
return "hide"
|
|
|
|
}
|
|
|
|
}
|
2024-03-03 16:34:08 +00:00
|
|
|
|
|
|
|
// Member role names:
|
|
|
|
function getMemberRoleText(memberRole) {
|
|
|
|
switch(memberRole) {
|
|
|
|
case Constants.memberRole.owner:
|
|
|
|
return qsTr("Owner")
|
|
|
|
case Constants.memberRole.admin:
|
|
|
|
return qsTr("Admin")
|
|
|
|
case Constants.memberRole.tokenMaster:
|
|
|
|
return qsTr("TokenMaster")
|
|
|
|
}
|
|
|
|
return qsTr("Member")
|
|
|
|
}
|
2022-12-05 09:56:44 +00:00
|
|
|
}
|