diff --git a/linphone-desktop/resources.qrc b/linphone-desktop/resources.qrc index 295ad6a77..c6edfc35f 100644 --- a/linphone-desktop/resources.qrc +++ b/linphone-desktop/resources.qrc @@ -195,11 +195,13 @@ ui/modules/Common/Form/ListForm.qml ui/modules/Common/Form/Placements/FormEmptyLine.qml ui/modules/Common/Form/Placements/FormGroup.qml + ui/modules/Common/Form/Placements/FormHGroup.qml ui/modules/Common/Form/Placements/FormLine.qml ui/modules/Common/Form/Placements/Form.qml ui/modules/Common/Form/Placements/FormTableEntry.qml ui/modules/Common/Form/Placements/FormTableLine.qml ui/modules/Common/Form/Placements/FormTable.qml + ui/modules/Common/Form/Placements/FormVGroup.qml ui/modules/Common/Form/SearchBox.qml ui/modules/Common/Form/StaticListForm.qml ui/modules/Common/Form/Switch.qml @@ -239,11 +241,12 @@ ui/modules/Common/Styles/Form/Fields/TextAreaFieldStyle.qml ui/modules/Common/Styles/Form/Fields/TextFieldStyle.qml ui/modules/Common/Styles/Form/ListFormStyle.qml - ui/modules/Common/Styles/Form/Placements/FormGroupStyle.qml + ui/modules/Common/Styles/Form/Placements/FormHGroupStyle.qml ui/modules/Common/Styles/Form/Placements/FormLineStyle.qml ui/modules/Common/Styles/Form/Placements/FormStyle.qml ui/modules/Common/Styles/Form/Placements/FormTableLineStyle.qml ui/modules/Common/Styles/Form/Placements/FormTableStyle.qml + ui/modules/Common/Styles/Form/Placements/FormVGroupStyle.qml ui/modules/Common/Styles/Form/SearchBoxStyle.qml ui/modules/Common/Styles/Form/SwitchStyle.qml ui/modules/Common/Styles/Form/Tab/TabButtonStyle.qml diff --git a/linphone-desktop/ui/modules/Common/Form/Placements/Form.qml b/linphone-desktop/ui/modules/Common/Form/Placements/Form.qml index 0e192fa4f..5276eda04 100644 --- a/linphone-desktop/ui/modules/Common/Form/Placements/Form.qml +++ b/linphone-desktop/ui/modules/Common/Form/Placements/Form.qml @@ -7,6 +7,7 @@ import Common.Styles 1.0 Column { property alias title: title.text + property int orientation: Qt.Horizontal // --------------------------------------------------------------------------- diff --git a/linphone-desktop/ui/modules/Common/Form/Placements/FormEmptyLine.qml b/linphone-desktop/ui/modules/Common/Form/Placements/FormEmptyLine.qml index 94fea4078..d2edb02ac 100644 --- a/linphone-desktop/ui/modules/Common/Form/Placements/FormEmptyLine.qml +++ b/linphone-desktop/ui/modules/Common/Form/Placements/FormEmptyLine.qml @@ -5,6 +5,6 @@ import Common.Styles 1.0 // ============================================================================= Item { - height: FormGroupStyle.legend.height + height: FormHGroupStyle.legend.height width: parent.width } diff --git a/linphone-desktop/ui/modules/Common/Form/Placements/FormGroup.qml b/linphone-desktop/ui/modules/Common/Form/Placements/FormGroup.qml index 1a3347dba..169fa590c 100644 --- a/linphone-desktop/ui/modules/Common/Form/Placements/FormGroup.qml +++ b/linphone-desktop/ui/modules/Common/Form/Placements/FormGroup.qml @@ -1,66 +1,39 @@ import QtQuick 2.7 -import QtQuick.Layouts 1.3 - -import Common.Styles 1.0 // ============================================================================= -RowLayout { - property alias label: label.text +Loader { + id: loader + + // --------------------------------------------------------------------------- + + property string label + readonly property int orientation: parent.orientation default property var _content: null // --------------------------------------------------------------------------- - spacing: FormGroupStyle.spacing + sourceComponent: orientation === Qt.Horizontal ? hGroup : vGroup width: parent.maxItemWidth // --------------------------------------------------------------------------- - Text { - id: label + Component { + id: hGroup - Layout.preferredHeight: FormGroupStyle.legend.height - Layout.preferredWidth: FormGroupStyle.legend.width - - color: FormGroupStyle.legend.color - elide: Text.ElideRight - font.pointSize: FormGroupStyle.legend.fontSize - - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter + FormHGroup { + _content: loader._content + label: loader.label + } } - // --------------------------------------------------------------------------- + Component { + id: vGroup - Item { - readonly property int currentHeight: _content ? _content.height : 0 - - Layout.alignment: ( - currentHeight < FormGroupStyle.legend.height - ? Qt.AlignVCenter - : Qt.AlignTop - ) | Qt.AlignLeft - - Layout.fillWidth: true - Layout.preferredHeight: currentHeight - - Loader { - active: !!_content - anchors.fill: parent - - sourceComponent: Item { - id: content - - data: [ _content ] - width: parent.width - - Component.onCompleted: _content.width = Qt.binding(function () { - var contentWidth = content.width - var wishedWidth = FormGroupStyle.content.maxWidth - return contentWidth > wishedWidth ? wishedWidth : contentWidth - }) - } + FormVGroup { + _content: loader._content + label: loader.label } } } diff --git a/linphone-desktop/ui/modules/Common/Form/Placements/FormHGroup.qml b/linphone-desktop/ui/modules/Common/Form/Placements/FormHGroup.qml new file mode 100644 index 000000000..ddf58c7be --- /dev/null +++ b/linphone-desktop/ui/modules/Common/Form/Placements/FormHGroup.qml @@ -0,0 +1,65 @@ +import QtQuick 2.7 +import QtQuick.Layouts 1.3 + +import Common.Styles 1.0 + +// ============================================================================= + +RowLayout { + property alias label: label.text + + default property var _content: null + + // --------------------------------------------------------------------------- + + spacing: FormHGroupStyle.spacing + + // --------------------------------------------------------------------------- + + Text { + id: label + + Layout.preferredHeight: FormHGroupStyle.legend.height + Layout.preferredWidth: FormHGroupStyle.legend.width + + color: FormHGroupStyle.legend.color + elide: Text.ElideRight + font.pointSize: FormHGroupStyle.legend.fontSize + + horizontalAlignment: Text.AlignRight + verticalAlignment: Text.AlignVCenter + } + + // --------------------------------------------------------------------------- + + Item { + readonly property int currentHeight: _content ? _content.height : 0 + + Layout.alignment: ( + currentHeight < FormHGroupStyle.legend.height + ? Qt.AlignVCenter + : Qt.AlignTop + ) | Qt.AlignLeft + + Layout.fillWidth: true + Layout.preferredHeight: currentHeight + + Loader { + active: !!_content + anchors.fill: parent + + sourceComponent: Item { + id: content + + data: [ _content ] + width: parent.width + + Component.onCompleted: _content.width = Qt.binding(function () { + var contentWidth = content.width + var wishedWidth = FormHGroupStyle.content.maxWidth + return contentWidth > wishedWidth ? wishedWidth : contentWidth + }) + } + } + } +} diff --git a/linphone-desktop/ui/modules/Common/Form/Placements/FormLine.qml b/linphone-desktop/ui/modules/Common/Form/Placements/FormLine.qml index 3860683b8..bcf1cd838 100644 --- a/linphone-desktop/ui/modules/Common/Form/Placements/FormLine.qml +++ b/linphone-desktop/ui/modules/Common/Form/Placements/FormLine.qml @@ -1,5 +1,4 @@ import QtQuick 2.7 -import QtQuick.Layouts 1.3 import Common.Styles 1.0 @@ -9,10 +8,13 @@ Row { readonly property double maxItemWidth: { var n = children.length var curWidth = width / n - (n - 1) * spacing - var maxWidth = FormGroupStyle.legend.width + FormGroupStyle.content.maxWidth + FormGroupStyle.spacing + var maxWidth = orientation === Qt.Horizontal + ? FormHGroupStyle.legend.width + FormHGroupStyle.content.maxWidth + FormHGroupStyle.spacing + : FormVGroupStyle.content.maxWidth return curWidth < maxWidth ? curWidth : maxWidth } + readonly property int orientation: parent.orientation // --------------------------------------------------------------------------- diff --git a/linphone-desktop/ui/modules/Common/Form/Placements/FormVGroup.qml b/linphone-desktop/ui/modules/Common/Form/Placements/FormVGroup.qml new file mode 100644 index 000000000..793139b5c --- /dev/null +++ b/linphone-desktop/ui/modules/Common/Form/Placements/FormVGroup.qml @@ -0,0 +1,62 @@ +import QtQuick 2.7 +import QtQuick.Layouts 1.3 + +import Common.Styles 1.0 + +// ============================================================================= + +ColumnLayout { + property alias label: label.text + + default property var _content: null + + // --------------------------------------------------------------------------- + + spacing: FormVGroupStyle.spacing + width: parent.maxItemWidth + + // --------------------------------------------------------------------------- + + Text { + id: label + + Layout.fillWidth: true + + color: FormVGroupStyle.legend.color + elide: Text.ElideRight + + font { + bold: true + pointSize: FormVGroupStyle.legend.fontSize + } + + verticalAlignment: Text.AlignVCenter + } + + // --------------------------------------------------------------------------- + + Item { + readonly property int currentHeight: _content ? _content.height : 0 + + Layout.fillWidth: true + Layout.preferredHeight: currentHeight + + Loader { + active: !!_content + anchors.fill: parent + + sourceComponent: Item { + id: content + + data: [ _content ] + width: parent.width + + Component.onCompleted: _content.width = Qt.binding(function () { + var contentWidth = content.width + var wishedWidth = FormVGroupStyle.content.maxWidth + return contentWidth > wishedWidth ? wishedWidth : contentWidth + }) + } + } + } +} diff --git a/linphone-desktop/ui/modules/Common/Styles/Form/Placements/FormGroupStyle.qml b/linphone-desktop/ui/modules/Common/Styles/Form/Placements/FormHGroupStyle.qml similarity index 100% rename from linphone-desktop/ui/modules/Common/Styles/Form/Placements/FormGroupStyle.qml rename to linphone-desktop/ui/modules/Common/Styles/Form/Placements/FormHGroupStyle.qml diff --git a/linphone-desktop/ui/modules/Common/Styles/Form/Placements/FormVGroupStyle.qml b/linphone-desktop/ui/modules/Common/Styles/Form/Placements/FormVGroupStyle.qml new file mode 100644 index 000000000..e7e6db8dd --- /dev/null +++ b/linphone-desktop/ui/modules/Common/Styles/Form/Placements/FormVGroupStyle.qml @@ -0,0 +1,19 @@ +pragma Singleton +import QtQuick 2.7 + +import Common 1.0 + +// ============================================================================= + +QtObject { + property int spacing: 5 + + property QtObject content: QtObject { + property int maxWidth: 400 + } + + property QtObject legend: QtObject { + property color color: Colors.j + property int fontSize: 10 + } +} diff --git a/linphone-desktop/ui/modules/Common/Styles/qmldir b/linphone-desktop/ui/modules/Common/Styles/qmldir index 1abc677d3..bcc3f304f 100644 --- a/linphone-desktop/ui/modules/Common/Styles/qmldir +++ b/linphone-desktop/ui/modules/Common/Styles/qmldir @@ -28,11 +28,12 @@ singleton NumericFieldStyle 1.0 Form/Fields/NumericFieldStyle.qml singleton TextAreaFieldStyle 1.0 Form/Fields/TextAreaFieldStyle.qml singleton TextFieldStyle 1.0 Form/Fields/TextFieldStyle.qml -singleton FormGroupStyle 1.0 Form/Placements/FormGroupStyle.qml +singleton FormHGroupStyle 1.0 Form/Placements/FormHGroupStyle.qml singleton FormLineStyle 1.0 Form/Placements/FormLineStyle.qml singleton FormStyle 1.0 Form/Placements/FormStyle.qml singleton FormTableLineStyle 1.0 Form/Placements/FormTableLineStyle.qml singleton FormTableStyle 1.0 Form/Placements/FormTableStyle.qml +singleton FormVGroupStyle 1.0 Form/Placements/FormVGroupStyle.qml singleton TabButtonStyle 1.0 Form/Tab/TabButtonStyle.qml singleton TabContainerStyle 1.0 Form/Tab/TabContainerStyle.qml