Changeset View
Changeset View
Standalone View
Standalone View
src/context/context_qml_package/contents/ui/main.qml
Show All 23 Lines | |||||
24 | Item { | 24 | Item { | ||
25 | id: root | 25 | id: root | ||
26 | 26 | | |||
27 | Component.onCompleted: Context.debug("Context created") | 27 | Component.onCompleted: Context.debug("Context created") | ||
28 | 28 | | |||
29 | ColumnLayout { | 29 | ColumnLayout { | ||
30 | anchors.fill: parent | 30 | anchors.fill: parent | ||
31 | 31 | | |||
32 | ListView { | 32 | Flickable { | ||
33 | id: appletListView | 33 | id: appletFlickable | ||
34 | 34 | | |||
35 | signal scrollToApplet(string id) | 35 | signal scrollToApplet(string id) | ||
36 | 36 | | |||
37 | Layout.alignment: Qt.AlignTop | 37 | Layout.alignment: Qt.AlignTop | ||
38 | Layout.fillHeight: true | 38 | Layout.fillHeight: true | ||
39 | Layout.fillWidth: true | 39 | Layout.fillWidth: true | ||
40 | spacing: Kirigami.Units.smallSpacing | 40 | contentWidth: scrollBar.visible ? width - scrollBar.width : width | ||
41 | displayMarginEnd: 100000 | 41 | contentHeight: appletColumn.height | ||
42 | displayMarginBeginning: 100000 | 42 | flickableDirection: Flickable.VerticalFlick | ||
43 | clip: true | 43 | focus: true | ||
44 | 44 | | |||
45 | model: AppletProxyModel | 45 | Keys.onUpPressed: scrollBar.decrease() | ||
46 | Keys.onDownPressed: scrollBar.increase() | ||||
46 | 47 | | |||
47 | ScrollBar.vertical: ScrollBar { id: scrollBar } | 48 | ScrollBar.vertical: ScrollBar { id: scrollBar } | ||
48 | 49 | | |||
50 | Column { | ||||
51 | id: appletColumn | ||||
52 | | ||||
53 | width: parent.width | ||||
54 | spacing: Kirigami.Units.smallSpacing | ||||
55 | | ||||
56 | Repeater { | ||||
57 | model: AppletProxyModel | ||||
58 | | ||||
49 | delegate: Loader { | 59 | delegate: Loader { | ||
50 | width: scrollBar.visible ? parent.width - scrollBar.width : parent.width | 60 | width: appletColumn.width | ||
51 | active: true | 61 | active: true | ||
52 | asynchronous: true | 62 | asynchronous: false | ||
53 | 63 | | |||
54 | function initialize() { | 64 | function initialize() { | ||
55 | setSource(mainscript, { | 65 | setSource(mainscript, { | ||
56 | "name": name, | 66 | "name": name, | ||
57 | "appletId": appletId, | 67 | "appletId": appletId, | ||
58 | "iconSource": icon, | 68 | "iconSource": icon, | ||
59 | "collapsed": collapsed, | 69 | "collapsed": collapsed, | ||
60 | "contentHeight": contentHeight, | 70 | "contentHeight": contentHeight, | ||
61 | "packagePath": packagePath, | | |||
62 | "configEnabled": Qt.binding(function() { return appletToolbar.configEnabled; } ) | 71 | "configEnabled": Qt.binding(function() { return appletToolbar.configEnabled; } ) | ||
63 | }); | 72 | }); | ||
64 | } | 73 | } | ||
65 | 74 | | |||
66 | Component.onCompleted: initialize() | 75 | Component.onCompleted: initialize() | ||
67 | 76 | | |||
68 | onStatusChanged: { | 77 | onStatusChanged: { | ||
69 | if (status == Loader.Error) { | 78 | if (status == Loader.Error) { | ||
Show All 11 Lines | 87 | Connections { | |||
81 | onDataChanged: { | 90 | onDataChanged: { | ||
82 | if (!!mainscript && mainscript != source) { | 91 | if (!!mainscript && mainscript != source) { | ||
83 | Context.debug("Data changed for applet " + appletId); | 92 | Context.debug("Data changed for applet " + appletId); | ||
84 | initialize(); | 93 | initialize(); | ||
85 | } | 94 | } | ||
86 | } | 95 | } | ||
87 | } | 96 | } | ||
88 | Connections { | 97 | Connections { | ||
89 | target: appletListView | 98 | target: appletFlickable | ||
90 | 99 | | |||
91 | onScrollToApplet: { | 100 | onScrollToApplet: { | ||
92 | if (id == appletId) { | 101 | if (id == appletId) { | ||
93 | appletListView.positionViewAtIndex(index, ListView.Beginning); | 102 | appletFlickable.contentY = y; | ||
94 | Context.debug("Scroll to applet: " + appletId); | 103 | Context.debug("Scroll to applet: " + appletId); | ||
95 | } | 104 | } | ||
96 | } | 105 | } | ||
97 | } | 106 | } | ||
98 | } | 107 | } | ||
99 | } | 108 | } | ||
109 | } | ||||
110 | } | ||||
100 | AppletToolbarAddItem { | 111 | AppletToolbarAddItem { | ||
101 | id: appletToolbarAddItem | 112 | id: appletToolbarAddItem | ||
102 | 113 | | |||
103 | Layout.fillWidth: true | 114 | Layout.fillWidth: true | ||
104 | height: Kirigami.Units.iconSizes.enormous | 115 | height: Kirigami.Units.iconSizes.enormous | ||
105 | visible: appletToolbar.configEnabled | 116 | visible: appletToolbar.configEnabled | ||
106 | } | 117 | } | ||
107 | AppletToolbar { | 118 | AppletToolbar { | ||
108 | id: appletToolbar | 119 | id: appletToolbar | ||
109 | 120 | | |||
110 | contextRoot: root | 121 | contextRoot: root | ||
111 | addItem: appletToolbarAddItem | 122 | addItem: appletToolbarAddItem | ||
112 | listView: appletListView | 123 | flickable: appletFlickable | ||
113 | Layout.alignment: Qt.AlignBottom | 124 | Layout.alignment: Qt.AlignBottom | ||
114 | Layout.fillWidth: true | 125 | Layout.fillWidth: true | ||
115 | } | 126 | } | ||
116 | } | 127 | } | ||
117 | } | 128 | } |