From 473e0a02d0b87eb92284acd29ed02f90b9410237 Mon Sep 17 00:00:00 2001 From: erinn Date: Thu, 3 Dec 2020 16:24:40 -0800 Subject: [PATCH] history warning and beginnings of new zoom system and listoverlay fixes --- go/ui/gcd.go | 72 ++++++++++++++++++++++++++++++++++- i18n/translation_de.ts | 41 +++++++++++++------- i18n/translation_en.qm | Bin 9487 -> 9952 bytes i18n/translation_en.ts | 44 ++++++++++++++------- i18n/translation_fr.ts | 41 +++++++++++++------- i18n/translation_pt.ts | 41 +++++++++++++------- qml/main.qml | 2 +- qml/overlays/ChatOverlay.qml | 39 +++++++++++++++++-- 8 files changed, 223 insertions(+), 57 deletions(-) diff --git a/go/ui/gcd.go b/go/ui/gcd.go index 39458ab9..8c80e867 100644 --- a/go/ui/gcd.go +++ b/go/ui/gcd.go @@ -12,6 +12,7 @@ import ( "github.com/therecipe/qt/qml" "strconv" "sync" + "time" "cwtch.im/ui/go/the" "encoding/base32" @@ -69,7 +70,7 @@ type GrandCentralDispatcher struct { _ func(server string) `signal:"startServer,auto"` _ func(server string) `signal:"stopServer,auto"` _ func(server string) `signal:"checkServer,auto"` - _ func(server string, enabled bool) `signal:"autostartServer",auto` + _ func(server string, enabled bool) `signal:"autostartServer,auto"` // contact list stuff _ func(handle, displayName, image string, badge, status int, authorization string, loading bool, lastMsgTime int) `signal:"AddContact"` @@ -139,6 +140,11 @@ type GrandCentralDispatcher struct { _ func(handle string) `signal:"requestServerSettings,auto"` _ func() `constructor:"init"` + + // legacy overlay model support + _ func(onion string, overlay int) `signal:"legacyLoadOverlay,auto"` + _ func(handle, from, displayName, message, image string, mID string, fromMe bool, ts int64, ackd bool, error bool) `signal:"AppendMessage"` + _ func(handle, from, displayName, message, image string, mID string, fromMe bool, ts int64, ackd bool, error bool) `signal:"PrependMessage"` } func (this *GrandCentralDispatcher) init() { @@ -326,6 +332,70 @@ func (this *GrandCentralDispatcher) loadMessagesPaneHelper(handle string) { } updateLastReadTime(contact.Onion) this.SetToolbarTitle(nick) + + this.legacyLoadOverlay(handle, 4) +} + +func (this *GrandCentralDispatcher) legacyLoadOverlay(handle string, overlay int) { + go this.legacyLoadOverlay_helper(handle, overlay) +} + +func (this *GrandCentralDispatcher) legacyLoadOverlay_helper(handle string, overlay int) { + if isGroup(handle) { + group := the.CwtchApp.GetPeer(this.selectedProfile()).GetGroup(handle) + tl := group.GetTimeline() + + for i := len(tl) - 1; i >= 0; i-- { + if tl[i].PeerID == the.Peer.GetOnion() { + handle = "me" + } else { + handle = tl[i].PeerID + } + + name := GetNick(tl[i].PeerID) + image := GetProfilePic(tl[i].PeerID) + + this.PrependMessage( + handle, + tl[i].PeerID, + name, + tl[i].Message, + image, + string(tl[i].Signature), + tl[i].PeerID == the.Peer.GetOnion(), + tl[i].Timestamp.Unix(), + tl[i].Received.Equal(time.Unix(0, 0)) == false, // If the received timestamp is epoch, we have not yet received this message through an active server + false, + ) + } + + } else {// !isGroup + messages := the.CwtchApp.GetPeer(this.selectedProfile()).GetContact(handle).Timeline.GetMessages() + for i := len(messages) - 1; i >= 0; i-- { + from := messages[i].PeerID + fromMe := messages[i].PeerID == the.Peer.GetOnion() + if fromMe { + from = "me" + } + + displayname := GetNick(messages[i].PeerID) + image := GetProfilePic(messages[i].PeerID) + + this.PrependMessage( + from, + messages[i].PeerID, + displayname, + messages[i].Message, + image, + string(messages[i].Signature), + fromMe, + messages[i].Timestamp.Unix(), + messages[i].Acknowledged, + messages[i].Error != "", + ) + } + + } } func (this *GrandCentralDispatcher) requestSettings() { diff --git a/i18n/translation_de.ts b/i18n/translation_de.ts index c27fa42e..2722864c 100644 --- a/i18n/translation_de.ts +++ b/i18n/translation_de.ts @@ -105,23 +105,38 @@ Name BulletinOverlay - + new-bulletin-label Neue Meldung - + post-new-bulletin-label Post a new Bulletin Post Neue Meldung veröffentlichen - + title-placeholder title place holder text Titel... + + ChatOverlay + + + chat-history-disabled + This conversation will be deleted when Cwtch is closed! Message history can be enabled per-conversation via the Settings menu in the upper right. + + + + + chat-history-enabled + Message history is enabled. + + + ContactList @@ -233,18 +248,18 @@ Name noch zu erledigen - + search-list ex: "... paste an address here to add a contact ..." - + peer-not-online - + add-list-item-btn @@ -252,7 +267,7 @@ Name MembershipOverlay - + membership-description Below is a list of users who have sent messages to the group. This list may not reflect all users who have access to the group. Unten steht eine Liste der Benutzer, die Nachrichten an die Gruppe gesendet haben. Möglicherweise enthält diese Benutzerzliste nicht alle, die Zugang zur Gruppe haben. @@ -267,18 +282,18 @@ Name Klicken, um DM zu senden - + could-not-send-msg-error Could not send this message Nachricht konnte nicht gesendet werden - + acknowledged-label bestätigt - + pending-label Bestätigung ausstehend @@ -286,13 +301,13 @@ Name MessageEditor - + peer-blocked-message Peer is blocked - + peer-offline-message Peer is offline, messages can't be delivered right now @@ -719,7 +734,7 @@ Name main - + new-connection-pane-title New Connection diff --git a/i18n/translation_en.qm b/i18n/translation_en.qm index eb00a31c060b923a3b4a468c5d9fe843c6741265..588c4b12f435a3d1da673ac7707d556623e51a86 100644 GIT binary patch delta 1287 zcmaJqH)HNV6?1dt=6%$w=PT2 zj^W}TlYs%V49Ak0ps2MdxFy5@Y9{Fj8_^Ll1j*D9iB7Tv%wj^+cfA<0#F*y#zW2VL z?|Yy3x$nOE>4yEjbOk(ZBY-l1^~K);rOS}I-wN0+;n+ugfG~M)k%zVN3Y z_l}GAz zpzH#BE{a9W;y|5czww+oUnp+tSM>tgy#2!; zXLxYfo~x9k+_&dP*cj*8K>OjhKm8s-S4jgIbuZlL%t;tk?i;vd8}9ojxU2VJNOCwhm_I!EJs$YoKwjA zDwO$?Y^dma)&KW>fG4Y#zSYje_p0IEM|cN9YH}{l#y?dL?%m8Fm(`-AI?vQ_(u}YsHo!oB*F)Pp6cYElLRTuuUvs^&funajT;uvAzwv9X zi7uk=2e z&R+oAxf?*3|8YJ#pKyLZ%9T;MiM2YFqFn#08mCG!Us+1FfvaR*zXfSS%(T~8lt3rn zn`v!GnO25uh-<^nuxcYFQ2sy7rf3{urA}o-{~7-4{Kcr$LgN5lA=8R>1k!o(PH8*k zO@jbUVl0pH;2OIzc8O16b2OxvM`KBSXQHz_97~3_$0K2xJL)FxY)M5D@ldBAk_avc d`d>LYo@zF;FyI|8-vX~l>q4s&$K~f&`~%0hG_L>v delta 805 zcmXAnZAepb6vofp-FDya+??+^T`z>F5tf4xwIU&`RYakMK|yL(lsbofFg7jggJg<@ zSt1%(R?8xrB%xMVsOh8(D=;xq3ba^g_$8{R?x)|q=l{RwJkN8_jPp`Xz15sR<`O>< z|DMuqZ;0X#G^E%((iD^Y#7D$VGdqV1h(f2Bs(b^HEsOCby(O|tGWRBui3}f^p|1g= zC>Jv>Oc2G~)NQcfJld(t+nP(1uu|98vV%z1t1-gOCLQY_vTtV38MmX~L-zJkC6RKM zomqqmyO&)smXU|_>H7Xz9B@_o#g`Z$^cceARYb84L+kEVd@yf#T``IV6-JwG9P+mt zE3;H0dZ5u@*Qj3AXg+UT?)!J1tx@mSsHSK%M{&ms(a&Pxn!-+cFhJm1TAm|;{hU9i z98Oxf7irhwFrHhub%rRen`ewj#+t}S$6ArVAfIO*grGV8sI`kIa)hsyEJTunzw>Dp ziOldrnVCe!H5yHi`MF6w3=RnEde)b|r0U3Ds4jRCpaQ;fDjz9u& zZed~pb-qcM@5H;{7TJIqKQ2aGeQla3BwKVe`-n`u=qp6@;UC1F90*cQiz6cHmQ&(# zF9bzKNRfXMaqpXCZ*UXIMbeSlO%U8BxjexWL}F07d@&o&qNL8C4g=bxu}5%fd@9Xa z2GO8Ow!T}y4m8T)B`e_Ihn&`k4PqR!KxFPy$Gl)@tV#a7g($4R Y^gpSH_+o5efF BulletinOverlay - + new-bulletin-label New Bulletin - + post-new-bulletin-label Post a new Bulletin Post Post new bulletin - + title-placeholder title place holder text title... + + ChatOverlay + + + chat-history-disabled + This conversation will be deleted when Cwtch is closed! Message history can be enabled per-conversation via the Settings menu in the upper right. + + Your history with this peer is ephemeral and will not be saved. If you would like to save history, please go to settings and turn it on. + + + + chat-history-enabled + Message history is enabled. + Message history is enabled. + + ContactList @@ -326,18 +344,18 @@ Right-click to reset. ListOverlay - + search-list ex: "... paste an address here to add a contact ..." Search List - + peer-not-online Peer is Offline. Applications cannot be used right now. - + add-list-item-btn Add Item @@ -345,7 +363,7 @@ Right-click to reset. MembershipOverlay - + membership-description Below is a list of users who have sent messages to the group. This list may not reflect all users who have access to the group. Below is a list of users who have sent messages to the group. This list may not reflect all users who have access to the group. @@ -360,18 +378,18 @@ Right-click to reset. Click to DM - + could-not-send-msg-error Could not send this message Could not send this message - + acknowledged-label Acknowledged - + pending-label Pending @@ -379,13 +397,13 @@ Right-click to reset. MessageEditor - + peer-blocked-message Peer is blocked Peer is blocked - + peer-offline-message Peer is offline, messages can't be delivered right now Peer is offline, messages can't be delivered right now @@ -855,7 +873,7 @@ Right-click to reset. main - + new-connection-pane-title New Connection New Connection diff --git a/i18n/translation_fr.ts b/i18n/translation_fr.ts index 6d65ff5b..9ea4e441 100644 --- a/i18n/translation_fr.ts +++ b/i18n/translation_fr.ts @@ -105,23 +105,38 @@ Name BulletinOverlay - + new-bulletin-label Nouveau bulletin - + post-new-bulletin-label Post a new Bulletin Post Envoyer un nouveau bulletin - + title-placeholder title place holder text titre... + + ChatOverlay + + + chat-history-disabled + This conversation will be deleted when Cwtch is closed! Message history can be enabled per-conversation via the Settings menu in the upper right. + + + + + chat-history-enabled + Message history is enabled. + + + ContactList @@ -233,18 +248,18 @@ Name A faire... - + search-list ex: "... paste an address here to add a contact ..." - + peer-not-online - + add-list-item-btn @@ -252,7 +267,7 @@ Name MembershipOverlay - + membership-description Below is a list of users who have sent messages to the group. This list may not reflect all users who have access to the group. Liste des utilisateurs ayant envoyés un ou plusieurs messages au groupe. Cette liste peut ne pas être representatives de l'ensemble des membres du groupe. @@ -267,18 +282,18 @@ Name Envoyer un message privé - + could-not-send-msg-error Could not send this message Impossible d'envoyer ce message - + acknowledged-label Confirmé - + pending-label En attente @@ -286,13 +301,13 @@ Name MessageEditor - + peer-blocked-message Peer is blocked - + peer-offline-message Peer is offline, messages can't be delivered right now @@ -719,7 +734,7 @@ Name main - + new-connection-pane-title New Connection diff --git a/i18n/translation_pt.ts b/i18n/translation_pt.ts index d18c42f1..ed9b6164 100644 --- a/i18n/translation_pt.ts +++ b/i18n/translation_pt.ts @@ -105,23 +105,38 @@ Name BulletinOverlay - + new-bulletin-label Novo Boletim - + post-new-bulletin-label Post a new Bulletin Post Postar novo boletim - + title-placeholder title place holder text título… + + ChatOverlay + + + chat-history-disabled + This conversation will be deleted when Cwtch is closed! Message history can be enabled per-conversation via the Settings menu in the upper right. + + + + + chat-history-enabled + Message history is enabled. + + + ContactList @@ -233,18 +248,18 @@ Name Afazer… - + search-list ex: "... paste an address here to add a contact ..." - + peer-not-online - + add-list-item-btn @@ -252,7 +267,7 @@ Name MembershipOverlay - + membership-description Below is a list of users who have sent messages to the group. This list may not reflect all users who have access to the group. A lista abaixo é de usuários que enviaram mensagens ao grupo. Essa lista pode não refletir todos os usuários que têm acesso ao grupo. @@ -267,18 +282,18 @@ Name Clique para DM - + could-not-send-msg-error Could not send this message Não deu para enviar esta mensagem - + acknowledged-label Confirmada - + pending-label Pendente @@ -286,13 +301,13 @@ Name MessageEditor - + peer-blocked-message Peer is blocked - + peer-offline-message Peer is offline, messages can't be delivered right now @@ -719,7 +734,7 @@ Name main - + new-connection-pane-title New Connection diff --git a/qml/main.qml b/qml/main.qml index 6ef50a17..1c65a699 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -238,7 +238,7 @@ ApplicationWindow { Layout.fillHeight: true OverlayPane { // messagePane anchors.fill: parent - anchors.topMargin: 10 * gcd.themeScale + anchors.topMargin: 10// * gcd.themeScale } } diff --git a/qml/overlays/ChatOverlay.qml b/qml/overlays/ChatOverlay.qml index e30a0d17..c5c49711 100644 --- a/qml/overlays/ChatOverlay.qml +++ b/qml/overlays/ChatOverlay.qml @@ -50,12 +50,45 @@ W.Overlay { spacing: 6 clip: true - ScrollBar.vertical: Opaque.ScrollBar {} + ScrollBar.vertical: Opaque.ScrollBar {id:scrollbar} maximumFlickVelocity: 1250 section.delegate: sectionHeading section.property: "Day" + header: Component { + Column { + width: messagesListView.width + + Label { + wrapMode: Text.WordWrap + width: messagesListView.width + font.pointSize: Theme.textSmallPt + font.weight: Font.Bold + color: Theme.chatOverlayWarningTextColor + horizontalAlignment: Text.AlignHCenter + //: This conversation will be deleted when Cwtch is closed! Message history can be enabled per-conversation via the Settings menu in the upper right. + text: true ? qsTr("chat-history-disabled") : + //: Message history is enabled. + qsTr("chat-history-enabled") + } + + Opaque.Icon { + anchors.horizontalCenter: parent.horizontalCenter + backgroundColor: Theme.backgroundMainColor + iconColor: Theme.chatOverlayWarningTextColor + source: gcd.assetPath + "core/peer_settings-24px.webp" + size: Theme.uiIconSizeM + sourceWidth: 72 + sourceHeight: 72 + width: Theme.uiIconSizeM + height: Theme.uiIconSizeM + } + + Opaque.HLine {} + } + } + delegate: W.Message { handle: PeerID @@ -72,7 +105,7 @@ W.Overlay { calendarEvent: PeerID == "calendar" // listview doesnt do anchors right // https://stackoverflow.com/questions/31381997/why-does-anchors-fill-does-not-work-in-a-qml-listviews-delegates-subviews-and/31382307 - width: messagesListView.width + width: messagesListView.width - scrollbar.width } Component { @@ -83,7 +116,7 @@ W.Overlay { property string txt: section color: Theme.backgroundMainColor width: parent.width - height: texmet.height + 6 + 12 * gcd.themeScale + height: texmet.height + 6 + 12// * gcd.themeScale anchors.horizontalCenter: parent.horizontalCenter