Repository navigation
Expand file tree
/
Copy pathLanguageListPage.qml
More file actions
71 lines (59 loc) · 1.97 KB
/
Copy pathLanguageListPage.qml
File metadata and controls
71 lines (59 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import QtQuick 2.0
import Ubuntu.Components 0.1
import Ubuntu.Components.ListItems 0.1 as ListItem
import "JS.js" as JS
Page {
id: page
property string url: ""
property int maxLang: 1
onUrlChanged: listModel.source= (url === "") ? "" : url + oAuthTokenGetter.firstGet
LanguageListModel {
id: listModel
source: (url === "") ? "" : url + oAuthTokenGetter.firstGet
onDone: {
maxLang = 1;
for (var i = 0; i < listModel.count; i++) {
maxLang = Math.max(maxLang, Math.sqrt(listModel.model.get(i).value))
}
repeater.update()
}
}
SideBar {
id: sideBar
expanded: page.width > units.gu(80)
}
Flickable {
anchors.right: parent.right
anchors.left: sideBar.right
anchors.bottom: parent.bottom
height: parent.height
contentWidth: width
contentHeight: column.childrenRect.height
flickableDirection: Flickable.VerticalFlick
Column {
id: column
anchors.fill: parent
Repeater {
id: repeater
model: listModel.model
delegate: UbuntuShape {
anchors.left: parent.left
radius: "medium"
color: model.key === undefined ? "white" : JS.getLanguageColor(model.key)
height: units.gu(10)
width: page.width * Math.sqrt(model.value) / maxLang
Label {
anchors.left: contentWidth > page.width - parent.width ? parent.left : parent.right
anchors.verticalCenter: parent.verticalCenter
text: model.key === undefined ? "" : model.key
}
}
}
}
}
tools: ToolbarItems {
MeToolbarButton {}
DebugActionToolbarButton {}
SideBarButton{visible: !sideBar.expanded}
}
}