Changeset View
Changeset View
Standalone View
Standalone View
src/qml/GridBrowserView.qml
Show First 20 Lines • Show All 96 Lines • ▼ Show 20 Line(s) | 94 | FocusScope { | |||
---|---|---|---|---|---|
97 | Layout.fillWidth: true | 97 | Layout.fillWidth: true | ||
98 | 98 | | |||
99 | clip: true | 99 | clip: true | ||
100 | 100 | | |||
101 | GridView { | 101 | GridView { | ||
102 | id: contentDirectoryView | 102 | id: contentDirectoryView | ||
103 | anchors.topMargin: 20 | 103 | anchors.topMargin: 20 | ||
104 | 104 | | |||
105 | focus: true | | |||
106 | activeFocusOnTab: true | 105 | activeFocusOnTab: true | ||
107 | keyNavigationEnabled: true | 106 | keyNavigationEnabled: true | ||
108 | 107 | | |||
109 | anchors.fill: parent | 108 | anchors.fill: parent | ||
110 | 109 | | |||
111 | ScrollBar.vertical: ScrollBar { | 110 | ScrollBar.vertical: ScrollBar { | ||
112 | id: scrollBar | 111 | id: scrollBar | ||
113 | } | 112 | } | ||
114 | boundsBehavior: Flickable.StopAtBounds | 113 | boundsBehavior: Flickable.StopAtBounds | ||
115 | 114 | | |||
115 | currentIndex: -1 | ||||
116 | | ||||
116 | TextMetrics { | 117 | TextMetrics { | ||
117 | id: secondaryLabelSize | 118 | id: secondaryLabelSize | ||
118 | text: 'example' | 119 | text: 'example' | ||
119 | } | 120 | } | ||
120 | 121 | | |||
121 | ScrollHelper { | 122 | ScrollHelper { | ||
122 | id: scrollHelper | 123 | id: scrollHelper | ||
123 | flickable: contentDirectoryView | 124 | flickable: contentDirectoryView | ||
124 | anchors.fill: contentDirectoryView | 125 | anchors.fill: contentDirectoryView | ||
125 | } | 126 | } | ||
126 | 127 | | |||
127 | cellWidth: elisaTheme.gridDelegateWidth | 128 | cellWidth: elisaTheme.gridDelegateWidth | ||
128 | cellHeight: delegateDisplaySecondaryText ? | 129 | cellHeight: delegateDisplaySecondaryText ? | ||
129 | elisaTheme.gridDelegateHeight : | 130 | elisaTheme.gridDelegateHeight : | ||
130 | elisaTheme.gridDelegateHeight - (secondaryLabelSize.boundingRect.height - secondaryLabelSize.boundingRect.y) | 131 | elisaTheme.gridDelegateHeight - (secondaryLabelSize.boundingRect.height - secondaryLabelSize.boundingRect.y) | ||
131 | 132 | | |||
132 | delegate: GridBrowserDelegate { | 133 | delegate: GridBrowserDelegate { | ||
133 | width: contentDirectoryView.cellWidth | 134 | width: contentDirectoryView.cellWidth | ||
134 | height: contentDirectoryView.cellHeight | 135 | height: contentDirectoryView.cellHeight | ||
135 | 136 | | |||
136 | focus: true | 137 | focus: true | ||
137 | 138 | | |||
139 | isSelected: contentDirectoryView.currentIndex === index | ||||
140 | | ||||
138 | isPartial: false | 141 | isPartial: false | ||
139 | 142 | | |||
140 | mainText: model.display | 143 | mainText: model.display | ||
141 | secondaryText: if (gridView.delegateDisplaySecondaryText) {model.secondaryText} else {""} | 144 | secondaryText: if (gridView.delegateDisplaySecondaryText) {model.secondaryText} else {""} | ||
142 | imageUrl: (model && model.imageUrl && model.imageUrl.toString() !== "" ? model.imageUrl : defaultIcon) | 145 | imageUrl: (model && model.imageUrl && model.imageUrl.toString() !== "" ? model.imageUrl : defaultIcon) | ||
143 | shadowForImage: (model && model.imageUrl && model.imageUrl.toString() !== "" ? true : false) | 146 | shadowForImage: (model && model.imageUrl && model.imageUrl.toString() !== "" ? true : false) | ||
144 | databaseId: model.databaseId | 147 | databaseId: model.databaseId | ||
145 | delegateDisplaySecondaryText: gridView.delegateDisplaySecondaryText | 148 | delegateDisplaySecondaryText: gridView.delegateDisplaySecondaryText | ||
146 | 149 | | |||
147 | onEnqueue: gridView.enqueue(databaseId, name) | 150 | onEnqueue: gridView.enqueue(databaseId, name) | ||
148 | onReplaceAndPlay: gridView.replaceAndPlay(databaseId, name) | 151 | onReplaceAndPlay: gridView.replaceAndPlay(databaseId, name) | ||
149 | onOpen: gridView.open(model.display, model.secondaryText, | 152 | onOpen: gridView.open(model.display, model.secondaryText, | ||
150 | (model && model.imageUrl && model.imageUrl.toString() !== "" ? model.imageUrl : defaultIcon), | 153 | (model && model.imageUrl && model.imageUrl.toString() !== "" ? model.imageUrl : defaultIcon), | ||
151 | model.databaseId, model.dataType) | 154 | model.databaseId, model.dataType) | ||
152 | onSelected: { | 155 | onSelected: { | ||
153 | forceActiveFocus() | 156 | forceActiveFocus() | ||
154 | contentDirectoryView.currentIndex = model.index | 157 | contentDirectoryView.currentIndex = model.index | ||
155 | } | 158 | } | ||
159 | | ||||
160 | onActiveFocusChanged: { | ||||
161 | if (activeFocus && contentDirectoryView.currentIndex !== model.index) { | ||||
162 | contentDirectoryView.currentIndex = model.index | ||||
163 | } | ||||
164 | } | ||||
156 | } | 165 | } | ||
157 | } | 166 | } | ||
158 | } | 167 | } | ||
159 | } | 168 | } | ||
160 | } | 169 | } |