diff options
-rw-r--r-- | framework/qml/People.qml | 8 | ||||
-rw-r--r-- | framework/src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | framework/src/domain/contactcontroller.cpp | 1 | ||||
-rw-r--r-- | framework/src/domain/contactcontroller.h | 1 | ||||
-rw-r--r-- | framework/src/domain/peoplemodel.cpp | 6 | ||||
-rw-r--r-- | framework/src/domain/peoplemodel.h | 3 | ||||
-rw-r--r-- | framework/src/frameworkplugin.cpp | 3 | ||||
-rw-r--r-- | framework/src/kubeimage.cpp | 24 | ||||
-rw-r--r-- | framework/src/kubeimage.h | 15 |
9 files changed, 56 insertions, 6 deletions
diff --git a/framework/qml/People.qml b/framework/qml/People.qml index aa23a78d..3445a5ba 100644 --- a/framework/qml/People.qml +++ b/framework/qml/People.qml | |||
@@ -149,13 +149,13 @@ Item { | |||
149 | } | 149 | } |
150 | } | 150 | } |
151 | 151 | ||
152 | Rectangle { | 152 | Kube.KubeImage { |
153 | id: avatarPlaceholder | 153 | id: avatarPlaceholder |
154 | 154 | ||
155 | height: parent.height | 155 | height: parent.height |
156 | width: height | 156 | width: height |
157 | 157 | ||
158 | color: "lightgrey" | 158 | imageData: model.imageData |
159 | } | 159 | } |
160 | 160 | ||
161 | Column { | 161 | Column { |
@@ -241,13 +241,13 @@ Item { | |||
241 | height: Kube.Units.gridUnit * 8 | 241 | height: Kube.Units.gridUnit * 8 |
242 | width: personPageRoot.width - Kube.Units.largeSpacing | 242 | width: personPageRoot.width - Kube.Units.largeSpacing |
243 | 243 | ||
244 | Rectangle { | 244 | Kube.KubeImage { |
245 | id: avatar | 245 | id: avatar |
246 | 246 | ||
247 | height: parent.height | 247 | height: parent.height |
248 | width: height | 248 | width: height |
249 | 249 | ||
250 | color: "lightgrey" | 250 | imageData: contactController.imageData |
251 | } | 251 | } |
252 | 252 | ||
253 | //TODO replace with Kube.Heading once it is there | 253 | //TODO replace with Kube.Heading once it is there |
diff --git a/framework/src/CMakeLists.txt b/framework/src/CMakeLists.txt index 1b92e8c3..1c53530f 100644 --- a/framework/src/CMakeLists.txt +++ b/framework/src/CMakeLists.txt | |||
@@ -39,6 +39,7 @@ set(SRCS | |||
39 | accounts/accountsmodel.cpp | 39 | accounts/accountsmodel.cpp |
40 | fabric.cpp | 40 | fabric.cpp |
41 | sinkfabric.cpp | 41 | sinkfabric.cpp |
42 | kubeimage.cpp | ||
42 | ) | 43 | ) |
43 | 44 | ||
44 | add_library(frameworkplugin SHARED ${SRCS}) | 45 | add_library(frameworkplugin SHARED ${SRCS}) |
diff --git a/framework/src/domain/contactcontroller.cpp b/framework/src/domain/contactcontroller.cpp index 90ef6323..bc536bf6 100644 --- a/framework/src/domain/contactcontroller.cpp +++ b/framework/src/domain/contactcontroller.cpp | |||
@@ -59,6 +59,7 @@ void ContactController::loadContact(const QVariant &contact) | |||
59 | } | 59 | } |
60 | setCompany(addressee.organization()); | 60 | setCompany(addressee.organization()); |
61 | setJobTitle(addressee.role()); | 61 | setJobTitle(addressee.role()); |
62 | setImageData(addressee.photo().rawData()); | ||
62 | } | 63 | } |
63 | } | 64 | } |
64 | 65 | ||
diff --git a/framework/src/domain/contactcontroller.h b/framework/src/domain/contactcontroller.h index fea42430..72d8eee1 100644 --- a/framework/src/domain/contactcontroller.h +++ b/framework/src/domain/contactcontroller.h | |||
@@ -41,6 +41,7 @@ class ContactController : public Kube::Controller | |||
41 | KUBE_CONTROLLER_PROPERTY(QString, Country, country) | 41 | KUBE_CONTROLLER_PROPERTY(QString, Country, country) |
42 | KUBE_CONTROLLER_PROPERTY(QString, Company, company) | 42 | KUBE_CONTROLLER_PROPERTY(QString, Company, company) |
43 | KUBE_CONTROLLER_PROPERTY(QString, JobTitle, jobTitle) | 43 | KUBE_CONTROLLER_PROPERTY(QString, JobTitle, jobTitle) |
44 | KUBE_CONTROLLER_PROPERTY(QByteArray, ImageData, imageData) | ||
44 | 45 | ||
45 | KUBE_CONTROLLER_ACTION(save) | 46 | KUBE_CONTROLLER_ACTION(save) |
46 | 47 | ||
diff --git a/framework/src/domain/peoplemodel.cpp b/framework/src/domain/peoplemodel.cpp index c9e7248c..099c680a 100644 --- a/framework/src/domain/peoplemodel.cpp +++ b/framework/src/domain/peoplemodel.cpp | |||
@@ -38,6 +38,7 @@ PeopleModel::PeopleModel(QObject *parent) | |||
38 | query.request<Contact::Vcard>(); | 38 | query.request<Contact::Vcard>(); |
39 | query.request<Contact::Firstname>(); | 39 | query.request<Contact::Firstname>(); |
40 | query.request<Contact::Lastname>(); | 40 | query.request<Contact::Lastname>(); |
41 | query.request<Contact::Photo>(); | ||
41 | runQuery(query); | 42 | runQuery(query); |
42 | } | 43 | } |
43 | 44 | ||
@@ -65,7 +66,8 @@ QHash< int, QByteArray > PeopleModel::roleNames() const | |||
65 | {Type, "type"}, | 66 | {Type, "type"}, |
66 | {DomainObject, "domainObject"}, | 67 | {DomainObject, "domainObject"}, |
67 | {FirstName, "firstName"}, | 68 | {FirstName, "firstName"}, |
68 | {LastName, "lastName"} | 69 | {LastName, "lastName"}, |
70 | {ImageData, "imageData"} | ||
69 | }; | 71 | }; |
70 | return roles; | 72 | return roles; |
71 | } | 73 | } |
@@ -96,6 +98,8 @@ QVariant PeopleModel::data(const QModelIndex &idx, int role) const | |||
96 | return contact->getFirstname(); | 98 | return contact->getFirstname(); |
97 | case LastName: | 99 | case LastName: |
98 | return contact->getLastname(); | 100 | return contact->getLastname(); |
101 | case ImageData: | ||
102 | return contact->getPhoto(); | ||
99 | } | 103 | } |
100 | return QSortFilterProxyModel::data(idx, role); | 104 | return QSortFilterProxyModel::data(idx, role); |
101 | } | 105 | } |
diff --git a/framework/src/domain/peoplemodel.h b/framework/src/domain/peoplemodel.h index a59e752c..69d07417 100644 --- a/framework/src/domain/peoplemodel.h +++ b/framework/src/domain/peoplemodel.h | |||
@@ -51,7 +51,8 @@ public: | |||
51 | Addressbook, | 51 | Addressbook, |
52 | DomainObject, | 52 | DomainObject, |
53 | FirstName, | 53 | FirstName, |
54 | LastName | 54 | LastName, |
55 | ImageData | ||
55 | }; | 56 | }; |
56 | 57 | ||
57 | QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; | 58 | QHash<int, QByteArray> roleNames() const Q_DECL_OVERRIDE; |
diff --git a/framework/src/frameworkplugin.cpp b/framework/src/frameworkplugin.cpp index 84ada236..9c79f515 100644 --- a/framework/src/frameworkplugin.cpp +++ b/framework/src/frameworkplugin.cpp | |||
@@ -33,6 +33,7 @@ | |||
33 | #include "accounts/accountfactory.h" | 33 | #include "accounts/accountfactory.h" |
34 | #include "settings/settings.h" | 34 | #include "settings/settings.h" |
35 | #include "fabric.h" | 35 | #include "fabric.h" |
36 | #include "kubeimage.h" | ||
36 | 37 | ||
37 | #include <QtQml> | 38 | #include <QtQml> |
38 | 39 | ||
@@ -62,4 +63,6 @@ void FrameworkPlugin::registerTypes (const char *uri) | |||
62 | 63 | ||
63 | qmlRegisterType<Kube::Fabric::Listener>(uri, 1, 0, "Listener"); | 64 | qmlRegisterType<Kube::Fabric::Listener>(uri, 1, 0, "Listener"); |
64 | qmlRegisterSingletonType<Kube::Fabric::Fabric>(uri, 1, 0, "Fabric", fabric_singletontype_provider); | 65 | qmlRegisterSingletonType<Kube::Fabric::Fabric>(uri, 1, 0, "Fabric", fabric_singletontype_provider); |
66 | |||
67 | qmlRegisterType<KubeImage>(uri, 1, 0, "KubeImage"); | ||
65 | } | 68 | } |
diff --git a/framework/src/kubeimage.cpp b/framework/src/kubeimage.cpp new file mode 100644 index 00000000..4fec7f3d --- /dev/null +++ b/framework/src/kubeimage.cpp | |||
@@ -0,0 +1,24 @@ | |||
1 | #include "kubeimage.h" | ||
2 | |||
3 | #include <QQuickWindow> | ||
4 | #include <QSGTexture> | ||
5 | #include <QSGSimpleTextureNode> | ||
6 | |||
7 | KubeImage::KubeImage(QQuickItem *parent) | ||
8 | :QQuickItem(parent) | ||
9 | { | ||
10 | setFlag(QQuickItem::ItemHasContents); | ||
11 | } | ||
12 | |||
13 | QSGNode *KubeImage::updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *updatePaintNodeData) | ||
14 | { | ||
15 | QSGSimpleTextureNode *node = static_cast<QSGSimpleTextureNode *>(oldNode); | ||
16 | if (!node) { | ||
17 | node = new QSGSimpleTextureNode(); | ||
18 | auto img = QImage::fromData(mImageData); | ||
19 | QSGTexture *texture = window()->createTextureFromImage(img); | ||
20 | node->setTexture(texture); | ||
21 | } | ||
22 | node->setRect(boundingRect()); | ||
23 | return node; | ||
24 | } | ||
diff --git a/framework/src/kubeimage.h b/framework/src/kubeimage.h new file mode 100644 index 00000000..da4efed0 --- /dev/null +++ b/framework/src/kubeimage.h | |||
@@ -0,0 +1,15 @@ | |||
1 | |||
2 | #include <QQuickItem> | ||
3 | |||
4 | class KubeImage : public QQuickItem { | ||
5 | Q_OBJECT | ||
6 | Q_PROPERTY(QByteArray imageData MEMBER mImageData) | ||
7 | public: | ||
8 | KubeImage(QQuickItem *parent = nullptr); | ||
9 | |||
10 | protected: | ||
11 | QSGNode *updatePaintNode(QSGNode *oldNode, QQuickItem::UpdatePaintNodeData *updatePaintNodeData) Q_DECL_OVERRIDE; | ||
12 | |||
13 | private: | ||
14 | QByteArray mImageData; | ||
15 | }; | ||