feat: selector for online or invisible state

Fixes #3126
This commit is contained in:
Richard Ramos 2021-08-05 14:06:19 -04:00 committed by Iuri Matias
parent 531b2771a3
commit d1b46c0226
13 changed files with 198 additions and 44 deletions

View File

@ -41,11 +41,14 @@ proc init*(self: ProfileController, account: Account) =
let appearance = self.status.settings.getSetting[:int](Setting.Appearance)
let messagesFromContactsOnly = self.status.settings.getSetting[:bool](Setting.MessagesFromContactsOnly)
let sendUserStatus = self.status.settings.getSetting[:bool](Setting.SendUserStatus)
let currentUserStatus = self.status.settings.getSetting[:JsonNode](Setting.CurrentUserStatus)["statusType"].getInt()
profile.appearance = appearance
profile.id = pubKey
profile.address = account.keyUid
profile.messagesFromContactsOnly = messagesFromContactsOnly
profile.sendUserStatus = sendUserStatus
profile.currentUserStatus = currentUserStatus
let identityImage = self.status.profile.getIdentityImage(profile.address)

View File

@ -186,4 +186,3 @@ QtObject:
return
self.profile.setSendUserStatus(sendUserStatus)
self.status.saveSetting(Setting.SendUserStatus, sendUserStatus)

View File

@ -15,6 +15,7 @@ QtObject:
ensVerified*: bool
messagesFromContactsOnly*: bool
sendUserStatus*: bool
currentUserStatus*: int
proc setup(self: ProfileInfoView) =
self.QObject.setup
@ -33,10 +34,12 @@ QtObject:
result.ensVerified = false
result.messagesFromContactsOnly = false
result.sendUserStatus = false
result.currentUserStatus = 0
result.setup
proc identityImageChanged*(self: ProfileInfoView) {.signal.}
proc sendUserStatusChanged*(self: ProfileInfoView) {.signal.}
proc currentUserStatusChanged*(self: ProfileInfoView) {.signal.}
proc appearanceChanged*(self: ProfileInfoView) {.signal.}
proc messagesFromContactsOnlyChanged*(self: ProfileInfoView) {.signal.}
@ -50,6 +53,7 @@ QtObject:
self.identityImage = profile.identityImage
self.messagesFromContactsOnly = profile.messagesFromContactsOnly
self.sendUserStatus = profile.sendUserStatus
self.currentUserStatus = profile.currentUserStatus
proc username*(self: ProfileInfoView): string {.slot.} = result = self.username
@ -146,3 +150,15 @@ QtObject:
read = sendUserStatus
write = setSendUserStatus
notify = sendUserStatusChanged
proc currentUserStatus*(self: ProfileInfoView): int {.slot.} = result = self.currentUserStatus
proc setCurrentUserStatus*(self: ProfileInfoView, currentUserStatus: int) {.slot.} =
if self.currentUserStatus == currentUserStatus:
return
self.currentUserStatus = currentUserStatus
self.currentUserStatusChanged()
QtProperty[int] currentUserStatus:
read = currentUserStatus
write = setCurrentUserStatus
notify = currentUserStatusChanged

View File

@ -6,6 +6,7 @@ type Profile* = ref object
ensVerified*: bool
messagesFromContactsOnly*: bool
sendUserStatus*: bool
currentUserStatus*: int
identityImage*: IdentityImage
appearance*: int
systemTags*: seq[string]

View File

@ -203,6 +203,8 @@ type
PinnedMailservers = "pinned-mailservers"
WakuBloomFilterMode = "waku-bloom-filter-mode"
SendUserStatus = "send-status-updates?"
CurrentUserStatus = "current-user-status"
UpstreamConfig* = ref object
enabled* {.serializedFieldName("Enabled").}: bool

@ -1 +1 @@
Subproject commit a8e830f76caca16718353b84dfe77b5eac363943
Subproject commit 2e1359c9e253b5fa128e892ab6f3f9905b0ce42d

View File

