~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/generic/tools/remote-widgets-browser/main.qml

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import QtQuick 1.0
 
2
import org.kde.qtextracomponents 0.1
 
3
import org.kde.plasma.graphicswidgets 0.1
 
4
 
 
5
Rectangle {
 
6
    id: page
 
7
    width: 500; height: 500
 
8
    color: "white"
 
9
 
 
10
    Component {
 
11
        id: appDelegate
 
12
 
 
13
        Item {
 
14
            width: 200; height: 100
 
15
 
 
16
            Rectangle {
 
17
                id: background
 
18
                width: parent.width - 2
 
19
                height: parent.height
 
20
                anchors.centerIn: parent
 
21
                radius: 5
 
22
                color: "lightsteelblue"
 
23
                opacity: 0
 
24
                Behavior on opacity {
 
25
                    NumberAnimation {
 
26
                        duration: 200
 
27
                        easing.type: Easing.InOutCubic
 
28
                    }
 
29
                }
 
30
            }
 
31
            QIconItem {
 
32
                id: iconItem
 
33
                width: 64; height: 64
 
34
                y: 10; anchors.horizontalCenter: parent.horizontalCenter
 
35
                icon: decoration
 
36
            }
 
37
            Text {
 
38
                anchors { top: iconItem.bottom; horizontalCenter: parent.horizontalCenter }
 
39
                text: display
 
40
                width: parent.width - 8
 
41
                elide: Text.ElideRight
 
42
                horizontalAlignment: Text.AlignHCenter
 
43
            }
 
44
            MouseArea {
 
45
                anchors.fill: parent
 
46
                hoverEnabled: true
 
47
                onClicked: {
 
48
                    var point = mapToItem(gridView, mouse.x, mouse.y)
 
49
                    var index = gridView.indexAt(point.x, point.y)
 
50
                    gridView.currentIndex = index
 
51
 
 
52
                    var modelIndex = filterModel.modelIndex(index)
 
53
                    if (hasModelChildren) {
 
54
                        filterModel.rootIndex = modelIndex
 
55
                    } else {
 
56
                        plasmaModel.runIndex(modelIndex)
 
57
                    }
 
58
                }
 
59
                onEntered: background.opacity = 0.5
 
60
                onExited: background.opacity = 0
 
61
            }
 
62
        }
 
63
    }
 
64
 
 
65
    Component {
 
66
        id: appHighlight
 
67
        Rectangle {
 
68
            radius: 5
 
69
            border.color: "black"
 
70
            border.width: 2
 
71
        }
 
72
    }
 
73
 
 
74
    Component {
 
75
        id: backBar
 
76
 
 
77
        Rectangle {
 
78
            height: backButton.height + 8
 
79
            width: parent.width
 
80
            color: "transparent"
 
81
 
 
82
            PushButton {
 
83
                id: backButton
 
84
                anchors.verticalCenter: parent.verticalCenter
 
85
                x: 4
 
86
                text: i18n("Back")
 
87
                onClicked: {
 
88
                    filterModel.rootIndex = filterModel.parentModelIndex
 
89
                }
 
90
            }
 
91
        }
 
92
    }
 
93
 
 
94
    VisualDataModel {
 
95
        id: filterModel
 
96
        model: plasmaModel
 
97
        delegate: appDelegate
 
98
    }
 
99
 
 
100
    GridView {
 
101
        id: gridView
 
102
        anchors.fill: parent
 
103
        cellWidth: 206; cellHeight: 106
 
104
        header: backBar
 
105
        highlight: appHighlight
 
106
        focus: true
 
107
        model: filterModel
 
108
    }
 
109
}