Merge lp:~renatofilho/address-book-app/fix-1207774 into lp:address-book-app

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Renato Araujo Oliveira Filho
Approved revision: 70
Merged at revision: 84
Proposed branch: lp:~renatofilho/address-book-app/fix-1207774
Merge into: lp:address-book-app
Diff against target: 149 lines (+75/-2)
3 files modified
src/app/addressbookapp.cpp (+18/-1)
src/app/addressbookapp.h (+1/-0)
src/imports/ContactEdit/ContactDetailAvatarEditor.qml (+56/-1)
To merge this branch: bzr merge lp:~renatofilho/address-book-app/fix-1207774
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Gustavo Pichorim Boiko (community) Approve
Bill Filler (community) Needs Fixing
Review via email: mp+187131@code.launchpad.net

Commit message

Implemented support for avatar editor.

Description of the change

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

wasn't sure if this was ready for review yet, but I tried it. wasn't working. the gallery comes up and I choose a picture but when it goes back to address-book there is no picture. I see this error in the log. I was using address-book-service MR for support for avatar

file:///usr/share/address-book-app/imports/ContactEdit/ContactEditor.qml:31: Unable to assign null to QString
file:///usr/share/address-book-app/imports/ContactEdit/ContactDetailAvatarEditor.qml:85: ReferenceError: activeTransfer is not defined
file:///usr/share/address-book-app/imports/ContactEdit/ContactEditor.qml:32: Unable to assign null to QString

