~ubuntu-branches/ubuntu/quantal/kde-workspace/quantal

« back to all changes in this revision

Viewing changes to plasma/desktop/shell/activitymanager/package/contents/ui/main.qml

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-07-26 17:32:34 UTC
  • mfrom: (1.1.15)
  • Revision ID: package-import@ubuntu.com-20120726173234-bsn4gwllpbcwu2r4
Tags: 4:4.9.0-0ubuntu1
* Use direct build-depends versions rather than kde-sc-dev-latest
* Remove patches/kubuntu_revert_1554ba408633397066d31c3d565c217b5a385fb8.diff fixed upstream
* Remove debian/patches/kubuntu_fix_batterymonitor_panel_minsize.diff fix upstream
* New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import QtQuick 1.1
21
21
import org.kde.plasma.components 0.1 as PlasmaComponents
22
22
import org.kde.plasma.core 0.1 as PlasmaCore
 
23
import org.kde.qtextracomponents 0.1
23
24
 
24
25
Item {
25
26
    id: main
27
28
    //this is used to perfectly align the filter field and delegates
28
29
    property int cellWidth: theme.defaultFont.mSize.width * 20
29
30
 
30
 
    property int minimumWidth: cellWidth + (activityManager.orientation == Qt.Horizontal ? 0 : scrollBar.width)
 
31
    property int minimumWidth: cellWidth + (
 
32
        activityManager.orientation == Qt.Horizontal
 
33
        ? 0
 
34
        : (scrollBar.width + 4 * 2) // 4 * 2 == left and right margins
 
35
        )
31
36
    property int minimumHeight: topBar.height + list.delegateHeight + (activityManager.orientation == Qt.Horizontal ? scrollBar.height : 0) + 4
32
37
 
33
38
 
109
114
            left: parent.left
110
115
            right: parent.right
111
116
 
112
 
            margins: 4
 
117
            topMargin: activityManager.orientation == Qt.Horizontal ? 4 : 0
 
118
            leftMargin: 4
113
119
        }
114
120
    }
115
121
    Component {
189
195
 
190
196
            PlasmaComponents.Button {
191
197
                id: newActivityButton
 
198
                anchors {
 
199
                    left: parent.left
 
200
                    right: parent.right
 
201
                }
192
202
                iconSource: "list-add"
193
203
                text: i18n("Create activity...")
194
204
                onClicked: newActivityMenu.open()
195
205
            }
196
 
            PlasmaComponents.Button {
197
 
                iconSource: "plasma"
198
 
                text: i18n("Add widgets")
199
 
                onClicked: activityManager.addWidgetsRequested()
200
 
            }
201
206
            Component.onCompleted: {
202
207
                topBar.newActivityButton = newActivityButton
203
208
            }
204
209
        }
205
210
    }
206
211
 
