mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-04-29 14:26:22 +00:00
Fix leaving chat room when emptying history and still in the chat room. Delete chat room only if it is empty (no messages and no events), and if it has been left by the user. Remove timeline from list only if the chat room is on Deleted state (doesn't exist on server and local).
166 lines
No EOL
4.7 KiB
QML
166 lines
No EOL
4.7 KiB
QML
import QtQuick 2.7
|
|
import QtQuick.Layouts 1.3
|
|
import QtQuick.Controls 2.5
|
|
|
|
import Common 1.0
|
|
import Common.Styles 1.0
|
|
import Linphone 1.0
|
|
import Linphone.Styles 1.0
|
|
import ColorsList 1.0
|
|
|
|
import UtilsCpp 1.0
|
|
|
|
import 'Timeline.js' as Logic
|
|
import 'qrc:/ui/scripts/Utils/utils.js' as Utils
|
|
|
|
// =============================================================================
|
|
Item {
|
|
id: mainItem
|
|
property TimelineModel timelineModel
|
|
property bool optionsToggled: false
|
|
property int modelIndex: 0
|
|
|
|
height: TimelineStyle.contact.height
|
|
width: parent ? parent.width : 0
|
|
|
|
state: optionsToggled ? 'options' : 'normal'
|
|
states: [State {
|
|
name: "normal"
|
|
}, State {
|
|
name: "options"
|
|
}
|
|
]
|
|
|
|
transitions: [Transition {
|
|
from: 'normal'
|
|
to: 'options'
|
|
//NumberAnimation { target: contactView; property: 'x'; to:-contactView.width; duration: 200;}
|
|
NumberAnimation { target: optionsView; property: 'x'; to:0; duration: 200;}
|
|
},
|
|
Transition {
|
|
from: 'options'
|
|
to: 'normal'
|
|
//NumberAnimation { target: contactView; property: 'x'; to:0; duration: 200;}
|
|
NumberAnimation { target: optionsView; property: 'x'; to:optionsView.width; duration: 200;}
|
|
}
|
|
]
|
|
|
|
|
|
Contact {
|
|
id: contactView
|
|
property bool isSelected: mainItem.timelineModel != undefined && mainItem.timelineModel.selected //view.currentIndex === index
|
|
|
|
height: mainItem.height
|
|
width: mainItem.width
|
|
color: isSelected
|
|
? TimelineStyle.contact.backgroundColor.selected
|
|
: (
|
|
mainItem.modelIndex % 2 == 0
|
|
? TimelineStyle.contact.backgroundColor.a
|
|
: TimelineStyle.contact.backgroundColor.b
|
|
)
|
|
displayUnreadMessageCount: SettingsModel.standardChatEnabled || SettingsModel.secureChatEnabled
|
|
entry: mainItem.timelineModel && mainItem.timelineModel.chatRoomModel
|
|
sipAddressColor: isSelected
|
|
? TimelineStyle.contact.sipAddress.color.selected
|
|
: TimelineStyle.contact.sipAddress.color.normal
|
|
usernameColor: isSelected
|
|
? TimelineStyle.contact.username.color.selected
|
|
: TimelineStyle.contact.username.color.normal
|
|
TooltipArea {
|
|
id: contactTooltip
|
|
text: mainItem.timelineModel && UtilsCpp.toDateTimeString(mainItem.timelineModel.chatRoomModel.lastUpdateTime)
|
|
isClickable: true
|
|
}
|
|
Icon{
|
|
icon: TimelineStyle.ephemeralTimer.icon
|
|
iconSize: TimelineStyle.ephemeralTimer.iconSize
|
|
overwriteColor: mainItem.timelineModel && mainItem.timelineModel.selected ? TimelineStyle.ephemeralTimer.selectedTimerColor : TimelineStyle.ephemeralTimer.timerColor
|
|
anchors.right:parent.right
|
|
anchors.bottom:parent.bottom
|
|
anchors.bottomMargin: 7
|
|
anchors.rightMargin: 7
|
|
visible: mainItem.timelineModel && mainItem.timelineModel.chatRoomModel.ephemeralEnabled
|
|
}
|
|
MouseArea {
|
|
anchors.fill: parent
|
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
|
propagateComposedEvents: true
|
|
preventStealing: false
|
|
onClicked: {
|
|
if(mouse.button == Qt.LeftButton){
|
|
timeline.entryClicked(mainItem.timelineModel)
|
|
if(view.updateSelectionModels)
|
|
mainItem.timelineModel.selected = true
|
|
view.currentIndex = mainItem.modelIndex;
|
|
}else{
|
|
mainItem.optionsToggled = !mainItem.optionsToggled
|
|
}
|
|
}
|
|
}
|
|
}
|
|
Item{
|
|
id: optionsView
|
|
|
|
height: mainItem.height
|
|
width: mainItem.width
|
|
|
|
x:width
|
|
visible: x!=width
|
|
RowLayout{
|
|
anchors.fill: parent
|
|
MouseArea {
|
|
Layout.fillHeight: true
|
|
Layout.fillWidth: true
|
|
onClicked: {
|
|
mainItem.optionsToggled = !mainItem.optionsToggled
|
|
}
|
|
}
|
|
Rectangle{
|
|
Layout.fillHeight: true
|
|
Layout.preferredWidth: optionsLayout.width
|
|
|
|
color: contactView.color
|
|
MouseArea {// Grabber
|
|
anchors.fill: parent
|
|
cursorShape: Qt.ArrowCursor
|
|
}
|
|
RowLayout{
|
|
id: optionsLayout
|
|
anchors.centerIn: parent
|
|
/* TODO
|
|
CheckBoxText {
|
|
id: securedCheckBox
|
|
Layout.alignment: Qt.AlignCenter
|
|
text: ''
|
|
|
|
onClicked: {
|
|
|
|
}
|
|
}*/
|
|
ActionButton{
|
|
id: deleteButton
|
|
Layout.alignment: Qt.AlignCenter
|
|
Layout.rightMargin: 6
|
|
|
|
isCustom: true
|
|
colorSet: contactView.isSelected ? TimelineStyle.selectedDeleteAction : TimelineStyle.deleteAction
|
|
onClicked: window.attachVirtualWindow(Utils.buildCommonDialogUri('ConfirmDialog'), {
|
|
//: 'Are you sure you want to delete and leave this timeline?'
|
|
descriptionText: qsTr('deleteTimeline'),
|
|
}, function (status) {
|
|
if (status) {
|
|
mainItem.timelineModel.chatRoomModel.deleteChatRoom()
|
|
}
|
|
})
|
|
TooltipArea {
|
|
//: 'After confirmation, it will erase all history, leave the chat room if it is a group chat and delete it in database.'
|
|
text: qsTr('deleteTimelineTooltip')
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
} |