ShaderEffect: Property 'source' is not assigned a valid texture provider (QQuickImage*).
ShaderEffect: Property 'source' is not assigned a valid texture provider (QQuickImage*).
QObject* qml_content_hub(QQmlEngine*, QJSEngine*)
QmlImportExportHandler::QmlImportExportHandler(QObject*)
virtual void com::ubuntu::content::Hub::register_import_export_handler(com::ubuntu::content::ImportExportHandler*)
QString {anonymous}::sanitize_id(const QString&)
virtual void com::ubuntu::content::Hub::register_import_export_handler(com::ubuntu::content::ImportExportHandler*) BUS_NAME: "com.ubuntu.content.handler.address_2dbook_2dapp"
com::ubuntu::content::detail::Handler::Private::Private(QDBusConnection, const QString&, QObject*)
com::ubuntu::content::detail::Handler::Handler(QDBusConnection, const QString&, com::ubuntu::content::ImportExportHandler*)
ContentPeer* ContentHub::defaultSourceForType(int)
static const com::ubuntu::content::Type& ContentType::contentType2HubType(int) 2
ContentPeer::ContentPeer(QObject*)
ContentTransfer* ContentHub::importContent(int, ContentPeer*) 2 ContentPeer(0x1530160)
static const com::ubuntu::content::Type& ContentType::contentType2HubType(int) 2
ContentTransfer::ContentTransfer(QObject*)
void ContentTransfer::setTransfer(com::ubuntu::content::Transfer*, ContentTransfer::Direction)
void ContentTransfer::updateSelectionType()
void ContentTransfer::updateStore()
void ContentTransfer::updateState()
bool ContentTransfer::start()
QDBusConnection: name 'com.ubuntu.content.dbus.Service' had owner '' but we thought it was ':1.34'
void com::ubuntu::content::detail::Handler::HandleImport(const QDBusObjectPath&)
void com::ubuntu::content::detail::Handler::HandleImport(const QDBusObjectPath&) State: 1
void ContentTransfer::updateStore()
void ContentTransfer::updateState()
QObject::connect: Cannot connect QQuickShaderEffectSource:: to ShapeItem::onImagePropertiesChanged()
QObject::connect: Cannot connect QQuickShaderEffectSource:: to ShapeItem::onImagePropertiesChanged()
QObject::connect: Cannot connect QQuickShaderEffectSource:: to ShapeItem::onImagePropertiesChanged()
void ContentTransfer::updateState()
void ContentTransfer::updateState()
file:///usr/share/unity8/Components/CrossFadeImage.qml:39: Unable to assign QSize to QSizeF
Detectable autorepeat not supported.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Looks good and works as expected!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/app/addressbookapp.cpp'
2--- src/app/addressbookapp.cpp 2013-09-23 13:48:33 +0000
3+++ src/app/addressbookapp.cpp 2013-09-29 21:37:42 +0000
4@@ -32,6 +32,7 @@
5 #include <QDBusConnectionInterface>
6 #include <QLibrary>
7 #include <QIcon>
8+#include <QTemporaryFile>
9
10 #include <QQmlEngine>
11
12@@ -76,7 +77,7 @@
13 static void installIconPath()
14 {
15 QByteArray iconTheme = qgetenv("ADDRESS_BOOK_APP_ICON_THEME");
16- if (!iconTheme.isEmpty()) {
17+ if (!iconTheme.isEmpty()) {
18 QIcon::setThemeName(iconTheme);
19 }
20 }
21@@ -353,3 +354,19 @@
22 m_view->requestActivate();
23 }
24 }
25+
26+QUrl AddressBookApp::copyImage(QObject *contact, const QUrl &imageUrl)
27+{
28+ QFile img(imageUrl.toLocalFile());
29+ if (img.exists() && img.open(QFile::ReadOnly)) {
30+ QTemporaryFile *tmp = new QTemporaryFile(contact);
31+ if (tmp->open()) {
32+ tmp->close();
33+ QImage tmpAvatar = QImage(img.fileName());
34+ QImage scaledAvatar = tmpAvatar.scaledToHeight(720, Qt::SmoothTransformation);
35+ scaledAvatar.save(tmp->fileName(), "png", 9);
36+ return QUrl(tmp->fileName());
37+ }
38+ }
39+ return QUrl();
40+}
41
42=== modified file 'src/app/addressbookapp.h'
43--- src/app/addressbookapp.h 2013-09-17 22:19:02 +0000
44+++ src/app/addressbookapp.h 2013-09-29 21:37:42 +0000
45@@ -35,6 +35,7 @@
46
47 public Q_SLOTS:
48 void activateWindow();
49+ QUrl copyImage(QObject *contact, const QUrl &imageUrl);
50
51 private:
52 void parseArgument(const QString &arg);
53
54=== modified file 'src/imports/ContactEdit/ContactDetailAvatarEditor.qml'
55--- src/imports/ContactEdit/ContactDetailAvatarEditor.qml 2013-08-07 18:57:30 +0000
56+++ src/imports/ContactEdit/ContactDetailAvatarEditor.qml 2013-09-29 21:37:42 +0000
57@@ -17,6 +17,8 @@
58 import QtQuick 2.0
59 import Ubuntu.Components 0.1
60 import QtContacts 5.0
61+import Ubuntu.Content 0.1
62+import Ubuntu.Components.Popups 0.1 as Popups
63
64 import "../Common"
65
66@@ -24,7 +26,11 @@
67 id: root
68
69 function save() {
70- //TODO: not implemented
71+ if (root.detail.imageUrl != avatarImage.source) {
72+ console.debug("Save new image:" + avatarImage.source)
73+ root.detail.imageUrl = avatarImage.source
74+ return true
75+ }
76 return false
77 }
78
79@@ -32,14 +38,37 @@
80 implicitHeight: units.gu(17)
81
82 Image {
83+ id: avatarImage
84+
85 anchors.fill: parent
86 source: root.detail && root.detail.imageUrl != "" ? root.detail.imageUrl : "artwork:/avatar-default.svg"
87 asynchronous: true
88 fillMode: Image.PreserveAspectCrop
89
90+ Component {
91+ id: loadingDialog
92+
93+ Popups.Dialog {
94+ id: dialogue
95+
96+ title: i18n.tr("Loading")
97+
98+ ActivityIndicator {
99+ id: activity
100+
101+ anchors.centerIn: parent
102+ running: true
103+ visible: running
104+ }
105+ }
106+ }
107+
108 AbstractButton {
109 id: changeButton
110
111+ property var activeTransfer
112+ property var loadingDialog: null
113+
114 anchors {
115 right: parent.right
116 bottom: parent.bottom
117@@ -54,6 +83,32 @@
118 source: "artwork:/import-image.svg"
119 fillMode: Image.PreserveAspectFit
120 }
121+
122+ onClicked: {
123+ if (!changeButton.loadingDialog) {
124+ changeButton.loadingDialog = PopupUtils.open(loadingDialog, null)
125+ changeButton.activeTransfer = ContentHub.importContent(ContentType.Pictures,
126+ ContentHub.defaultSourceForType(ContentType.Pictures));
127+ changeButton.activeTransfer.start();
128+ }
129+ }
130+
131+ Connections {
132+ target: changeButton.activeTransfer != null ? changeButton.activeTransfer : null
133+ onStateChanged: {
134+ if (changeButton.activeTransfer.state === ContentTransfer.Charged) {
135+ if (changeButton.activeTransfer.items.length > 0) {
136+ avatarImage.source = application.copyImage(root.contact, changeButton.activeTransfer.items[0].url);
137+ //avatarImage.source = changeButton.activeTransfer.items[0].url
138+ }
139+ }
140+ if ((changeButton.activeTransfer.state === ContentTransfer.Charged) ||
141+ (changeButton.activeTransfer.state === ContentTransfer.Aborted)) {
142+ PopupUtils.close(changeButton.loadingDialog)
143+ changeButton.loadingDialog = null
144+ }
145+ }
146+ }
147 }
148 }
149 }

Subscribers

People subscribed via source and target branches