207
 
    ListView {
208
 
        id: list
209
 
 
210
 
        property int delegateWidth: (activityManager.orientation == Qt.Horizontal) ? (list.width / Math.floor(list.width / cellWidth)) : cellWidth
211
 
        property int delegateHeight: theme.defaultFont.mSize.height * 7 - 4
212
 
 
213
 
 
 
212
    MouseEventListener {
 
213
        id: listParent
214
214
        anchors {
215
215
            top: topBar.bottom
216
216
            left: parent.left
217
 
            right: activityManager.orientation == Qt.Horizontal ? parent.right : scrollBar.left
218
 
            bottom: activityManager.orientation == Qt.Horizontal ? scrollBar.top : parent.bottom
 
217
            right: activityManager.orientation == Qt.Horizontal
 
218
                ? parent.right
 
219
                : (scrollBar.visible ? scrollBar.left : parent.right)
 
220
            bottom: activityManager.orientation == Qt.Horizontal ? scrollBar.top : bottomBar.top
219
221
            leftMargin: 4
220
 
            rightMargin: 4
221
222
            bottomMargin: 4
222
223
        }
223
 
 
224
 
        orientation: activityManager.orientation == Qt.Horizontal ? ListView.Horizontal : ListView.vertical
225
 
        snapMode: ListView.SnapToItem
226
 
        model: PlasmaCore.SortFilterModel {
227
 
            sourceModel: PlasmaCore.DataModel {
228
 
                dataSource: activitySource
229
 
            }
230
 
            filterRole: "Name"
231
 
            filterRegExp: ".*"+topBar.query+".*"
232
 
        }
233
 
 
234
 
        delegate: ActivityDelegate {}
 
224
        onWheelMoved: {
 
225
            //use this only if the wheel orientation is vertical and the list orientation is horizontal, otherwise will be the list itself managing the wheel
 
226
            if (wheel.orientation == Qt.Vertical && list.orientation == ListView.Horizontal) {
 
227
                var delta = wheel.delta > 0 ? 20 : -20
 
228
                list.contentX = Math.min(Math.max(0, list.contentWidth - list.width),
 
229
                                         Math.max(0, list.contentX - delta))
 
230
            }
 
231
        }
 
232
        ListView {
 
233
            id: list
 
234
 
 
235
            property int delegateWidth: (activityManager.orientation == Qt.Horizontal) ? (list.width / Math.floor(list.width / cellWidth)) : list.width
 
236
            property int delegateHeight: theme.defaultFont.mSize.height * 7 - 4
 
237
 
 
238
 
 
239
            anchors.fill: parent
 
240
 
 
241
            orientation: activityManager.orientation == Qt.Horizontal ? ListView.Horizontal : ListView.vertical
 
242
            snapMode: ListView.SnapToItem
 
243
            model: PlasmaCore.SortFilterModel {
 
244
                sourceModel: PlasmaCore.DataModel {
 
245
                    dataSource: activitySource
 
246
                }
 
247
                filterRole: "Name"
 
248
                filterRegExp: ".*"+topBar.query+".*"
 
249
            }
 
250
            clip: activityManager.orientation == Qt.Vertical
 
251
 
 
252
            delegate: ActivityDelegate {}
 
253
        }
235
254
    }
236
255
    PlasmaComponents.ScrollBar {
237
256
        id: scrollBar
238
257
        orientation: activityManager.orientation == Qt.Horizontal ? ListView.Horizontal : ListView.Vertical
239
258
        anchors {
240
 
            top: activityManager.orientation == Qt.Horizontal ? undefined : list.top
241
 
            bottom: parent.bottom
 
259
            top: activityManager.orientation == Qt.Horizontal ? undefined : listParent.top
 
260
            bottom: activityManager.orientation == Qt.Horizontal ? parent.bottom : bottomBar.top
242
261
            left: activityManager.orientation == Qt.Horizontal ? parent.left : undefined
243
262
            right: parent.right
244
263
        }
245
264
        flickableItem: list
246
265
    }
 
266
 
 
267
    Loader {
 
268
        id: bottomBar
 
269
 
 
270
        sourceComponent: (activityManager.orientation == Qt.Horizontal) ? undefined : verticalBottomBarComponent
 
271
        height: item.height
 
272
        anchors {
 
273
            left: parent.left
 
274
            right: parent.right
 
275
            bottom: parent.bottom
 
276
            leftMargin: 4
 
277
        }
 
278
    }
 
279
 
 
280
    Component {
 
281
        id: verticalBottomBarComponent
 
282
        Column {
 
283
            anchors {
 
284
                left: parent.left
 
285
                right: parent.right
 
286
                bottom: parent.bottom
 
287
            }
 
288
 
 
289
            spacing: 4
 
290
 
 
291
            PlasmaComponents.Button {
 
292
                anchors {
 
293
                    left: parent.left
 
294
                    right: parent.right
 
295
                }
 
296
                iconSource: "plasma"
 
297
                text: i18n("Add widgets")
 
298
                onClicked: activityManager.addWidgetsRequested()
 
299
            }
 
300
        }
 
301
    }
247
302
}