[Merge] lp:~renatofilho/address-book-app/fix-1377334 into lp:~phablet-team/address-book-app/staging

Renato Araujo Oliveira Filho renato.filho at canonical.com
Tue Oct 7 20:53:30 UTC 2014



Diff comments:

> === modified file 'src/imports/ContactEdit/AvatarImport.qml'
> --- src/imports/ContactEdit/AvatarImport.qml	2014-08-13 20:52:57 +0000
> +++ src/imports/ContactEdit/AvatarImport.qml	2014-10-07 19:24:25 +0000
> @@ -18,103 +18,108 @@
>  
>  import Ubuntu.Components 1.1
>  import Ubuntu.Components.Popups 1.0
> -import Ubuntu.Content 0.1
> +import Ubuntu.Content 1.1
>  
> -Item {
> +Page {
>      id: root
>  
> -    property var importDialog: null
> +    property var avatarListener: null
> +    property alias activeTransfer: signalConnections.target
> +    property alias isTransferRunning: activityIndicator.running
>  
>      signal avatarReceived(string avatarUrl)
>  
> -    function requestNewAvatar()
> -    {
> -        if (!root.importDialog) {
> -            root.importDialog = PopupUtils.open(contentHubDialog, null)
> -        } else {
> -            console.warn("Import dialog already running")
> -        }
> -    }
> -
> -    Component {
> -        id: contentHubDialog
> -
> -        PopupBase {
> -            id: dialogue
> -
> -            property alias activeTransfer: signalConnections.target
> -
> -            parent: QuickUtils.rootItem(this)
> -            focus: true
> -
> -            Rectangle {
> -                anchors.fill: parent
> -
> -                ContentTransferHint {
> -                    anchors.fill: parent
> -                    activeTransfer: dialogue.activeTransfer
> -                }
> -
> -                ContentPeerPicker {
> -                    id: peerPicker
> -
> -                    anchors.fill: parent
> -                    visible: dialogue.done
> -                    contentType: ContentType.Pictures
> -                    handler: ContentHandler.Source
> -
> -                    onPeerSelected: {
> -                        peer.selectionType = ContentTransfer.Single
> -                        dialogue.activeTransfer = peer.request()
> -                    }
> -
> -                    onCancelPressed: {
> -                        PopupUtils.close(root.importDialog)
> -                    }
> -                }
> -            }
> -
> -            Connections {
> -                id: signalConnections
> -
> -                target: dialogue.activeTransfer
> -                onStateChanged: {
> -                    var done = ((dialogue.activeTransfer.state === ContentTransfer.Charged) ||
> -                                (dialogue.activeTransfer.state === ContentTransfer.Aborted))
> -
> -                    if (dialogue.activeTransfer.state === ContentTransfer.Charged) {
> -                        dialogue.hide()
> -                        if (dialogue.activeTransfer.items.length > 0) {
> -                            root.avatarReceived(dialogue.activeTransfer.items[0].url)
> -                        }
> -                    }
> -
> -                    if (done) {
> -                        acceptTimer.restart()
> -                    }
> -                }
> -            }
> -
> -            // WORKAROUND: Work around for application becoming insensitive to touch events
> -            // if the dialog is dismissed while the application is inactive.
> -            // Just listening for changes to Qt.application.active doesn't appear
> -            // to be enough to resolve this, so it seems that something else needs
> -            // to be happening first. As such there's a potential for a race
> -            // condition here, although as yet no problem has been encountered.
> -            Timer {
> -                id: acceptTimer
> -
> -                interval: 100
> -                repeat: true
> -                running: false
> -                onTriggered: {
> -                   if(Qt.application.active) {
> -                       PopupUtils.close(root.importDialog)
> -                   }
> -                }
> -            }
> -
> -            Component.onDestruction: root.importDialog = null
> +    title: i18n.tr("Import avatar from...")
> +
> +    Item {
> +        id: transferHint
> +
> +        anchors.fill: parent
> +        visible: root.isTransferRunning
> +
> +        ActivityIndicator {
> +            id: activityIndicator
> +
> +            anchors {
> +                horizontalCenter: parent.horizontalCenter
> +                verticalCenter: parent.verticalCenter
> +                verticalCenterOffset: units.gu(-4)
> +            }
> +            running: root.activeTransfer
> +        }
> +
> +        Label {
> +            anchors {
> +                top: activityIndicator.bottom
> +                topMargin: units.gu(2)
> +                horizontalCenter: parent.horizontalCenter
> +            }
> +            // TRANSLATORS: This message appear while waiting for a external application content,
> +            // %1 refers to the the name of source application
> +            text: i18n.tr("Waiting content from %1..").arg(peerPicker.peer.name)

done

> +        }
> +
> +        Button {
> +            id: cancelButton
> +
> +            enabled: root.activeTransfer && (root.activeTransfer.state === ContentTransfer.InProgress)
> +            anchors {
> +                bottom: parent.bottom
> +                left: parent.left
> +                right: parent.right
> +                margins: units.gu(2)
> +            }
> +            text: i18n.tr("Cancel")
> +            onClicked: root.activeTransfer.state = ContentTransfer.Aborted
> +        }
> +    }
> +
> +    ContentPeerPicker {
> +        id: peerPicker
> +
> +        anchors.fill: parent
> +        contentType: ContentType.Pictures
> +        handler: ContentHandler.Source
> +        showTitle: false
> +        visible: !root.isTransferRunning
> +
> +        onPeerSelected: {
> +            peer.selectionType = ContentTransfer.Single
> +            root.activeTransfer = peer.request()
> +        }
> +
> +        onCancelPressed: pageStack.pop()
> +    }
> +
> +    Connections {
> +        id: signalConnections
> +
> +        target: null
> +        onStateChanged: {
> +            var done = ((root.activeTransfer.state === ContentTransfer.Charged) ||
> +                        (root.activeTransfer.state === ContentTransfer.Aborted))
> +            transferHint.enabled = !done
> +            if (root.activeTransfer.state === ContentTransfer.Charged) {
> +                if (( root.activeTransfer.items.length > 0) && root.avatarListener) {
> +                    root.avatarListener.avatarReceived( root.activeTransfer.items[0].url)
> +                }
> +            }
> +
> +            if (done) {
> +                pageStack.pop()
> +            }
> +        }
> +    }
> +
> +    Component.onDestruction: {
> +        if (root.avatarListener) {
> +            root.avatarListener.busy = false
> +        }
> +    }
> +
> +    Component.onCompleted: {
> +        if (root.avatarListener) {
> +            root.avatarListener.busy = true
>          }
>      }
>  }
> 
> === modified file 'src/imports/ContactEdit/ContactDetailAvatarEditor.qml'
> --- src/imports/ContactEdit/ContactDetailAvatarEditor.qml	2014-09-29 13:20:08 +0000
> +++ src/imports/ContactEdit/ContactDetailAvatarEditor.qml	2014-10-07 19:24:25 +0000
> @@ -23,7 +23,7 @@
>  ContactDetailBase {
>      id: root
>  
> -    readonly property alias busy: activityIndicator.running
> +    property alias busy: activityIndicator.running
>      readonly property string defaultAvatar: "image://theme/add"
>  
>      function isEmpty() {
> @@ -61,6 +61,16 @@
>          return avatarUrl
>      }
>  
> +    function avatarReceived(avatarUrl)
> +    {
> +        // remove the previous image, this is nessary to make sure that the new image
> +        // get updated otherwise if the new image has the same name the image will not
> +        // be updated
> +        avatarImage.source = ""
> +        // Update with the new value
> +        avatarImage.source = application.copyImage(root.contact, avatarUrl);
> +    }
> +
>      detail: contact ? contact.detail(ContactDetail.Avatar) : null
>      implicitHeight: units.gu(8)
>      implicitWidth: units.gu(8)
> @@ -81,7 +91,7 @@
>              anchors.centerIn: visible ? avatar : undefined
>              height: units.gu(3)
>              width: units.gu(3)
> -            visible: source == defaultAvatar
> +            visible: source == defaultAvatar && !root.busy
>  
>              // When updating the avatar using the content picker the temporary file returned
>              // can contain the same name as the previous one and if the cache is enabled this
> @@ -94,29 +104,16 @@
>          id: activityIndicator
>  
>          anchors.centerIn: avatar
> -        running: (avatarImport.importDialog != null)
>          visible: running
>      }
>  
> -    AvatarImport {
> -        id: avatarImport
> -
> -        onAvatarReceived: {
> -            // remove the previous image, this is nessary to make sure that the new image
> -            // get updated otherwise if the new image has the same name the image will not
> -            // be updated
> -            avatarImage.source = ""
> -            // Update with the new value
> -            avatarImage.source = application.copyImage(root.contact, avatarUrl);
> -        }
> -    }
> -
>      MouseArea {
>          anchors.fill: parent
>          onClicked: {
>              // make sure the OSK disappear
>              root.forceActiveFocus()
> -            avatarImport.requestNewAvatar()
> +            root.busy = true
> +            pageStack.push(Qt.resolvedUrl("AvatarImport.qml"), {avatarListener: root})
>          }
>      }
>  }
> 
> === modified file 'src/imports/ContactList/ContactExporter.qml'
> --- src/imports/ContactList/ContactExporter.qml	2014-09-30 21:17:25 +0000
> +++ src/imports/ContactList/ContactExporter.qml	2014-10-07 19:24:25 +0000
> @@ -22,9 +22,10 @@
>  
>      property var contactModel
>      property var outputFile
> +    property var activeTransfer: null
>  
> -    signal contactExported(int error, string url)
>      signal contactsFetched(var contacts)
> +    signal done()
>  
>      function start(contacts) {
>          if (!contactModel) {
> @@ -59,7 +60,21 @@
>  
>              onExportCompleted: {
>                  priv.currentQueryId = -1
> -                root.contactExported(error, root.outputFile)
> +
> +                // send contacts back to source app (pick mode)
> +                if (error === ContactModel.ExportNoError) {
> +                    var obj = Qt.createQmlObject("import Ubuntu.Content 0.1;  ContentItem { url: '" + url + "' }", contactExporter)

done

> +                    if (root.activeTransfer) {
> +                        root.activeTransfer.items = [obj]
> +                        root.activeTransfer.state = ContentHub.ContentTransfer.Charged
> +                        return
> +                    }  else {
> +                        console.error("No active transfer")
> +                    }
> +                } else {
> +                    console.error("Fail to export contacts:" + error)
> +                }
> +                root.done()
>              }
>  
>              onContactsFetched: {
> @@ -74,5 +89,17 @@
>                  }
>              }
>          }
> +
> +        Connections {
> +            target: root.activeTransfer
> +
> +            onStateChanged: {
> +                if ((root.activeTransfer.state === ContentTransfer.Charged) ||
> +                    (root.activeTransfer.state === ContentTransfer.Aborted)) {
> +                    root.activeTransfer = null
> +                    root.done()
> +                }
> +            }
> +        }
>      }
>  }
> 
> === modified file 'src/imports/ContactList/ContactListPage.qml'
> --- src/imports/ContactList/ContactListPage.qml	2014-10-03 21:45:23 +0000
> +++ src/imports/ContactList/ContactListPage.qml	2014-10-07 19:24:25 +0000
> @@ -622,27 +622,13 @@
>      ContactExporter {
>          id: contactExporter
>  
> -        property var activeTransfer: null
> -
>          contactModel: contactList.listModel
>          outputFile: mainPage.pickMode ? "file:///tmp/address_book_app_export.vcf" : ""
> -        onContactExported: {
> -            // send contacts back to source app (pick mode)
> -            if (error === ContactModel.ExportNoError) {
> -                var obj = Qt.createQmlObject("import Ubuntu.Content 0.1;  ContentItem { url: '" + url + "' }", contactExporter)
> -                if (activeTransfer) {
> -                    activeTransfer.items = [obj]
> -                    activeTransfer.state = ContentHub.ContentTransfer.Charged
> -                }  else {
> -                    console.error("No active transfer")
> -                }
> -            } else {
> -                console.error("Fail to export contacts:" + error)
> -            }
> -            activeTransfer = null
> +
> +        onDone: {
>              mainPage.pickMode = false
>              mainPage.state = "default"
> -            application.returnVcard(url)
> +            application.returnVcard(contactExporter.outputFile)
>          }
>  
>          onContactsFetched: {
> 


-- 
https://code.launchpad.net/~renatofilho/address-book-app/fix-1377334/+merge/237480
Your team Ubuntu Phablet Team is requested to review the proposed merge of lp:~renatofilho/address-book-app/fix-1377334 into lp:~phablet-team/address-book-app/staging.



More information about the Ubuntu-reviews mailing list