Merge lp:~tiagosh/unity-2d/unity-2d-shell-homelens into lp:unity-2d

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 952
Merged at revision: 910
Proposed branch: lp:~tiagosh/unity-2d/unity-2d-shell-homelens
Merge into: lp:unity-2d
Diff against target: 341 lines (+92/-64)
9 files modified
libunity-2d-private/src/lens.cpp (+15/-3)
libunity-2d-private/src/lenses.cpp (+8/-5)
libunity-2d-private/src/lenses.h (+2/-0)
shell/app/shelldeclarativeview.cpp (+7/-0)
shell/app/shelldeclarativeview.h (+2/-0)
shell/dash/Dash.qml (+25/-17)
shell/dash/LensBar.qml (+20/-19)
shell/dash/LensView.qml (+7/-6)
shell/dash/RendererGrid.qml (+6/-14)
To merge this branch: bzr merge lp:~tiagosh/unity-2d/unity-2d-shell-homelens
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
Gerry Boland Pending
Michał Sawicz Pending
Review via email: mp+92571@code.launchpad.net

This proposal supersedes a proposal from 2012-01-31.

Description of the change

This MR replaces the old home lens by the new one provided by unity.
The following libqtdee branch must be installed in order to compile this branch: lp:~tiagosh/dee-qt/dee-qt-local-models .

To post a comment you must log in.
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

Hi Tiago,
great work, thanks for this! But we need tests to be able to accept this.

I think testing the following will be sufficient:
1. open dash, check somehow that this Home lens is showing
2. open dash, type a character, check search results appear in Home lens

Consult the existing tests to get an idea where to start. Getting started guide here:
https://wiki.ubuntu.com/Unity2DTestability
and this old test of mine might help you get started. Not it's for unity-2d, so things have changed a little
https://bazaar.launchpad.net/~gerboland/unity-2d/dash-test/view/head:/tests/places/show_hide_tests.rb

Ping me if you need a hand
-G

review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

Hey, this also looks like it could go into lp:unity-2d almost without modification. As it's a goal to have as small a diff between trunk and shell when we get to merging it, could you please have a MR against lp:unity-2d for this?

review: Needs Information
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

As discussed, let's wait with this until shell gets merged into trunk.

review: Abstain
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

Hey,
this is great work, thank you Tiago. It requires some fixes though:
- first, your patch to dee-qt may need fixing. I'm blaming it for these problems:
    - on first run, all the icons were ? icons with no text.
    - bug I can reproduce:
      1. I hope dash. I search for something, I get correct results
      2. if I empty search box, everything is still good
      3. I switch to applications lens, everything good
      4. I switch back to home lens, I get many ? icons everywhere with no text (just like first run)
  But the bug may be here. I've not tried to dig yet.
  Here's screengrab to show you: https://imgur.com/wTMaN

- possibly as a consequence, I get these unity-2d errors when viewing Home lens
[WARNING] shell/dash/RendererGrid.qml:92: ReferenceError: Can't find variable: column_0
[WARNING] shell/dash/RendererGrid.qml:92: ReferenceError: Can't find variable: display

[WARNING] shell/dash/LensView.qml:87: Unable to assign [undefined] to QString iconHint
[WARNING] shell/dash/LensView.qml:88: Unable to assign [undefined] to QString rendererName
[WARNING] shell/dash/LensView.qml:86: Unable to assign [undefined] to QString name
   <repeated many times>

[WARNING] shell/dash/RendererGrid.qml:92: ReferenceError: Can't find variable: column_0
   <repeated many times>

But your code looks clean, nothing obvious appears wrong to me.

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

Doesn't merge cleanly with lp:~unity-2d-team/unity-2d/unity-2d-shell Can you remerge it?

review: Needs Fixing
Revision history for this message
Albert Astals Cid (aacid) : Posted in a previous version of this proposal
review: Approve (fun)
Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

With fun i mean "Functional" :/

