[Merge] lp:~phablet-team/telephony-service/sip-account into lp:telephony-service/staging
Renato Araujo Oliveira Filho
renato.filho at canonical.com
Tue Mar 21 18:17:32 UTC 2017
Diff comments:
>
> === added directory 'accounts/common'
> === added file 'accounts/common/DynamicField.qml'
> --- accounts/common/DynamicField.qml 1970-01-01 00:00:00 +0000
> +++ accounts/common/DynamicField.qml 2017-03-03 12:22:04 +0000
> @@ -0,0 +1,151 @@
> +import QtQuick 2.0
> +import Ubuntu.Components 1.3
> +
> +Loader {
> + id: root
> +
> + property var model
> + readonly property string value: status === Loader.Ready ? item.value : ""
> + readonly property bool isEmpty: status === Loader.Ready ? item.isEmpty : true
> +
> + Component {
I agree that external components could help to improve performance for complex components. But these components are so small that the difference will be unnoticeable. I prefer to keep that way to keep the code simple and easy to understand.
But I am ok to change if you guys have strong feelings about that.
> + id: stringField
> +
> + TextField {
> + id: field
> +
> + property alias label: field.placeholderText
> + property string defaultValue
> +
> + readonly property alias value: field.text
> + readonly property bool isEmpty: value === "" || (defaultValue && value === model.defaultValue)
> +
> + text: defaultValue ? defaultValue : ""
> + }
> + }
> +
> + Component {
> + id: booleanField
> +
> + Item {
> + property alias label: fieldLabel.text
> + property string defaultValue
> +
> + readonly property string value: fieldValue.checked ? "true" : "false"
> + readonly property bool isEmpty: (defaultValue && value === model.defaultValue)
> +
> + height: fieldValue.height
> +
> + Label {
> + id: fieldLabel
> +
> + anchors {
> + left: parent.left
> + right: fieldValue.left
> + verticalCenter: parent.verticalCenter
> + }
> + }
> + Switch {
> + id: fieldValue
> +
> + anchors {
> + right: parent.right
> + verticalCenter: parent.verticalCenter
> + }
> + checked: (defaultValue && (defaultValue === 'true'))
> + }
> + }
> + }
> +
> + Component {
> + id: numericField
> +
> + TextField {
> + id: field
> +
> + property alias label: field.placeholderText
> + property string defaultValue
> +
> + readonly property alias value: field.text
> + readonly property bool isEmpty: value === "" || (defaultValue && (value === defaultValue))
> +
> + inputMethodHints: Qt.ImhDigitsOnly
> + validator: IntValidator {}
> + }
> + }
> +
> + Component{
> + id: passwordField
> +
> + Item {
> + property alias label: field.placeholderText
> + readonly property alias value: field.text
> + readonly property bool isEmpty: value === ""
> +
> + height: field.height + showPasswordCheck.height
> + TextField {
> + id: field
> +
> + echoMode: showPasswordCheck.checked ? TextInput.Normal : TextInput.Password
> + anchors {
> + left: parent.left
> + right: parent.right
> + }
> + onTextChanged: root.changed()
> + }
> + CheckBox {
> + id: showPasswordCheck
> + anchors {
> + left: field.left
> + top: field.bottom
> + topMargin: units.gu(1)
> + }
> + }
> + Label {
> + text: i18n.tr("Show Password")
> + anchors {
> + top: showPasswordCheck.top
> + left: showPasswordCheck.right
> + leftMargin: units.gu(1)
> + right: field.right
> + }
> + }
> + }
> + }
> +
> +
> + sourceComponent: {
> + if (!model)
> + return null
> +
> + if (!model.inputType) {
> + console.warn("Model does not contain 'inputType'")
> + return null
> + }
> +
> + switch (model.inputType) {
> + case 'string':
> + return stringField
> + case 'boolean':
> + return booleanField
> + case 'numeric':
> + return numericField
> + case 'password':
> + return passwordField
> + }
> + }
> +
> + Binding {
> + target: root.item
> + property: "label"
> + value: model.label
> + when: root.status == Loader.Ready
> + }
> +
> + Binding {
> + target: root.item
> + property: "defaultValue"
> + value: model.defaultValue
> + when: model.hasOwnProperty('defaultValue') && root.status == Loader.Ready
> + }
> +}
--
https://code.launchpad.net/~phablet-team/telephony-service/sip-account/+merge/314075
Your team Ubuntu Phablet Team is subscribed to branch lp:~phablet-team/telephony-service/voip_support.
More information about the Ubuntu-reviews
mailing list