Merge lp:~nicolas-doffay/unity/preview-click-exit into lp:unity

Proposed by Nicolas d'Offay
Status: Merged
Approved by: Omer Akram
Approved revision: no longer in the source branch.
Merged at revision: 2701
Proposed branch: lp:~nicolas-doffay/unity/preview-click-exit
Merge into: lp:unity
Diff against target: 116 lines (+33/-4)
6 files modified
dash/CoverflowResultView.cpp (+5/-3)
dash/previews/MusicPreview.cpp (+1/-0)
dash/previews/Preview.cpp (+8/-0)
dash/previews/Preview.h (+2/-0)
dash/previews/PreviewContainer.cpp (+15/-0)
dash/previews/PreviewContainer.h (+2/-1)
To merge this branch: bzr merge lp:~nicolas-doffay/unity/preview-click-exit
Reviewer Review Type Date Requested Status
Neil J. Patel (community) Approve
Nick Dedekind Pending
Review via email: mp+124650@code.launchpad.net

This proposal supersedes a proposal from 2012-09-11.

Commit message

Added left and right click exit to cover art for all previews.

Description of the change

Added left and right click exit to cover art for all previews.

To post a comment you must log in.
Revision history for this message
Omer Akram (om26er) wrote : Posted in a previous version of this proposal

Writing an AP test for this will be simple I guess. I think I will be able to do that easily.

Revision history for this message
Nick Dedekind (nick-dedekind) wrote : Posted in a previous version of this proposal

Looks like you've only added the functionality to the MusicPreview.
If you want to put it in all previews, put the mouse_click handling in Preview::UpdateCoverArtImage.

It also looks like this is also part of the fix for https://bugs.launchpad.net/unity-lens-applications/+bug/1045230. I've linked it.

review: Needs Fixing
Revision history for this message
Neil J. Patel (njpatel) wrote :

Code looks fine, but we'll need some AP tests before it gets in. Omer, can you help add them?

review: Needs Fixing
Revision history for this message
Omer Akram (om26er) wrote :

Left click still does not open preview for Apps available for Download because the flow render was disabled due to some reasons last week. see http://bazaar.launchpad.net/~unity-team/unity/trunk/revision/2685

I have autopilot test here: https://code.launchpad.net/~om26er/unity/autopilot_test_lp_1045752/+merge/124708

Revision history for this message
Unity Merger (unity-merger) wrote :

No commit message specified.

Revision history for this message
Neil J. Patel (njpatel) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'dash/CoverflowResultView.cpp'
2--- dash/CoverflowResultView.cpp 2012-09-13 10:56:42 +0000
3+++ dash/CoverflowResultView.cpp 2012-09-17 11:07:26 +0000
4@@ -124,10 +124,12 @@
5
6 void CoverflowResultItem::Activate(int button)
7 {
8- if (button == 1)
9+ //Left and right click take you to previews.
10+ if (button == 1 || button == 3)
11+ parent_->UriActivated.emit(result_.uri, ResultView::ActivateType::PREVIEW);
12+ //Scroll click opens up music player.
13+ else if (button == 2)
14 parent_->UriActivated.emit(result_.uri, ResultView::ActivateType::DIRECT);
15- else if (button == 3)
16- parent_->UriActivated.emit(result_.uri, ResultView::ActivateType::PREVIEW);
17
18 int index = Index();
19 int size = model_->Items().size();
20
21=== modified file 'dash/previews/MusicPreview.cpp'
22--- dash/previews/MusicPreview.cpp 2012-09-10 10:54:02 +0000
23+++ dash/previews/MusicPreview.cpp 2012-09-17 11:07:26 +0000
24@@ -145,6 +145,7 @@
25 /////////////////////
26 // Image
27 image_ = new CoverArt();
28+
29 AddChild(image_.GetPointer());
30 UpdateCoverArtImage(image_.GetPointer());
31 /////////////////////
32
33=== modified file 'dash/previews/Preview.cpp'
34--- dash/previews/Preview.cpp 2012-09-13 16:11:54 +0000
35+++ dash/previews/Preview.cpp 2012-09-17 11:07:26 +0000
36@@ -204,6 +204,14 @@
37 else
38 cover_art->SetNoImageAvailable();
39 cover_art->SetFont(style.no_preview_image_font());
40+
41+ cover_art->mouse_click.connect([this] (int x, int y, unsigned long button_flags, unsigned long key_flags)
42+ {
43+ if (nux::GetEventButton(button_flags) == nux::MOUSE_BUTTON1 || nux::GetEventButton(button_flags) == nux::MOUSE_BUTTON3)
44+ {
45+ request_close.emit();
46+ }
47+ });
48 }
49
50 }
51
52=== modified file 'dash/previews/Preview.h'
53--- dash/previews/Preview.h 2012-08-22 10:03:52 +0000
54+++ dash/previews/Preview.h 2012-09-17 11:07:26 +0000
55@@ -59,6 +59,8 @@
56 void AddProperties(GVariantBuilder* builder);
57
58 static previews::Preview::Ptr PreviewForModel(dash::Preview::Ptr model);
59+
60+ sigc::signal<void> request_close;
61
62 protected:
63 virtual void Draw(nux::GraphicsEngine& GfxContext, bool force_draw) {}
64
65=== modified file 'dash/previews/PreviewContainer.cpp'
66--- dash/previews/PreviewContainer.cpp 2012-09-17 10:00:38 +0000
67+++ dash/previews/PreviewContainer.cpp 2012-09-17 11:07:26 +0000
68@@ -381,6 +381,7 @@
69 last_progress_time_.tv_nsec = 0;
70
71 key_down.connect(sigc::mem_fun(this, &PreviewContainer::OnKeyDown));
72+ mouse_click.connect(sigc::mem_fun(this, &PreviewContainer::OnMouseDown));
73 }
74
75 PreviewContainer::~PreviewContainer()
76@@ -390,6 +391,12 @@
77 void PreviewContainer::Preview(dash::Preview::Ptr preview_model, Navigation direction)
78 {
79 previews::Preview::Ptr preview_view = previews::Preview::PreviewForModel(preview_model);
80+
81+ if (preview_view)
82+ {
83+ preview_view->request_close.connect([this]() { request_close.emit(); });
84+ }
85+
86 content_layout_->PushPreview(preview_view, direction);
87 }
88
89@@ -647,6 +654,14 @@
90 }
91 }
92
93+void PreviewContainer::OnMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags)
94+{
95+ if (nux::GetEventButton(button_flags) == nux::MOUSE_BUTTON1 || nux::GetEventButton(button_flags) == nux::MOUSE_BUTTON3)
96+ {
97+ request_close.emit();
98+ }
99+}
100+
101 nux::Area* PreviewContainer::KeyNavIteration(nux::KeyNavDirection direction)
102 {
103 return this;
104
105=== modified file 'dash/previews/PreviewContainer.h'
106--- dash/previews/PreviewContainer.h 2012-09-04 10:45:31 +0000
107+++ dash/previews/PreviewContainer.h 2012-09-17 11:07:26 +0000
108@@ -84,7 +84,8 @@
109
110 bool InspectKeyEvent(unsigned int eventType, unsigned int keysym, const char* character);
111 void OnKeyDown(unsigned long event_type, unsigned long event_keysym, unsigned long event_state, const TCHAR* character, unsigned short key_repeat_count);
112-
113+ void OnMouseDown(int x, int y, unsigned long button_flags, unsigned long key_flags);
114+
115 private:
116 void SetupViews();
117