linphone-desktop/linphone-app/ui/views/App/Main/Dialogs/NewChatRoom.qml
2021-08-02 14:45:01 +02:00

371 lines
No EOL
9.9 KiB
QML

import QtQuick 2.7
import QtQuick.Layouts 1.3
import Common 1.0
import Linphone 1.0
//import LinphoneUtils 1.0
import LinphoneEnums 1.0
import App.Styles 1.0
import Common.Styles 1.0
import Units 1.0
import UtilsCpp 1.0
// =============================================================================
DialogPlus {
id: conferenceManager
property ChatRoomModel chatRoomModel
readonly property int maxParticipants: 20
readonly property int minParticipants: 1
buttons: [
TextButtonA {
//: 'Cancel' : Cancel button
text: qsTr('cancelButton')
capitalization: Font.AllUppercase
onClicked: exit(0)
},
TextButtonB {
//enabled: toAddView.count >= conferenceManager.minParticipants
//: 'Launch' : Start button
text: qsTr('startButton')
capitalization: Font.AllUppercase
onClicked: {
if(CallsListModel.createChatRoom(subject.text, secureSwitch.checked, selectedParticipants.getParticipants() ))
exit(1)
}
}
]
buttonsAlignment: Qt.AlignRight
//: 'Start a chat room' : Title of a popup about creation of a chat room
title:qsTr('newChatRoomTitle')
height: 500
width: 800
// ---------------------------------------------------------------------------
RowLayout {
anchors.fill: parent
spacing: 0
// -------------------------------------------------------------------------
// Address selector.
// -------------------------------------------------------------------------
Item {
Layout.fillHeight: true
Layout.fillWidth: true
ColumnLayout {
anchors.fill: parent
spacing: 20
Item{
Layout.fillHeight: true
}
ColumnLayout{
Layout.fillWidth: true
Layout.topMargin:15
spacing:4
Text {
Layout.fillWidth: true
//: 'Would you like to encrypt your chat?' : Ask about setting the chat room as secured.
text:qsTr('askEncryption')
color: Colors.g.color
font.pointSize: Units.dp * 11
font.weight: Font.DemiBold
}
Item{
Layout.fillWidth: true
Layout.preferredHeight: 50
Icon{
id:secureOff
anchors.left:parent.left
anchors.leftMargin : 5
anchors.verticalCenter: parent.verticalCenter
width:20
height:20
icon: 'secure_off'
iconSize:20
}
Switch{
id:secureSwitch
anchors.left:secureOff.right
anchors.leftMargin : 5
anchors.verticalCenter: parent.verticalCenter
width:50
enabled:true
onClicked: checked = !checked
indicatorStyle: SwitchStyle.aux
}
Icon{
id:secureOn
anchors.left:secureSwitch.right
anchors.leftMargin : 15
anchors.verticalCenter: parent.verticalCenter
width:20
height:20
icon: 'secure_on'
iconSize:20
}
}
}
Item{
Layout.fillHeight:true
}
ColumnLayout {
Layout.fillWidth: true
//Layout.preferredHeight: 90
spacing:10
Text{
textFormat: Text.RichText
//: 'Subject' : Label of a text field about the subject of the chat room
text :qsTr('subjectLabel') +'<span style="color:red">*</span>'
color: Colors.g.color
font.pointSize: Units.dp * 11
font.weight: Font.DemiBold
}
TextField {
id:subject
Layout.fillWidth: true
Layout.rightMargin: 15
//: 'Give a subject' : Placeholder in a form about setting a subject
placeholderText :'Give a subject'
text:(chatRoomModel?chatRoomModel.getSubject():'')
Keys.onReturnPressed: nextItemInFocusChain().forceActiveFocus()
TooltipArea{
//: 'Current subject of the Chat Room. It cannot be empty'
//~ Tooltip Explanation about the subject of the chat room
text : qsTr('subjectTooltip')
}
}
}
Item{
Layout.fillHeight:true
}
ColumnLayout {
Layout.fillWidth: true
Layout.fillHeight: true
spacing:20
Text{
//: 'Last contacts' : Header for showing last contacts
text :'Last contacts'
color: Colors.g.color
font.pointSize: Units.dp * 11
font.weight: Font.DemiBold
}
RowLayout{
Layout.fillWidth: true
Layout.fillHeight : true
spacing:10
Repeater{
id:lastContacts
property int reloadCount : 0
model:TimelineListModel.getLastChatRooms(5)
delegate :
Item{
Layout.fillHeight: true
Layout.preferredWidth: 60
ColumnLayout{
anchors.fill:parent
Avatar{
id:avatar2
Layout.preferredHeight: 50
Layout.preferredWidth: 50
Layout.alignment: Qt.AlignCenter
username: modelData.username
image:modelData.avatar
Icon{
property int securityLevel : 2
anchors.right: parent.right
anchors.top:parent.top
anchors.topMargin: -5
visible: UtilsCpp.hasCapability(modelData.sipAddress, LinphoneEnums.FriendCapabilityLimeX3Dh)
icon: 'secure_on'
iconSize:20
}
}
Text{
Layout.fillHeight: true
Layout.preferredWidth: 60
Layout.alignment: Qt.AlignVCenter | Qt.AlignTop
maximumLineCount: 5
wrapMode:Text.Wrap
text: modelData.username
verticalAlignment: Text.AlignTop
horizontalAlignment: Text.AlignHCenter
font.weight: Font.DemiBold
lineHeight: 0.8
color: Colors.g.color
font.pointSize: Units.dp * 9
clip:false
}
}
Rectangle{
id:mask
anchors.fill:parent
anchors.topMargin: -5
color:'white'
opacity: 0.5
visible: smartSearchBar.isIgnored(modelData.sipAddress)
Connections{// Workaround for refreshing data on events
target:lastContacts
onReloadCountChanged: {
mask.visible=smartSearchBar.isIgnored(modelData.sipAddress)
}
}
}
MouseArea{
anchors.fill:parent
visible:!mask.visible
onClicked: {
selectedParticipants.add(modelData.sipAddress)
smartSearchBar.addAddressToIgnore(modelData.sipAddress);
++lastContacts.reloadCount
}
}
}
}
}
}
Item{
Layout.fillHeight: true
Layout.fillWidth: true
}
}
}
// -------------------------------------------------------------------------
// See and remove selected addresses.
// -------------------------------------------------------------------------
ColumnLayout{
Layout.fillHeight: true
Layout.fillWidth: true
Layout.topMargin: 10
Layout.bottomMargin: 10
Rectangle{
Layout.fillHeight: true
Layout.fillWidth: true
border.width: 1
border.color: "black"
ColumnLayout {
anchors.fill: parent
anchors.topMargin: 15
anchors.leftMargin: 10
anchors.rightMargin: 10
spacing: 0
SmartSearchBar {
id: smartSearchBar
Layout.fillWidth: true
Layout.topMargin: ConferenceManagerStyle.columns.selector.spacing
showHeader:false
maxMenuHeight: MainWindowStyle.searchBox.maxHeight
//: 'Select participants' : Placeholder for a search on participant to add them in selection.
placeholderText: qsTr('participantSelectionPlaceholder')
//: 'Search in your contacts or add a custom one to the chat room.'
tooltipText: qsTr('participantSelectionTooltip')
actions:[{
icon: 'add_participant',
secure:0,
handler: function (entry) {
selectedParticipants.add(entry.sipAddress)
smartSearchBar.addAddressToIgnore(entry.sipAddress);
++lastContacts.reloadCount
},
}]
onEntryClicked: {
selectedParticipants.add(entry)
smartSearchBar.addAddressToIgnore(entry);
++lastContacts.reloadCount
}
}
Text{
Layout.preferredHeight: 20
Layout.rightMargin: 65
Layout.alignment: Qt.AlignRight | Qt.AlignBottom
Layout.topMargin: ConferenceManagerStyle.columns.selector.spacing
//: 'Admin' : Admin(istrator)
//~ one word for admin status
text : qsTr('adminStatus')
color: Colors.g.color
font.pointSize: Units.dp * 11
font.weight: Font.Light
visible: participantView.count > 0
}
ScrollableListViewField {
Layout.fillHeight: true
Layout.fillWidth: true
Layout.bottomMargin: 5
//readOnly: toAddView.count >= conferenceManager.maxParticipants
textFieldStyle: TextFieldStyle.unbordered
ParticipantsView {
id: participantView
anchors.fill: parent
showContactAddress:false
showSwitch : true
showSeparator: false
isSelectable: false
showInvitingIndicator: false
actions: [{
icon: 'remove_participant',
//: 'Remove this participant from the selection' : Explanation abo^ut removing participant from a selection
//~ Tooltip This is a tooltip
tooltipText: qsTr('removeParticipantSelection'),
handler: function (entry) {
smartSearchBar.removeAddressToIgnore(entry.sipAddress)
selectedParticipants.remove(entry)
++lastContacts.reloadCount
}
}]
genSipAddress: ''
model: ParticipantProxyModel {
id:selectedParticipants
chatRoomModel:null
}
onEntryClicked: actions[0].handler(entry)
}
}
}
}
Item{
Layout.fillWidth: true
Layout.preferredHeight: 20
Text{
anchors.fill:parent
textFormat: Text.RichText
//: 'Required' : Word relative to a star to explain that it is a requirement (Field form)
text : '<span style="color:red">*</span> '+qsTr('requiredField')
//font.weight: Font.DemiBold
color: Colors.g.color
font.pointSize: Units.dp * 8
}
}
}
}
}