I still have to look at the code, there is also
unity-2d-shell: [CRITICAL] dee: dee_model_get_first_iter: assertion `DEE_IS_MODEL (self)' failed
unity-2d-shell: [CRITICAL] dee: dee_model_get_last_iter: assertion `DEE_IS_MODEL (self)' failed
unity-2d-shell: [CRITICAL] dee: dee_model_get_first_iter: assertion `DEE_IS_MODEL (self)' failed
unity-2d-shell: [CRITICAL] dee: dee_model_get_last_iter: assertion `DEE_IS_MODEL (self)' failed
unity-2d-shell: [CRITICAL] dee: dee_model_get_first_iter: assertion `DEE_IS_MODEL (self)' failed
unity-2d-shell: [CRITICAL] dee: dee_model_get_last_iter: assertion `DEE_IS_MODEL (self)' failed
unity-2d-shell: [CRITICAL] dee: dee_model_get_first_iter: assertion `DEE_IS_MODEL (self)' failed
unity-2d-shell: [CRITICAL] dee: dee_model_get_last_iter: assertion `DEE_IS_MODEL (self)' failed

That thiago says that can't remove but are somehow scary for my pov

Revision history for this message
Albert Astals Cid (aacid) wrote : Posted in a previous version of this proposal

And with Thiago i mean Tiago

Revision history for this message
Florian Boucault (fboucault) wrote : Posted in a previous version of this proposal

Please resubmit the MR against lp:unity-2d

Revision history for this message
Albert Astals Cid (aacid) wrote :

Had a more thorough look at those warnings and they really seem to come from unity libraries themselves without much interaction in our side.

