Commit 421eae38 authored by Ronan Abhamon's avatar Ronan Abhamon

feat(app): many changes:

- InvertedMouseArea use a asynchronous call on pressed event
- ListForm use an external style
- ListForm supports outside click
- ...
parent 2a1d92fa
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg width="80px" height="80px" viewBox="0 0 80 80" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
<!-- Generator: Sketch 3.3.3 (12081) - http://www.bohemiancoding.com/sketch -->
<title>add_field_over copy</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="OUTILS" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
<g id="linphone_v2.0_icones_buttons" sketch:type="MSArtboardGroup" transform="translate(-6981.000000, -12382.000000)">
<g id="add_field_over-copy" sketch:type="MSLayerGroup" transform="translate(6981.045368, 12382.656515)">
<g id="Oval-1-Copy-2-+-Imported-Layers-Copy-2" sketch:type="MSShapeGroup">
<ellipse id="Oval-1-Copy-2" fill="#444444" cx="39.8422909" cy="39.5061728" rx="39.8422909" ry="39.5061728"></ellipse>
<g id="Imported-Layers-Copy-2" transform="translate(18.593069, 19.423868)" stroke="#FFFFFF" stroke-width="5" stroke-linecap="round" stroke-linejoin="round">
<path d="M35.4786114,34.191652 L7.01983221,5.97295708 M7.02457534,34.191652 L35.4738683,5.97295708" transform="translate(21.249222, 20.082305) rotate(-315.000000) translate(-21.249222, -20.082305) "></path>
</g>
</g>
</g>
</g>
</g>
</svg>
<!DOCTYPE RCC><RCC version="1.0"> <!DOCTYPE RCC><RCC version="1.0">
<qresource prefix="/"> <qresource prefix="/">
<file>imgs/add_field.svg</file>
<file>imgs/call.svg</file> <file>imgs/call.svg</file>
<file>imgs/cam.svg</file> <file>imgs/cam.svg</file>
<file>imgs/chat_attachment.svg</file> <file>imgs/chat_attachment.svg</file>
...@@ -38,12 +39,12 @@ ...@@ -38,12 +39,12 @@
<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/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>
<file>ui/modules/Linphone/Form/ActionBar.qml</file> <file>ui/modules/Linphone/Form/ActionBar.qml</file>
<file>ui/modules/Linphone/Form/ActionButton.qml</file> <file>ui/modules/Linphone/Form/ActionButton.qml</file>
<file>ui/modules/Linphone/Form/CheckBoxText.qml</file> <file>ui/modules/Linphone/Form/CheckBoxText.qml</file>
<file>ui/modules/Linphone/Form/DropZone.qml</file>
<file>ui/modules/Linphone/Form/ExclusiveButtons.qml</file> <file>ui/modules/Linphone/Form/ExclusiveButtons.qml</file>
<file>ui/modules/Linphone/Form/ListForm.qml</file> <file>ui/modules/Linphone/Form/ListForm.qml</file>
<file>ui/modules/Linphone/Form/SmallButton.qml</file> <file>ui/modules/Linphone/Form/SmallButton.qml</file>
...@@ -65,6 +66,7 @@ ...@@ -65,6 +66,7 @@
<file>ui/modules/Linphone/Styles/Form/ActionBarStyle.qml</file> <file>ui/modules/Linphone/Styles/Form/ActionBarStyle.qml</file>
<file>ui/modules/Linphone/Styles/Form/CheckBoxTextStyle.qml</file> <file>ui/modules/Linphone/Styles/Form/CheckBoxTextStyle.qml</file>
<file>ui/modules/Linphone/Styles/Form/ExclusiveButtonsStyle.qml</file> <file>ui/modules/Linphone/Styles/Form/ExclusiveButtonsStyle.qml</file>
<file>ui/modules/Linphone/Styles/Form/ListFormStyle.qml</file>
<file>ui/modules/Linphone/Styles/Form/SmallButtonStyle.qml</file> <file>ui/modules/Linphone/Styles/Form/SmallButtonStyle.qml</file>
<file>ui/modules/Linphone/Styles/Form/TextButtonAStyle.qml</file> <file>ui/modules/Linphone/Styles/Form/TextButtonAStyle.qml</file>
<file>ui/modules/Linphone/Styles/Form/TextButtonBStyle.qml</file> <file>ui/modules/Linphone/Styles/Form/TextButtonBStyle.qml</file>
......
#include <cstdlib> #include <cstdlib>
#include <QQmlFileSelector>
#include <QMenu> #include <QMenu>
#include <QQmlApplicationEngine> #include <QQmlApplicationEngine>
#include <QQmlContext> #include <QQmlContext>
#include <QQmlFileSelector>
#include <QQuickView> #include <QQuickView>
#include <QSystemTrayIcon> #include <QSystemTrayIcon>
#include <QtDebug> #include <QtDebug>
......
...@@ -9,7 +9,7 @@ Text { ...@@ -9,7 +9,7 @@ Text {
// Never created. // Never created.
// Private data for `lupdate`. // Private data for `lupdate`.
Item { Item {
property variant i18n: [ property var i18n: [
QT_TR_NOOP('hangup'), QT_TR_NOOP('hangup'),
QT_TR_NOOP('incomingCall'), QT_TR_NOOP('incomingCall'),
QT_TR_NOOP('lostIncomingCall'), QT_TR_NOOP('lostIncomingCall'),
......
...@@ -4,7 +4,7 @@ import QtQuick.Dialogs 1.2 ...@@ -4,7 +4,7 @@ import QtQuick.Dialogs 1.2
// =================================================================== // ===================================================================
Rectangle { Rectangle {
signal dropped (variant files) signal dropped (var files)
color: '#DDDDDD' color: '#DDDDDD'
id: dropZone id: dropZone
......
...@@ -5,8 +5,9 @@ import Linphone.Styles 1.0 ...@@ -5,8 +5,9 @@ import Linphone.Styles 1.0
// =================================================================== // ===================================================================
Row { Row {
property var texts
property int _selectedButton: 0 property int _selectedButton: 0
property variant texts
signal clicked (int button) signal clicked (int button)
......
import QtQuick 2.7 import QtQuick 2.7
import QtQuick.Layouts 1.3 import QtQuick.Layouts 1.3
import Linphone 1.0
import Linphone.Styles 1.0
// ===================================================================
RowLayout { RowLayout {
readonly property int lineHeight: 30 property alias model: values.model
property alias title: text.text
property alias title: text.text
function _addValue (value) {
spacing: 0 if (model.count === 0 ||
model.get(model.count - 1).$value.length !== 0) {
RowLayout { model.append({ $value: value })
Layout.alignment: Qt.AlignTop }
Layout.preferredHeight: lineHeight }
spacing: 20
function _handleEditionFinished (index, text) {
// Add item in list. if (text.length === 0) {
ActionButton { model.remove(index)
Layout.preferredHeight: 16 } else {
Layout.preferredWidth: 16 model.set(index, { $value: text })
onClicked: { }
if (valuesModel.count === 0 || }
valuesModel.get(valuesModel.count - 1).$value.length !== 0) {
valuesModel.append({ $value: '' }) spacing: 0
}
} // Title area.
} RowLayout {
Layout.alignment: Qt.AlignTop
// List title. Layout.preferredHeight: ListFormStyle.lineHeight
Text { spacing: ListFormStyle.titleArea.spacing
Layout.preferredWidth: 130
id: text // Button: Add item in list.
} ActionButton {
Layout.preferredHeight: ListFormStyle.titleArea.iconSize
Layout.preferredWidth: ListFormStyle.titleArea.iconSize
icon: ListFormStyle.titleArea.icon
onClicked: _addValue('')
} }
// Content list. // Title text.
ListView { Text {
Layout.fillWidth: true id: text
Layout.preferredHeight: values.count * lineHeight
id: values Layout.preferredWidth: ListFormStyle.titleArea.text.width
interactive: false color: ListFormStyle.titleArea.text.color
font.pointSize: ListFormStyle.titleArea.text.fontSize
model: ListModel { }
id: valuesModel }
ListElement { $value: 'toto' } // Values.
ListElement { $value: 'abc' } ListView {
ListElement { $value: 'machin' } id: values
ListElement { $value: 'bidule' }
ListElement { $value: 'truc' } Layout.fillWidth: true
} Layout.preferredHeight: count * ListFormStyle.lineHeight
interactive: false
delegate: Item {
implicitHeight: textEdit.height delegate: Item {
width: parent.width implicitHeight: textEdit.height
width: parent.width
Rectangle {
color: textEdit.focus ? '#E6E6E6' : 'transparent' // Background.
id: background Rectangle {
implicitHeight: textEdit.height color: textEdit.activeFocus
implicitWidth: textEdit.contentWidth + ? ListFormStyle.value.backgroundColor.focused
textEdit.padding * 2 : ListFormStyle.value.backgroundColor.normal
} implicitHeight: textEdit.height
implicitWidth: textEdit.width
Text { }
anchors.fill: textEdit
color: '#5A585B' // Placeholder.
font.italic: true Text {
padding: textEdit.padding anchors.fill: textEdit
text: textEdit.text.length === 0 && !textEdit.focus color: ListFormStyle.value.placeholder.color
? qsTr('fillPlaceholder') font.italic: true
: '' font.pointSize: ListFormStyle.value.placeholder.fontSize
verticalAlignment: Text.AlignVCenter padding: textEdit.padding
} text: textEdit.text.length === 0 && !textEdit.activeFocus
? qsTr('fillPlaceholder')
TextEdit { : ''
color: focus ? '#000000' : '#5A585B' verticalAlignment: Text.AlignVCenter
font.bold: !focus }
height: lineHeight
id: textEdit // Input.
padding: 10 TextEdit {
selectByMouse: true id: textEdit
text: $value
verticalAlignment: TextEdit.AlignVCenter color: activeFocus
width: parent.width ? ListFormStyle.value.text.color.focused
: ListFormStyle.value.text.color.normal
// To handle editingFinished, it's necessary to set font.bold: !activeFocus
// focus on another component. height: ListFormStyle.lineHeight
Keys.onReturnPressed: parent.forceActiveFocus() padding: ListFormStyle.value.text.padding
selectByMouse: true
onEditingFinished: { text: $value
if (text.length === 0) { verticalAlignment: TextEdit.AlignVCenter
valuesModel.remove(index) width: !activeFocus
} else { ? parent.width
// textEdit.text is not the same value than : contentWidth + padding * 2
// valuesModel.get(index)
valuesModel.set(index, { $value: text }) Keys.onEscapePressed: focus = false
} Keys.onReturnPressed: focus = false
// Hack: The edition is finished but the focus onEditingFinished: _handleEditionFinished(index, text)
// can be set. }
focus = false
} // Handle click outside `TextEdit` instance.
} InvertedMouseArea {
} enabled: textEdit.activeFocus
height: textEdit.height
parent: parent
width: textEdit.width
onPressed: textEdit.focus = false
}
} }
}
} }
...@@ -2,6 +2,8 @@ import QtQuick 2.7 ...@@ -2,6 +2,8 @@ import QtQuick 2.7
import Linphone 1.0 import Linphone 1.0
import 'qrc:/ui/scripts/utils.js' as Utils
// =================================================================== // ===================================================================
// Helper to handle button click outside a component. // Helper to handle button click outside a component.
// =================================================================== // ===================================================================
...@@ -39,9 +41,9 @@ Item { ...@@ -39,9 +41,9 @@ Item {
function _isInItem (point) { function _isInItem (point) {
return ( return (
point.x >= item.x && point.x >= item.x &&
point.y >= item.y && point.y >= item.y &&
point.x <= item.x + item.width && point.x <= item.x + item.width &&
point.y <= item.y + item.height point.y <= item.y + item.height
) )
} }
...@@ -49,7 +51,7 @@ Item { ...@@ -49,7 +51,7 @@ Item {
// See: http://doc.qt.io/qt-5/qml-qtqml-component.html#completed-signal // See: http://doc.qt.io/qt-5/qml-qtqml-component.html#completed-signal
// //
// The creation order of components in a view is undefined, // The creation order of components in a view is undefined,
// so the mouse area must be created only when `enabled == true`. // so the mouse area must be created only when `enabled === true`.
// //
// In the first render, `enabled` must be equal to false. // In the first render, `enabled` must be equal to false.
Component.onCompleted: enabled && _createMouseArea() Component.onCompleted: enabled && _createMouseArea()
...@@ -67,6 +69,8 @@ Item { ...@@ -67,6 +69,8 @@ Item {
id: builder id: builder
MouseArea { MouseArea {
property var _timeout
anchors.fill: parent anchors.fill: parent
propagateComposedEvents: true propagateComposedEvents: true
z: Constants.zMax z: Constants.zMax
...@@ -75,11 +79,23 @@ Item { ...@@ -75,11 +79,23 @@ Item {
// Propagate event. // Propagate event.
mouse.accepted = false mouse.accepted = false
// Click is outside or not.
if (!_isInItem( if (!_isInItem(
mapToItem(item.parent, mouse.x, mouse.y) mapToItem(item.parent, mouse.x, mouse.y)
)) { )) {
// Outside!!! if (_timeout != null) {
item.pressed() Utils.clearTimeout(_timeout)
}
// Use a asynchronous call that is executed
// after the propagated event.
//
// It's useful to ensure the window's context is not
// modified with the mouse event before the `onPressed`
// function.
//
// The timeout is destroyed with the `MouseArea` component.
_timeout = Utils.setTimeout.call(this, 0, item.pressed.bind(this))
} }
} }
} }
......
...@@ -12,7 +12,7 @@ ColumnLayout { ...@@ -12,7 +12,7 @@ ColumnLayout {
property int entryHeight property int entryHeight
property int entryWidth property int entryWidth
property variant entries property var entries
property int _selectedEntry: 0 property int _selectedEntry: 0
......
...@@ -11,6 +11,14 @@ Rectangle { ...@@ -11,6 +11,14 @@ Rectangle {
property int entryHeight property int entryHeight
property int maxMenuHeight property int maxMenuHeight
function show () {
visible = true
}
function hide () {
visible = false
}
// Ugly. Just ugly. // Ugly. Just ugly.
// `model` is a reference on a unknown component! // `model` is a reference on a unknown component!
// See usage with SearchBox. // See usage with SearchBox.
...@@ -20,14 +28,6 @@ Rectangle { ...@@ -20,14 +28,6 @@ Rectangle {
} }
visible: false visible: false
function show () {
visible = true
}
function hide () {
visible = false
}
Rectangle { Rectangle {
id: content id: content
......
pragma Singleton
import QtQuick 2.7
import Linphone 1.0
QtObject {
property int lineHeight: 30
property QtObject value: QtObject {
property QtObject backgroundColor: QtObject {
property color focused: '#E6E6E6'
property color normal: 'transparent'
}
property QtObject placeholder: QtObject {
property color color: '#5A585B'
property int fontSize: 10
}
property QtObject text: QtObject {
property int padding: 10
property QtObject color: QtObject {
property color focused: '#000000'
property color normal: '#5A585B'
}
}
}
property QtObject titleArea: QtObject {
property int spacing: 10
property int iconSize: 16
property string icon: 'add_field'
property QtObject text: QtObject {
property color color: '#000000'
property int fontSize: 10
property int width: 130
}
}
}
...@@ -15,6 +15,7 @@ singleton AbstractTextButtonStyle 1.0 Form/AbstractTextButtonStyle.qml ...@@ -15,6 +15,7 @@ singleton AbstractTextButtonStyle 1.0 Form/AbstractTextButtonStyle.qml
singleton ActionBarStyle 1.0 Form/ActionBarStyle.qml singleton ActionBarStyle 1.0 Form/ActionBarStyle.qml
singleton CheckBoxTextStyle 1.0 Form/CheckBoxTextStyle.qml singleton CheckBoxTextStyle 1.0 Form/CheckBoxTextStyle.qml
singleton ExclusiveButtonsStyle 1.0 Form/ExclusiveButtonsStyle.qml singleton ExclusiveButtonsStyle 1.0 Form/ExclusiveButtonsStyle.qml
singleton ListFormStyle 1.0 Form/ListFormStyle.qml
singleton SmallButtonStyle 1.0 Form/SmallButtonStyle.qml singleton SmallButtonStyle 1.0 Form/SmallButtonStyle.qml
singleton TextButtonAStyle 1.0 Form/TextButtonAStyle.qml singleton TextButtonAStyle 1.0 Form/TextButtonAStyle.qml
singleton TextButtonBStyle 1.0 Form/TextButtonBStyle.qml singleton TextButtonBStyle 1.0 Form/TextButtonBStyle.qml
......
...@@ -25,6 +25,9 @@ ContactDescription 1.0 Contact/ContactDescription.qml ...@@ -25,6 +25,9 @@ ContactDescription 1.0 Contact/ContactDescription.qml
# Dialog # Dialog
DialogPlus 1.0 Dialog/DialogPlus.qml DialogPlus 1.0 Dialog/DialogPlus.qml
# DropZone
DropZone 1.0 DropZone.qml
# ForceScrollBar # ForceScrollBar
ForceScrollBar 1.0 ForceScrollBar.qml ForceScrollBar 1.0 ForceScrollBar.qml
...@@ -32,7 +35,6 @@ ForceScrollBar 1.0 ForceScrollBar.qml ...@@ -32,7 +35,6 @@ ForceScrollBar 1.0 ForceScrollBar.qml
ActionBar 1.0 Form/ActionBar.qml ActionBar 1.0 Form/ActionBar.qml
ActionButton 1.0 Form/ActionButton.qml ActionButton 1.0 Form/ActionButton.qml
CheckBoxText 1.0 Form/CheckBoxText.qml CheckBoxText 1.0 Form/CheckBoxText.qml
DropZone 1.0 Form/DropZone.qml
ExclusiveButtons 1.0 Form/ExclusiveButtons.qml ExclusiveButtons 1.0 Form/ExclusiveButtons.qml
LightButton 1.0 Form/LightButton.qml LightButton 1.0 Form/LightButton.qml
ListForm 1.0 Form/ListForm.qml ListForm 1.0 Form/ListForm.qml
......
...@@ -76,3 +76,28 @@ function snakeToCamel (s) { ...@@ -76,3 +76,28 @@ function snakeToCamel (s) {
return matches[1].toUpperCase() return matches[1].toUpperCase()
}) })
} }
// -------------------------------------------------------------------
function Timer (parent) {
return Qt.createQmlObject('import QtQuick 2.7; Timer { }', parent)
}
// A copy of `Window.setTimeout` from js.
// Use setTimeout.call(parentContext, delayTime, cb) to use it.
//
// delay is in milliseconds.
function setTimeout (delay, cb) {
var timer = new Timer(this)
timer.interval = delay
timer.repeat = false
timer.triggered.connect(cb)
timer.start()
return timer
}
function clearTimeout (timer) {
timer.destroy() // Not necessary: `timer.stop()`
}
...@@ -72,18 +72,33 @@ ColumnLayout { ...@@ -72,18 +72,33 @@ ColumnLayout {
ListForm { ListForm {
title: qsTr('sipAccounts') title: qsTr('sipAccounts')
model: ListModel {
ListElement { $value: 'merinos@sip.linphone.org' }
ListElement { $value: 'elisabeth.pro@sip.linphone.org' }
}
} }
ListForm { ListForm {
title: qsTr('address') title: qsTr('address')
model: ListModel {
ListElement { $value: '312 East 10th Street - New York, NY 1009' }
}
} }
ListForm { ListForm {
title: qsTr('emails') title: qsTr('emails')
model: ListModel {
ListElement { $value: 'e.meri@gmail.com' }
ListElement { $value: 'toto@truc.machin' }
}
} }
ListForm { ListForm {
title: qsTr('webSites') title: qsTr('webSites')
model: ListModel {
ListElement { $value: 'www.totogro.com' }
ListElement { $value: 'www.404.unknown' }
}
} }
} }
} }
......
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