Commit c2881ac6 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(DropZone): new DropZone component, supports filedialog and DropArea

parent f940f53d
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1"> <TS version="2.1">
<context>
<name>DropZone</name>
<message>
<source>fileChooserTitle</source>
<translation>Please choose one or many files</translation>
</message>
</context>
<context> <context>
<name>SelectContact</name> <name>SelectContact</name>
<message> <message>
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS> <!DOCTYPE TS>
<TS version="2.1"> <TS version="2.1">
<context>
<name>DropZone</name>
<message>
<source>fileChooserTitle</source>
<translation>Merci de choisir un ou plusieurs fichiers</translation>
</message>
</context>
<context> <context>
<name>SelectContact</name> <name>SelectContact</name>
<message> <message>
......
...@@ -11,7 +11,8 @@ ...@@ -11,7 +11,8 @@
<file>ui/components/dialog/DialogDescription.qml</file> <file>ui/components/dialog/DialogDescription.qml</file>
<file>ui/components/dialog/DialogPlus.qml</file> <file>ui/components/dialog/DialogPlus.qml</file>
<file>ui/components/form/DarkButton.qml</file> <file>ui/components/form/DarkButton.qml</file>
<file>ui/components/form/DialogCheckBox.qml</file> <file>ui/components/form/CheckBoxText.qml</file>
<file>ui/components/form/DropZone.qml</file>
<file>ui/components/form/ExclusiveButtons.qml</file> <file>ui/components/form/ExclusiveButtons.qml</file>
<file>ui/components/form/LightButton.qml</file> <file>ui/components/form/LightButton.qml</file>
<file>ui/components/form/SmallButton.qml</file> <file>ui/components/form/SmallButton.qml</file>
......
...@@ -19,7 +19,7 @@ Item { ...@@ -19,7 +19,7 @@ Item {
Text { Text {
anchors.centerIn: parent anchors.centerIn: parent
color: '#FFFFFF' color: '#FFFFFF'
text: (function () { text: {
var spaceIndex = username.indexOf(' ') var spaceIndex = username.indexOf(' ')
var firstLetter = username.charAt(0) var firstLetter = username.charAt(0)
...@@ -28,7 +28,7 @@ Item { ...@@ -28,7 +28,7 @@ Item {
} }
return firstLetter + username.charAt(spaceIndex + 1) return firstLetter + username.charAt(spaceIndex + 1)
})() }
} }
Image { Image {
......
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 2.0 import QtQuick.Controls 2.0
// ===================================================================
// Checkbox with clickable text.
// =================================================================== // ===================================================================
CheckBox { CheckBox {
......
import QtQuick 2.7
import QtQuick.Dialogs 1.2
// ===================================================================
Rectangle {
signal dropped (variant files)
color: '#DDDDDD'
id: dropZone
function emitFiles (files) {
// Filtering files, urls are forbidden.
files = files.reduce(function (files, file) {
var result = file.match(/^file:\/\/(.*)/)
if (result) {
files.push(result[1])
}
return files
}, [])
if (files.length > 0) {
dropped(files)
}
}
DropArea {
anchors.fill: parent
onDropped: {
dropZone.state = ''
if (drop.hasUrls) {
emitFiles(drop.urls)
}
}
onEntered: dropZone.state = 'hover'
onExited: dropZone.state = ''
}
MouseArea {
anchors.fill: parent
onClicked: fileDialog.visible = true
}
Image {
anchors.centerIn: parent
fillMode: Image.PreserveAspectFit
height: parent.height
source: 'qrc:/imgs/chat_attachment.svg'
width: parent.width
}
FileDialog {
folder: shortcuts.home
id: fileDialog
title: qsTr('fileChooserTitle')
onAccepted: emitFiles(fileDialog.fileUrls)
}
states: State {
name: 'hover'
PropertyChanges { target: dropZone; color: '#BBBBBB' }
}
}
...@@ -6,7 +6,7 @@ Row { ...@@ -6,7 +6,7 @@ Row {
property int selectedButton: 0 property int selectedButton: 0
property variant texts property variant texts
signal buttonChanged (int button) signal clicked (int button)
spacing: 8 spacing: 8
...@@ -26,7 +26,7 @@ Row { ...@@ -26,7 +26,7 @@ Row {
onClicked: { onClicked: {
if (selectedButton !== index) { if (selectedButton !== index) {
selectedButton = index selectedButton = index
buttonChanged(index) clicked(index)
} }
} }
} }
......
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Controls 2.0 import QtQuick.Controls 2.0
// ===================================================================
// Discrete ComboBox which can be integrated in text.
// =================================================================== // ===================================================================
ComboBox { ComboBox {
......
...@@ -130,6 +130,7 @@ ColumnLayout { ...@@ -130,6 +130,7 @@ ColumnLayout {
} }
} }
// Send area.
Rectangle { Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 70 Layout.preferredHeight: 70
...@@ -140,7 +141,6 @@ ColumnLayout { ...@@ -140,7 +141,6 @@ ColumnLayout {
RowLayout { RowLayout {
anchors.fill: parent anchors.fill: parent
// Message to send.
Flickable { Flickable {
Layout.preferredHeight: parent.height Layout.preferredHeight: parent.height
Layout.fillWidth: true Layout.fillWidth: true
...@@ -151,24 +151,9 @@ ColumnLayout { ...@@ -151,24 +151,9 @@ ColumnLayout {
} }
} }
// DropArea. DropZone {
Rectangle {
Layout.preferredHeight: parent.height - newMessageArea.border.width * 2 Layout.preferredHeight: parent.height - newMessageArea.border.width * 2
Layout.preferredWidth: 40 Layout.preferredWidth: 40
color: '#DDDDDD'
DropArea {
anchors.fill: parent
}
Image {
anchors.right: parent.right
anchors.top: parent.top
fillMode: Image.PreserveAspectFit
height: parent.height
source: 'qrc:/imgs/chat_attachment.svg'
width: parent.width
}
} }
} }
} }
......
...@@ -59,7 +59,7 @@ ColumnLayout { ...@@ -59,7 +59,7 @@ ColumnLayout {
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: 70 Layout.preferredHeight: 70
DialogCheckBox { CheckBoxText {
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: 50 anchors.leftMargin: 50
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
......
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