So Approve it is

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'libunity-2d-private/src/lens.cpp'
--- libunity-2d-private/src/lens.cpp 2011-12-14 22:45:04 +0000
+++ libunity-2d-private/src/lens.cpp 2012-02-10 20:42:23 +0000
@@ -224,9 +224,21 @@
224224
225 m_filters = new Filters(m_unityLens->filters, this);225 m_filters = new Filters(m_unityLens->filters, this);
226226
227 m_results->setName(QString::fromStdString(m_unityLens->results()->swarm_name));227 if (QString::fromStdString(m_unityLens->results()->swarm_name) == QString(":local")) {
228 m_globalResults->setName(QString::fromStdString(m_unityLens->global_results()->swarm_name));228 m_results->setModel(m_unityLens->results()->model());
229 m_categories->setName(QString::fromStdString(m_unityLens->categories()->swarm_name));229 } else {
230 m_results->setName(QString::fromStdString(m_unityLens->results()->swarm_name));
231 }
232 if (QString::fromStdString(m_unityLens->global_results()->swarm_name) == QString(":local")) {
233 m_globalResults->setModel(m_unityLens->global_results()->model());
234 } else {
235 m_globalResults->setName(QString::fromStdString(m_unityLens->global_results()->swarm_name));
236 }
237 if (QString::fromStdString(m_unityLens->categories()->swarm_name) == QString(":local")) {
238 m_categories->setModel(m_unityLens->categories()->model());
239 } else {
240 m_categories->setName(QString::fromStdString(m_unityLens->categories()->swarm_name));
241 }
230242
231 /* Property change signals */243 /* Property change signals */
232 m_unityLens->id.changed.connect(sigc::mem_fun(this, &Lens::idChanged));244 m_unityLens->id.changed.connect(sigc::mem_fun(this, &Lens::idChanged));
233245
=== modified file 'libunity-2d-private/src/lenses.cpp'
--- libunity-2d-private/src/lenses.cpp 2011-09-09 10:15:14 +0000
+++ libunity-2d-private/src/lenses.cpp 2012-02-10 20:42:23 +0000
@@ -27,6 +27,8 @@
2727
28// libunity-core28// libunity-core
29#include <UnityCore/FilesystemLenses.h>29#include <UnityCore/FilesystemLenses.h>
30#include <UnityCore/HomeLens.h>
31#include <unity2dtr.h>
3032
31Lenses::Lenses(QObject *parent) :33Lenses::Lenses(QObject *parent) :
32 QAbstractListModel(parent)34 QAbstractListModel(parent)
@@ -36,17 +38,18 @@
36 roles[Lenses::RoleVisible] = "visible";38 roles[Lenses::RoleVisible] = "visible";
37 setRoleNames(roles);39 setRoleNames(roles);
3840
41 m_homeLens = new unity::dash::HomeLens(u2dTr("Home").toStdString(), u2dTr("Home screen").toStdString(), u2dTr("Search").toStdString());
39 m_unityLenses = new unity::dash::FilesystemLenses("/usr/share/unity/lenses");42 m_unityLenses = new unity::dash::FilesystemLenses("/usr/share/unity/lenses");
40 for (unsigned int i=0; i<m_unityLenses->count(); i++) {43 m_homeLens->AddLenses(*m_unityLenses);
41 unity::dash::Lens::Ptr unityLens = m_unityLenses->GetLensAtIndex(i);44 m_homeLens->lens_added.connect(sigc::mem_fun(this, &Lenses::onLensAdded));
42 addUnityLens(unityLens, i);45 unity::dash::HomeLens::Ptr homeLensPtr(m_homeLens);
43 }46 addUnityLens(homeLensPtr, 0);
44 m_unityLenses->lens_added.connect(sigc::mem_fun(this, &Lenses::onLensAdded));
45}47}
4648
47Lenses::~Lenses()49Lenses::~Lenses()
48{50{
49 delete m_unityLenses;51 delete m_unityLenses;
52 delete m_homeLens;
50}53}
5154
52int Lenses::rowCount(const QModelIndex& parent) const55int Lenses::rowCount(const QModelIndex& parent) const
5356
=== modified file 'libunity-2d-private/src/lenses.h'
--- libunity-2d-private/src/lenses.h 2011-08-11 14:38:51 +0000
+++ libunity-2d-private/src/lenses.h 2012-02-10 20:42:23 +0000
@@ -26,6 +26,7 @@
2626
27// libunity-core27// libunity-core
28#include <UnityCore/Lens.h>28#include <UnityCore/Lens.h>
29#include <UnityCore/HomeLens.h>
2930
30namespace unity31namespace unity
31{32{
@@ -64,6 +65,7 @@
6465
65private:66private:
66 unity::dash::Lenses* m_unityLenses;67 unity::dash::Lenses* m_unityLenses;
68 unity::dash::HomeLens* m_homeLens;
67 QList<Lens*> m_lenses;69 QList<Lens*> m_lenses;
6870
69 void addUnityLens(unity::dash::Lens::Ptr unity_lens, int index);71 void addUnityLens(unity::dash::Lens::Ptr unity_lens, int index);
7072
=== modified file 'shell/app/shelldeclarativeview.cpp'
--- shell/app/shelldeclarativeview.cpp 2012-02-09 12:27:35 +0000
+++ shell/app/shelldeclarativeview.cpp 2012-02-10 20:42:23 +0000
@@ -41,6 +41,7 @@
41#include <QtDBus/QDBusInterface>41#include <QtDBus/QDBusInterface>
42#include <QX11Info>42#include <QX11Info>
43#include <QGraphicsObject>43#include <QGraphicsObject>
44#include <QFileInfo>
4445
45// X1146// X11
46#include <X11/Xlib.h>47#include <X11/Xlib.h>
@@ -188,6 +189,12 @@
188 return m_active;189 return m_active;
189}190}
190191
192bool
193ShellDeclarativeView::haveCustomHomeShortcuts() const
194{
195 return QFileInfo(unity2dDirectory() + "/shell/dash/HomeShortcutsCustomized.qml").exists();
196}
197
191void198void
192ShellDeclarativeView::setDashMode(ShellDeclarativeView::DashMode mode)199ShellDeclarativeView::setDashMode(ShellDeclarativeView::DashMode mode)
193{200{
194201
=== modified file 'shell/app/shelldeclarativeview.h'
--- shell/app/shelldeclarativeview.h 2012-02-09 02:22:19 +0000
+++ shell/app/shelldeclarativeview.h 2012-02-10 20:42:23 +0000
@@ -39,6 +39,7 @@
39 Q_PROPERTY(QString activeLens READ activeLens WRITE setActiveLens NOTIFY activeLensChanged)39 Q_PROPERTY(QString activeLens READ activeLens WRITE setActiveLens NOTIFY activeLensChanged)
40 Q_PROPERTY(bool focus READ hasFocus NOTIFY focusChanged) // overridden to add notify40 Q_PROPERTY(bool focus READ hasFocus NOTIFY focusChanged) // overridden to add notify
41 Q_PROPERTY(bool superKeyHeld READ superKeyHeld NOTIFY superKeyHeldChanged)41 Q_PROPERTY(bool superKeyHeld READ superKeyHeld NOTIFY superKeyHeldChanged)
42 Q_PROPERTY(bool haveCustomHomeShortcuts READ haveCustomHomeShortcuts)
4243
43 /* These two properties and mouse movement tracking on the widget are added here only because44 /* These two properties and mouse movement tracking on the widget are added here only because
44 we need to detect when the mouse is inside the area occupied by the lancher. This should45 we need to detect when the mouse is inside the area occupied by the lancher. This should
@@ -59,6 +60,7 @@
5960
60 /* getters */61 /* getters */
61 bool dashActive() const;62 bool dashActive() const;
63 bool haveCustomHomeShortcuts() const;
62 DashMode dashMode() const;64 DashMode dashMode() const;
63 const QString& activeLens() const;65 const QString& activeLens() const;
64 bool expanded() const;66 bool expanded() const;
6567
=== modified file 'shell/dash/Dash.qml'
--- shell/dash/Dash.qml 2012-02-09 11:22:43 +0000
+++ shell/dash/Dash.qml 2012-02-10 20:42:23 +0000
@@ -106,6 +106,7 @@
106 for (var i=0; i<lenses.rowCount(); i++) {106 for (var i=0; i<lenses.rowCount(); i++) {
107 lenses.get(i).viewType = Lens.Hidden107 lenses.get(i).viewType = Lens.Hidden
108 }108 }
109 declarativeView.activeLens = ""
109 }110 }
110111
111 SpreadMonitor {112 SpreadMonitor {
@@ -133,11 +134,19 @@
133 return134 return
134 }135 }
135136
136 /* To activate lens, we set its viewType to LensView, and then set all
137 other lenses to Hidden */
138 for (var i=0; i<lenses.rowCount(); i++) {137 for (var i=0; i<lenses.rowCount(); i++) {
139 var thislens = lenses.get(i)138 var thislens = lenses.get(i)
140 thislens.viewType = (lens == thislens) ? Lens.LensView : Lens.Hidden139 if (lensId == "home.lens") {
140 if (thislens.id == lensId) {
141 thislens.viewType = Lens.LensView
142 continue
143 }
144 /* When Home is shown, need to notify all other lenses. Those in the global view
145 (in home search results page) are set to HomeView, all others to Hidden */
146 thislens.viewType = (thislens.searchInGlobal) ? Lens.HomeView : Lens.Hidden
147 } else {
148 thislens.viewType = (lens == thislens) ? Lens.LensView : Lens.Hidden
149 }
141 }150 }
142151
143 buildLensPage(lens)152 buildLensPage(lens)
@@ -147,20 +156,19 @@
147156
148 function activateHome() {157 function activateHome() {
149 if (spreadMonitor.shown) return158 if (spreadMonitor.shown) return
150159 if (declarativeView.haveCustomHomeShortcuts) {
151 /* When Home is shown, need to notify all other lenses. Those in the global view160 for (var i=0; i<lenses.rowCount(); i++) {
152 (in home search results page) are set to HomeView, all others to Hidden */161 lenses.get(i).viewType = Lens.Hidden
153 for (var i=0; i<lenses.rowCount(); i++) {162 }
154 var thislens = lenses.get(i)163 pageLoader.setSource("Home.qml")
155 thislens.viewType = (thislens.searchInGlobal) ? Lens.HomeView : Lens.Hidden164 /* Take advantage of the fact that the loaded qml is local and setting
165 the source loads it immediately making pageLoader.item valid */
166 activatePage(pageLoader.item)
167 declarativeView.activeLens = ""
168 dash.active = true
169 } else {
170 activateLens("home.lens")
156 }171 }
157
158 pageLoader.setSource("Home.qml")
159 /* Take advantage of the fact that the loaded qml is local and setting
160 the source loads it immediately making pageLoader.item valid */
161 activatePage(pageLoader.item)
162 declarativeView.activeLens = ""
163 dash.active = true
164 }172 }
165173
166 function activateLensWithOptionFilter(lensId, filterId, optionId) {174 function activateLensWithOptionFilter(lensId, filterId, optionId) {
@@ -304,7 +312,7 @@
304 KeyNavigation.left: search_entry312 KeyNavigation.left: search_entry
305313
306 /* FilterPane is only to be displayed for lenses, not in the home page or Alt+F2 Run page */314 /* FilterPane is only to be displayed for lenses, not in the home page or Alt+F2 Run page */
307 visible: declarativeView.activeLens != "" && declarativeView.activeLens != "commands.lens"315 visible: declarativeView.activeLens != "home.lens" && declarativeView.activeLens != "" && declarativeView.activeLens != "commands.lens"
308 lens: visible && currentPage != undefined ? currentPage.model : undefined316 lens: visible && currentPage != undefined ? currentPage.model : undefined
309317
310 anchors.top: search_entry.anchors.top318 anchors.top: search_entry.anchors.top
311319
=== modified file 'shell/dash/LensBar.qml'
--- shell/dash/LensBar.qml 2012-01-10 13:07:48 +0000
+++ shell/dash/LensBar.qml 2012-02-10 20:42:23 +0000
@@ -93,22 +93,6 @@
93 return undefined93 return undefined
94 }94 }
9595
96 /* Need to manually include the Home lens */
97 LensButton {
98 id: homeLens
99
100 Accessible.name: u2d.tr("home")
101
102 focus: true
103 icon: "artwork/lens-nav-home.svg"
104 onClicked: dash.activateHome()
105 active: ( declarativeView.activeLens == "" )
106 iconWidth: lensBar.iconWidth
107 iconSpacing: lensBar.iconSpacing
108 width: iconWidth+iconSpacing
109 height: lensContainer.height
110 }
111
112 /* Now fetch all other lenses and display */96 /* Now fetch all other lenses and display */
113 Repeater{97 Repeater{
114 id: repeater98 id: repeater
@@ -118,9 +102,26 @@
118 Accessible.name: u2d.tr(item.name)102 Accessible.name: u2d.tr(item.name)
119103
120 /* Heuristic: if iconHint does not contain a '/' then it is an icon name */104 /* Heuristic: if iconHint does not contain a '/' then it is an icon name */
121 icon: item.iconHint.indexOf("/") == -1 ? "image://icons/" + item.iconHint : item.iconHint105 icon: {
122 active: item.viewType == Lens.LensView106 if (item.id == "home.lens") {
123 onClicked: dash.activateLens(item.id)107 return "artwork/lens-nav-home.svg"
108 }
109 item.iconHint.indexOf("/") == -1 ? "image://icons/" + item.iconHint : item.iconHint
110 }
111 active: {
112 /* we need this in order to activate the arrow when using a custom shortcuts file */
113 if (item.id == "home.lens" && declarativeView.activeLens == "") {
114 return true
115 }
116 return item.viewType == Lens.LensView
117 }
118 onClicked: {
119 if (item.id == "home.lens") {
120 dash.activateHome()
121 } else {
122 dash.activateLens(item.id)
123 }
124 }
124 iconWidth: lensBar.iconWidth125 iconWidth: lensBar.iconWidth
125 iconSpacing: lensBar.iconSpacing126 iconSpacing: lensBar.iconSpacing
126 width: iconWidth+iconSpacing127 width: iconWidth+iconSpacing
127128
=== modified file 'shell/dash/LensView.qml'
--- shell/dash/LensView.qml 2012-01-10 10:42:46 +0000
+++ shell/dash/LensView.qml 2012-02-10 20:42:23 +0000
@@ -81,7 +81,7 @@
81 bodyDelegate: Loader {81 bodyDelegate: Loader {
82 visible: category_model.count > 082 visible: category_model.count > 0
83 width: parent.width83 width: parent.width
84 height: visible ? item.contentHeight : 084 height: item ? visible ? item.contentHeight : 0 : 0
8585
86 property string name: model.column_086 property string name: model.column_0
87 property string iconHint: model.column_187 property string iconHint: model.column_1
@@ -119,18 +119,19 @@
119 Binding { target: item; property: "categoryId"; value: categoryId }119 Binding { target: item; property: "categoryId"; value: categoryId }
120 Binding { target: item; property: "category_model"; value: category_model }120 Binding { target: item; property: "category_model"; value: category_model }
121 Binding { target: item; property: "lens"; value: lensView.model }121 Binding { target: item; property: "lens"; value: lensView.model }
122 Binding { target: item; property: "lensId"; value: lensView.model.id }
122123
123 onLoaded: item.focus = true124 onLoaded: item.focus = true
124 }125 }
125126
126 headerDelegate: CategoryHeader {127 headerDelegate: CategoryHeader {
127 visible: body.item.needHeader && body.visible128 visible: body.item ? body.item.needHeader && body.visible : false
128 height: visible ? 32 : 0129 height: visible ? 32 : 0
129130
130 property bool foldable: body.item.folded != undefined131 property bool foldable: body.item ? body.item.folded != undefined : false
131 availableCount: foldable ? body.category_model.count - body.item.cellsPerRow : 0132 availableCount: body.item ? foldable ? body.category_model.count - body.item.cellsPerRow : 0 : 0
132 folded: foldable ? body.item.folded : false133 folded: body.item ? foldable ? body.item.folded : false : false
133 onClicked: if(foldable) body.item.folded = !body.item.folded134 onClicked: if(foldable && body.item) body.item.folded = !body.item.folded
134 moving: flickerMoving135 moving: flickerMoving
135136
136 icon: body.iconHint137 icon: body.iconHint
137138
=== modified file 'shell/dash/RendererGrid.qml'
--- shell/dash/RendererGrid.qml 2011-11-23 10:27:05 +0000
+++ shell/dash/RendererGrid.qml 2012-02-10 20:42:23 +0000
@@ -77,14 +77,6 @@
7777
78 FocusPath.index: index78 FocusPath.index: index
7979
80 property string uri: column_0
81 property string iconHint: column_1
82 property string categoryId: column_2 // FIXME: rename to categoryIndex
83 property string mimetype: column_3
84 property string displayName: column_4 // FIXME: rename to name
85 property string comment: column_5
86 property string dndUri: column_6
87
88 Loader {80 Loader {
89 id: loader81 id: loader
9082
@@ -96,13 +88,13 @@
9688
97 sourceComponent: cellRenderer89 sourceComponent: cellRenderer
98 onLoaded: {90 onLoaded: {
99 item.uri = uri91 item.uri = column_0
100 item.iconHint = iconHint92 item.iconHint = column_1
101 item.mimetype = mimetype93 item.mimetype = column_3
102 item.displayName = displayName94 item.displayName = column_4
103 item.comment = comment95 item.comment = column_5
104 item.focus = true96 item.focus = true
105 item.dndUri = dndUri97 item.dndUri = column_6
106 }98 }
107 }99 }
108 }100 }

Subscribers

People subscribed via source and target branches