@ -18,7 +18,6 @@ StatusAppThreePanelLayout {
property alias chatColumn: chatColumn
property bool stickersLoaded: false
property bool profilePopupOpened: false
signal profileButtonClicked()
Connections {
@ -88,28 +87,6 @@ StatusAppThreePanelLayout {
}
}
function openProfilePopup(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam, parentPopup){
var popup = profilePopupComponent.createObject(chatView);
if(parentPopup){
popup.parentPopup = parentPopup;
}
popup.openPopup(profileModel.profile.pubKey !== fromAuthorParam, userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam);
profilePopupOpened = true
}
property Component profilePopupComponent: ProfilePopup {
id: profilePopup
height: 504
onClosed: {
if(profilePopup.parentPopup){
profilePopup.parentPopup.close();
}
profilePopupOpened = false
destroy()
}
}
ConfirmationDialog {
id: removeContactConfirmationDialog
// % "Remove contact"

View File

@ -156,23 +156,6 @@ ScrollView {
}
}
Loader {
active: onlineUsers.switchChecked
anchors.left: parent.left
anchors.right: parent.right
sourceComponent: StatusSettingsLineButton {
//% "Broadcast user status"
text: qsTrId("broadcast-user-status")
isSwitch: true
switchChecked: profileModel.profile.sendUserStatus
onClicked: function (checked) {
if (profileModel.profile.sendUserStatus !== checked) {
profileModel.setSendUserStatus(checked)
}
}
}
}
StatusSettingsLineButton {
//% "GIF Widget"
text: qsTrId("gif-widget")

View File

@ -24,6 +24,9 @@ StatusAppLayout {
anchors.fill: parent
property alias appSettings: appSettings
property bool profilePopupOpened: false
signal settingsLoaded()
function changeAppSection(section) {
@ -106,6 +109,27 @@ StatusAppLayout {
}
}
function openProfilePopup(userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam, parentPopup){
var popup = profilePopupComponent.createObject(appMain);
if(parentPopup){
popup.parentPopup = parentPopup;
}
popup.openPopup(profileModel.profile.pubKey !== fromAuthorParam, userNameParam, fromAuthorParam, identiconParam, textParam, nicknameParam);
profilePopupOpened = true
}
property Component profilePopupComponent: ProfilePopup {
id: profilePopup
height: 504
onClosed: {
if(profilePopup.parentPopup){
profilePopup.parentPopup.close();
}
profilePopupOpened = false
destroy()
}
}
appNavBar: StatusAppNavBar {
height: appMain.height
@ -254,6 +278,37 @@ StatusAppLayout {
badge.border.width: 2
}
]
navBarProfileButton: StatusNavBarTabButton {
id: profileButton
icon.source: profileModel.profile.thumbnailImage || ""
badge.visible: true
badge.anchors.rightMargin: 4
badge.anchors.topMargin: 25
badge.implicitHeight: 15
badge.implicitWidth: 15
badge.border.color: hovered ? Theme.palette.statusBadge.hoverBorderColor : Theme.palette.statusAppNavBar.backgroundColor
badge.color: {
return profileModel.profile.sendUserStatus ? Style.current.green : Style.current.darkGrey
/*
// Use this code once support for custom user status is added
switch(profileModel.profile.currentUserStatus){
case Constants.statusType_Online:
return Style.current.green;
case Constants.statusType_DoNotDisturb:
return Style.current.red;
default:
return Style.current.darkGrey;
}*/
}
badge.border.width: 3
onClicked: userStatusContextMenu.open()
UserStatusContextMenu {
id: userStatusContextMenu
y: profileButton.y - userStatusContextMenu.height
}
}
}
appView: StackLayout {

View File

@ -14,8 +14,10 @@ Menu {
topPadding: paddingSize
bottomPadding: paddingSize
property string overrideTextColor: ""
delegate: MenuItem {
property color textColor: this.action.icon.color.toString() !== "#00000000" ? this.action.icon.color : Style.current.textColor
property color textColor: popupMenu.overrideTextColor !== "" ? popupMenu.overrideTextColor : (this.action.icon.color.toString() !== "#00000000" ? this.action.icon.color : Style.current.textColor)
property color hoverColor: popupMenuItem.action.icon.color === Style.current.danger ? Style.current.buttonWarnBackgroundColor : Style.current.backgroundHover
property int subMenuIndex: {
if (!this.subMenu) {

View File

@ -0,0 +1,110 @@
import QtQuick 2.12
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.3
import QtQml.Models 2.3
import "../imports"
import "status"
import "./"
PopupMenu {
id: root
width: profileHeader.width
closePolicy: Popup.CloseOnPressOutside | Popup.CloseOnEscape
Item {
id: profileHeader
width: 200
height: visible ? profileImage.height + username.height + viewProfileBtn.height + Style.current.padding * 2 : 0
Rectangle {
anchors.fill: parent
visible: mouseArea.containsMouse
color: Style.current.backgroundHover
}
StatusImageIdenticon {
id: profileImage
source: profileModel.profile.thumbnailImage || ""
anchors.top: parent.top
anchors.topMargin: 4
anchors.horizontalCenter: parent.horizontalCenter
}
StyledText {
id: username
text: Utils.removeStatusEns(profileModel.ens.preferredUsername || profileModel.profile.username)
elide: Text.ElideRight
maximumLineCount: 3
horizontalAlignment: Text.AlignHCenter
wrapMode: Text.Wrap
anchors.top: profileImage.bottom
anchors.topMargin: 4
anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding
anchors.right: parent.right
anchors.rightMargin: Style.current.smallPadding
font.weight: Font.Medium
font.pixelSize: 13
}
StyledText {
id: viewProfileBtn
text: qsTr("My profile →")
horizontalAlignment: Text.AlignHCenter
anchors.top: username.bottom
anchors.topMargin: 4
anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding
anchors.right: parent.right
anchors.rightMargin: Style.current.smallPadding
font.weight: Font.Medium
font.pixelSize: 12
color: Style.current.secondaryText
}
MouseArea {
id: mouseArea
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onClicked: {
openProfilePopup(profileModel.profile.username, profileModel.profile.pubKey, profileModel.profile.thumbnailImage || "");
root.close()
}
}
}
Separator {
anchors.bottom: viewProfileAction.top
}
overrideTextColor: Style.current.textColor
Action {
text: qsTr("Online")
onTriggered: {
if (profileModel.profile.sendUserStatus != true) {
profileModel.setSendUserStatus(true)
}
root.close()
}
icon.color: Style.current.green
icon.source: "img/online.svg"
icon.width: 16
icon.height: 16
}
Action {
text: qsTr("Offline")
onTriggered: {
if (profileModel.profile.sendUserStatus != false) {
profileModel.setSendUserStatus(false)
}
root.close()
}
icon.color: Style.current.darkGrey
icon.source: "img/offline.svg"
icon.width: 16
icon.height: 16
}
}

View File

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="7.5" cy="7.5" r="5" fill="#939BA1"/>
</svg>

After

Width:  |  Height:  |  Size: 152 B

3
ui/shared/img/online.svg Normal file
View File

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="7.5" cy="7.5" r="5" fill="#4EBC60"/>
</svg>

After

Width:  |  Height:  |  Size: 152 B