summaryrefslogtreecommitdiff
path: root/sowatchui/qml/WatchPage.qml
blob: a47faf8dbf7a53415d04325f7c7945c9aaaf8098 (plain)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import QtQuick 1.1
import com.nokia.meego 1.1
import com.nokia.extras 1.1
import com.javispedro.sowatch 1.0

Page {
	id: watchPage
	anchors.leftMargin: UiConstants.DefaultMargin
	anchors.rightMargin: UiConstants.DefaultMargin
	orientationLock: PageOrientation.LockPortrait

	property string configKey;
	property url configQmlUrl;

	tools: ToolBarLayout {
		ToolIcon {
			id: backToolIcon
			platformIconId: "toolbar-back"
			anchors.left: parent.left
			onClicked: pageStack.pop()
		}
		ToolIcon {
			id: menuToolIcon
			platformIconId: "toolbar-view-menu"
			anchors.right: parent.right
			onClicked: (watchMenu.status === DialogStatus.Closed) ? watchMenu.open() : watchMenu.close();
		}
	}

	Menu {
		id: watchMenu
		MenuLayout {
			MenuItem {
				text: qsTr("Remove watch")
				onClicked: {
					watchMenu.close();
					watches.removeWatch(watchPage.configKey);
					pageStack.pop();
				}
			}
		}
	}

	Menu {
		id: watchletMenu
		property string watchlet;
		property url watchletConfigQmlUrl;
		MenuLayout {
			MenuItem {
				text: qsTr("Move up")
				onClicked: watchletsModel.moveWatchletUp(watchletMenu.watchlet)
			}
			MenuItem {
				text: qsTr("Move down")
				onClicked: watchletsModel.moveWatchletDown(watchletMenu.watchlet)
			}
			MenuItem {
				text: qsTr("Configure watchlet...")
				onClicked: pageStack.push(watchletMenu.watchletConfigQmlUrl, {'configKey': configKey})
				visible: watchletMenu.watchletConfigQmlUrl != ""
			}
			MenuItem {
				text: qsTr("Remove watchlet")
				onClicked: watchletsModel.removeWatchlet(watchletMenu.watchlet)
			}
		}
	}

	AddWatchletSheet {
		id: addWatchletSheet
		configKey: watchPage.configKey
	}

	GConfKey {
		id: nameKey
		key: configKey + "/name"
	}

	Flickable {
		id: mainFlickable
		anchors.fill: parent
		contentHeight: mainColumn.height

		Column {
			id: mainColumn
			width: parent.width

			Item {
				id: enableItem
				width: parent.width
				height: UiConstants.ListItemHeightDefault

				GConfKey {
					id: enableKey
					key: configKey + "/enable"
				}
				Label {
					text: qsTr("Enabled")
					font: UiConstants.TitleFont
					anchors.verticalCenter: parent.verticalCenter
					anchors.left: parent.left
				}
				Switch {
					id: enableSwitch
					anchors.verticalCenter: parent.verticalCenter
					anchors.right: parent.right
					checked: enableKey.value
					onCheckedChanged: enableKey.value = checked
				}
			}

			GroupHeader {
				width: parent.width
				text: "Watch settings"
				visible: configQmlLoader.status === Loader.Ready
			}

			Loader {
				id: configQmlLoader
				source: configQmlUrl
				width: parent.width
				onLoaded: item.configKey = configKey;
			}

			GroupHeader {
				width: parent.width
				text: "Notification sources"
				visible: configQmlLoader.status === Loader.Ready
			}

			ListView {
				id: providersListView
				interactive: false
				width: parent.width
				height: UiConstants.ListItemHeightDefault * count
				model: ProvidersModel {
					id: providersModel
					configKey: watchPage.configKey
				}
				delegate: ListDelegate {
					CheckBox {
						anchors.verticalCenter: parent.verticalCenter
						anchors.right: parent.right
						checked: model.enabled
						onCheckedChanged: providersModel.setProviderEnabled(model.name, checked);
					}
				}
			}

			GroupHeader {
				width: parent.width
				text: "Watchlets"
				visible: configQmlLoader.status === Loader.Ready
			}

			ListView {
				id: watchletsListView
				interactive: false
				width: parent.width
				height: UiConstants.ListItemHeightDefault * count
				model: ConfiguredWatchletsModel {
					id: watchletsModel
					configKey: watchPage.configKey
					displayUnadded: false
				}

				delegate: ListDelegate {
					onClicked: {
						watchletMenu.watchlet = model.name;
						watchletMenu.watchletConfigQmlUrl = model.configQmlUrl;
						watchletMenu.open();
					}
				}
			}

			Button {
				anchors.horizontalCenter: parent.horizontalCenter
				text: qsTr("Add new watchlet")
				onClicked: addWatchletSheet.open()
			}
		}
	}
	ScrollDecorator {
		flickableItem: mainFlickable
	}
}