~ubuntu-branches/ubuntu/trusty/content-hub/trusty-proposed

« back to all changes in this revision

Viewing changes to import/Ubuntu/Content/ContentPeerPicker.qml

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Loïc Minier, Ken VanDine, Javier Collado, Dimitri John Ledkov, Michael Sheldon
  • Date: 2014-04-02 14:46:54 UTC
  • mfrom: (1.1.20)
  • Revision ID: package-import@ubuntu.com-20140402144654-8ilsrlzz6bx5p3ox
Tags: 0.0+14.04.20140402-0ubuntu1
[ Loïc Minier ]
* Downgrade content-hub Recommends to a Suggests as we don't want
  content-hub pulled via ubuntu-sdk on developer desktops.

[ Ken VanDine ]
* protect against queries for Type::unknown (LP: #1293463)
* Replace a couple missed qDebug lines for logging
* Don't unref the g_icon, the value belongs to app
* Ensure m_defaultSources is a StringList before attempting to use it
  as a list
* ContentPeerPicker: Make headers translatable and use a
  ResponsiveGridView for the devices grid to match the apps grid.
  ContentPeerPicker: hide the devices section until we have a way to
  populate it

[ Javier Collado ]
* Added README file (LP: #1274899)

[ Dimitri John Ledkov ]
* Exit quicker, if there is nothing to do. (LP: #1287674) (LP:
  #1287674)

[ Michael Sheldon ]
* Fixes updating of the ContentPeerModel when using Loader and
  changing ContentType or ContentHandler dynamically and ensures that
  ContentPeerModel Loader doesn't begin loading the model until the
  peer picker becomes visible (avoiding delaying app start-up time).
* Make qdoc based documentation compatible with the Qt 5.2 version of
  qdoc.
* Fixes version number of import statements in QML documentation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
/*!
24
24
    \qmltype ContentPeerPicker
25
 
    \inqmlmodule Ubuntu.Content 0.1
 
25
    \inqmlmodule Ubuntu.Content
26
26
    \brief Component that allows users to select a source/destination for content transfer
27
27
 
28
28
    This component displays a list of applications, devices and services which
68
68
    */
69
69
    property var customPeerModelLoader
70
70
 
 
71
    property var completed: false
 
72
 
71
73
    /*! \qmlsignal peerSelected
72
74
        \brief Emitted when a user selects a peer.
73
75
 
88
90
 
89
91
    Header {
90
92
        id: header
91
 
        title: (handler === ContentHandler.Source) ? i18n.tr("Choose from") : i18n.tr("Share to")
 
93
        title: (handler === ContentHandler.Source) ? i18n.tr("Choose from") : (handler === ContentHandler.Destination ? i18n.tr("Open with") : i18n.tr("Share to"))
92
94
    }
93
95
 
94
96
    Loader {
95
97
        id: peerModelLoader
96
98
        active: false
97
 
        sourceComponent: ContentPeerModel {
98
 
            id: peerModel
99
 
        }
 
99
        sourceComponent: ContentPeerModel { }
100
100
        onLoaded: {
101
 
            item.handler = root.handler
102
 
            item.contentType = root.contentType
 
101
            item.handler = root.handler;
 
102
            item.contentType = root.contentType;
103
103
        }
104
104
    }
105
105
 
106
106
    Component.onCompleted: {
107
 
        if(customPeerModelLoader) {
108
 
            customPeerModelLoader.active = true;
109
 
        } else {
110
 
            peerModelLoader.active = true;
 
107
        if (root.visible) {
 
108
            if (customPeerModelLoader) {
 
109
                customPeerModelLoader.active = true;
 
110
            } else {
 
111
                peerModelLoader.active = true;
 
112
            }
 
113
        }
 
114
        completed = true;
 
115
    }
 
116
 
 
117
    onVisibleChanged: {
 
118
        if (completed) {
 
119
            if (customPeerModelLoader) {
 
120
                customPeerModelLoader.active = true;
 
121
            } else {
 
122
                peerModelLoader.active = true;
 
123
            }
 
124
        }
 
125
    }
 
126
 
 
127
    onHandlerChanged: {
 
128
        if (!customPeerModelLoader && peerModelLoader.item) {
 
129
            appPeers.model = undefined; // Clear grid view
 
130
            peerModelLoader.item.handler = root.handler;
 
131
            appPeers.model = peerModelLoader.item.peers;
 
132
        }
 
133
    }
 
134
 
 
135
    onContentTypeChanged: {
 
136
        if (!customPeerModelLoader && peerModelLoader.item) {
 
137
            appPeers.model = undefined; // Clear grid view
 
138
            peerModelLoader.item.contentType = root.contentType;
 
139
            appPeers.model = peerModelLoader.item.peers;
111
140
        }
112
141
    }
113
142
 
171
200
    ListItem.Header {
172
201
        id: appTitle
173
202
        anchors.top: header.visible ? header.bottom : parent.top
174
 
        text: "Apps"
 
203
        text: i18n.tr("Apps")
175
204
    }
176
205
 
177
206
    Rectangle {
178
207
        id: apps
179
208
        color: "#FFFFFF"
180
 
        height: (parent.height / 2.4)
 
209
        height: devices.visible ? (parent.height / 2.4) : parent.height
181
210
        width: parent.width
182
211
        clip: true
183
212
        anchors {
200
229
                model: customPeerModelLoader ? customPeerModelLoader.item.peers : peerModelLoader.item.peers
201
230
                delegate: peerDelegate
202
231
            }
203
 
 
204
232
        }
205
233
    }
206
234
 
207
235
    ListItem.Header {
208
236
        id: devTitle
 
237
        // TODO: make this visible when we have a way to populate devices
 
238
        visible: false
209
239
        anchors {
210
240
            left: parent.left
211
241
            right: parent.right
212
242
            top: apps.bottom
213
243
        }
214
 
        text: "Devices"
 
244
        text: i18n.tr("Devices")
215
245
    }
216
246
 
217
247
    Rectangle {
218
248
        id: devices
 
249
        // TODO: make this visible when we have a way to populate devices
 
250
        visible: false
219
251
        color: "#FFFFFF"
220
252
        width: parent.width
221
253
        radius: 0
230
262
        Flickable {
231
263
            anchors.fill: parent
232
264
 
233
 
            GridView {
 
265
            ResponsiveGridView {
234
266
                id: devPeers
235
 
                header: Item { height: units.gu(2) }
236
 
                cellWidth: units.gu(13.5)
237
 
                cellHeight: units.gu(16)
 
267
                anchors.fill: parent
 
268
                minimumHorizontalSpacing: units.gu(0.5)
 
269
                maximumNumberOfColumns: 6
 
270
                delegateWidth: units.gu(11)
 
271
                delegateHeight: units.gu(9.5)
 
272
                verticalSpacing: units.gu(2)
238
273
                delegate: peerDelegate
239
274
            }
240
 
 
241
275
        }
242
276
    }
243
277