Merge lp:~osomon/webbrowser-app/itemSelector into lp:webbrowser-app

Proposed by Olivier Tilloy
Status: Merged
Approved by: Günter Schwann
Approved revision: 102
Merged at revision: 97
Proposed branch: lp:~osomon/webbrowser-app/itemSelector
Merge into: lp:webbrowser-app
Diff against target: 80 lines (+65/-0)
2 files modified
src/Ubuntu/Browser/Browser.qml (+2/-0)
src/Ubuntu/Browser/ItemSelector.qml (+63/-0)
To merge this branch: bzr merge lp:~osomon/webbrowser-app/itemSelector
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Günter Schwann (community) Approve
Review via email: mp+154704@code.launchpad.net

Commit message

Add support for <select> dropdowns.

Description of the change

The bug was originally reported for the dropdowns at http://juju.ubuntu.com/survey. This branch fixes it, however it uncovered another bug (a crasher), which makes this page not usable (and thus not a good one for testing).

The following page is suitable for testing the functionality though: http://mdn.mozillademos.org/en-US/docs/HTML/Element/optgroup$samples/Example?revision=344959

A known issue is that when an option is selected, the dropdown widget on the page is not always updated to display the current selection, until clicking somewhere else on the page. This seems to be an issue in QtWebkit itself though, as I’m observing the same problem with the QML MiniBrowser built from WebKit’s source tree. I’ll try to get confirmation from the QtWebKit developers.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Note: a minor issue I’m seeing is a binding loop warning issued when the item selector is shown:

    file:///home/osomon/dev/phablet/browser/itemSelector/src/Ubuntu/Browser/Browser.qml:166:36: QML ItemSelector: Binding loop detected for property "contentHeight"

This is harmless though, and I haven’t found a way to get rid of it yet. I think it can be addressed separately.

Revision history for this message
Günter Schwann (schwann) wrote :

In case there is no grouping - should the section delegate have height 0, and be set visible false?

After every model.accept(), the itemSelector would become invisible (I guess). So in that case every model.accept() would be followed by a model.reject(). Is that correct?

Revision history for this message
Olivier Tilloy (osomon) wrote :

> In case there is no grouping - should the section delegate have height 0, and
> be set visible false?

Not needed: the listview internals already take care of that, so if there is no grouping the section delegates won’t even be instantiated. You can test it with e.g. http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select.

> After every model.accept(), the itemSelector would become invisible (I guess).
> So in that case every model.accept() would be followed by a model.reject(). Is
> that correct?

No need to call selectorModel.reject(). Calling selectorModel.accept() already takes care of destroying the component and communicating the selected value back to the <select> element.

Revision history for this message
Günter Schwann (schwann) wrote :

I see that warning: src/Ubuntu/Browser/Browser.qml:166:36: QML ItemSelector: Binding loop detected for property "contentHeight"

And the selector only gets updated, once I click somewhere in the document.

Revision history for this message
Günter Schwann (schwann) wrote :

And good to know the first issues are no issues :)

Revision history for this message
Olivier Tilloy (osomon) wrote :

> I see that warning: src/Ubuntu/Browser/Browser.qml:166:36: QML ItemSelector:
> Binding loop detected for property "contentHeight"
>
> And the selector only gets updated, once I click somewhere in the document.

Yes, known issues. See the description of the MR, and my first comment.

101. By Olivier Tilloy

Use an intermediate property to fool the QML engine and get rid of a binding loop warning.

Revision history for this message
Olivier Tilloy (osomon) wrote :

> Note: a minor issue I’m seeing is a binding loop warning issued when the item
> selector is shown:
>
> file:///home/osomon/dev/phablet/browser/itemSelector/src/Ubuntu/Browser/Br
> owser.qml:166:36: QML ItemSelector: Binding loop detected for property
> "contentHeight"
>
> This is harmless though, and I haven’t found a way to get rid of it yet. I
> think it can be addressed separately.

Revision 101 fixes that.

102. By Olivier Tilloy

Get rid of a useless id.

Revision history for this message
Günter Schwann (schwann) wrote :

fine now

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/Ubuntu/Browser/Browser.qml'
2--- src/Ubuntu/Browser/Browser.qml 2013-03-14 09:27:06 +0000
3+++ src/Ubuntu/Browser/Browser.qml 2013-03-21 16:47:19 +0000
4@@ -163,6 +163,8 @@
5 }
6 }
7
8+ experimental.itemSelector: ItemSelector {}
9+
10 onUrlChanged: {
11 if (!browser.chromeless) {
12 chromeLoader.item.url = url
13
14=== added file 'src/Ubuntu/Browser/ItemSelector.qml'
15--- src/Ubuntu/Browser/ItemSelector.qml 1970-01-01 00:00:00 +0000
16+++ src/Ubuntu/Browser/ItemSelector.qml 2013-03-21 16:47:19 +0000
17@@ -0,0 +1,63 @@
18+/*
19+ * Copyright 2013 Canonical Ltd.
20+ *
21+ * This file is part of webbrowser-app.
22+ *
23+ * webbrowser-app is free software; you can redistribute it and/or modify
24+ * it under the terms of the GNU General Public License as published by
25+ * the Free Software Foundation; version 3.
26+ *
27+ * webbrowser-app is distributed in the hope that it will be useful,
28+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
29+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30+ * GNU General Public License for more details.
31+ *
32+ * You should have received a copy of the GNU General Public License
33+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
34+ */
35+
36+import QtQuick 2.0
37+import Ubuntu.Components 0.1
38+import Ubuntu.Components.ListItems 0.1 as ListItem
39+import Ubuntu.Components.Popups 0.1
40+
41+Popover {
42+ id: itemSelector
43+
44+ property QtObject selectorModel: model
45+
46+ caller: parent
47+ contentWidth: Math.min(parent.width - units.gu(10), units.gu(40))
48+ property real listContentHeight: 0 // intermediate property to avoid binding loop
49+ contentHeight: Math.min(parent.height - units.gu(10), listContentHeight)
50+
51+ ListView {
52+ clip: true
53+ width: itemSelector.contentWidth
54+ height: itemSelector.contentHeight
55+
56+ model: selectorModel.items
57+
58+ delegate: ListItem.Standard {
59+ text: model.text
60+ enabled: model.enabled
61+ selected: model.selected
62+ onClicked: selectorModel.accept(model.index)
63+ }
64+
65+ section.property: "group"
66+ section.delegate: ListItem.Header {
67+ text: section
68+ }
69+
70+ onContentHeightChanged: itemSelector.listContentHeight = contentHeight
71+ }
72+
73+ Component.onCompleted: show()
74+
75+ onVisibleChanged: {
76+ if (!visible) {
77+ selectorModel.reject()
78+ }
79+ }
80+}

Subscribers

People subscribed via source and target branches

to status/vote changes: