Commit 5182938f authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): new `Borders` component

parent 25183046
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
<file>imgs/valid.svg</file> <file>imgs/valid.svg</file>
<file>languages/en.qm</file> <file>languages/en.qm</file>
<file>languages/fr.qm</file> <file>languages/fr.qm</file>
<file>ui/modules/Linphone/Borders.qml</file>
<file>ui/modules/Linphone/Chat/Chat.qml</file> <file>ui/modules/Linphone/Chat/Chat.qml</file>
<file>ui/modules/Linphone/Chat/Event.qml</file> <file>ui/modules/Linphone/Chat/Event.qml</file>
<file>ui/modules/Linphone/Chat/IncomingMessage.qml</file> <file>ui/modules/Linphone/Chat/IncomingMessage.qml</file>
...@@ -40,6 +41,7 @@ ...@@ -40,6 +41,7 @@
<file>ui/modules/Linphone/Dialog/ConfirmDialog.qml</file> <file>ui/modules/Linphone/Dialog/ConfirmDialog.qml</file>
<file>ui/modules/Linphone/Dialog/DialogDescription.qml</file> <file>ui/modules/Linphone/Dialog/DialogDescription.qml</file>
<file>ui/modules/Linphone/Dialog/DialogPlus.qml</file> <file>ui/modules/Linphone/Dialog/DialogPlus.qml</file>
<file>ui/modules/Linphone/DroppableTextArea.qml</file>
<file>ui/modules/Linphone/DropZone.qml</file> <file>ui/modules/Linphone/DropZone.qml</file>
<file>ui/modules/Linphone/ForceScrollBar.qml</file> <file>ui/modules/Linphone/ForceScrollBar.qml</file>
<file>ui/modules/Linphone/Form/AbstractTextButton.qml</file> <file>ui/modules/Linphone/Form/AbstractTextButton.qml</file>
......
import QtQuick 2.7
// ===================================================================
Item {
default property alias content: content.data
property var borderColor
property var borderWidth
property color bottomColor: 'transparent'
property color leftColor: 'transparent'
property color rightColor: 'transparent'
property color topColor: 'transparent'
property int bottomWidth: 0
property int leftWidth: 0
property int rightWidth: 0
property int topWidth: 0
Rectangle {
id: bottomBorder
anchors.bottom: parent.bottom
color: borderColor != null ? borderColor : bottomColor
height: borderWidth != null ? borderWidth : bottomWidth
width: parent.width
}
Rectangle {
id: leftBorder
anchors.left: parent.left
color: borderColor != null ? borderColor : leftColor
height: parent.height
width: borderWidth != null ? borderWidth : leftWidth
}
Rectangle {
id: rightBorder
anchors.right: parent.right
color: borderColor != null ? borderColor : rigthColor
height: parent.height
width: borderWidth != null ? borderWidth : rightWidth
}
Rectangle {
id: topBorder
anchors.top: parent.top
color: borderColor != null ? borderColor : topColor
height: borderWidth != null ? borderWidth : topWidth
width: parent.width
}
Item {
id: content
anchors {
fill: parent
bottomMargin: bottomBorder.height
leftMargin: leftBorder.width
rightMargin: rightBorder.width
topMargin: topBorder.height
}
}
}
pragma Singleton pragma Singleton
import QtQuick 2.7 import QtQuick 2.7
// ===================================================================
QtObject { QtObject {
property int zPopup: 999 property int zPopup: 999
property int zMax: 999999 property int zMax: 999999
......
...@@ -4,64 +4,64 @@ import QtQuick.Dialogs 1.2 ...@@ -4,64 +4,64 @@ import QtQuick.Dialogs 1.2
// =================================================================== // ===================================================================
Rectangle { Rectangle {
signal dropped (var files) signal dropped (var files)
color: '#DDDDDD' color: '#DDDDDD'
id: dropZone id: dropZone
function emitFiles (files) { function emitFiles (files) {
// Filtering files, urls are forbidden. // Filtering files, urls are forbidden.
files = files.reduce(function (files, file) { files = files.reduce(function (files, file) {
var result = file.match(/^file:\/\/(.*)/) var result = file.match(/^file:\/\/(.*)/)
if (result) { if (result) {
files.push(result[1]) files.push(result[1])
} }
return files return files
}, []) }, [])
if (files.length > 0) { if (files.length > 0) {
dropped(files) dropped(files)
}
} }
}
DropArea { DropArea {
anchors.fill: parent anchors.fill: parent
onDropped: { onDropped: {
dropZone.state = '' dropZone.state = ''
if (drop.hasUrls) { if (drop.hasUrls) {
emitFiles(drop.urls) emitFiles(drop.urls)
} }
}
onEntered: dropZone.state = 'hover'
onExited: dropZone.state = ''
} }
onEntered: dropZone.state = 'hover'
onExited: dropZone.state = ''
}
MouseArea { MouseArea {
anchors.fill: parent anchors.fill: parent
onClicked: fileDialog.visible = true onClicked: fileDialog.visible = true
} }
Image { Image {
anchors.centerIn: parent anchors.centerIn: parent
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
height: parent.height height: parent.height
source: 'qrc:/imgs/chat_attachment.svg' source: 'qrc:/imgs/chat_attachment.svg'
width: parent.width width: parent.width
} }
FileDialog { FileDialog {
folder: shortcuts.home folder: shortcuts.home
id: fileDialog id: fileDialog
title: qsTr('fileChooserTitle') title: qsTr('fileChooserTitle')
onAccepted: emitFiles(fileDialog.fileUrls) onAccepted: emitFiles(fileDialog.fileUrls)
} }
states: State { states: State {
name: 'hover' name: 'hover'
PropertyChanges { target: dropZone; color: '#BBBBBB' } PropertyChanges { target: dropZone; color: '#BBBBBB' }
} }
} }
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.3
RowLayout {
property alias placeholderText: textArea.placeholderText
Flickable {
Layout.preferredHeight: parent.height
Layout.fillWidth: true
ScrollBar.vertical: ScrollBar { }
TextArea.flickable: TextArea {
id: textArea
wrapMode: TextArea.Wrap
}
}
DropZone {
Layout.preferredHeight: parent.height
Layout.preferredWidth: 40
}
}
...@@ -11,6 +11,9 @@ singleton Constants 1.0 Constants.qml ...@@ -11,6 +11,9 @@ singleton Constants 1.0 Constants.qml
# Components --------------------------------------------------------- # Components ---------------------------------------------------------
# Chat
Borders 1.0 Borders.qml
# Chat # Chat
Chat 1.0 Chat/Chat.qml Chat 1.0 Chat/Chat.qml
...@@ -29,6 +32,9 @@ DialogPlus 1.0 Dialog/DialogPlus.qml ...@@ -29,6 +32,9 @@ DialogPlus 1.0 Dialog/DialogPlus.qml
# DropZone # DropZone
DropZone 1.0 DropZone.qml DropZone 1.0 DropZone.qml
# DroppableTextArea
DroppableTextArea 1.0 DroppableTextArea.qml
# ForceScrollBar # ForceScrollBar
ForceScrollBar 1.0 ForceScrollBar.qml ForceScrollBar 1.0 ForceScrollBar.qml
......
...@@ -105,47 +105,29 @@ ColumnLayout { ...@@ -105,47 +105,29 @@ ColumnLayout {
} }
} }
Rectangle { Borders {
Layout.fillHeight: true Layout.fillHeight: true
Layout.fillWidth: true Layout.fillWidth: true
border.color: '#C7C7C7' borderColor: '#C7C7C7'
border.width: 1 bottomWidth: 1
id: messagesArea leftWidth: 1
topWidth: 1
Chat { Chat {
ScrollBar.vertical: ForceScrollBar { } ScrollBar.vertical: ForceScrollBar { }
anchors.bottomMargin: messagesArea.border.width
anchors.fill: parent anchors.fill: parent
anchors.topMargin: messagesArea.border.width
} }
} }
// Send area. Borders {
Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 70 Layout.preferredHeight: 70
border.color: textArea.activeFocus ? '#8E8E8E' : '#C7C7C7' borderColor: '#C7C7C7'
border.width: 1 leftWidth: 1
id: newMessageArea
RowLayout { DroppableTextArea {
anchors.fill: parent anchors.fill: parent
placeholderText: qsTr('newMessagePlaceholder')
Flickable {
Layout.preferredHeight: parent.height
Layout.fillWidth: true
ScrollBar.vertical: ScrollBar { }
TextArea.flickable: TextArea {
id: textArea
placeholderText: qsTr('newMessagePlaceholder')
wrapMode: TextArea.Wrap
}
}
DropZone {
Layout.preferredHeight: parent.height - newMessageArea.border.width * 2
Layout.preferredWidth: 40
}
} }
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment