Merge lp:~fboucault/unity-2d/keyboard_navigation_experimental into lp:~fboucault/unity-2d/icon_provide_better_error_handling
- keyboard_navigation_experimental
- Merge into icon_provide_better_error_...
Proposed by
Florian Boucault
Status: | Superseded |
---|---|
Proposed branch: | lp:~fboucault/unity-2d/keyboard_navigation_experimental |
Merge into: | lp:~fboucault/unity-2d/icon_provide_better_error_handling |
Diff against target: |
2920 lines (+1417/-409) 54 files modified
.bzrignore (+1/-0) CMakeLists.txt (+31/-0) data/com.canonical.Unity2d.gschema.xml (+19/-0) data/unity-2d.convert (+7/-0) debian/20_unity-2d-gconf-default (+0/-4) debian/changelog (+19/-2) debian/control (+3/-1) debian/gconf/schemas/unity-2d.schemas (+0/-56) debian/unity-2d.install (+3/-1) debian/unity-2d.triggers (+1/-1) launcher/app/CMakeLists.txt (+3/-2) launcher/app/launcher.cpp (+13/-28) launcher/app/launcherview.cpp (+12/-3) launcher/app/launcherview.h (+4/-3) launcher/app/visibilitycontroller.cpp (+7/-8) launcher/app/visibilitycontroller.h (+3/-3) libunity-2d-private/Unity2d/CMakeLists.txt (+3/-6) libunity-2d-private/Unity2d/launcherapplicationslist.cpp (+11/-9) libunity-2d-private/Unity2d/launcherapplicationslist.h (+2/-1) libunity-2d-private/Unity2d/plugin.cpp (+3/-0) libunity-2d-private/Unity2d/qsortfilterproxymodelqml.cpp (+114/-6) libunity-2d-private/Unity2d/qsortfilterproxymodelqml.h (+18/-3) libunity-2d-private/Unity2d/workspacesinfo.cpp (+0/-2) libunity-2d-private/src/CMakeLists.txt (+1/-4) libunity-2d-private/src/giodefaultapplication.cpp (+107/-0) libunity-2d-private/src/giodefaultapplication.h (+63/-0) libunity-2d-private/src/unity2dapplication.cpp (+38/-0) libunity-2d-private/src/unity2dapplication.h (+7/-0) libunity-2d-private/tests/CMakeLists.txt (+1/-0) libunity-2d-private/tests/keyboardmodifiersmonitortest.cpp (+1/-0) libunity-2d-private/tests/mouseareademo.cpp (+1/-0) libunity-2d-private/tests/qsortfilterproxymodeltest.cpp (+384/-0) panel/app/main.cpp (+1/-15) panel/applets/CMakeLists.txt (+0/-4) panel/applets/indicator/indicator.c (+15/-0) places/Home.qml (+37/-43) places/HomeButtonDefaultApplication.qml (+48/-0) places/HomeShortcuts.qml (+30/-5) places/ListViewWithHeaders.qml (+277/-0) places/ListViewWithScrollbar.qml (+7/-30) places/PlaceEntryView.qml (+41/-23) places/Renderer.qml (+3/-3) places/RendererGrid.qml (+24/-77) places/Scrollbar.qml (+11/-5) places/SearchEntry.qml (+3/-1) places/SearchRefine.qml (+5/-0) places/SearchRefineOptionType.qml (+6/-2) places/TickBox.qml (+4/-4) places/UnityEmptySearchRenderer.qml (+1/-1) places/app/CMakeLists.txt (+0/-2) places/app/places.cpp (+3/-19) places/dash.qml (+18/-7) spread/app/CMakeLists.txt (+0/-4) spread/app/spread.cpp (+3/-21) |
To merge this branch: | bzr merge lp:~fboucault/unity-2d/keyboard_navigation_experimental |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gerry Boland | Pending | ||
Review via email: mp+69479@code.launchpad.net |
Commit message
Description of the change
[dash] Implemented keyboard navigation.
To post a comment you must log in.
- 639. By Florian Boucault
-
Remade RendererGrid.
interactive false thus preventing mouse interaction with the individual groups. - 640. By Florian Boucault
-
Prevent the focus to be on the refine search pane when it is folded.
- 641. By Florian Boucault
-
Added FIXME/
- 642. By Florian Boucault
-
Merged colo:proper_grid
Unmerged revisions
- 642. By Florian Boucault
-
Merged colo:proper_grid
- 641. By Florian Boucault
-
Added FIXME/
- 640. By Florian Boucault
-
Prevent the focus to be on the refine search pane when it is folded.
- 639. By Florian Boucault
-
Remade RendererGrid.
interactive false thus preventing mouse interaction with the individual groups. - 638. By Florian Boucault
-
Merged colo:proper_grid
- 637. By Florian Boucault
-
Merged colo:proper_grid
- 636. By Florian Boucault
-
No change.
- 635. By Florian Boucault
-
Merged colo:proper_grid
- 634. By Florian Boucault
-
Merged colo:proper_grid
- 633. By Florian Boucault
-
Merged colo:proper_grid
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file '.bzrignore' | |||
2 | --- .bzrignore 2011-06-15 14:39:35 +0000 | |||
3 | +++ .bzrignore 2011-07-27 15:02:42 +0000 | |||
4 | @@ -78,3 +78,4 @@ | |||
5 | 78 | debian/unity-qt-spread | 78 | debian/unity-qt-spread |
6 | 79 | debian/libuqpanel-dev | 79 | debian/libuqpanel-dev |
7 | 80 | debian/libuqpanel0 | 80 | debian/libuqpanel0 |
8 | 81 | data/gschemas.compiled | ||
9 | 81 | 82 | ||
10 | === modified file 'CMakeLists.txt' | |||
11 | --- CMakeLists.txt 2011-06-27 13:40:51 +0000 | |||
12 | +++ CMakeLists.txt 2011-07-27 15:02:42 +0000 | |||
13 | @@ -4,6 +4,7 @@ | |||
14 | 4 | # Dirs | 4 | # Dirs |
15 | 5 | set(UNITY_2D_DIR share/unity-2d) | 5 | set(UNITY_2D_DIR share/unity-2d) |
16 | 6 | set(UNITY_DIR /usr/share/unity/) | 6 | set(UNITY_DIR /usr/share/unity/) |
17 | 7 | set(UNITY_2D_DATA_DIR "${CMAKE_SOURCE_DIR}/data") | ||
18 | 7 | 8 | ||
19 | 8 | configure_file(config.h.in config.h) | 9 | configure_file(config.h.in config.h) |
20 | 9 | 10 | ||
21 | @@ -23,6 +24,36 @@ | |||
22 | 23 | find_package(Qt4 REQUIRED) | 24 | find_package(Qt4 REQUIRED) |
23 | 24 | find_package(X11 REQUIRED) | 25 | find_package(X11 REQUIRED) |
24 | 25 | find_package(Gettext REQUIRED) | 26 | find_package(Gettext REQUIRED) |
25 | 27 | pkg_check_modules(GLIB REQUIRED glib-2.0) | ||
26 | 28 | pkg_check_modules(GDK REQUIRED gdk-2.0) | ||
27 | 29 | pkg_check_modules(GTK REQUIRED gtk+-2.0) | ||
28 | 30 | pkg_check_modules(GIO REQUIRED gio-2.0) | ||
29 | 31 | pkg_check_modules(WNCK REQUIRED libwnck-1.0) | ||
30 | 32 | |||
31 | 33 | |||
32 | 34 | # GSettings schemas | ||
33 | 35 | pkg_check_modules(GLIB REQUIRED glib-2.0) | ||
34 | 36 | set (UNITY_2D_SCHEMAS "com.canonical.Unity2d.gschema.xml") | ||
35 | 37 | set (UNITY_2D_GCONF_CONVERT "unity-2d.convert") | ||
36 | 38 | set (GSETTINGS_DIR "${CMAKE_INSTALL_PREFIX}/share/glib-2.0/schemas/") | ||
37 | 39 | set (GCONF_CONVERT_DIR "${CMAKE_INSTALL_PREFIX}/share/GConf/gsettings") | ||
38 | 40 | execute_process (COMMAND ${PKG_CONFIG_EXECUTABLE} gio-2.0 --variable glib_compile_schemas OUTPUT_VARIABLE GLIB_COMPILE_SCHEMAS OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
39 | 41 | |||
40 | 42 | # Run the schemas validator and error if it fails | ||
41 | 43 | execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS} ${UNITY_2D_DATA_DIR} ERROR_VARIABLE _schemas_invalid OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
42 | 44 | |||
43 | 45 | if (_schemas_invalid) | ||
44 | 46 | message (SEND_ERROR "Schemas validation error: ${_schemas_invalid}") | ||
45 | 47 | endif (_schemas_invalid) | ||
46 | 48 | |||
47 | 49 | # Actually install and recompile the schemas | ||
48 | 50 | message (STATUS "GSettings schemas will be installed into ${GSETTINGS_DIR}") | ||
49 | 51 | install (FILES ${UNITY_2D_DATA_DIR}/${UNITY_2D_SCHEMAS} DESTINATION ${GSETTINGS_DIR}) | ||
50 | 52 | install (CODE "message (STATUS \"Compiling GSettings schemas\")") | ||
51 | 53 | install (CODE "execute_process (COMMAND ${GLIB_COMPILE_SCHEMAS} ${GSETTINGS_DIR})") | ||
52 | 54 | |||
53 | 55 | # Install GConf to GSettings conversion file | ||
54 | 56 | install (FILES ${UNITY_2D_DATA_DIR}/${UNITY_2D_GCONF_CONVERT} DESTINATION ${GCONF_CONVERT_DIR}) | ||
55 | 26 | 57 | ||
56 | 27 | include_directories( | 58 | include_directories( |
57 | 28 | ${CMAKE_BINARY_DIR} | 59 | ${CMAKE_BINARY_DIR} |
58 | 29 | 60 | ||
59 | === added directory 'data' | |||
60 | === added file 'data/com.canonical.Unity2d.gschema.xml' | |||
61 | --- data/com.canonical.Unity2d.gschema.xml 1970-01-01 00:00:00 +0000 | |||
62 | +++ data/com.canonical.Unity2d.gschema.xml 2011-07-27 15:02:42 +0000 | |||
63 | @@ -0,0 +1,19 @@ | |||
64 | 1 | <schemalist> | ||
65 | 2 | <schema path="/com/canonical/unity-2d/launcher/" id="com.canonical.Unity2d.Launcher" gettext-domain="unity-2d"> | ||
66 | 3 | <key type="b" name="super-key-enable"> | ||
67 | 4 | <default>true</default> | ||
68 | 5 | <summary>Super key activation.</summary> | ||
69 | 6 | <description>Whether or not the super (also called windows key) key is used.</description> | ||
70 | 7 | </key> | ||
71 | 8 | <key name="hide-mode" type="i"> | ||
72 | 9 | <default>2</default> | ||
73 | 10 | <summary>Hiding mode of the launcher</summary> | ||
74 | 11 | <description>Possible values: 0: never hide; the launcher is always visible. Always set /com/canonical/unity-2d/launcher/use-strut to true when using that mode 1: auto hide; the launcher will disappear after a short time if the user is not interacting with it 2: intellihide; the launcher will disappear if a window is placed on top of it and if the user is not interacting with it</description> | ||
75 | 12 | </key> | ||
76 | 13 | <key name="use-strut" type="b"> | ||
77 | 14 | <default>false</default> | ||
78 | 15 | <summary>Reserve launcher area</summary> | ||
79 | 16 | <description>Use EWMH standard to reserve an area of the desktop (struts) so that no window can use the launcher's area</description> | ||
80 | 17 | </key> | ||
81 | 18 | </schema> | ||
82 | 19 | </schemalist> | ||
83 | 0 | 20 | ||
84 | === added file 'data/unity-2d.convert' | |||
85 | --- data/unity-2d.convert 1970-01-01 00:00:00 +0000 | |||
86 | +++ data/unity-2d.convert 2011-07-27 15:02:42 +0000 | |||
87 | @@ -0,0 +1,7 @@ | |||
88 | 1 | [com.canonical.Unity2d.Launcher] | ||
89 | 2 | super-key-enable = /desktop/unity-2d/launcher/super_key_enable | ||
90 | 3 | hide-mode = /desktop/unity-2d/launcher/hide_mode | ||
91 | 4 | use-strut = /desktop/unity-2d/launcher/use_strut | ||
92 | 5 | |||
93 | 6 | [com.canonical.Unity.Launcher] | ||
94 | 7 | favorites = /desktop/unity-2d/launcher/favorites | ||
95 | 0 | 8 | ||
96 | === modified file 'debian/20_unity-2d-gconf-default' | |||
97 | --- debian/20_unity-2d-gconf-default 2011-06-15 13:05:38 +0000 | |||
98 | +++ debian/20_unity-2d-gconf-default 2011-07-27 15:02:42 +0000 | |||
99 | @@ -1,9 +1,5 @@ | |||
100 | 1 | /apps/gnome-power-manager/lock/use_screensaver_settings true | 1 | /apps/gnome-power-manager/lock/use_screensaver_settings true |
101 | 2 | /apps/gnome-power-manager/general/use_time_for_policy false | 2 | /apps/gnome-power-manager/general/use_time_for_policy false |
102 | 3 | /desktop/unity-2d/launcher/favorites [ubiquity-gtkui.desktop,nautilus-home.desktop,firefox.desktop,libreoffice-writer.desktop,libreoffice-calc.desktop,libreoffice-impress.desktop,ubuntu-software-center.desktop,ubuntuone-control-panel-gtk.desktop] | ||
103 | 4 | /desktop/unity-2d/launcher/hide_mode 2 | ||
104 | 5 | /desktop/unity-2d/launcher/use_strut false | ||
105 | 6 | /desktop/unity-2d/launcher/super_key_enable true | ||
106 | 7 | /desktop/gnome/applications/window_manager/default /usr/bin/metacity | 3 | /desktop/gnome/applications/window_manager/default /usr/bin/metacity |
107 | 8 | /desktop/gnome/applications/window_manager/current /usr/bin/metacity | 4 | /desktop/gnome/applications/window_manager/current /usr/bin/metacity |
108 | 9 | /apps/metacity/general/show_maximized_titlebars false | 5 | /apps/metacity/general/show_maximized_titlebars false |
109 | 10 | 6 | ||
110 | === modified file 'debian/changelog' | |||
111 | --- debian/changelog 2011-07-13 10:11:55 +0000 | |||
112 | +++ debian/changelog 2011-07-27 15:02:42 +0000 | |||
113 | @@ -1,10 +1,27 @@ | |||
114 | 1 | unity-2d (3.8.12-0ubuntu1) UNRELEASED; urgency=low | 1 | unity-2d (3.8.12-0ubuntu1) UNRELEASED; urgency=low |
115 | 2 | 2 | ||
116 | 3 | [ Florian Boucault ] | ||
117 | 3 | * do not run pkgbinarymangler to convert images to 8bit since this breaks | 4 | * do not run pkgbinarymangler to convert images to 8bit since this breaks |
118 | 4 | the launcher icon background handling. (LP: #809205) | 5 | the launcher icon background handling. (LP: #809205) |
119 | 5 | (QT upstream bug: http://bugreports.qt.nokia.com/browse/QTBUG-4459) | 6 | (QT upstream bug: http://bugreports.qt.nokia.com/browse/QTBUG-4459) |
122 | 6 | 7 | * debian/unity-2d.install: | |
123 | 7 | -- Florian Boucault <florian.boucault@canonical.com> Wed, 13 Jul 2011 12:11:05 +0200 | 8 | - install GSettings schemas into usr/share/glib-2.0/schemas |
124 | 9 | - install GConf to GSettings conversion into usr/share/GConf/gsettings | ||
125 | 10 | * debian/gconf/schemas/unity-2d.schemas: | ||
126 | 11 | - remove GConf schema for /desktop/unity-2d/launcher/super_key_enable | ||
127 | 12 | - remove GConf schema for /desktop/unity-2d/launcher/favorites | ||
128 | 13 | * debian/20_unity-2d-gconf-default: | ||
129 | 14 | - remove default value for /desktop/unity-2d/launcher/super_key_enable | ||
130 | 15 | - remove default value for /desktop/unity-2d/launcher/favorites | ||
131 | 16 | * debian/control: | ||
132 | 17 | - add dependency on libdconf-qt-dev | ||
133 | 18 | |||
134 | 19 | [ Didier Roche ] | ||
135 | 20 | * Fix typo in trigger (debian/unity-2d.triggers): (LP: #807358) | ||
136 | 21 | * Install the apport hook in the right directory so that it's not launched | ||
137 | 22 | unconditionally (LP: #712343) | ||
138 | 23 | |||
139 | 24 | -- Florian Boucault <florian.boucault@canonical.com> Fri, 22 Jul 2011 18:56:33 +0200 | ||
140 | 8 | 25 | ||
141 | 9 | unity-2d (3.8.10-0ubuntu1) natty; urgency=low | 26 | unity-2d (3.8.10-0ubuntu1) natty; urgency=low |
142 | 10 | 27 | ||
143 | 11 | 28 | ||
144 | === modified file 'debian/control' | |||
145 | --- debian/control 2011-06-22 21:17:49 +0000 | |||
146 | +++ debian/control 2011-07-27 15:02:42 +0000 | |||
147 | @@ -12,6 +12,7 @@ | |||
148 | 12 | libglib2.0-dev, | 12 | libglib2.0-dev, |
149 | 13 | libwnck-dev, | 13 | libwnck-dev, |
150 | 14 | libqtgconf-dev, | 14 | libqtgconf-dev, |
151 | 15 | libdconf-qt-dev, | ||
152 | 15 | libqtbamf-dev, | 16 | libqtbamf-dev, |
153 | 16 | libqtdee-dev, | 17 | libqtdee-dev, |
154 | 17 | libdbusmenu-qt-dev, | 18 | libdbusmenu-qt-dev, |
155 | @@ -42,7 +43,8 @@ | |||
156 | 42 | Section: libs | 43 | Section: libs |
157 | 43 | Architecture: any | 44 | Architecture: any |
158 | 44 | Depends: ${shlibs:Depends}, | 45 | Depends: ${shlibs:Depends}, |
160 | 45 | ${misc:Depends} | 46 | ${misc:Depends}, |
161 | 47 | unity-common, | ||
162 | 46 | Description: Unity 2D shared library | 48 | Description: Unity 2D shared library |
163 | 47 | This library is used to host common code used by several Unity 2D components | 49 | This library is used to host common code used by several Unity 2D components |
164 | 48 | It is only used internally, there is no use case for it outside of the unity-2d | 50 | It is only used internally, there is no use case for it outside of the unity-2d |
165 | 49 | 51 | ||
166 | === removed directory 'debian/gconf/schemas' | |||
167 | === removed file 'debian/gconf/schemas/unity-2d.schemas' | |||
168 | --- debian/gconf/schemas/unity-2d.schemas 2011-06-15 13:10:14 +0000 | |||
169 | +++ debian/gconf/schemas/unity-2d.schemas 1970-01-01 00:00:00 +0000 | |||
170 | @@ -1,56 +0,0 @@ | |||
171 | 1 | <gconfschemafile> | ||
172 | 2 | <schemalist> | ||
173 | 3 | <schema> | ||
174 | 4 | <key>/schemas/desktop/unity-2d/launcher/favorites</key> | ||
175 | 5 | <applyto>/desktop/unity-2d/launcher/favorites</applyto> | ||
176 | 6 | <owner>unity-2d</owner> | ||
177 | 7 | <type>list</type> | ||
178 | 8 | <list_type>string</list_type> | ||
179 | 9 | <default>[ubiquity-gtkui.desktop,nautilus-home.desktop,firefox.desktop,libreoffice-writer.desktop,libreoffice-calc.desktop,libreoffice-impress.desktop,ubuntu-software-center.desktop,ubuntuone-control-panel-gtk.desktop]</default> | ||
180 | 10 | <locale name="C"> | ||
181 | 11 | <short>Favorite applications</short> | ||
182 | 12 | <long>List of desktop files of applications that have been marked as favorites by the user in the launcher</long> | ||
183 | 13 | </locale> | ||
184 | 14 | </schema> | ||
185 | 15 | |||
186 | 16 | <schema> | ||
187 | 17 | <key>/schemas/desktop/unity-2d/launcher/hide_mode</key> | ||
188 | 18 | <applyto>/desktop/unity-2d/launcher/hide_mode</applyto> | ||
189 | 19 | <owner>unity-2d</owner> | ||
190 | 20 | <type>int</type> | ||
191 | 21 | <default>2</default> | ||
192 | 22 | <locale name="C"> | ||
193 | 23 | <short>Hiding mode of the launcher</short> | ||
194 | 24 | <long>Possible values: | ||
195 | 25 | 0: never hide; the launcher is always visible. Always set /desktop/unity-2d/launcher/use_strut to true when using that mode | ||
196 | 26 | 1: auto hide; the launcher will disappear after a short time if the user is not interacting with it | ||
197 | 27 | 2: intellihide; the launcher will disappear if a window is placed on top of it and if the user is not interacting with it</long> | ||
198 | 28 | </locale> | ||
199 | 29 | </schema> | ||
200 | 30 | |||
201 | 31 | <schema> | ||
202 | 32 | <key>/schemas/desktop/unity-2d/launcher/use_strut</key> | ||
203 | 33 | <applyto>/desktop/unity-2d/launcher/use_strut</applyto> | ||
204 | 34 | <owner>unity-2d</owner> | ||
205 | 35 | <type>bool</type> | ||
206 | 36 | <default>false</default> | ||
207 | 37 | <locale name="C"> | ||
208 | 38 | <short>Reserve launcher area</short> | ||
209 | 39 | <long>Use EWMH standard to reserve an area of the desktop (struts) so that no window can use the launcher's area</long> | ||
210 | 40 | </locale> | ||
211 | 41 | </schema> | ||
212 | 42 | |||
213 | 43 | <schema> | ||
214 | 44 | <key>/schemas/desktop/unity-2d/launcher/super_key_enable</key> | ||
215 | 45 | <applyto>/desktop/unity-2d/launcher/super_key_enable</applyto> | ||
216 | 46 | <owner>unity-2d</owner> | ||
217 | 47 | <type>bool</type> | ||
218 | 48 | <default>true</default> | ||
219 | 49 | <locale name="C"> | ||
220 | 50 | <short>Super key activation</short> | ||
221 | 51 | <long>Whether or not the super (also called windows key) key is used</long> | ||
222 | 52 | </locale> | ||
223 | 53 | </schema> | ||
224 | 54 | </schemalist> | ||
225 | 55 | </gconfschemafile> | ||
226 | 56 | |||
227 | 57 | 0 | ||
228 | === modified file 'debian/unity-2d.install' | |||
229 | --- debian/unity-2d.install 2011-06-15 13:05:38 +0000 | |||
230 | +++ debian/unity-2d.install 2011-07-27 15:02:42 +0000 | |||
231 | @@ -1,7 +1,9 @@ | |||
233 | 1 | debian/unity-2d.py /usr/share/apport/general-hooks | 1 | debian/unity-2d.py /usr/share/apport/package-hooks |
234 | 2 | debian/gconf/* /usr/share/gconf | 2 | debian/gconf/* /usr/share/gconf |
235 | 3 | session/unity-2d.desktop /usr/share/xsessions | 3 | session/unity-2d.desktop /usr/share/xsessions |
236 | 4 | session/2d-ubuntu.session /usr/share/gnome-session/sessions | 4 | session/2d-ubuntu.session /usr/share/gnome-session/sessions |
237 | 5 | debian/20_unity-2d-gconf-mandatory /usr/share/gconf/unity-2d/mandatory | 5 | debian/20_unity-2d-gconf-mandatory /usr/share/gconf/unity-2d/mandatory |
238 | 6 | debian/20_unity-2d-gconf-default /usr/share/gconf/unity-2d/default | 6 | debian/20_unity-2d-gconf-default /usr/share/gconf/unity-2d/default |
239 | 7 | usr/share/locale/*/LC_MESSAGES/unity-2d.mo | 7 | usr/share/locale/*/LC_MESSAGES/unity-2d.mo |
240 | 8 | usr/share/glib-2.0/schemas/com.canonical.Unity2d.gschema.xml | ||
241 | 9 | usr/share/GConf/gsettings | ||
242 | 8 | 10 | ||
243 | === modified file 'debian/unity-2d.triggers' | |||
244 | --- debian/unity-2d.triggers 2011-01-26 11:34:38 +0000 | |||
245 | +++ debian/unity-2d.triggers 2011-07-27 15:02:42 +0000 | |||
246 | @@ -1,2 +1,2 @@ | |||
248 | 1 | interest /usr/share/gconf/unity-2d/defaults | 1 | interest /usr/share/gconf/unity-2d/default |
249 | 2 | interest /usr/share/gconf/unity-2d/mandatory | 2 | interest /usr/share/gconf/unity-2d/mandatory |
250 | 3 | 3 | ||
251 | === modified file 'launcher/app/CMakeLists.txt' | |||
252 | --- launcher/app/CMakeLists.txt 2011-06-11 11:33:52 +0000 | |||
253 | +++ launcher/app/CMakeLists.txt 2011-07-27 15:02:42 +0000 | |||
254 | @@ -1,8 +1,7 @@ | |||
255 | 1 | # Dependencies | 1 | # Dependencies |
256 | 2 | pkg_check_modules(GTK REQUIRED gtk+-2.0) | ||
257 | 3 | pkg_check_modules(X11 REQUIRED x11) | ||
258 | 4 | pkg_check_modules(GEIS REQUIRED libutouch-geis) | 2 | pkg_check_modules(GEIS REQUIRED libutouch-geis) |
259 | 5 | pkg_check_modules(QTGCONF REQUIRED libqtgconf) | 3 | pkg_check_modules(QTGCONF REQUIRED libqtgconf) |
260 | 4 | pkg_check_modules(DCONFQT REQUIRED dconf-qt) | ||
261 | 6 | 5 | ||
262 | 7 | # Sources | 6 | # Sources |
263 | 8 | set(launcher_SRCS | 7 | set(launcher_SRCS |
264 | @@ -38,6 +37,7 @@ | |||
265 | 38 | ${X11_INCLUDE_DIRS} | 37 | ${X11_INCLUDE_DIRS} |
266 | 39 | ${GEIS_INCLUDE_DIRS} | 38 | ${GEIS_INCLUDE_DIRS} |
267 | 40 | ${QTGCONF_INCLUDE_DIRS} | 39 | ${QTGCONF_INCLUDE_DIRS} |
268 | 40 | ${DCONFQT_INCLUDE_DIRS} | ||
269 | 41 | ${libunity-2d-private_SOURCE_DIR}/src | 41 | ${libunity-2d-private_SOURCE_DIR}/src |
270 | 42 | ) | 42 | ) |
271 | 43 | 43 | ||
272 | @@ -50,6 +50,7 @@ | |||
273 | 50 | ${X11_LDFLAGS} | 50 | ${X11_LDFLAGS} |
274 | 51 | ${GEIS_LDFLAGS} | 51 | ${GEIS_LDFLAGS} |
275 | 52 | ${QTGCONF_LDFLAGS} | 52 | ${QTGCONF_LDFLAGS} |
276 | 53 | ${DCONFQT_LDFLAGS} | ||
277 | 53 | unity-2d-private | 54 | unity-2d-private |
278 | 54 | ) | 55 | ) |
279 | 55 | 56 | ||
280 | 56 | 57 | ||
281 | === modified file 'launcher/app/launcher.cpp' | |||
282 | --- launcher/app/launcher.cpp 2011-06-22 08:33:52 +0000 | |||
283 | +++ launcher/app/launcher.cpp 2011-07-27 15:02:42 +0000 | |||
284 | @@ -17,16 +17,14 @@ | |||
285 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
286 | 18 | */ | 18 | */ |
287 | 19 | 19 | ||
288 | 20 | #include <gtk/gtk.h> | ||
289 | 21 | |||
290 | 22 | // unity-2d | 20 | // unity-2d |
291 | 23 | #include <gnomesessionclient.h> | 21 | #include <gnomesessionclient.h> |
292 | 24 | #include <launcherclient.h> | 22 | #include <launcherclient.h> |
293 | 25 | #include <unity2dapplication.h> | 23 | #include <unity2dapplication.h> |
294 | 26 | #include <propertybinder.h> | 24 | #include <propertybinder.h> |
295 | 27 | 25 | ||
298 | 28 | // libqtgconf | 26 | // libdconf-qt |
299 | 29 | #include <gconfitem-qml-wrapper.h> | 27 | #include "qconf.h" |
300 | 30 | 28 | ||
301 | 31 | // Qt | 29 | // Qt |
302 | 32 | #include <QApplication> | 30 | #include <QApplication> |
303 | @@ -44,6 +42,11 @@ | |||
304 | 44 | #include "unity2dpanel.h" | 42 | #include "unity2dpanel.h" |
305 | 45 | #include "gesturehandler.h" | 43 | #include "gesturehandler.h" |
306 | 46 | 44 | ||
307 | 45 | // libc | ||
308 | 46 | #include <stdlib.h> | ||
309 | 47 | |||
310 | 48 | static const char* LAUNCHER_DCONF_SCHEMA = "com.canonical.Unity2d.Launcher"; | ||
311 | 49 | |||
312 | 47 | #if defined(QMLJSDEBUGGER) | 50 | #if defined(QMLJSDEBUGGER) |
313 | 48 | #include <qt_private/qdeclarativedebughelper_p.h> | 51 | #include <qt_private/qdeclarativedebughelper_p.h> |
314 | 49 | #endif | 52 | #endif |
315 | @@ -73,24 +76,7 @@ | |||
316 | 73 | 76 | ||
317 | 74 | int main(int argc, char *argv[]) | 77 | int main(int argc, char *argv[]) |
318 | 75 | { | 78 | { |
337 | 76 | /* Unity2d plugin uses GTK APIs to retrieve theme icons | 79 | Unity2dApplication::earlySetup(argc, argv); |
320 | 77 | (gtk_icon_theme_get_default) and requires a call to gtk_init */ | ||
321 | 78 | gtk_init(&argc, &argv); | ||
322 | 79 | |||
323 | 80 | Unity2dDebug::installHandlers(); | ||
324 | 81 | |||
325 | 82 | /* When the environment variable QT_GRAPHICSSYSTEM is not set, | ||
326 | 83 | force graphics system to 'raster' instead of the default 'native' | ||
327 | 84 | which on X11 is 'XRender'. | ||
328 | 85 | 'XRender' defaults to using a TrueColor visual. We do _not_ mimick that | ||
329 | 86 | behaviour with 'raster' by calling QApplication::setColorSpec because | ||
330 | 87 | of a bug where black rectangular artifacts were appearing randomly: | ||
331 | 88 | |||
332 | 89 | https://bugs.launchpad.net/unity-2d/+bug/734143 | ||
333 | 90 | */ | ||
334 | 91 | if(getenv("QT_GRAPHICSSYSTEM") == 0) { | ||
335 | 92 | QApplication::setGraphicsSystem("raster"); | ||
336 | 93 | } | ||
338 | 94 | Unity2dApplication application(argc, argv); | 80 | Unity2dApplication application(argc, argv); |
339 | 95 | QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments()); | 81 | QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments()); |
340 | 96 | 82 | ||
341 | @@ -132,12 +118,11 @@ | |||
342 | 132 | 118 | ||
343 | 133 | launcherView->setSource(QUrl("./Launcher.qml")); | 119 | launcherView->setSource(QUrl("./Launcher.qml")); |
344 | 134 | 120 | ||
349 | 135 | /* Synchronise panel's "useStrut" property with its corresponding GConf key */ | 121 | /* Synchronise panel's "useStrut" property with its corresponding DConf key */ |
350 | 136 | GConfItemQmlWrapper useStrutGconf; | 122 | QConf dconfLauncher(LAUNCHER_DCONF_SCHEMA); |
351 | 137 | useStrutGconf.setKey("/desktop/unity-2d/launcher/use_strut"); | 123 | panel.setUseStrut(dconfLauncher.property("useStrut").toBool()); |
348 | 138 | panel.setUseStrut(useStrutGconf.getValue().toBool()); | ||
352 | 139 | PropertyBinder useStrutBinder; | 124 | PropertyBinder useStrutBinder; |
354 | 140 | useStrutBinder.bind(&useStrutGconf, "value", &panel, "useStrut"); | 125 | useStrutBinder.bind(&dconfLauncher, "useStrut", &panel, "useStrut"); |
355 | 141 | 126 | ||
356 | 142 | /* Composing the QML declarative view inside the panel */ | 127 | /* Composing the QML declarative view inside the panel */ |
357 | 143 | panel.addWidget(launcherView); | 128 | panel.addWidget(launcherView); |
358 | @@ -149,7 +134,7 @@ | |||
359 | 149 | the launcher itself was autostarted (which is the common case when | 134 | the launcher itself was autostarted (which is the common case when |
360 | 150 | running installed). | 135 | running installed). |
361 | 151 | For a discussion, see https://bugs.launchpad.net/upicek/+bug/684160. */ | 136 | For a discussion, see https://bugs.launchpad.net/upicek/+bug/684160. */ |
363 | 152 | g_unsetenv("DESKTOP_AUTOSTART_ID"); | 137 | unsetenv("DESKTOP_AUTOSTART_ID"); |
364 | 153 | 138 | ||
365 | 154 | /* Gesture handler instance in charge of listening to gesture events and | 139 | /* Gesture handler instance in charge of listening to gesture events and |
366 | 155 | trigger appropriate actions in response. */ | 140 | trigger appropriate actions in response. */ |
367 | 156 | 141 | ||
368 | === modified file 'launcher/app/launcherview.cpp' | |||
369 | --- launcher/app/launcherview.cpp 2011-06-22 08:54:52 +0000 | |||
370 | +++ launcher/app/launcherview.cpp 2011-07-27 15:02:42 +0000 | |||
371 | @@ -36,6 +36,9 @@ | |||
372 | 36 | #include <X11/Xlib.h> | 36 | #include <X11/Xlib.h> |
373 | 37 | #include <X11/Xatom.h> | 37 | #include <X11/Xatom.h> |
374 | 38 | 38 | ||
375 | 39 | // libdconf-qt | ||
376 | 40 | #include "qconf.h" | ||
377 | 41 | |||
378 | 39 | #include <keyboardmodifiersmonitor.h> | 42 | #include <keyboardmodifiersmonitor.h> |
379 | 40 | #include <hotkey.h> | 43 | #include <hotkey.h> |
380 | 41 | #include <hotkeymonitor.h> | 44 | #include <hotkeymonitor.h> |
381 | @@ -55,6 +58,7 @@ | |||
382 | 55 | static const char* SPREAD_DBUS_METHOD_IS_SHOWN = "IsShown"; | 58 | static const char* SPREAD_DBUS_METHOD_IS_SHOWN = "IsShown"; |
383 | 56 | static const char* APPLICATIONS_PLACE = "/usr/share/unity/places/applications.place"; | 59 | static const char* APPLICATIONS_PLACE = "/usr/share/unity/places/applications.place"; |
384 | 57 | static const char* COMMANDS_PLACE_ENTRY = "Runner"; | 60 | static const char* COMMANDS_PLACE_ENTRY = "Runner"; |
385 | 61 | static const char* LAUNCHER_DCONF_SCHEMA = "com.canonical.Unity2d.Launcher"; | ||
386 | 58 | 62 | ||
387 | 59 | LauncherView::LauncherView(QWidget* parent) : | 63 | LauncherView::LauncherView(QWidget* parent) : |
388 | 60 | Unity2DDeclarativeView(parent), | 64 | Unity2DDeclarativeView(parent), |
389 | @@ -67,8 +71,8 @@ | |||
390 | 67 | connect(&m_superKeyHoldTimer, SIGNAL(timeout()), SLOT(updateSuperKeyHoldState())); | 71 | connect(&m_superKeyHoldTimer, SIGNAL(timeout()), SLOT(updateSuperKeyHoldState())); |
391 | 68 | connect(this, SIGNAL(superKeyTapped()), SLOT(toggleDash())); | 72 | connect(this, SIGNAL(superKeyTapped()), SLOT(toggleDash())); |
392 | 69 | 73 | ||
395 | 70 | m_enableSuperKey.setKey("/desktop/unity-2d/launcher/super_key_enable"); | 74 | m_dconf_launcher = new QConf(LAUNCHER_DCONF_SCHEMA); |
396 | 71 | connect(&m_enableSuperKey, SIGNAL(valueChanged()), SLOT(updateSuperKeyMonitoring())); | 75 | connect(m_dconf_launcher, SIGNAL(superKeyEnableChanged(bool)), SLOT(updateSuperKeyMonitoring())); |
397 | 72 | updateSuperKeyMonitoring(); | 76 | updateSuperKeyMonitoring(); |
398 | 73 | 77 | ||
399 | 74 | /* Alt+F1 gives the keyboard focus to the launcher. */ | 78 | /* Alt+F1 gives the keyboard focus to the launcher. */ |
400 | @@ -86,6 +90,11 @@ | |||
401 | 86 | } | 90 | } |
402 | 87 | } | 91 | } |
403 | 88 | 92 | ||
404 | 93 | LauncherView::~LauncherView() | ||
405 | 94 | { | ||
406 | 95 | delete m_dconf_launcher; | ||
407 | 96 | } | ||
408 | 97 | |||
409 | 89 | void | 98 | void |
410 | 90 | LauncherView::activateWindow() | 99 | LauncherView::activateWindow() |
411 | 91 | { | 100 | { |
412 | @@ -111,7 +120,7 @@ | |||
413 | 111 | { | 120 | { |
414 | 112 | KeyboardModifiersMonitor *modifiersMonitor = KeyboardModifiersMonitor::instance(); | 121 | KeyboardModifiersMonitor *modifiersMonitor = KeyboardModifiersMonitor::instance(); |
415 | 113 | 122 | ||
417 | 114 | QVariant value = m_enableSuperKey.getValue(); | 123 | QVariant value = m_dconf_launcher->property("superKeyEnable"); |
418 | 115 | if (!value.isValid() || value.toBool() == true) { | 124 | if (!value.isValid() || value.toBool() == true) { |
419 | 116 | QObject::connect(modifiersMonitor, | 125 | QObject::connect(modifiersMonitor, |
420 | 117 | SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)), | 126 | SIGNAL(keyboardModifiersChanged(Qt::KeyboardModifiers)), |
421 | 118 | 127 | ||
422 | === modified file 'launcher/app/launcherview.h' | |||
423 | --- launcher/app/launcherview.h 2011-06-22 08:54:52 +0000 | |||
424 | +++ launcher/app/launcherview.h 2011-07-27 15:02:42 +0000 | |||
425 | @@ -24,13 +24,13 @@ | |||
426 | 24 | #include <QList> | 24 | #include <QList> |
427 | 25 | #include <QUrl> | 25 | #include <QUrl> |
428 | 26 | #include <QTimer> | 26 | #include <QTimer> |
431 | 27 | 27 | #include <QVariant> | |
430 | 28 | #include "gconfitem-qml-wrapper.h" | ||
432 | 29 | 28 | ||
433 | 30 | #include <unity2ddeclarativeview.h> | 29 | #include <unity2ddeclarativeview.h> |
434 | 31 | 30 | ||
435 | 32 | class DeclarativeDragDropEvent; | 31 | class DeclarativeDragDropEvent; |
436 | 33 | class LauncherDBus; | 32 | class LauncherDBus; |
437 | 33 | class QConf; | ||
438 | 34 | 34 | ||
439 | 35 | class LauncherView : public Unity2DDeclarativeView | 35 | class LauncherView : public Unity2DDeclarativeView |
440 | 36 | { | 36 | { |
441 | @@ -40,6 +40,7 @@ | |||
442 | 40 | 40 | ||
443 | 41 | public: | 41 | public: |
444 | 42 | explicit LauncherView(QWidget* parent = NULL); | 42 | explicit LauncherView(QWidget* parent = NULL); |
445 | 43 | ~LauncherView(); | ||
446 | 43 | 44 | ||
447 | 44 | bool superKeyHeld() const { return m_superKeyHeld; } | 45 | bool superKeyHeld() const { return m_superKeyHeld; } |
448 | 45 | 46 | ||
449 | @@ -66,7 +67,7 @@ | |||
450 | 66 | void focusOutEvent(QFocusEvent* event); | 67 | void focusOutEvent(QFocusEvent* event); |
451 | 67 | 68 | ||
452 | 68 | private: | 69 | private: |
454 | 69 | GConfItemQmlWrapper m_enableSuperKey; | 70 | QConf* m_dconf_launcher; |
455 | 70 | bool m_superKeyPressed; | 71 | bool m_superKeyPressed; |
456 | 71 | bool m_superKeyHeld; | 72 | bool m_superKeyHeld; |
457 | 72 | QTimer m_superKeyHoldTimer; | 73 | QTimer m_superKeyHoldTimer; |
458 | 73 | 74 | ||
459 | === modified file 'launcher/app/visibilitycontroller.cpp' | |||
460 | --- launcher/app/visibilitycontroller.cpp 2011-06-11 11:33:52 +0000 | |||
461 | +++ launcher/app/visibilitycontroller.cpp 2011-07-27 15:02:42 +0000 | |||
462 | @@ -30,27 +30,25 @@ | |||
463 | 30 | #include <debug_p.h> | 30 | #include <debug_p.h> |
464 | 31 | #include <unity2dpanel.h> | 31 | #include <unity2dpanel.h> |
465 | 32 | 32 | ||
468 | 33 | // libqtgconf | 33 | // libdconf-qt |
469 | 34 | #include <gconfitem-qml-wrapper.h> | 34 | #include "qconf.h" |
470 | 35 | 35 | ||
471 | 36 | // Qt | 36 | // Qt |
472 | 37 | #include <QDBusConnection> | 37 | #include <QDBusConnection> |
473 | 38 | #include <QDBusServiceWatcher> | 38 | #include <QDBusServiceWatcher> |
474 | 39 | 39 | ||
476 | 40 | static const char* GCONF_LAUNCHER_HIDEMODE_KEY = "/desktop/unity-2d/launcher/hide_mode"; | 40 | static const char* LAUNCHER_DCONF_SCHEMA = "com.canonical.Unity2d.Launcher"; |
477 | 41 | 41 | ||
478 | 42 | VisibilityController::VisibilityController(Unity2dPanel* panel) | 42 | VisibilityController::VisibilityController(Unity2dPanel* panel) |
479 | 43 | : QObject(panel) | 43 | : QObject(panel) |
480 | 44 | , m_panel(panel) | 44 | , m_panel(panel) |
482 | 45 | , m_hideModeKey(new GConfItemQmlWrapper(this)) | 45 | , m_dconf_launcher(new QConf(LAUNCHER_DCONF_SCHEMA)) |
483 | 46 | , m_dbusWatcher(new QDBusServiceWatcher(this)) | 46 | , m_dbusWatcher(new QDBusServiceWatcher(this)) |
484 | 47 | { | 47 | { |
485 | 48 | m_hideModeKey->setKey(GCONF_LAUNCHER_HIDEMODE_KEY); | ||
486 | 49 | |||
487 | 50 | m_dbusWatcher->setConnection(QDBusConnection::sessionBus()); | 48 | m_dbusWatcher->setConnection(QDBusConnection::sessionBus()); |
488 | 51 | m_dbusWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration); | 49 | m_dbusWatcher->setWatchMode(QDBusServiceWatcher::WatchForUnregistration); |
489 | 52 | 50 | ||
491 | 53 | connect(m_hideModeKey, SIGNAL(valueChanged()), SLOT(update())); | 51 | connect(m_dconf_launcher, SIGNAL(hideModeChanged(int)), SLOT(update())); |
492 | 54 | connect(m_panel, SIGNAL(useStrutChanged(bool)), SLOT(update())); | 52 | connect(m_panel, SIGNAL(useStrutChanged(bool)), SLOT(update())); |
493 | 55 | connect(m_panel, SIGNAL(manualSlidingChanged(bool)), SLOT(update())); | 53 | connect(m_panel, SIGNAL(manualSlidingChanged(bool)), SLOT(update())); |
494 | 56 | connect(m_dbusWatcher, SIGNAL(serviceUnregistered(const QString&)), SLOT(slotServiceUnregistered(const QString&))); | 54 | connect(m_dbusWatcher, SIGNAL(serviceUnregistered(const QString&)), SLOT(slotServiceUnregistered(const QString&))); |
495 | @@ -59,6 +57,7 @@ | |||
496 | 59 | 57 | ||
497 | 60 | VisibilityController::~VisibilityController() | 58 | VisibilityController::~VisibilityController() |
498 | 61 | { | 59 | { |
499 | 60 | delete m_dconf_launcher; | ||
500 | 62 | } | 61 | } |
501 | 63 | 62 | ||
502 | 64 | void VisibilityController::update() | 63 | void VisibilityController::update() |
503 | @@ -66,7 +65,7 @@ | |||
504 | 66 | if (!m_forceVisibleCountHash.isEmpty()) { | 65 | if (!m_forceVisibleCountHash.isEmpty()) { |
505 | 67 | return; | 66 | return; |
506 | 68 | } | 67 | } |
508 | 69 | AutoHideMode mode = AutoHideMode(m_hideModeKey->getValue().toInt()); | 68 | AutoHideMode mode = AutoHideMode(m_dconf_launcher->property("hideMode").toInt()); |
509 | 70 | 69 | ||
510 | 71 | setBehavior(0); | 70 | setBehavior(0); |
511 | 72 | 71 | ||
512 | 73 | 72 | ||
513 | === modified file 'launcher/app/visibilitycontroller.h' | |||
514 | --- launcher/app/visibilitycontroller.h 2011-06-11 11:33:52 +0000 | |||
515 | +++ launcher/app/visibilitycontroller.h 2011-07-27 15:02:42 +0000 | |||
516 | @@ -28,14 +28,14 @@ | |||
517 | 28 | #include <QObject> | 28 | #include <QObject> |
518 | 29 | #include <QScopedPointer> | 29 | #include <QScopedPointer> |
519 | 30 | 30 | ||
521 | 31 | class GConfItemQmlWrapper; | 31 | class QConf; |
522 | 32 | 32 | ||
523 | 33 | class AbstractVisibilityBehavior; | 33 | class AbstractVisibilityBehavior; |
524 | 34 | class Unity2dPanel; | 34 | class Unity2dPanel; |
525 | 35 | class QDBusServiceWatcher; | 35 | class QDBusServiceWatcher; |
526 | 36 | 36 | ||
527 | 37 | /** | 37 | /** |
529 | 38 | * This class monitors the hide_mode gconf key and set up an instance of | 38 | * This class monitors the hide_mode dconf key and set up an instance of |
530 | 39 | * AbstractVisibilityBehavior depending on its value | 39 | * AbstractVisibilityBehavior depending on its value |
531 | 40 | * | 40 | * |
532 | 41 | * It also tracks requests for forced visibility: the launcher or another | 41 | * It also tracks requests for forced visibility: the launcher or another |
533 | @@ -77,7 +77,7 @@ | |||
534 | 77 | }; | 77 | }; |
535 | 78 | Q_DISABLE_COPY(VisibilityController); | 78 | Q_DISABLE_COPY(VisibilityController); |
536 | 79 | Unity2dPanel* m_panel; | 79 | Unity2dPanel* m_panel; |
538 | 80 | GConfItemQmlWrapper* m_hideModeKey; | 80 | QConf* m_dconf_launcher; |
539 | 81 | QDBusServiceWatcher* m_dbusWatcher; | 81 | QDBusServiceWatcher* m_dbusWatcher; |
540 | 82 | QScopedPointer<AbstractVisibilityBehavior> m_behavior; | 82 | QScopedPointer<AbstractVisibilityBehavior> m_behavior; |
541 | 83 | 83 | ||
542 | 84 | 84 | ||
543 | === modified file 'libunity-2d-private/Unity2d/CMakeLists.txt' | |||
544 | --- libunity-2d-private/Unity2d/CMakeLists.txt 2011-06-22 08:54:52 +0000 | |||
545 | +++ libunity-2d-private/Unity2d/CMakeLists.txt 2011-07-27 15:02:42 +0000 | |||
546 | @@ -1,16 +1,11 @@ | |||
547 | 1 | # Dependencies | 1 | # Dependencies |
548 | 2 | pkg_check_modules(WNCK REQUIRED libwnck-1.0) | ||
549 | 3 | pkg_check_modules(QTBAMF REQUIRED libqtbamf) | 2 | pkg_check_modules(QTBAMF REQUIRED libqtbamf) |
550 | 4 | pkg_check_modules(QTGCONF REQUIRED libqtgconf) | 3 | pkg_check_modules(QTGCONF REQUIRED libqtgconf) |
551 | 5 | pkg_check_modules(QTDEE REQUIRED libqtdee) | 4 | pkg_check_modules(QTDEE REQUIRED libqtdee) |
552 | 6 | pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt) | 5 | pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt) |
553 | 7 | pkg_check_modules(GLIB REQUIRED glib-2.0) | ||
554 | 8 | pkg_check_modules(GDK REQUIRED gdk-2.0) | ||
555 | 9 | pkg_check_modules(GIO REQUIRED gio-2.0) | ||
556 | 10 | pkg_check_modules(STARTUPNOTIFICATION REQUIRED libstartup-notification-1.0) | 6 | pkg_check_modules(STARTUPNOTIFICATION REQUIRED libstartup-notification-1.0) |
557 | 11 | pkg_check_modules(INDICATOR REQUIRED indicator) | 7 | pkg_check_modules(INDICATOR REQUIRED indicator) |
560 | 12 | 8 | pkg_check_modules(DCONFQT REQUIRED dconf-qt) | |
559 | 13 | find_package(X11 REQUIRED) | ||
561 | 14 | 9 | ||
562 | 15 | # Sources | 10 | # Sources |
563 | 16 | set(unity-2d-private-qml_SRCS | 11 | set(unity-2d-private-qml_SRCS |
564 | @@ -100,6 +95,7 @@ | |||
565 | 100 | ${STARTUPNOTIFICATION_INCLUDE_DIRS} | 95 | ${STARTUPNOTIFICATION_INCLUDE_DIRS} |
566 | 101 | ${INDICATOR_INCLUDE_DIRS} | 96 | ${INDICATOR_INCLUDE_DIRS} |
567 | 102 | ${X11_INCLUDE_DIR} | 97 | ${X11_INCLUDE_DIR} |
568 | 98 | ${DCONFQT_INCLUDE_DIRS} | ||
569 | 103 | ${libunity-2d-private_SOURCE_DIR}/src | 99 | ${libunity-2d-private_SOURCE_DIR}/src |
570 | 104 | ) | 100 | ) |
571 | 105 | 101 | ||
572 | @@ -119,6 +115,7 @@ | |||
573 | 119 | ${GIO_LDFLAGS} | 115 | ${GIO_LDFLAGS} |
574 | 120 | ${STARTUPNOTIFICATION_LDFLAGS} | 116 | ${STARTUPNOTIFICATION_LDFLAGS} |
575 | 121 | ${INDICATOR_LDFLAGS} | 117 | ${INDICATOR_LDFLAGS} |
576 | 118 | ${DCONFQT_LDFLAGS} | ||
577 | 122 | ${X11_Xcomposite_LIB} | 119 | ${X11_Xcomposite_LIB} |
578 | 123 | unity-2d-private | 120 | unity-2d-private |
579 | 124 | ) | 121 | ) |
580 | 125 | 122 | ||
581 | === modified file 'libunity-2d-private/Unity2d/launcherapplicationslist.cpp' | |||
582 | --- libunity-2d-private/Unity2d/launcherapplicationslist.cpp 2011-07-13 16:04:50 +0000 | |||
583 | +++ libunity-2d-private/Unity2d/launcherapplicationslist.cpp 2011-07-27 15:02:42 +0000 | |||
584 | @@ -23,6 +23,9 @@ | |||
585 | 23 | #include "bamf-application.h" | 23 | #include "bamf-application.h" |
586 | 24 | #include "gconfitem-qml-wrapper.h" | 24 | #include "gconfitem-qml-wrapper.h" |
587 | 25 | 25 | ||
588 | 26 | // libdconf-qt | ||
589 | 27 | #include "qconf.h" | ||
590 | 28 | |||
591 | 26 | // unity-2d | 29 | // unity-2d |
592 | 27 | #include <debug_p.h> | 30 | #include <debug_p.h> |
593 | 28 | 31 | ||
594 | @@ -40,7 +43,8 @@ | |||
595 | 40 | } | 43 | } |
596 | 41 | 44 | ||
597 | 42 | 45 | ||
599 | 43 | #define FAVORITES_KEY QString("/desktop/unity-2d/launcher/favorites") | 46 | #define LAUNCHER_DCONF_SCHEMA QString("com.canonical.Unity.Launcher") |
600 | 47 | #define LAUNCHER_DCONF_PATH QString("/desktop/unity/launcher") | ||
601 | 44 | #define DBUS_SERVICE_UNITY "com.canonical.Unity" | 48 | #define DBUS_SERVICE_UNITY "com.canonical.Unity" |
602 | 45 | #define DBUS_SERVICE_LAUNCHER_ENTRY "com.canonical.Unity.LauncherEntry" | 49 | #define DBUS_SERVICE_LAUNCHER_ENTRY "com.canonical.Unity.LauncherEntry" |
603 | 46 | #define DBUS_SERVICE_LAUNCHER "com.canonical.Unity.Launcher" | 50 | #define DBUS_SERVICE_LAUNCHER "com.canonical.Unity.Launcher" |
604 | @@ -52,8 +56,7 @@ | |||
605 | 52 | LauncherApplicationsList::LauncherApplicationsList(QObject *parent) : | 56 | LauncherApplicationsList::LauncherApplicationsList(QObject *parent) : |
606 | 53 | QAbstractListModel(parent) | 57 | QAbstractListModel(parent) |
607 | 54 | { | 58 | { |
610 | 55 | m_favorites_list = new GConfItemQmlWrapper(); | 59 | m_dconf_launcher = new QConf(LAUNCHER_DCONF_SCHEMA); |
609 | 56 | m_favorites_list->setKey(FAVORITES_KEY); | ||
611 | 57 | 60 | ||
612 | 58 | QDBusConnection session = QDBusConnection::sessionBus(); | 61 | QDBusConnection session = QDBusConnection::sessionBus(); |
613 | 59 | /* FIXME: libunity will send out the Update signal for LauncherEntries | 62 | /* FIXME: libunity will send out the Update signal for LauncherEntries |
614 | @@ -171,7 +174,7 @@ | |||
615 | 171 | sn_display_unref(m_snDisplay); | 174 | sn_display_unref(m_snDisplay); |
616 | 172 | 175 | ||
617 | 173 | qDeleteAll(m_applications); | 176 | qDeleteAll(m_applications); |
619 | 174 | delete m_favorites_list; | 177 | delete m_dconf_launcher; |
620 | 175 | } | 178 | } |
621 | 176 | 179 | ||
622 | 177 | QString | 180 | QString |
623 | @@ -366,9 +369,8 @@ | |||
624 | 366 | LauncherApplicationsList::load() | 369 | LauncherApplicationsList::load() |
625 | 367 | { | 370 | { |
626 | 368 | /* Insert favorites */ | 371 | /* Insert favorites */ |
627 | 369 | /* FIXME: migrate to GSettings, like unity. */ | ||
628 | 370 | QString desktop_file; | 372 | QString desktop_file; |
630 | 371 | QStringList favorites = m_favorites_list->getValue().toStringList(); | 373 | QStringList favorites = m_dconf_launcher->property("favorites").toStringList(); |
631 | 372 | 374 | ||
632 | 373 | Q_FOREACH(QString favorite, favorites) { | 375 | Q_FOREACH(QString favorite, favorites) { |
633 | 374 | insertFavoriteApplication(favorite); | 376 | insertFavoriteApplication(favorite); |
634 | @@ -453,9 +455,9 @@ | |||
635 | 453 | } | 455 | } |
636 | 454 | } | 456 | } |
637 | 455 | 457 | ||
641 | 456 | m_favorites_list->blockSignals(true); | 458 | m_dconf_launcher->blockSignals(true); |
642 | 457 | m_favorites_list->setValue(QVariant(favorites)); | 459 | m_dconf_launcher->setProperty("favorites", QVariant(favorites)); |
643 | 458 | m_favorites_list->blockSignals(false); | 460 | m_dconf_launcher->blockSignals(false); |
644 | 459 | } | 461 | } |
645 | 460 | 462 | ||
646 | 461 | int | 463 | int |
647 | 462 | 464 | ||
648 | === modified file 'libunity-2d-private/Unity2d/launcherapplicationslist.h' | |||
649 | --- libunity-2d-private/Unity2d/launcherapplicationslist.h 2011-07-13 16:04:50 +0000 | |||
650 | +++ libunity-2d-private/Unity2d/launcherapplicationslist.h 2011-07-27 15:02:42 +0000 | |||
651 | @@ -37,6 +37,7 @@ | |||
652 | 37 | class BamfApplication; | 37 | class BamfApplication; |
653 | 38 | class BamfView; | 38 | class BamfView; |
654 | 39 | class GConfItemQmlWrapper; | 39 | class GConfItemQmlWrapper; |
655 | 40 | class QConf; | ||
656 | 40 | 41 | ||
657 | 41 | class LauncherApplicationsList : public QAbstractListModel, protected AbstractX11EventFilter, protected QDBusContext | 42 | class LauncherApplicationsList : public QAbstractListModel, protected AbstractX11EventFilter, protected QDBusContext |
658 | 42 | { | 43 | { |
659 | @@ -88,7 +89,7 @@ | |||
660 | 88 | displayed (m_applications). | 89 | displayed (m_applications). |
661 | 89 | */ | 90 | */ |
662 | 90 | QHash<QString, LauncherApplication*> m_applicationForExecutable; | 91 | QHash<QString, LauncherApplication*> m_applicationForExecutable; |
664 | 91 | GConfItemQmlWrapper* m_favorites_list; | 92 | QConf* m_dconf_launcher; |
665 | 92 | 93 | ||
666 | 93 | /* Startup notification support */ | 94 | /* Startup notification support */ |
667 | 94 | SnDisplay *m_snDisplay; | 95 | SnDisplay *m_snDisplay; |
668 | 95 | 96 | ||
669 | === modified file 'libunity-2d-private/Unity2d/plugin.cpp' | |||
670 | --- libunity-2d-private/Unity2d/plugin.cpp 2011-07-14 11:17:30 +0000 | |||
671 | +++ libunity-2d-private/Unity2d/plugin.cpp 2011-07-27 15:02:42 +0000 | |||
672 | @@ -47,6 +47,7 @@ | |||
673 | 47 | #include "cacheeffect.h" | 47 | #include "cacheeffect.h" |
674 | 48 | #include "iconutilities.h" | 48 | #include "iconutilities.h" |
675 | 49 | #include "unity2dtr.h" | 49 | #include "unity2dtr.h" |
676 | 50 | #include "giodefaultapplication.h" | ||
677 | 50 | 51 | ||
678 | 51 | #include "mimedata.h" | 52 | #include "mimedata.h" |
679 | 52 | #include "dragdropevent.h" | 53 | #include "dragdropevent.h" |
680 | @@ -127,6 +128,8 @@ | |||
681 | 127 | qmlRegisterType<ForceVisibleBehavior>(uri, 0, 1, "ForceVisibleBehavior"); | 128 | qmlRegisterType<ForceVisibleBehavior>(uri, 0, 1, "ForceVisibleBehavior"); |
682 | 128 | 129 | ||
683 | 129 | qmlRegisterType<IconUtilities>(); // Register the type as non creatable | 130 | qmlRegisterType<IconUtilities>(); // Register the type as non creatable |
684 | 131 | |||
685 | 132 | qmlRegisterType<GioDefaultApplication>(uri, 0, 1, "GioDefaultApplication"); | ||
686 | 130 | } | 133 | } |
687 | 131 | 134 | ||
688 | 132 | void Unity2dPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) | 135 | void Unity2dPlugin::initializeEngine(QDeclarativeEngine *engine, const char *uri) |
689 | 133 | 136 | ||
690 | === modified file 'libunity-2d-private/Unity2d/qsortfilterproxymodelqml.cpp' | |||
691 | --- libunity-2d-private/Unity2d/qsortfilterproxymodelqml.cpp 2011-04-28 13:09:25 +0000 | |||
692 | +++ libunity-2d-private/Unity2d/qsortfilterproxymodelqml.cpp 2011-07-27 15:02:42 +0000 | |||
693 | @@ -18,14 +18,17 @@ | |||
694 | 18 | #include <debug_p.h> | 18 | #include <debug_p.h> |
695 | 19 | 19 | ||
696 | 20 | QSortFilterProxyModelQML::QSortFilterProxyModelQML(QObject *parent) : | 20 | QSortFilterProxyModelQML::QSortFilterProxyModelQML(QObject *parent) : |
698 | 21 | QSortFilterProxyModel(parent) | 21 | QSortFilterProxyModel(parent), m_limit(-1) |
699 | 22 | { | 22 | { |
700 | 23 | connect(this, SIGNAL(modelReset()), SIGNAL(countChanged())); | ||
701 | 24 | connect(this, SIGNAL(rowsInserted(QModelIndex,int,int)), SIGNAL(countChanged())); | ||
702 | 25 | connect(this, SIGNAL(rowsRemoved(QModelIndex,int,int)), SIGNAL(countChanged())); | ||
703 | 23 | } | 26 | } |
704 | 24 | 27 | ||
707 | 25 | void | 28 | void QSortFilterProxyModelQML::setRoleNames(const QHash<int,QByteArray> &roleNames) |
706 | 26 | QSortFilterProxyModelQML::updateRoleNames() | ||
708 | 27 | { | 29 | { |
710 | 28 | setRoleNames(((QAbstractItemModel*)sourceModel())->roleNames()); | 30 | QSortFilterProxyModel::setRoleNames(roleNames); |
711 | 31 | Q_EMIT roleNamesChanged(roleNames); | ||
712 | 29 | } | 32 | } |
713 | 30 | 33 | ||
714 | 31 | QObject* | 34 | QObject* |
715 | @@ -51,10 +54,25 @@ | |||
716 | 51 | sourceModel()->disconnect(this); | 54 | sourceModel()->disconnect(this); |
717 | 52 | } | 55 | } |
718 | 53 | 56 | ||
719 | 57 | /* Workaround for limitation of QAbstractProxyModel: if sourceModel's | ||
720 | 58 | roleNames changes, the QAbstractProxyModel's roleNames are not updated | ||
721 | 59 | to reflect that change. | ||
722 | 60 | As a consequence it works around Qt bug http://bugreports.qt.nokia.com/browse/QTBUG-20405 | ||
723 | 61 | */ | ||
724 | 62 | bool hasRoleNamesChangedSignal; | ||
725 | 63 | hasRoleNamesChangedSignal = connect(itemModel, SIGNAL(roleNamesChanged(QHash<int,QByteArray>)), SLOT(setRoleNames(QHash<int,QByteArray>))); | ||
726 | 64 | if (!hasRoleNamesChangedSignal) { | ||
727 | 65 | UQ_WARNING << "received a sourceModel that does not notify of changes of its roleNames"; | ||
728 | 66 | } | ||
729 | 67 | setRoleNames(itemModel->roleNames()); | ||
730 | 68 | |||
731 | 54 | setSourceModel(itemModel); | 69 | setSourceModel(itemModel); |
732 | 55 | 70 | ||
735 | 56 | connect(itemModel, SIGNAL(modelAboutToBeReset()), SLOT(updateRoleNames())); | 71 | connect(itemModel, SIGNAL(modelReset()), SIGNAL(totalCountChanged())); |
736 | 57 | connect(itemModel, SIGNAL(modelReset()), SLOT(updateRoleNames())); | 72 | connect(itemModel, SIGNAL(rowsInserted(QModelIndex,int,int)), SIGNAL(totalCountChanged())); |
737 | 73 | connect(itemModel, SIGNAL(rowsRemoved(QModelIndex,int,int)), SIGNAL(totalCountChanged())); | ||
738 | 74 | Q_EMIT totalCountChanged(); | ||
739 | 75 | Q_EMIT countChanged(); | ||
740 | 58 | } | 76 | } |
741 | 59 | 77 | ||
742 | 60 | QVariantMap | 78 | QVariantMap |
743 | @@ -76,7 +94,97 @@ | |||
744 | 76 | } | 94 | } |
745 | 77 | 95 | ||
746 | 78 | int | 96 | int |
747 | 97 | QSortFilterProxyModelQML::totalCount() const | ||
748 | 98 | { | ||
749 | 99 | if (sourceModel() != NULL) { | ||
750 | 100 | return sourceModel()->rowCount(); | ||
751 | 101 | } else { | ||
752 | 102 | return 0; | ||
753 | 103 | } | ||
754 | 104 | } | ||
755 | 105 | |||
756 | 106 | int | ||
757 | 79 | QSortFilterProxyModelQML::count() | 107 | QSortFilterProxyModelQML::count() |
758 | 80 | { | 108 | { |
759 | 81 | return rowCount(); | 109 | return rowCount(); |
760 | 82 | } | 110 | } |
761 | 111 | |||
762 | 112 | int | ||
763 | 113 | QSortFilterProxyModelQML::rowCount(const QModelIndex &parent) const | ||
764 | 114 | { | ||
765 | 115 | int count = QSortFilterProxyModel::rowCount(parent); | ||
766 | 116 | if (m_limit >= 0) { | ||
767 | 117 | return qMin(count, m_limit); | ||
768 | 118 | } else { | ||
769 | 119 | return count; | ||
770 | 120 | } | ||
771 | 121 | } | ||
772 | 122 | |||
773 | 123 | int | ||
774 | 124 | QSortFilterProxyModelQML::limit() const | ||
775 | 125 | { | ||
776 | 126 | return m_limit; | ||
777 | 127 | } | ||
778 | 128 | |||
779 | 129 | void | ||
780 | 130 | QSortFilterProxyModelQML::setLimit(int limit) | ||
781 | 131 | { | ||
782 | 132 | if (limit != m_limit) { | ||
783 | 133 | int count = QSortFilterProxyModel::rowCount(); | ||
784 | 134 | int start; | ||
785 | 135 | int end; | ||
786 | 136 | bool inserted = false; | ||
787 | 137 | bool removed = false; | ||
788 | 138 | |||
789 | 139 | if (m_limit == -1) { | ||
790 | 140 | if (limit < count) { | ||
791 | 141 | start = qMin(count, limit); | ||
792 | 142 | end = count-1; | ||
793 | 143 | removed = true; | ||
794 | 144 | } | ||
795 | 145 | } else if (limit == -1) { | ||
796 | 146 | if (m_limit < count) { | ||
797 | 147 | start = qMin(count, m_limit); | ||
798 | 148 | end = count-1; | ||
799 | 149 | inserted = true; | ||
800 | 150 | } | ||
801 | 151 | } else if (m_limit >= count && limit >= count) { | ||
802 | 152 | // Nothing | ||
803 | 153 | } else if (m_limit >= count && limit < count) { | ||
804 | 154 | start = qMin(count, limit); | ||
805 | 155 | end = count-1; | ||
806 | 156 | removed = true; | ||
807 | 157 | } else if (m_limit < count && limit >= count) { | ||
808 | 158 | start = qMin(count, m_limit); | ||
809 | 159 | end = count-1; | ||
810 | 160 | inserted = true; | ||
811 | 161 | } else if (m_limit < count && limit < count) { | ||
812 | 162 | if (m_limit < limit) { | ||
813 | 163 | start = qMin(count, m_limit); | ||
814 | 164 | end = qMin(count, limit)-1; | ||
815 | 165 | inserted = true; | ||
816 | 166 | } else { | ||
817 | 167 | start = qMin(count, limit); | ||
818 | 168 | end = qMin(count, m_limit)-1; | ||
819 | 169 | removed = true; | ||
820 | 170 | } | ||
821 | 171 | } | ||
822 | 172 | |||
823 | 173 | if (inserted) { | ||
824 | 174 | beginInsertRows(QModelIndex(), start, end); | ||
825 | 175 | } | ||
826 | 176 | if (removed) { | ||
827 | 177 | beginRemoveRows(QModelIndex(), start, end); | ||
828 | 178 | } | ||
829 | 179 | m_limit = limit; | ||
830 | 180 | |||
831 | 181 | if (inserted) { | ||
832 | 182 | endInsertRows(); | ||
833 | 183 | } | ||
834 | 184 | if (removed) { | ||
835 | 185 | endRemoveRows(); | ||
836 | 186 | } | ||
837 | 187 | |||
838 | 188 | Q_EMIT limitChanged(); | ||
839 | 189 | } | ||
840 | 190 | } | ||
841 | 83 | 191 | ||
842 | === modified file 'libunity-2d-private/Unity2d/qsortfilterproxymodelqml.h' | |||
843 | --- libunity-2d-private/Unity2d/qsortfilterproxymodelqml.h 2011-03-23 14:04:23 +0000 | |||
844 | +++ libunity-2d-private/Unity2d/qsortfilterproxymodelqml.h 2011-07-27 15:02:42 +0000 | |||
845 | @@ -24,21 +24,36 @@ | |||
846 | 24 | Q_OBJECT | 24 | Q_OBJECT |
847 | 25 | 25 | ||
848 | 26 | Q_PROPERTY(QObject* model READ sourceModelQObject WRITE setSourceModelQObject) | 26 | Q_PROPERTY(QObject* model READ sourceModelQObject WRITE setSourceModelQObject) |
849 | 27 | Q_PROPERTY(int limit READ limit WRITE setLimit NOTIFY limitChanged) | ||
850 | 28 | Q_PROPERTY(int totalCount READ totalCount NOTIFY totalCountChanged) | ||
851 | 29 | Q_PROPERTY(int count READ count NOTIFY countChanged) | ||
852 | 27 | 30 | ||
853 | 28 | public: | 31 | public: |
854 | 29 | explicit QSortFilterProxyModelQML(QObject *parent = 0); | 32 | explicit QSortFilterProxyModelQML(QObject *parent = 0); |
855 | 30 | 33 | ||
856 | 31 | Q_INVOKABLE QVariantMap get(int row); | 34 | Q_INVOKABLE QVariantMap get(int row); |
857 | 32 | Q_INVOKABLE int count(); | 35 | Q_INVOKABLE int count(); |
858 | 36 | int rowCount(const QModelIndex &parent = QModelIndex()) const; | ||
859 | 33 | 37 | ||
860 | 34 | /* getters */ | 38 | /* getters */ |
861 | 35 | QObject* sourceModelQObject() const; | 39 | QObject* sourceModelQObject() const; |
862 | 40 | int limit() const; | ||
863 | 41 | int totalCount() const; | ||
864 | 36 | 42 | ||
865 | 37 | /* setters */ | 43 | /* setters */ |
866 | 38 | void setSourceModelQObject(QObject *model); | 44 | void setSourceModelQObject(QObject *model); |
870 | 39 | 45 | void setLimit(int limit); | |
871 | 40 | private Q_SLOTS: | 46 | |
872 | 41 | void updateRoleNames(); | 47 | Q_SLOT void setRoleNames(const QHash<int,QByteArray> &roleNames); |
873 | 48 | |||
874 | 49 | Q_SIGNALS: | ||
875 | 50 | void limitChanged(); | ||
876 | 51 | void totalCountChanged(); | ||
877 | 52 | void countChanged(); | ||
878 | 53 | void roleNamesChanged(const QHash<int,QByteArray> &); | ||
879 | 54 | |||
880 | 55 | private: | ||
881 | 56 | int m_limit; | ||
882 | 42 | }; | 57 | }; |
883 | 43 | 58 | ||
884 | 44 | #endif // QSORTFILTERPROXYMODELQML_H | 59 | #endif // QSORTFILTERPROXYMODELQML_H |
885 | 45 | 60 | ||
886 | === modified file 'libunity-2d-private/Unity2d/workspacesinfo.cpp' | |||
887 | --- libunity-2d-private/Unity2d/workspacesinfo.cpp 2011-06-27 13:43:05 +0000 | |||
888 | +++ libunity-2d-private/Unity2d/workspacesinfo.cpp 2011-07-27 15:02:42 +0000 | |||
889 | @@ -9,8 +9,6 @@ | |||
890 | 9 | #include <libwnck/workspace.h> | 9 | #include <libwnck/workspace.h> |
891 | 10 | } | 10 | } |
892 | 11 | 11 | ||
893 | 12 | #include "gconfitem-qml-wrapper.h" | ||
894 | 13 | |||
895 | 14 | #include <QAbstractEventDispatcher> | 12 | #include <QAbstractEventDispatcher> |
896 | 15 | #include <QX11Info> | 13 | #include <QX11Info> |
897 | 16 | 14 | ||
898 | 17 | 15 | ||
899 | === modified file 'libunity-2d-private/src/CMakeLists.txt' | |||
900 | --- libunity-2d-private/src/CMakeLists.txt 2011-07-12 10:30:50 +0000 | |||
901 | +++ libunity-2d-private/src/CMakeLists.txt 2011-07-27 15:02:42 +0000 | |||
902 | @@ -1,7 +1,3 @@ | |||
903 | 1 | # Dependencies | ||
904 | 2 | pkg_check_modules(GLIB REQUIRED glib-2.0) | ||
905 | 3 | pkg_check_modules(WNCK REQUIRED libwnck-1.0) | ||
906 | 4 | |||
907 | 5 | # Sources | 1 | # Sources |
908 | 6 | set(libunity-2d-private_SRCS | 2 | set(libunity-2d-private_SRCS |
909 | 7 | gconnector.cpp | 3 | gconnector.cpp |
910 | @@ -24,6 +20,7 @@ | |||
911 | 24 | edgehitdetector.cpp | 20 | edgehitdetector.cpp |
912 | 25 | forcevisiblebehavior.cpp | 21 | forcevisiblebehavior.cpp |
913 | 26 | intellihidebehavior.cpp | 22 | intellihidebehavior.cpp |
914 | 23 | giodefaultapplication.cpp | ||
915 | 27 | ) | 24 | ) |
916 | 28 | 25 | ||
917 | 29 | # Build | 26 | # Build |
918 | 30 | 27 | ||
919 | === added file 'libunity-2d-private/src/giodefaultapplication.cpp' | |||
920 | --- libunity-2d-private/src/giodefaultapplication.cpp 1970-01-01 00:00:00 +0000 | |||
921 | +++ libunity-2d-private/src/giodefaultapplication.cpp 2011-07-27 15:02:42 +0000 | |||
922 | @@ -0,0 +1,107 @@ | |||
923 | 1 | /* | ||
924 | 2 | * Copyright (C) 2011 Canonical, Ltd. | ||
925 | 3 | * | ||
926 | 4 | * Authors: | ||
927 | 5 | * Florian Boucault <florian.boucault@canonical.com> | ||
928 | 6 | * | ||
929 | 7 | * This program is free software; you can redistribute it and/or modify | ||
930 | 8 | * it under the terms of the GNU General Public License as published by | ||
931 | 9 | * the Free Software Foundation; version 3. | ||
932 | 10 | * | ||
933 | 11 | * This program is distributed in the hope that it will be useful, | ||
934 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
935 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
936 | 14 | * GNU General Public License for more details. | ||
937 | 15 | * | ||
938 | 16 | * You should have received a copy of the GNU General Public License | ||
939 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
940 | 18 | */ | ||
941 | 19 | |||
942 | 20 | #include "giodefaultapplication.h" | ||
943 | 21 | |||
944 | 22 | // libunity-2d | ||
945 | 23 | #include <gscopedpointer.h> | ||
946 | 24 | |||
947 | 25 | // Qt | ||
948 | 26 | #include <QFileSystemWatcher> | ||
949 | 27 | #include <QDir> | ||
950 | 28 | #include <QTimer> | ||
951 | 29 | |||
952 | 30 | // gio | ||
953 | 31 | #include <gio/gio.h> | ||
954 | 32 | #include <gio/gdesktopappinfo.h> | ||
955 | 33 | |||
956 | 34 | static const QString MIMEAPPS_FILE = QDir::homePath() + QString("/.local/share/applications/mimeapps.list"); | ||
957 | 35 | |||
958 | 36 | GioDefaultApplication::GioDefaultApplication(QObject* parent) | ||
959 | 37 | : QObject(parent), | ||
960 | 38 | m_contentType(""), | ||
961 | 39 | m_desktopFile(""), | ||
962 | 40 | m_mimeappsWatcher(new QFileSystemWatcher(this)) | ||
963 | 41 | { | ||
964 | 42 | /* GIO does not have any signal to inform us of changes in default | ||
965 | 43 | applications to handle a certain content type. Work around that | ||
966 | 44 | by monitoring file MIMEAPPS_FILE that is overwritten when default | ||
967 | 45 | applications change. */ | ||
968 | 46 | m_mimeappsWatcher->addPath(MIMEAPPS_FILE); | ||
969 | 47 | connect(m_mimeappsWatcher, SIGNAL(fileChanged(const QString&)), | ||
970 | 48 | SLOT(onMimeappsFileChanged())); | ||
971 | 49 | |||
972 | 50 | } | ||
973 | 51 | |||
974 | 52 | void GioDefaultApplication::onMimeappsFileChanged() | ||
975 | 53 | { | ||
976 | 54 | /* FIXME: wait for 10 seconds before updating the desktop file because | ||
977 | 55 | of a bug in gio where g_app_info_get_default_for_type will not immediately | ||
978 | 56 | return the updated result. | ||
979 | 57 | Ref.: https://bugzilla.gnome.org/show_bug.cgi?id=653999 | ||
980 | 58 | */ | ||
981 | 59 | QTimer::singleShot(10000, this, SLOT(updateDesktopFile())); | ||
982 | 60 | /* If the file is already being monitored, we shouldn’t need to do anything. | ||
983 | 61 | However it seems that in some cases, a change to the file will stop | ||
984 | 62 | emiting further fileChanged signals, despite the file still being in the | ||
985 | 63 | list of monitored files. This is the case when the desktop file is being | ||
986 | 64 | edited in gedit for example. This may be a bug in QT itself. | ||
987 | 65 | To work around this issue, remove the path and add it again. */ | ||
988 | 66 | m_mimeappsWatcher->removePath(MIMEAPPS_FILE); | ||
989 | 67 | m_mimeappsWatcher->addPath(MIMEAPPS_FILE); | ||
990 | 68 | } | ||
991 | 69 | |||
992 | 70 | QString GioDefaultApplication::desktopFile() const | ||
993 | 71 | { | ||
994 | 72 | return m_desktopFile; | ||
995 | 73 | } | ||
996 | 74 | |||
997 | 75 | QString GioDefaultApplication::contentType() const | ||
998 | 76 | { | ||
999 | 77 | return m_contentType; | ||
1000 | 78 | } | ||
1001 | 79 | |||
1002 | 80 | void GioDefaultApplication::setContentType(const QString& contentType) | ||
1003 | 81 | { | ||
1004 | 82 | if (contentType == m_contentType) { | ||
1005 | 83 | return; | ||
1006 | 84 | } | ||
1007 | 85 | |||
1008 | 86 | m_contentType = contentType; | ||
1009 | 87 | Q_EMIT contentTypeChanged(); | ||
1010 | 88 | updateDesktopFile(); | ||
1011 | 89 | } | ||
1012 | 90 | |||
1013 | 91 | void GioDefaultApplication::updateDesktopFile() | ||
1014 | 92 | { | ||
1015 | 93 | GObjectScopedPointer<GAppInfo> app_info; | ||
1016 | 94 | QByteArray byte_array = m_contentType.toUtf8(); | ||
1017 | 95 | gchar *content_type = byte_array.data(); | ||
1018 | 96 | |||
1019 | 97 | app_info.reset(g_app_info_get_default_for_type(content_type, false)); | ||
1020 | 98 | if (!app_info.isNull()) { | ||
1021 | 99 | m_desktopFile = QString::fromUtf8(g_desktop_app_info_get_filename((GDesktopAppInfo*)app_info.data())); | ||
1022 | 100 | } else { | ||
1023 | 101 | m_desktopFile = ""; | ||
1024 | 102 | } | ||
1025 | 103 | |||
1026 | 104 | Q_EMIT desktopFileChanged(); | ||
1027 | 105 | } | ||
1028 | 106 | |||
1029 | 107 | #include "giodefaultapplication.moc" | ||
1030 | 0 | 108 | ||
1031 | === added file 'libunity-2d-private/src/giodefaultapplication.h' | |||
1032 | --- libunity-2d-private/src/giodefaultapplication.h 1970-01-01 00:00:00 +0000 | |||
1033 | +++ libunity-2d-private/src/giodefaultapplication.h 2011-07-27 15:02:42 +0000 | |||
1034 | @@ -0,0 +1,63 @@ | |||
1035 | 1 | /* | ||
1036 | 2 | * Copyright (C) 2011 Canonical, Ltd. | ||
1037 | 3 | * | ||
1038 | 4 | * Authors: | ||
1039 | 5 | * Florian Boucault <florian.boucault@canonical.com> | ||
1040 | 6 | * | ||
1041 | 7 | * This program is free software; you can redistribute it and/or modify | ||
1042 | 8 | * it under the terms of the GNU General Public License as published by | ||
1043 | 9 | * the Free Software Foundation; version 3. | ||
1044 | 10 | * | ||
1045 | 11 | * This program is distributed in the hope that it will be useful, | ||
1046 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1047 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1048 | 14 | * GNU General Public License for more details. | ||
1049 | 15 | * | ||
1050 | 16 | * You should have received a copy of the GNU General Public License | ||
1051 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1052 | 18 | */ | ||
1053 | 19 | |||
1054 | 20 | #ifndef GIODEFAULTAPPLICATION_H | ||
1055 | 21 | #define GIODEFAULTAPPLICATION_H | ||
1056 | 22 | |||
1057 | 23 | #include <QObject> | ||
1058 | 24 | #include <QString> | ||
1059 | 25 | |||
1060 | 26 | class QFileSystemWatcher; | ||
1061 | 27 | |||
1062 | 28 | /* Wrapper around GIO's g_app_info_get_default_for_type. | ||
1063 | 29 | To use it, set the contentType property and the desktopFile will contain the | ||
1064 | 30 | path to the desktop file of the application handling that kind of content. | ||
1065 | 31 | */ | ||
1066 | 32 | class GioDefaultApplication : public QObject | ||
1067 | 33 | { | ||
1068 | 34 | Q_OBJECT | ||
1069 | 35 | |||
1070 | 36 | Q_PROPERTY(QString desktopFile READ desktopFile NOTIFY desktopFileChanged) | ||
1071 | 37 | Q_PROPERTY(QString contentType READ contentType WRITE setContentType NOTIFY contentTypeChanged) | ||
1072 | 38 | |||
1073 | 39 | public: | ||
1074 | 40 | GioDefaultApplication(QObject* parent=0); | ||
1075 | 41 | |||
1076 | 42 | /* getters */ | ||
1077 | 43 | QString desktopFile() const; | ||
1078 | 44 | QString contentType() const; | ||
1079 | 45 | |||
1080 | 46 | /* setters */ | ||
1081 | 47 | void setContentType(const QString& contentType); | ||
1082 | 48 | |||
1083 | 49 | Q_SIGNALS: | ||
1084 | 50 | void desktopFileChanged(); | ||
1085 | 51 | void contentTypeChanged(); | ||
1086 | 52 | |||
1087 | 53 | private: | ||
1088 | 54 | Q_SLOT void updateDesktopFile(); | ||
1089 | 55 | Q_SLOT void onMimeappsFileChanged(); | ||
1090 | 56 | |||
1091 | 57 | QString m_contentType; | ||
1092 | 58 | QString m_desktopFile; | ||
1093 | 59 | QFileSystemWatcher* m_mimeappsWatcher; | ||
1094 | 60 | }; | ||
1095 | 61 | |||
1096 | 62 | #endif // GIODEFAULTAPPLICATION | ||
1097 | 63 | |||
1098 | 0 | 64 | ||
1099 | === modified file 'libunity-2d-private/src/unity2dapplication.cpp' | |||
1100 | --- libunity-2d-private/src/unity2dapplication.cpp 2011-06-11 10:50:03 +0000 | |||
1101 | +++ libunity-2d-private/src/unity2dapplication.cpp 2011-07-27 15:02:42 +0000 | |||
1102 | @@ -21,8 +21,17 @@ | |||
1103 | 21 | 21 | ||
1104 | 22 | // Self | 22 | // Self |
1105 | 23 | #include "unity2dapplication.h" | 23 | #include "unity2dapplication.h" |
1106 | 24 | #include "config.h" | ||
1107 | 25 | |||
1108 | 26 | // libunity-2d | ||
1109 | 27 | #include <debug_p.h> | ||
1110 | 28 | #include <unity2ddebug.h> | ||
1111 | 24 | 29 | ||
1112 | 25 | // Qt | 30 | // Qt |
1113 | 31 | #include <QWindowsStyle> | ||
1114 | 32 | |||
1115 | 33 | // GTK | ||
1116 | 34 | #include <gtk/gtk.h> | ||
1117 | 26 | 35 | ||
1118 | 27 | AbstractX11EventFilter::~AbstractX11EventFilter() | 36 | AbstractX11EventFilter::~AbstractX11EventFilter() |
1119 | 28 | { | 37 | { |
1120 | @@ -32,9 +41,38 @@ | |||
1121 | 32 | } | 41 | } |
1122 | 33 | } | 42 | } |
1123 | 34 | 43 | ||
1124 | 44 | void Unity2dApplication::earlySetup(int& argc, char** argv) | ||
1125 | 45 | { | ||
1126 | 46 | // Parts of unity-2d uses GTK so it needs to be initialized | ||
1127 | 47 | gtk_init(&argc, &argv); | ||
1128 | 48 | |||
1129 | 49 | Unity2dDebug::installHandlers(); | ||
1130 | 50 | |||
1131 | 51 | /* When the environment variable QT_GRAPHICSSYSTEM is not set, force | ||
1132 | 52 | * graphics system to 'raster' instead of the default 'native' which on X11 | ||
1133 | 53 | * is 'XRender'. 'XRender' defaults to using a TrueColor visual. We do | ||
1134 | 54 | * _not_ mimick that behaviour with 'raster' by calling | ||
1135 | 55 | * QApplication::setColorSpec because of bugs where some pixmaps become | ||
1136 | 56 | * blueish or black rectangular artifacts were appearing randomly: | ||
1137 | 57 | * | ||
1138 | 58 | * https://bugs.launchpad.net/unity-2d/+bug/689877 | ||
1139 | 59 | * https://bugs.launchpad.net/unity-2d/+bug/734143 | ||
1140 | 60 | */ | ||
1141 | 61 | if(getenv("QT_GRAPHICSSYSTEM") == 0) { | ||
1142 | 62 | QApplication::setGraphicsSystem("raster"); | ||
1143 | 63 | } | ||
1144 | 64 | } | ||
1145 | 65 | |||
1146 | 35 | Unity2dApplication::Unity2dApplication(int& argc, char** argv) | 66 | Unity2dApplication::Unity2dApplication(int& argc, char** argv) |
1147 | 36 | : QApplication(argc, argv) | 67 | : QApplication(argc, argv) |
1148 | 37 | { | 68 | { |
1149 | 69 | /* Allow developers to run Unity 2D uninstalled by telling dconf-qt | ||
1150 | 70 | where to look for Unity 2D's schemas. | ||
1151 | 71 | It relies on the fact that the schema is compiled when running cmake. | ||
1152 | 72 | */ | ||
1153 | 73 | if (!isRunningInstalled()) { | ||
1154 | 74 | qputenv("GSETTINGS_SCHEMA_DIR", unity2dDirectory().toLocal8Bit() + "/data"); | ||
1155 | 75 | } | ||
1156 | 38 | } | 76 | } |
1157 | 39 | 77 | ||
1158 | 40 | Unity2dApplication::~Unity2dApplication() | 78 | Unity2dApplication::~Unity2dApplication() |
1159 | 41 | 79 | ||
1160 | === modified file 'libunity-2d-private/src/unity2dapplication.h' | |||
1161 | --- libunity-2d-private/src/unity2dapplication.h 2011-02-28 17:14:19 +0000 | |||
1162 | +++ libunity-2d-private/src/unity2dapplication.h 2011-07-27 15:02:42 +0000 | |||
1163 | @@ -49,6 +49,13 @@ | |||
1164 | 49 | void removeX11EventFilter(AbstractX11EventFilter*); | 49 | void removeX11EventFilter(AbstractX11EventFilter*); |
1165 | 50 | 50 | ||
1166 | 51 | /** | 51 | /** |
1167 | 52 | * This method must be called *before* instantiating a Unity2dApplication. | ||
1168 | 53 | * It inits gtk and adjusts settings like the graphics system and the Qt | ||
1169 | 54 | * style. | ||
1170 | 55 | */ | ||
1171 | 56 | static void earlySetup(int& argc, char** argv); | ||
1172 | 57 | |||
1173 | 58 | /** | ||
1174 | 52 | * Note: This function will return a null pointer if you did not use a Unity2dApplication in your application! | 59 | * Note: This function will return a null pointer if you did not use a Unity2dApplication in your application! |
1175 | 53 | */ | 60 | */ |
1176 | 54 | static Unity2dApplication* instance(); | 61 | static Unity2dApplication* instance(); |
1177 | 55 | 62 | ||
1178 | === modified file 'libunity-2d-private/tests/CMakeLists.txt' | |||
1179 | --- libunity-2d-private/tests/CMakeLists.txt 2011-07-12 10:30:50 +0000 | |||
1180 | +++ libunity-2d-private/tests/CMakeLists.txt 2011-07-27 15:02:42 +0000 | |||
1181 | @@ -40,6 +40,7 @@ | |||
1182 | 40 | unity2dtrtest | 40 | unity2dtrtest |
1183 | 41 | launchermenutest | 41 | launchermenutest |
1184 | 42 | listaggregatormodeltest | 42 | listaggregatormodeltest |
1185 | 43 | qsortfilterproxymodeltest | ||
1186 | 43 | ) | 44 | ) |
1187 | 44 | 45 | ||
1188 | 45 | add_custom_target(unity2dtr_po COMMAND | 46 | add_custom_target(unity2dtr_po COMMAND |
1189 | 46 | 47 | ||
1190 | === modified file 'libunity-2d-private/tests/keyboardmodifiersmonitortest.cpp' | |||
1191 | --- libunity-2d-private/tests/keyboardmodifiersmonitortest.cpp 2011-01-26 15:50:26 +0000 | |||
1192 | +++ libunity-2d-private/tests/keyboardmodifiersmonitortest.cpp 2011-07-27 15:02:42 +0000 | |||
1193 | @@ -39,6 +39,7 @@ | |||
1194 | 39 | #define UQ_TEST_MAIN(TestObject) \ | 39 | #define UQ_TEST_MAIN(TestObject) \ |
1195 | 40 | int main(int argc, char *argv[]) \ | 40 | int main(int argc, char *argv[]) \ |
1196 | 41 | { \ | 41 | { \ |
1197 | 42 | Unity2dApplication::earlySetup(argc, argv); \ | ||
1198 | 42 | Unity2dApplication app(argc, argv); \ | 43 | Unity2dApplication app(argc, argv); \ |
1199 | 43 | QTEST_DISABLE_KEYPAD_NAVIGATION \ | 44 | QTEST_DISABLE_KEYPAD_NAVIGATION \ |
1200 | 44 | TestObject tc; \ | 45 | TestObject tc; \ |
1201 | 45 | 46 | ||
1202 | === modified file 'libunity-2d-private/tests/mouseareademo.cpp' | |||
1203 | --- libunity-2d-private/tests/mouseareademo.cpp 2011-02-15 18:18:13 +0000 | |||
1204 | +++ libunity-2d-private/tests/mouseareademo.cpp 2011-07-27 15:02:42 +0000 | |||
1205 | @@ -29,6 +29,7 @@ | |||
1206 | 29 | 29 | ||
1207 | 30 | int main(int argc, char** argv) | 30 | int main(int argc, char** argv) |
1208 | 31 | { | 31 | { |
1209 | 32 | Unity2dApplication::earlySetup(argc, argv); | ||
1210 | 32 | Unity2dApplication app(argc, argv); | 33 | Unity2dApplication app(argc, argv); |
1211 | 33 | QWidget window; | 34 | QWidget window; |
1212 | 34 | QLabel* enteredLabel = new QLabel("Entered"); | 35 | QLabel* enteredLabel = new QLabel("Entered"); |
1213 | 35 | 36 | ||
1214 | === added file 'libunity-2d-private/tests/qsortfilterproxymodeltest.cpp' | |||
1215 | --- libunity-2d-private/tests/qsortfilterproxymodeltest.cpp 1970-01-01 00:00:00 +0000 | |||
1216 | +++ libunity-2d-private/tests/qsortfilterproxymodeltest.cpp 2011-07-27 15:02:42 +0000 | |||
1217 | @@ -0,0 +1,384 @@ | |||
1218 | 1 | /* | ||
1219 | 2 | * Copyright (C) 2011 Canonical, Ltd. | ||
1220 | 3 | * | ||
1221 | 4 | * Authors: | ||
1222 | 5 | * Florian Boucault <florian.boucault@canonical.com> | ||
1223 | 6 | * | ||
1224 | 7 | * This program is free software; you can redistribute it and/or modify | ||
1225 | 8 | * it under the terms of the GNU General Public License as published by | ||
1226 | 9 | * the Free Software Foundation; version 3. | ||
1227 | 10 | * | ||
1228 | 11 | * This program is distributed in the hope that it will be useful, | ||
1229 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1230 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1231 | 14 | * GNU General Public License for more details. | ||
1232 | 15 | * | ||
1233 | 16 | * You should have received a copy of the GNU General Public License | ||
1234 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1235 | 18 | */ | ||
1236 | 19 | |||
1237 | 20 | // local | ||
1238 | 21 | #include "qsortfilterproxymodelqml.h" | ||
1239 | 22 | |||
1240 | 23 | // Qt | ||
1241 | 24 | #include <QTest> | ||
1242 | 25 | #include <QSignalSpy> | ||
1243 | 26 | #include <QModelIndex> | ||
1244 | 27 | #include <QAbstractListModel> | ||
1245 | 28 | #include <QDebug> | ||
1246 | 29 | |||
1247 | 30 | |||
1248 | 31 | class MockListModel : public QAbstractListModel | ||
1249 | 32 | { | ||
1250 | 33 | Q_OBJECT | ||
1251 | 34 | |||
1252 | 35 | public: | ||
1253 | 36 | MockListModel(QObject* parent = 0) | ||
1254 | 37 | : QAbstractListModel(parent) | ||
1255 | 38 | { | ||
1256 | 39 | } | ||
1257 | 40 | |||
1258 | 41 | int rowCount(const QModelIndex& parent = QModelIndex()) const | ||
1259 | 42 | { | ||
1260 | 43 | return m_list.size(); | ||
1261 | 44 | } | ||
1262 | 45 | |||
1263 | 46 | QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const | ||
1264 | 47 | { | ||
1265 | 48 | Q_UNUSED(role) | ||
1266 | 49 | |||
1267 | 50 | if (!index.isValid() || index.row() < 0 || index.row() >= m_list.size()) { | ||
1268 | 51 | return QVariant(); | ||
1269 | 52 | } | ||
1270 | 53 | return QVariant(m_list[index.row()]); | ||
1271 | 54 | } | ||
1272 | 55 | |||
1273 | 56 | void setRoleNames(const QHash<int,QByteArray> &roleNames) { | ||
1274 | 57 | QAbstractListModel::setRoleNames(roleNames); | ||
1275 | 58 | Q_EMIT roleNamesChanged(roleNames); | ||
1276 | 59 | } | ||
1277 | 60 | |||
1278 | 61 | bool insertRows(int row, int count, const QModelIndex &parent=QModelIndex()) { | ||
1279 | 62 | beginInsertRows(parent, row, row+count-1); | ||
1280 | 63 | for (int i=0; i<count; i++) { | ||
1281 | 64 | m_list.insert(i+row, "test"+i); | ||
1282 | 65 | } | ||
1283 | 66 | endInsertRows(); | ||
1284 | 67 | return true; | ||
1285 | 68 | } | ||
1286 | 69 | |||
1287 | 70 | bool removeRows(int row, int count, const QModelIndex &parent=QModelIndex()) { | ||
1288 | 71 | beginRemoveRows(parent, row, row+count-1); | ||
1289 | 72 | for (int i=0; i<count; i++) { | ||
1290 | 73 | m_list.removeAt(row); | ||
1291 | 74 | } | ||
1292 | 75 | endInsertRows(); | ||
1293 | 76 | return true; | ||
1294 | 77 | } | ||
1295 | 78 | |||
1296 | 79 | Q_SIGNALS: | ||
1297 | 80 | void roleNamesChanged(const QHash<int,QByteArray> &); | ||
1298 | 81 | |||
1299 | 82 | private: | ||
1300 | 83 | QStringList m_list; | ||
1301 | 84 | }; | ||
1302 | 85 | |||
1303 | 86 | class QSortFilterProxyModelTest : public QObject | ||
1304 | 87 | { | ||
1305 | 88 | Q_OBJECT | ||
1306 | 89 | |||
1307 | 90 | private Q_SLOTS: | ||
1308 | 91 | |||
1309 | 92 | void initTestCase() { | ||
1310 | 93 | qRegisterMetaType<QModelIndex>("QModelIndex"); | ||
1311 | 94 | } | ||
1312 | 95 | |||
1313 | 96 | void testRoleNamesSetAfter() | ||
1314 | 97 | { | ||
1315 | 98 | QSortFilterProxyModelQML proxy; | ||
1316 | 99 | MockListModel model; | ||
1317 | 100 | QHash<int, QByteArray> roles; | ||
1318 | 101 | |||
1319 | 102 | proxy.setSourceModelQObject(&model); | ||
1320 | 103 | |||
1321 | 104 | roles.clear(); | ||
1322 | 105 | roles[0] = "role0"; | ||
1323 | 106 | roles[1] = "role1"; | ||
1324 | 107 | model.setRoleNames(roles); | ||
1325 | 108 | QCOMPARE(model.roleNames(), proxy.roleNames()); | ||
1326 | 109 | } | ||
1327 | 110 | |||
1328 | 111 | void testRoleNamesSetBefore() | ||
1329 | 112 | { | ||
1330 | 113 | QSortFilterProxyModelQML proxy; | ||
1331 | 114 | MockListModel model; | ||
1332 | 115 | QHash<int, QByteArray> roles; | ||
1333 | 116 | |||
1334 | 117 | roles.clear(); | ||
1335 | 118 | roles[0] = "role0"; | ||
1336 | 119 | roles[1] = "role1"; | ||
1337 | 120 | model.setRoleNames(roles); | ||
1338 | 121 | |||
1339 | 122 | proxy.setSourceModelQObject(&model); | ||
1340 | 123 | QCOMPARE(model.roleNames(), proxy.roleNames()); | ||
1341 | 124 | } | ||
1342 | 125 | |||
1343 | 126 | void testCountSetAfter() | ||
1344 | 127 | { | ||
1345 | 128 | QSortFilterProxyModelQML proxy; | ||
1346 | 129 | MockListModel model; | ||
1347 | 130 | model.insertRows(0, 5); | ||
1348 | 131 | |||
1349 | 132 | QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged())); | ||
1350 | 133 | |||
1351 | 134 | proxy.setSourceModelQObject(&model); | ||
1352 | 135 | QCOMPARE(proxy.count(), 5); | ||
1353 | 136 | QVERIFY(spyOnCountChanged.count() >= 1); | ||
1354 | 137 | } | ||
1355 | 138 | |||
1356 | 139 | void testCountInsert() | ||
1357 | 140 | { | ||
1358 | 141 | QSortFilterProxyModelQML proxy; | ||
1359 | 142 | MockListModel model; | ||
1360 | 143 | |||
1361 | 144 | proxy.setSourceModelQObject(&model); | ||
1362 | 145 | |||
1363 | 146 | QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged())); | ||
1364 | 147 | |||
1365 | 148 | model.insertRows(0, 5); | ||
1366 | 149 | QCOMPARE(proxy.count(), 5); | ||
1367 | 150 | QCOMPARE(spyOnCountChanged.count(), 1); | ||
1368 | 151 | } | ||
1369 | 152 | |||
1370 | 153 | void testCountRemove() | ||
1371 | 154 | { | ||
1372 | 155 | QSortFilterProxyModelQML proxy; | ||
1373 | 156 | MockListModel model; | ||
1374 | 157 | model.insertRows(0, 5); | ||
1375 | 158 | |||
1376 | 159 | proxy.setSourceModelQObject(&model); | ||
1377 | 160 | |||
1378 | 161 | QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged())); | ||
1379 | 162 | |||
1380 | 163 | model.removeRows(0, 3); | ||
1381 | 164 | QCOMPARE(proxy.count(), 2); | ||
1382 | 165 | QCOMPARE(spyOnCountChanged.count(), 1); | ||
1383 | 166 | } | ||
1384 | 167 | |||
1385 | 168 | void testLimitCount() | ||
1386 | 169 | { | ||
1387 | 170 | QSortFilterProxyModelQML proxy; | ||
1388 | 171 | MockListModel model; | ||
1389 | 172 | |||
1390 | 173 | proxy.setSourceModelQObject(&model); | ||
1391 | 174 | proxy.setLimit(3); | ||
1392 | 175 | |||
1393 | 176 | QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged())); | ||
1394 | 177 | |||
1395 | 178 | model.insertRows(0, 5); | ||
1396 | 179 | QCOMPARE(proxy.count(), 3); | ||
1397 | 180 | QCOMPARE(spyOnCountChanged.count(), 1); | ||
1398 | 181 | } | ||
1399 | 182 | |||
1400 | 183 | void testLimitLesserThanCount() | ||
1401 | 184 | { | ||
1402 | 185 | QSortFilterProxyModelQML proxy; | ||
1403 | 186 | MockListModel model; | ||
1404 | 187 | QList<QVariant> arguments; | ||
1405 | 188 | model.insertRows(0, 10); | ||
1406 | 189 | |||
1407 | 190 | proxy.setSourceModelQObject(&model); | ||
1408 | 191 | |||
1409 | 192 | QSignalSpy spyOnRowsRemoved(&proxy, SIGNAL(rowsRemoved(const QModelIndex &, int, int))); | ||
1410 | 193 | QSignalSpy spyOnRowsInserted(&proxy, SIGNAL(rowsInserted(const QModelIndex &, int, int))); | ||
1411 | 194 | QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged())); | ||
1412 | 195 | |||
1413 | 196 | proxy.setLimit(5); | ||
1414 | 197 | QCOMPARE(spyOnRowsRemoved.count(), 1); | ||
1415 | 198 | QCOMPARE(spyOnRowsInserted.count(), 0); | ||
1416 | 199 | QCOMPARE(spyOnCountChanged.count(), 1); | ||
1417 | 200 | arguments = spyOnRowsRemoved.takeFirst(); | ||
1418 | 201 | QCOMPARE(arguments.at(1).toInt(), 5); | ||
1419 | 202 | QCOMPARE(arguments.at(2).toInt(), 9); | ||
1420 | 203 | QCOMPARE(proxy.count(), 5); | ||
1421 | 204 | spyOnRowsRemoved.clear(); | ||
1422 | 205 | spyOnCountChanged.clear(); | ||
1423 | 206 | |||
1424 | 207 | proxy.setLimit(7); | ||
1425 | 208 | QCOMPARE(spyOnRowsInserted.count(), 1); | ||
1426 | 209 | QCOMPARE(spyOnRowsRemoved.count(), 0); | ||
1427 | 210 | QCOMPARE(spyOnCountChanged.count(), 1); | ||
1428 | 211 | arguments = spyOnRowsInserted.takeFirst(); | ||
1429 | 212 | QCOMPARE(arguments.at(1).toInt(), 5); | ||
1430 | 213 | QCOMPARE(arguments.at(2).toInt(), 6); | ||
1431 | 214 | QCOMPARE(proxy.count(), 7); | ||
1432 | 215 | spyOnRowsInserted.clear(); | ||
1433 | 216 | spyOnCountChanged.clear(); | ||
1434 | 217 | |||
1435 | 218 | proxy.setLimit(3); | ||
1436 | 219 | QCOMPARE(spyOnRowsRemoved.count(), 1); | ||
1437 | 220 | QCOMPARE(spyOnRowsInserted.count(), 0); | ||
1438 | 221 | QCOMPARE(spyOnCountChanged.count(), 1); | ||
1439 | 222 | arguments = spyOnRowsRemoved.takeFirst(); | ||
1440 | 223 | QCOMPARE(arguments.at(1).toInt(), 3); | ||
1441 | 224 | QCOMPARE(arguments.at(2).toInt(), 6); | ||
1442 | 225 | QCOMPARE(proxy.count(), 3); | ||
1443 | 226 | spyOnRowsRemoved.clear(); | ||
1444 | 227 | spyOnCountChanged.clear(); | ||
1445 | 228 | } | ||
1446 | 229 | |||
1447 | 230 | void testLimitGreaterThanCount() | ||
1448 | 231 | { | ||
1449 | 232 | QSortFilterProxyModelQML proxy; | ||
1450 | 233 | MockListModel model; | ||
1451 | 234 | QList<QVariant> arguments; | ||
1452 | 235 | model.insertRows(0, 5); | ||
1453 | 236 | |||
1454 | 237 | proxy.setSourceModelQObject(&model); | ||
1455 | 238 | |||
1456 | 239 | QSignalSpy spyOnRowsRemoved(&proxy, SIGNAL(rowsRemoved(const QModelIndex &, int, int))); | ||
1457 | 240 | QSignalSpy spyOnRowsInserted(&proxy, SIGNAL(rowsInserted(const QModelIndex &, int, int))); | ||
1458 | 241 | QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged())); | ||
1459 | 242 | |||
1460 | 243 | proxy.setLimit(7); | ||
1461 | 244 | QCOMPARE(spyOnRowsRemoved.count(), 0); | ||
1462 | 245 | QCOMPARE(spyOnRowsInserted.count(), 0); | ||
1463 | 246 | QCOMPARE(spyOnCountChanged.count(), 0); | ||
1464 | 247 | QCOMPARE(proxy.count(), 5); | ||
1465 | 248 | |||
1466 | 249 | proxy.setLimit(5); | ||
1467 | 250 | QCOMPARE(spyOnRowsRemoved.count(), 0); | ||
1468 | 251 | QCOMPARE(spyOnRowsInserted.count(), 0); | ||
1469 | 252 | QCOMPARE(spyOnCountChanged.count(), 0); | ||
1470 | 253 | QCOMPARE(proxy.count(), 5); | ||
1471 | 254 | |||
1472 | 255 | proxy.setLimit(3); | ||
1473 | 256 | QCOMPARE(spyOnRowsInserted.count(), 0); | ||
1474 | 257 | QCOMPARE(spyOnRowsRemoved.count(), 1); | ||
1475 | 258 | QCOMPARE(spyOnCountChanged.count(), 1); | ||
1476 | 259 | arguments = spyOnRowsRemoved.takeFirst(); | ||
1477 | 260 | QCOMPARE(arguments.at(1).toInt(), 3); | ||
1478 | 261 | QCOMPARE(arguments.at(2).toInt(), 4); | ||
1479 | 262 | QCOMPARE(proxy.count(), 3); | ||
1480 | 263 | spyOnRowsRemoved.clear(); | ||
1481 | 264 | spyOnCountChanged.clear(); | ||
1482 | 265 | |||
1483 | 266 | proxy.setLimit(4); | ||
1484 | 267 | QCOMPARE(spyOnRowsRemoved.count(), 0); | ||
1485 | 268 | QCOMPARE(spyOnRowsInserted.count(), 1); | ||
1486 | 269 | QCOMPARE(spyOnCountChanged.count(), 1); | ||
1487 | 270 | arguments = spyOnRowsInserted.takeFirst(); | ||
1488 | 271 | QCOMPARE(arguments.at(1).toInt(), 3); | ||
1489 | 272 | QCOMPARE(arguments.at(2).toInt(), 3); | ||
1490 | 273 | QCOMPARE(proxy.count(), 4); | ||
1491 | 274 | spyOnRowsInserted.clear(); | ||
1492 | 275 | spyOnCountChanged.clear(); | ||
1493 | 276 | |||
1494 | 277 | proxy.setLimit(7); | ||
1495 | 278 | QCOMPARE(spyOnRowsRemoved.count(), 0); | ||
1496 | 279 | QCOMPARE(spyOnRowsInserted.count(), 1); | ||
1497 | 280 | QCOMPARE(spyOnCountChanged.count(), 1); | ||
1498 | 281 | arguments = spyOnRowsInserted.takeFirst(); | ||
1499 | 282 | QCOMPARE(arguments.at(1).toInt(), 4); | ||
1500 | 283 | QCOMPARE(arguments.at(2).toInt(), 4); | ||
1501 | 284 | QCOMPARE(proxy.count(), 5); | ||
1502 | 285 | spyOnRowsInserted.clear(); | ||
1503 | 286 | spyOnCountChanged.clear(); | ||
1504 | 287 | } | ||
1505 | 288 | |||
1506 | 289 | void testLimitMinusOne() | ||
1507 | 290 | { | ||
1508 | 291 | QSortFilterProxyModelQML proxy; | ||
1509 | 292 | MockListModel model; | ||
1510 | 293 | QList<QVariant> arguments; | ||
1511 | 294 | model.insertRows(0, 5); | ||
1512 | 295 | |||
1513 | 296 | proxy.setSourceModelQObject(&model); | ||
1514 | 297 | |||
1515 | 298 | QSignalSpy spyOnRowsRemoved(&proxy, SIGNAL(rowsRemoved(const QModelIndex &, int, int))); | ||
1516 | 299 | QSignalSpy spyOnRowsInserted(&proxy, SIGNAL(rowsInserted(const QModelIndex &, int, int))); | ||
1517 | 300 | QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged())); | ||
1518 | 301 | |||
1519 | 302 | proxy.setLimit(7); | ||
1520 | 303 | QCOMPARE(spyOnRowsRemoved.count(), 0); | ||
1521 | 304 | QCOMPARE(spyOnRowsInserted.count(), 0); | ||
1522 | 305 | QCOMPARE(spyOnCountChanged.count(), 0); | ||
1523 | 306 | QCOMPARE(proxy.count(), 5); | ||
1524 | 307 | |||
1525 | 308 | proxy.setLimit(-1); | ||
1526 | 309 | QCOMPARE(spyOnRowsRemoved.count(), 0); | ||
1527 | 310 | QCOMPARE(spyOnRowsInserted.count(), 0); | ||
1528 | 311 | QCOMPARE(spyOnCountChanged.count(), 0); | ||
1529 | 312 | QCOMPARE(proxy.count(), 5); | ||
1530 | 313 | |||
1531 | 314 | proxy.setLimit(3); | ||
1532 | 315 | QCOMPARE(spyOnRowsInserted.count(), 0); | ||
1533 | 316 | QCOMPARE(spyOnRowsRemoved.count(), 1); | ||
1534 | 317 | QCOMPARE(spyOnCountChanged.count(), 1); | ||
1535 | 318 | arguments = spyOnRowsRemoved.takeFirst(); | ||
1536 | 319 | QCOMPARE(arguments.at(1).toInt(), 3); | ||
1537 | 320 | QCOMPARE(arguments.at(2).toInt(), 4); | ||
1538 | 321 | QCOMPARE(proxy.count(), 3); | ||
1539 | 322 | spyOnRowsRemoved.clear(); | ||
1540 | 323 | spyOnCountChanged.clear(); | ||
1541 | 324 | |||
1542 | 325 | proxy.setLimit(-1); | ||
1543 | 326 | QCOMPARE(spyOnRowsRemoved.count(), 0); | ||
1544 | 327 | QCOMPARE(spyOnRowsInserted.count(), 1); | ||
1545 | 328 | QCOMPARE(spyOnCountChanged.count(), 1); | ||
1546 | 329 | arguments = spyOnRowsInserted.takeFirst(); | ||
1547 | 330 | QCOMPARE(arguments.at(1).toInt(), 3); | ||
1548 | 331 | QCOMPARE(arguments.at(2).toInt(), 4); | ||
1549 | 332 | QCOMPARE(proxy.count(), 5); | ||
1550 | 333 | spyOnRowsInserted.clear(); | ||
1551 | 334 | spyOnCountChanged.clear(); | ||
1552 | 335 | } | ||
1553 | 336 | |||
1554 | 337 | void testLimitInsert() { | ||
1555 | 338 | QSortFilterProxyModelQML proxy; | ||
1556 | 339 | MockListModel model; | ||
1557 | 340 | QList<QVariant> arguments; | ||
1558 | 341 | |||
1559 | 342 | proxy.setSourceModelQObject(&model); | ||
1560 | 343 | proxy.setLimit(7); | ||
1561 | 344 | |||
1562 | 345 | QSignalSpy spyOnRowsRemoved(&proxy, SIGNAL(rowsRemoved(const QModelIndex &, int, int))); | ||
1563 | 346 | QSignalSpy spyOnRowsInserted(&proxy, SIGNAL(rowsInserted(const QModelIndex &, int, int))); | ||
1564 | 347 | QSignalSpy spyOnCountChanged(&proxy, SIGNAL(countChanged())); | ||
1565 | 348 | |||
1566 | 349 | model.insertRows(0, 5); | ||
1567 | 350 | QCOMPARE(spyOnRowsRemoved.count(), 0); | ||
1568 | 351 | QCOMPARE(spyOnRowsInserted.count(), 1); | ||
1569 | 352 | QCOMPARE(spyOnCountChanged.count(), 1); | ||
1570 | 353 | arguments = spyOnRowsInserted.takeFirst(); | ||
1571 | 354 | QCOMPARE(arguments.at(1).toInt(), 0); | ||
1572 | 355 | QCOMPARE(arguments.at(2).toInt(), 4); | ||
1573 | 356 | QCOMPARE(proxy.count(), 5); | ||
1574 | 357 | spyOnRowsInserted.clear(); | ||
1575 | 358 | spyOnCountChanged.clear(); | ||
1576 | 359 | |||
1577 | 360 | model.insertRows(2, 2); | ||
1578 | 361 | QCOMPARE(spyOnRowsRemoved.count(), 0); | ||
1579 | 362 | QCOMPARE(spyOnRowsInserted.count(), 1); | ||
1580 | 363 | QCOMPARE(spyOnCountChanged.count(), 1); | ||
1581 | 364 | arguments = spyOnRowsInserted.takeFirst(); | ||
1582 | 365 | QCOMPARE(arguments.at(1).toInt(), 2); | ||
1583 | 366 | QCOMPARE(arguments.at(2).toInt(), 3); | ||
1584 | 367 | QCOMPARE(proxy.count(), 7); | ||
1585 | 368 | spyOnRowsInserted.clear(); | ||
1586 | 369 | spyOnCountChanged.clear(); | ||
1587 | 370 | |||
1588 | 371 | /* FIXME: failing case due to QSortFilterProxyModel emitting | ||
1589 | 372 | rowsInserted/rowsRemoved regardless of the limit */ | ||
1590 | 373 | //model.insertRows(5, 3); | ||
1591 | 374 | //QCOMPARE(proxy.count(), 7); | ||
1592 | 375 | //QCOMPARE(spyOnRowsRemoved.count(), 0); | ||
1593 | 376 | //QCOMPARE(spyOnRowsInserted.count(), 0); | ||
1594 | 377 | //QCOMPARE(spyOnCountChanged.count(), 0); | ||
1595 | 378 | } | ||
1596 | 379 | }; | ||
1597 | 380 | |||
1598 | 381 | QTEST_MAIN(QSortFilterProxyModelTest) | ||
1599 | 382 | |||
1600 | 383 | #include "qsortfilterproxymodeltest.moc" | ||
1601 | 384 | |||
1602 | 0 | 385 | ||
1603 | === modified file 'panel/app/main.cpp' | |||
1604 | --- panel/app/main.cpp 2011-06-06 09:23:48 +0000 | |||
1605 | +++ panel/app/main.cpp 2011-07-27 15:02:42 +0000 | |||
1606 | @@ -52,21 +52,7 @@ | |||
1607 | 52 | int main(int argc, char** argv) | 52 | int main(int argc, char** argv) |
1608 | 53 | { | 53 | { |
1609 | 54 | ThemeEngineHandler handler; | 54 | ThemeEngineHandler handler; |
1625 | 55 | 55 | Unity2dApplication::earlySetup(argc, argv); | |
1611 | 56 | Unity2dDebug::installHandlers(); | ||
1612 | 57 | |||
1613 | 58 | /* When the environment variable QT_GRAPHICSSYSTEM is not set, | ||
1614 | 59 | force graphics system to 'raster' instead of the default 'native' | ||
1615 | 60 | which on X11 is 'XRender'. | ||
1616 | 61 | 'XRender' defaults to using a TrueColor visual. We do _not_ mimick that | ||
1617 | 62 | behaviour with 'raster' by calling QApplication::setColorSpec because | ||
1618 | 63 | of a bug where black rectangular artifacts were appearing randomly: | ||
1619 | 64 | |||
1620 | 65 | https://bugs.launchpad.net/unity-2d/+bug/734143 | ||
1621 | 66 | */ | ||
1622 | 67 | if(getenv("QT_GRAPHICSSYSTEM") == 0) { | ||
1623 | 68 | QApplication::setGraphicsSystem("raster"); | ||
1624 | 69 | } | ||
1626 | 70 | Unity2dApplication app(argc, argv); | 56 | Unity2dApplication app(argc, argv); |
1627 | 71 | QApplication::setStyle(new Unity2dStyle); | 57 | QApplication::setStyle(new Unity2dStyle); |
1628 | 72 | 58 | ||
1629 | 73 | 59 | ||
1630 | === modified file 'panel/applets/CMakeLists.txt' | |||
1631 | --- panel/applets/CMakeLists.txt 2011-06-22 08:22:14 +0000 | |||
1632 | +++ panel/applets/CMakeLists.txt 2011-07-27 15:02:42 +0000 | |||
1633 | @@ -14,11 +14,7 @@ | |||
1634 | 14 | 14 | ||
1635 | 15 | pkg_check_modules(QTBAMF REQUIRED libqtbamf) | 15 | pkg_check_modules(QTBAMF REQUIRED libqtbamf) |
1636 | 16 | pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt) | 16 | pkg_check_modules(DBUSMENUQT REQUIRED dbusmenu-qt) |
1637 | 17 | pkg_check_modules(GTK REQUIRED gtk+-2.0) | ||
1638 | 18 | pkg_check_modules(INDICATOR REQUIRED indicator) | 17 | pkg_check_modules(INDICATOR REQUIRED indicator) |
1639 | 19 | pkg_check_modules(WNCK REQUIRED libwnck-1.0) | ||
1640 | 20 | |||
1641 | 21 | find_package(X11 REQUIRED) | ||
1642 | 22 | 18 | ||
1643 | 23 | # Get indicator dirs from pkgconfig | 19 | # Get indicator dirs from pkgconfig |
1644 | 24 | read_pkg_variable(INDICATOR_DIR indicator indicatordir) | 20 | read_pkg_variable(INDICATOR_DIR indicator indicatordir) |
1645 | 25 | 21 | ||
1646 | === modified file 'panel/applets/indicator/indicator.c' | |||
1647 | --- panel/applets/indicator/indicator.c 2011-03-30 14:50:35 +0000 | |||
1648 | +++ panel/applets/indicator/indicator.c 2011-07-27 15:02:42 +0000 | |||
1649 | @@ -152,6 +152,20 @@ | |||
1650 | 152 | return; | 152 | return; |
1651 | 153 | } | 153 | } |
1652 | 154 | 154 | ||
1653 | 155 | static gboolean | ||
1654 | 156 | entry_scrolled (GtkWidget *menuitem, GdkEventScroll *event, gpointer data) | ||
1655 | 157 | { | ||
1656 | 158 | IndicatorObject *io = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_OBJECT); | ||
1657 | 159 | IndicatorObjectEntry *entry = g_object_get_data (G_OBJECT (menuitem), MENU_DATA_INDICATOR_ENTRY); | ||
1658 | 160 | |||
1659 | 161 | g_return_val_if_fail(INDICATOR_IS_OBJECT(io), FALSE); | ||
1660 | 162 | |||
1661 | 163 | g_signal_emit_by_name (io, "scroll", 1, event->direction); | ||
1662 | 164 | g_signal_emit_by_name (io, "scroll-entry", entry, 1, event->direction); | ||
1663 | 165 | |||
1664 | 166 | return FALSE; | ||
1665 | 167 | } | ||
1666 | 168 | |||
1667 | 155 | static void | 169 | static void |
1668 | 156 | entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar) | 170 | entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar) |
1669 | 157 | { | 171 | { |
1670 | @@ -233,6 +247,7 @@ | |||
1671 | 233 | 247 | ||
1672 | 234 | g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY, entry); | 248 | g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_ENTRY, entry); |
1673 | 235 | g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_OBJECT, io); | 249 | g_object_set_data(G_OBJECT(menuitem), MENU_DATA_INDICATOR_OBJECT, io); |
1674 | 250 | g_signal_connect(G_OBJECT (menuitem), "scroll-event", G_CALLBACK(entry_scrolled), NULL); | ||
1675 | 236 | 251 | ||
1676 | 237 | return; | 252 | return; |
1677 | 238 | } | 253 | } |
1678 | 239 | 254 | ||
1679 | === modified file 'places/Home.qml' | |||
1680 | --- places/Home.qml 2011-06-23 17:08:53 +0000 | |||
1681 | +++ places/Home.qml 2011-07-27 15:02:42 +0000 | |||
1682 | @@ -19,7 +19,7 @@ | |||
1683 | 19 | import QtQuick 1.0 | 19 | import QtQuick 1.0 |
1684 | 20 | import Unity2d 1.0 /* Necessary for SortFilterProxyModel and for the ImageProvider serving image://icons/theme_name/icon_name */ | 20 | import Unity2d 1.0 /* Necessary for SortFilterProxyModel and for the ImageProvider serving image://icons/theme_name/icon_name */ |
1685 | 21 | 21 | ||
1687 | 22 | Item { | 22 | FocusScope { |
1688 | 23 | property variant model: PageModel { | 23 | property variant model: PageModel { |
1689 | 24 | /* model.entrySearchQuery is copied over to all place entries's globalSearchQuery property */ | 24 | /* model.entrySearchQuery is copied over to all place entries's globalSearchQuery property */ |
1690 | 25 | onEntrySearchQueryChanged: { | 25 | onEntrySearchQueryChanged: { |
1691 | @@ -36,7 +36,7 @@ | |||
1692 | 36 | var placeEntry, i | 36 | var placeEntry, i |
1693 | 37 | for (i=0; i<dash.places.rowCount(); i=i+1) { | 37 | for (i=0; i<dash.places.rowCount(); i=i+1) { |
1694 | 38 | placeEntry = dash.places.get(i) | 38 | placeEntry = dash.places.get(i) |
1696 | 39 | if (placeEntry.globalResultsModel != null && placeEntry.globalResultsModel.count() != 0) { | 39 | if (placeEntry.globalResultsModel != null && placeEntry.globalResultsModel.count != 0) { |
1697 | 40 | var firstResult = placeEntry.globalResultsModel.get(0) | 40 | var firstResult = placeEntry.globalResultsModel.get(0) |
1698 | 41 | /* Places give back the uri of the item in 'column_0' per specification */ | 41 | /* Places give back the uri of the item in 'column_0' per specification */ |
1699 | 42 | var uri = firstResult.column_0 | 42 | var uri = firstResult.column_0 |
1700 | @@ -96,50 +96,39 @@ | |||
1701 | 96 | ListViewWithScrollbar { | 96 | ListViewWithScrollbar { |
1702 | 97 | id: globalSearch | 97 | id: globalSearch |
1703 | 98 | 98 | ||
1704 | 99 | focus: globalSearchActive | ||
1705 | 99 | opacity: globalSearchActive ? 1 : 0 | 100 | opacity: globalSearchActive ? 1 : 0 |
1706 | 100 | anchors.fill: parent | 101 | anchors.fill: parent |
1707 | 101 | 102 | ||
1743 | 102 | list.model: dash.places | 103 | model: dash.places |
1744 | 103 | 104 | ||
1745 | 104 | list.delegate: UnityDefaultRenderer { | 105 | bodyDelegate: UnityDefaultRenderer { |
1746 | 105 | width: ListView.view.width | 106 | placeEntryModel: model.item |
1747 | 106 | 107 | displayName: model.item.name | |
1748 | 107 | parentListView: list | 108 | iconHint: model.item.icon |
1749 | 108 | placeEntryModel: item | 109 | |
1750 | 109 | displayName: item.name | 110 | group_model: model.item.globalResultsModel |
1751 | 110 | iconHint: item.icon | 111 | property bool focusable: group_model != undefined && group_model.count > 0 |
1752 | 111 | 112 | } | |
1753 | 112 | /* Filter out results for which the corresponding group's renderer | 113 | |
1754 | 113 | is 'UnityEmptySearchRenderer'. | 114 | headerDelegate: GroupHeader { |
1755 | 114 | Each result has a column (the second one) containing the id of | 115 | visible: body.needHeader && body.focusable |
1756 | 115 | the group it belongs to (groupId). | 116 | height: visible ? 32 : 0 |
1757 | 116 | */ | 117 | |
1758 | 117 | model: SortFilterProxyModel { | 118 | property bool foldable: body.folded != undefined |
1759 | 118 | model: item.globalResultsModel | 119 | availableCount: foldable && body.group_model != null ? body.group_model.count - body.cellsPerRow : 0 |
1760 | 119 | 120 | folded: foldable ? body.folded : false | |
1761 | 120 | /* FIXME: we ignore the groupId with renderer 'UnityEmptySearchRenderer' | 121 | onClicked: if(foldable) body.folded = !body.folded |
1762 | 121 | by hardcoding it instead of looking it up in the Place's | 122 | |
1763 | 122 | groupsModel as Unity does. | 123 | icon: body.iconHint |
1764 | 123 | 124 | label: body.displayName | |
1730 | 124 | Two solutions could be envisioned: | ||
1731 | 125 | 1) Actually looking for the row in the Place's groupsModel | ||
1732 | 126 | that has in its first column 'UnityEmptySearchRenderer'. | ||
1733 | 127 | That would require adding an API in libqtdee's DeeListModel. | ||
1734 | 128 | 2) Changing the behaviour of the place daemons so that the | ||
1735 | 129 | Place's globalResultsModel is empty when there are no | ||
1736 | 130 | results. The applications place does that but not the | ||
1737 | 131 | files place. | ||
1738 | 132 | */ | ||
1739 | 133 | property int ignoredGroupId: 5 | ||
1740 | 134 | filterRole: 2 /* groupId column */ | ||
1741 | 135 | filterRegExp: RegExp("^[^%1]$".arg(ignoredGroupId)) /* anything but the ignoredGroupId */ | ||
1742 | 136 | } | ||
1765 | 137 | } | 125 | } |
1766 | 138 | } | 126 | } |
1767 | 139 | 127 | ||
1769 | 140 | Rectangle { | 128 | FocusScope { |
1770 | 141 | id: shortcuts | 129 | id: shortcuts |
1771 | 142 | 130 | ||
1772 | 131 | focus: !globalSearchActive | ||
1773 | 143 | opacity: (!globalSearchActive && (shortcutsActive || dashView.dashMode == DashDeclarativeView.FullScreenMode)) ? 1 : 0 | 132 | opacity: (!globalSearchActive && (shortcutsActive || dashView.dashMode == DashDeclarativeView.FullScreenMode)) ? 1 : 0 |
1774 | 144 | anchors.horizontalCenter: parent.horizontalCenter | 133 | anchors.horizontalCenter: parent.horizontalCenter |
1775 | 145 | anchors.verticalCenter: parent.verticalCenter | 134 | anchors.verticalCenter: parent.verticalCenter |
1776 | @@ -147,11 +136,14 @@ | |||
1777 | 147 | width: 888 | 136 | width: 888 |
1778 | 148 | height: 466 | 137 | height: 466 |
1779 | 149 | 138 | ||
1785 | 150 | radius: 5 | 139 | Rectangle { |
1786 | 151 | border.width: 1 | 140 | anchors.fill: parent |
1787 | 152 | /* FIXME: wrong colors */ | 141 | radius: 5 |
1788 | 153 | border.color: Qt.rgba(1, 1, 1, 0.2) | 142 | border.width: 1 |
1789 | 154 | color: Qt.rgba(0, 0, 0, 0.3) | 143 | /* FIXME: wrong colors */ |
1790 | 144 | border.color: Qt.rgba(1, 1, 1, 0.2) | ||
1791 | 145 | color: Qt.rgba(0, 0, 0, 0.3) | ||
1792 | 146 | } | ||
1793 | 155 | 147 | ||
1794 | 156 | Button { | 148 | Button { |
1795 | 157 | id: closeShortcutsButton | 149 | id: closeShortcutsButton |
1796 | @@ -182,11 +174,13 @@ | |||
1797 | 182 | on the default version if a custom one doesn’t exist. */ | 174 | on the default version if a custom one doesn’t exist. */ |
1798 | 183 | Loader { | 175 | Loader { |
1799 | 184 | id: customShortcutsLoader | 176 | id: customShortcutsLoader |
1800 | 177 | focus: status == Loader.Ready | ||
1801 | 185 | anchors.fill: parent | 178 | anchors.fill: parent |
1802 | 186 | source: "HomeShortcutsCustomized.qml" | 179 | source: "HomeShortcutsCustomized.qml" |
1803 | 187 | } | 180 | } |
1804 | 188 | Loader { | 181 | Loader { |
1805 | 189 | id: defaultShortcutsLoader | 182 | id: defaultShortcutsLoader |
1806 | 183 | focus: !customShortcutsLoader.focus | ||
1807 | 190 | anchors.fill: parent | 184 | anchors.fill: parent |
1808 | 191 | source: (customShortcutsLoader.status == Loader.Error) ? "HomeShortcuts.qml" : "" | 185 | source: (customShortcutsLoader.status == Loader.Error) ? "HomeShortcuts.qml" : "" |
1809 | 192 | } | 186 | } |
1810 | 193 | 187 | ||
1811 | === added file 'places/HomeButtonDefaultApplication.qml' | |||
1812 | --- places/HomeButtonDefaultApplication.qml 1970-01-01 00:00:00 +0000 | |||
1813 | +++ places/HomeButtonDefaultApplication.qml 2011-07-27 15:02:42 +0000 | |||
1814 | @@ -0,0 +1,48 @@ | |||
1815 | 1 | /* | ||
1816 | 2 | * This file is part of unity-2d | ||
1817 | 3 | * | ||
1818 | 4 | * Copyright 2011 Canonical Ltd. | ||
1819 | 5 | * | ||
1820 | 6 | * This program is free software; you can redistribute it and/or modify | ||
1821 | 7 | * it under the terms of the GNU General Public License as published by | ||
1822 | 8 | * the Free Software Foundation; version 3. | ||
1823 | 9 | * | ||
1824 | 10 | * This program is distributed in the hope that it will be useful, | ||
1825 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1826 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1827 | 13 | * GNU General Public License for more details. | ||
1828 | 14 | * | ||
1829 | 15 | * You should have received a copy of the GNU General Public License | ||
1830 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1831 | 17 | */ | ||
1832 | 18 | |||
1833 | 19 | import QtQuick 1.0 | ||
1834 | 20 | /* Necessary for: | ||
1835 | 21 | - ImageProvider serving image://icons/theme_name/icon_name | ||
1836 | 22 | - LauncherApplication | ||
1837 | 23 | */ | ||
1838 | 24 | import Unity2d 1.0 | ||
1839 | 25 | |||
1840 | 26 | HomeButton { | ||
1841 | 27 | property alias contentType: defaultApplication.contentType | ||
1842 | 28 | |||
1843 | 29 | GioDefaultApplication { | ||
1844 | 30 | id: defaultApplication | ||
1845 | 31 | } | ||
1846 | 32 | |||
1847 | 33 | LauncherApplication { | ||
1848 | 34 | id: application | ||
1849 | 35 | desktop_file: defaultApplication.desktopFile | ||
1850 | 36 | } | ||
1851 | 37 | |||
1852 | 38 | visible: application.desktop_file != "" | ||
1853 | 39 | |||
1854 | 40 | onClicked: { | ||
1855 | 41 | dashView.active = false | ||
1856 | 42 | application.activate() | ||
1857 | 43 | } | ||
1858 | 44 | |||
1859 | 45 | icon: "image://icons/" + application.icon | ||
1860 | 46 | iconSourceSize.width: 128 | ||
1861 | 47 | iconSourceSize.height: 128 | ||
1862 | 48 | } | ||
1863 | 0 | 49 | ||
1864 | === modified file 'places/HomeShortcuts.qml' | |||
1865 | --- places/HomeShortcuts.qml 2011-06-23 17:08:53 +0000 | |||
1866 | +++ places/HomeShortcuts.qml 2011-07-27 15:02:42 +0000 | |||
1867 | @@ -19,16 +19,41 @@ | |||
1868 | 19 | import QtQuick 1.0 | 19 | import QtQuick 1.0 |
1869 | 20 | import Unity2d 1.0 /* Necessary for the ImageProvider serving image://icons/theme_name/icon_name */ | 20 | import Unity2d 1.0 /* Necessary for the ImageProvider serving image://icons/theme_name/icon_name */ |
1870 | 21 | 21 | ||
1872 | 22 | Flow { | 22 | Grid { |
1873 | 23 | anchors.fill: parent | 23 | anchors.fill: parent |
1874 | 24 | anchors.topMargin: 26 | 24 | anchors.topMargin: 26 |
1875 | 25 | anchors.bottomMargin: 35 | 25 | anchors.bottomMargin: 35 |
1876 | 26 | anchors.leftMargin: 32 | 26 | anchors.leftMargin: 32 |
1877 | 27 | anchors.rightMargin: 32 | 27 | anchors.rightMargin: 32 |
1878 | 28 | spacing: 61 | 28 | spacing: 61 |
1879 | 29 | columns: 4 | ||
1880 | 30 | rows: 2 | ||
1881 | 31 | |||
1882 | 32 | function selectChild(index) { | ||
1883 | 33 | if (index < 0 || index >= children.length) return false | ||
1884 | 34 | currentIndex = index | ||
1885 | 35 | children[index].focus = true | ||
1886 | 36 | return true | ||
1887 | 37 | } | ||
1888 | 38 | |||
1889 | 39 | property int currentIndex: 0 | ||
1890 | 40 | Keys.onPressed: if (handleKeyPress(event.key)) event.accepted = true | ||
1891 | 41 | function handleKeyPress(key) { | ||
1892 | 42 | switch (key) { | ||
1893 | 43 | case Qt.Key_Right: | ||
1894 | 44 | return selectChild(currentIndex+1) | ||
1895 | 45 | case Qt.Key_Left: | ||
1896 | 46 | return selectChild(currentIndex-1) | ||
1897 | 47 | case Qt.Key_Up: | ||
1898 | 48 | return selectChild(currentIndex-columns) | ||
1899 | 49 | case Qt.Key_Down: | ||
1900 | 50 | return selectChild(currentIndex+columns) | ||
1901 | 51 | } | ||
1902 | 52 | } | ||
1903 | 29 | 53 | ||
1904 | 30 | /* FIXME: dummy icons need to be replaced by design's */ | 54 | /* FIXME: dummy icons need to be replaced by design's */ |
1905 | 31 | HomeButton { | 55 | HomeButton { |
1906 | 56 | focus: true | ||
1907 | 32 | label: u2d.tr("Media Apps") | 57 | label: u2d.tr("Media Apps") |
1908 | 33 | icon: "artwork/find_media_apps.png" | 58 | icon: "artwork/find_media_apps.png" |
1909 | 34 | onClicked: activatePlaceEntry("/usr/share/unity/places/applications.place", "Files", 9) | 59 | onClicked: activatePlaceEntry("/usr/share/unity/places/applications.place", "Files", 9) |
1910 | @@ -53,9 +78,9 @@ | |||
1911 | 53 | } | 78 | } |
1912 | 54 | 79 | ||
1913 | 55 | /* FIXME: use user's preferred applications instead of hardcoding them */ | 80 | /* FIXME: use user's preferred applications instead of hardcoding them */ |
1915 | 56 | HomeButtonApplication { | 81 | HomeButtonDefaultApplication { |
1916 | 57 | label: u2d.tr("Browse the Web") | 82 | label: u2d.tr("Browse the Web") |
1918 | 58 | key: "/desktop/gnome/applications/browser/exec" | 83 | contentType: "x-scheme-handler/http" |
1919 | 59 | } | 84 | } |
1920 | 60 | 85 | ||
1921 | 61 | HomeButtonApplication { | 86 | HomeButtonApplication { |
1922 | @@ -63,9 +88,9 @@ | |||
1923 | 63 | desktopFile: "shotwell.desktop" | 88 | desktopFile: "shotwell.desktop" |
1924 | 64 | } | 89 | } |
1925 | 65 | 90 | ||
1927 | 66 | HomeButtonApplication { | 91 | HomeButtonDefaultApplication { |
1928 | 67 | label: u2d.tr("Check Email") | 92 | label: u2d.tr("Check Email") |
1930 | 68 | key: "/desktop/gnome/url-handlers/mailto/command" | 93 | contentType: "x-scheme-handler/mailto" |
1931 | 69 | } | 94 | } |
1932 | 70 | 95 | ||
1933 | 71 | HomeButtonApplication { | 96 | HomeButtonApplication { |
1934 | 72 | 97 | ||
1935 | === added file 'places/ListViewWithHeaders.qml' | |||
1936 | --- places/ListViewWithHeaders.qml 1970-01-01 00:00:00 +0000 | |||
1937 | +++ places/ListViewWithHeaders.qml 2011-07-27 15:02:42 +0000 | |||
1938 | @@ -0,0 +1,277 @@ | |||
1939 | 1 | /* | ||
1940 | 2 | * This file is part of unity-2d | ||
1941 | 3 | * | ||
1942 | 4 | * Copyright 2010-2011 Canonical Ltd. | ||
1943 | 5 | * | ||
1944 | 6 | * This program is free software; you can redistribute it and/or modify | ||
1945 | 7 | * it under the terms of the GNU General Public License as published by | ||
1946 | 8 | * the Free Software Foundation; version 3. | ||
1947 | 9 | * | ||
1948 | 10 | * This program is distributed in the hope that it will be useful, | ||
1949 | 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
1950 | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
1951 | 13 | * GNU General Public License for more details. | ||
1952 | 14 | * | ||
1953 | 15 | * You should have received a copy of the GNU General Public License | ||
1954 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1955 | 17 | */ | ||
1956 | 18 | |||
1957 | 19 | import QtQuick 1.0 | ||
1958 | 20 | |||
1959 | 21 | /* | ||
1960 | 22 | List item that behaves similarly to a ListView but supports adding headers | ||
1961 | 23 | before every delegate. | ||
1962 | 24 | It works around the lack of flexibility in section headers positioning of | ||
1963 | 25 | ListView (cf. http://bugreports.qt.nokia.com/browse/QTBUG-12880). It also | ||
1964 | 26 | supports delegates that are flickable by flicking their content properly | ||
1965 | 27 | depending on where you are in the list. | ||
1966 | 28 | |||
1967 | 29 | To use it the following properties need to be set: | ||
1968 | 30 | - bodyDelegate: Component used as a template for each item of the model; it | ||
1969 | 31 | must have the following properties: | ||
1970 | 32 | - 'contentY': same definition as a Flickable's | ||
1971 | 33 | - 'totalHeight': the total height of the content of the body | ||
1972 | 34 | - 'currentItem': a reference to the item of the body (e.g. a delegate of | ||
1973 | 35 | a ListView) currently focused by the body | ||
1974 | 36 | - headerDelegate: Component used as a template for the header preceding each body | ||
1975 | 37 | |||
1976 | 38 | Two behaviours are available for the headers positioning: | ||
1977 | 39 | - normal: the headers are always positioned just before the body | ||
1978 | 40 | - accordion: the headers are stacked at the top and bottom of the list | ||
1979 | 41 | |||
1980 | 42 | Currently, it only works in a vertical layout. | ||
1981 | 43 | */ | ||
1982 | 44 | FocusScope { | ||
1983 | 45 | id: list | ||
1984 | 46 | |||
1985 | 47 | property alias flickable: mouse | ||
1986 | 48 | property alias model: repeater.model | ||
1987 | 49 | property bool accordion: false | ||
1988 | 50 | /* bodyDelegate must be an item that has the following properties: | ||
1989 | 51 | - 'contentY' | ||
1990 | 52 | - 'totalHeight' | ||
1991 | 53 | - 'currentItem' | ||
1992 | 54 | */ | ||
1993 | 55 | property Component bodyDelegate | ||
1994 | 56 | property Component headerDelegate | ||
1995 | 57 | property int currentIndex: -1 | ||
1996 | 58 | /* FIXME: Should be read-only but it is not possible to define a read-only property from QML. | ||
1997 | 59 | Ref.: https://bugreports.qt.nokia.com//browse/QTBUG-15257 | ||
1998 | 60 | */ | ||
1999 | 61 | property variant currentItem: items.childFromIndex(currentIndex) | ||
2000 | 62 | |||
2001 | 63 | |||
2002 | 64 | clip: true | ||
2003 | 65 | |||
2004 | 66 | /* updateMouseContentY() needs to be called when any of the variable | ||
2005 | 67 | involved in the computation of the 'y' property of the currentSubItem changes. | ||
2006 | 68 | |||
2007 | 69 | if accordion is false: | ||
2008 | 70 | - heightFirstChildren(index) | ||
2009 | 71 | - headerLoader.height | ||
2010 | 72 | - list.height | ||
2011 | 73 | |||
2012 | 74 | if accordion is true: | ||
2013 | 75 | - heightFirstChildren(index) | ||
2014 | 76 | - items.availableHeight | ||
2015 | 77 | - heightFirstHeaders(index) | ||
2016 | 78 | |||
2017 | 79 | items.contentHeight seems to depend on all of those so it's enough to | ||
2018 | 80 | depend only on it. | ||
2019 | 81 | */ | ||
2020 | 82 | function updateMouseContentY() { | ||
2021 | 83 | if (currentSubItem != undefined) { | ||
2022 | 84 | mouse.contentY = Math.max(currentSubItem.mapToItem(mouse.contentItem, 0, 0).y -list.height/2, 0) | ||
2023 | 85 | } | ||
2024 | 86 | } | ||
2025 | 87 | property variant currentSubItem: currentItem != undefined ? currentItem.bodyLoader.item.currentItem : undefined | ||
2026 | 88 | onCurrentSubItemChanged: updateMouseContentY() | ||
2027 | 89 | |||
2028 | 90 | Connections { | ||
2029 | 91 | target: items | ||
2030 | 92 | onContentHeightChanged: updateMouseContentY() | ||
2031 | 93 | } | ||
2032 | 94 | |||
2033 | 95 | FocusScope { | ||
2034 | 96 | id: items | ||
2035 | 97 | |||
2036 | 98 | property int availableHeight: list.height - heightFirstHeaders(repeater.count) | ||
2037 | 99 | property int contentHeight: items.heightFirstChildren(repeater.count) | ||
2038 | 100 | property real value: mouse.contentY | ||
2039 | 101 | |||
2040 | 102 | anchors.fill: parent | ||
2041 | 103 | |||
2042 | 104 | function heightFirstChildren(n) { | ||
2043 | 105 | var i | ||
2044 | 106 | var totalHeight = 0 | ||
2045 | 107 | /* items.children contains both the repeated items and the repeater | ||
2046 | 108 | itself. Skip and ignore the repeater. */ | ||
2047 | 109 | for (i=0; i<n && i<children.length; i++) { | ||
2048 | 110 | if(children[i] == repeater) {n += 1; continue} | ||
2049 | 111 | totalHeight += children[i].height | ||
2050 | 112 | } | ||
2051 | 113 | return totalHeight | ||
2052 | 114 | } | ||
2053 | 115 | |||
2054 | 116 | function heightFirstHeaders(n) { | ||
2055 | 117 | var i | ||
2056 | 118 | var totalHeight = 0 | ||
2057 | 119 | /* items.children contains both the repeated items and the repeater | ||
2058 | 120 | itself. Skip and ignore the repeater. */ | ||
2059 | 121 | for (i=0; i<n && i<children.length; i++) { | ||
2060 | 122 | if(children[i] == repeater) {n += 1; continue} | ||
2061 | 123 | totalHeight += children[i].headerLoader.height | ||
2062 | 124 | } | ||
2063 | 125 | return totalHeight | ||
2064 | 126 | } | ||
2065 | 127 | |||
2066 | 128 | function clamp(x, min, max) { | ||
2067 | 129 | return Math.max(Math.min(x, max), min) | ||
2068 | 130 | } | ||
2069 | 131 | |||
2070 | 132 | |||
2071 | 133 | /* Keyboard navigation */ | ||
2072 | 134 | function isIndexValid(index) { | ||
2073 | 135 | /* Assuming that children contains exactly one item that is not a child (repeater) */ | ||
2074 | 136 | return index >= 0 && index < children.length-1 | ||
2075 | 137 | } | ||
2076 | 138 | |||
2077 | 139 | focus: true | ||
2078 | 140 | Keys.onPressed: if (handleKeyPress(event.key)) event.accepted = true | ||
2079 | 141 | function handleKeyPress(key) { | ||
2080 | 142 | switch (key) { | ||
2081 | 143 | case Qt.Key_Down: | ||
2082 | 144 | return selectNextEnabled() | ||
2083 | 145 | case Qt.Key_Up: | ||
2084 | 146 | return selectPreviousEnabled() | ||
2085 | 147 | } | ||
2086 | 148 | } | ||
2087 | 149 | |||
2088 | 150 | function childFromIndex(index) { | ||
2089 | 151 | var indexInChildren = 0 | ||
2090 | 152 | for(var i=0; i<children.length; i++) { | ||
2091 | 153 | if (children[i] != repeater) { | ||
2092 | 154 | if (indexInChildren == index) return children[i] | ||
2093 | 155 | indexInChildren++ | ||
2094 | 156 | } | ||
2095 | 157 | } | ||
2096 | 158 | |||
2097 | 159 | return undefined | ||
2098 | 160 | } | ||
2099 | 161 | |||
2100 | 162 | function selectNextEnabled() { | ||
2101 | 163 | var index = currentIndex | ||
2102 | 164 | do { | ||
2103 | 165 | index += 1 | ||
2104 | 166 | if (!isIndexValid(index)) return false | ||
2105 | 167 | } while(!childFromIndex(index).focusable) | ||
2106 | 168 | currentIndex = index | ||
2107 | 169 | return true | ||
2108 | 170 | } | ||
2109 | 171 | |||
2110 | 172 | function selectPreviousEnabled() { | ||
2111 | 173 | var index = currentIndex | ||
2112 | 174 | do { | ||
2113 | 175 | index -= 1 | ||
2114 | 176 | if (!isIndexValid(index)) return false | ||
2115 | 177 | } while(!childFromIndex(index).focusable) | ||
2116 | 178 | currentIndex = index | ||
2117 | 179 | return true | ||
2118 | 180 | } | ||
2119 | 181 | |||
2120 | 182 | property bool needsFocus: false | ||
2121 | 183 | onChildrenChanged: { | ||
2122 | 184 | /* FIXME: this workarounds the fact that list.focus is set to false | ||
2123 | 185 | when the child with focus is destroyed | ||
2124 | 186 | */ | ||
2125 | 187 | if (needsFocus) { | ||
2126 | 188 | list.focus = true | ||
2127 | 189 | needsFocus = false | ||
2128 | 190 | } | ||
2129 | 191 | /* Assuming that children contains exactly one item that is not a child (repeater) */ | ||
2130 | 192 | if(children.length <= 1) { | ||
2131 | 193 | list.currentIndex = -1 | ||
2132 | 194 | } else { | ||
2133 | 195 | list.currentIndex = -1 | ||
2134 | 196 | selectNextEnabled() | ||
2135 | 197 | } | ||
2136 | 198 | } | ||
2137 | 199 | |||
2138 | 200 | Repeater { | ||
2139 | 201 | id: repeater | ||
2140 | 202 | |||
2141 | 203 | FocusScope { | ||
2142 | 204 | property alias bodyLoader: bodyLoader | ||
2143 | 205 | property alias headerLoader: headerLoader | ||
2144 | 206 | |||
2145 | 207 | focus: index == list.currentIndex | ||
2146 | 208 | Component.onDestruction: items.needsFocus = true | ||
2147 | 209 | |||
2148 | 210 | width: list.width | ||
2149 | 211 | height: headerLoader.height + bodyLoader.item.totalHeight | ||
2150 | 212 | property bool focusable: bodyLoader.item.focusable | ||
2151 | 213 | |||
2152 | 214 | property int pmin: pmax - (ymax - ymin) | ||
2153 | 215 | property int pmax: items.heightFirstChildren(index) - ymin | ||
2154 | 216 | property int ymin: list.accordion ? items.heightFirstHeaders(index) : -headerLoader.height | ||
2155 | 217 | property int ymax: list.accordion ? ymin + items.availableHeight : list.height | ||
2156 | 218 | y: items.clamp(-items.value + ymax + pmin, ymin, ymax) | ||
2157 | 219 | |||
2158 | 220 | Loader { | ||
2159 | 221 | id: headerLoader | ||
2160 | 222 | |||
2161 | 223 | focus: visible | ||
2162 | 224 | KeyNavigation.down: bodyLoader | ||
2163 | 225 | sourceComponent: headerDelegate | ||
2164 | 226 | onLoaded: item.focus = true | ||
2165 | 227 | width: parent.width | ||
2166 | 228 | |||
2167 | 229 | /* Workaround Qt bug http://bugreports.qt.nokia.com/browse/QTBUG-18857 | ||
2168 | 230 | More documentation at http://bugreports.qt.nokia.com/browse/QTBUG-18011 | ||
2169 | 231 | */ | ||
2170 | 232 | property int index | ||
2171 | 233 | Binding { target: headerLoader; property: "index"; value: index } | ||
2172 | 234 | property variant model | ||
2173 | 235 | Binding { target: headerLoader; property: "model"; value: model } | ||
2174 | 236 | property variant body | ||
2175 | 237 | Binding { target: headerLoader; property: "body"; value: bodyLoader.item } | ||
2176 | 238 | } | ||
2177 | 239 | |||
2178 | 240 | Loader { | ||
2179 | 241 | id: bodyLoader | ||
2180 | 242 | |||
2181 | 243 | focus: !headerLoader.focus | ||
2182 | 244 | KeyNavigation.up: headerLoader | ||
2183 | 245 | sourceComponent: list.bodyDelegate | ||
2184 | 246 | onLoaded: item.focus = true | ||
2185 | 247 | width: parent.width | ||
2186 | 248 | anchors.top: headerLoader.bottom | ||
2187 | 249 | height: items.clamp(parent.ymax - parent.y, 0, item.totalHeight) | ||
2188 | 250 | |||
2189 | 251 | Binding { | ||
2190 | 252 | target: bodyLoader.item | ||
2191 | 253 | property: "contentY" | ||
2192 | 254 | value: Math.max(items.value - pmax, 0) | ||
2193 | 255 | } | ||
2194 | 256 | |||
2195 | 257 | /* Workaround Qt bug http://bugreports.qt.nokia.com/browse/QTBUG-18857 | ||
2196 | 258 | More documentation at http://bugreports.qt.nokia.com/browse/QTBUG-18011 | ||
2197 | 259 | */ | ||
2198 | 260 | property int index | ||
2199 | 261 | Binding { target: bodyLoader; property: "index"; value: index } | ||
2200 | 262 | property variant model | ||
2201 | 263 | Binding { target: bodyLoader; property: "model"; value: model } | ||
2202 | 264 | } | ||
2203 | 265 | } | ||
2204 | 266 | } | ||
2205 | 267 | } | ||
2206 | 268 | |||
2207 | 269 | Flickable { | ||
2208 | 270 | id: mouse | ||
2209 | 271 | |||
2210 | 272 | z: -1 | ||
2211 | 273 | anchors.fill: parent | ||
2212 | 274 | contentWidth: parent.width | ||
2213 | 275 | contentHeight: items.contentHeight | ||
2214 | 276 | } | ||
2215 | 277 | } | ||
2216 | 0 | 278 | ||
2217 | === modified file 'places/ListViewWithScrollbar.qml' | |||
2218 | --- places/ListViewWithScrollbar.qml 2011-06-23 17:08:53 +0000 | |||
2219 | +++ places/ListViewWithScrollbar.qml 2011-07-27 15:02:42 +0000 | |||
2220 | @@ -18,44 +18,21 @@ | |||
2221 | 18 | 18 | ||
2222 | 19 | import QtQuick 1.0 | 19 | import QtQuick 1.0 |
2223 | 20 | 20 | ||
2226 | 21 | Item { | 21 | FocusScope { |
2225 | 22 | property alias list: list | ||
2227 | 23 | property alias scrollbar: scrollbar | 22 | property alias scrollbar: scrollbar |
2228 | 23 | property alias model: list.model | ||
2229 | 24 | property alias bodyDelegate: list.bodyDelegate | ||
2230 | 25 | property alias headerDelegate: list.headerDelegate | ||
2231 | 24 | 26 | ||
2233 | 25 | ListView { | 27 | ListViewWithHeaders { |
2234 | 26 | id: list | 28 | id: list |
2235 | 27 | 29 | ||
2236 | 30 | focus: true | ||
2237 | 28 | anchors.top: parent.top | 31 | anchors.top: parent.top |
2238 | 29 | anchors.bottom: parent.bottom | 32 | anchors.bottom: parent.bottom |
2239 | 30 | anchors.left: parent.left | 33 | anchors.left: parent.left |
2240 | 31 | anchors.right: scrollbar.left | 34 | anchors.right: scrollbar.left |
2241 | 32 | anchors.rightMargin: 15 | 35 | anchors.rightMargin: 15 |
2242 | 33 | |||
2243 | 34 | clip: true | ||
2244 | 35 | /* FIXME: proper spacing cannot be set because of the hack in Group.qml | ||
2245 | 36 | whereby empty groups are still in the list but invisible and of | ||
2246 | 37 | height 0. | ||
2247 | 38 | */ | ||
2248 | 39 | //spacing: 31 | ||
2249 | 40 | |||
2250 | 41 | orientation: ListView.Vertical | ||
2251 | 42 | |||
2252 | 43 | /* WARNING - HACK - FIXME | ||
2253 | 44 | Issue: | ||
2254 | 45 | User wise annoying jumps in the list are observable if cacheBuffer is | ||
2255 | 46 | set to 0 (which is the default value). States such as 'folded' are | ||
2256 | 47 | lost when scrolling a lot. | ||
2257 | 48 | |||
2258 | 49 | Explanation: | ||
2259 | 50 | The height of the Group delegate depends on its content. However its | ||
2260 | 51 | content is not known until the delegate is instantiated because it | ||
2261 | 52 | depends on the number of results displayed by its GridView. | ||
2262 | 53 | |||
2263 | 54 | Resolution: | ||
2264 | 55 | We set the cacheBuffer to the biggest possible int in order to make | ||
2265 | 56 | sure all delegates are always instantiated. | ||
2266 | 57 | */ | ||
2267 | 58 | cacheBuffer: 2147483647 | ||
2268 | 59 | } | 36 | } |
2269 | 60 | 37 | ||
2270 | 61 | Scrollbar { | 38 | Scrollbar { |
2271 | @@ -67,7 +44,7 @@ | |||
2272 | 67 | anchors.bottomMargin: 10 | 44 | anchors.bottomMargin: 10 |
2273 | 68 | anchors.right: parent.right | 45 | anchors.right: parent.right |
2274 | 69 | 46 | ||
2276 | 70 | targetFlickable: list | 47 | targetFlickable: list.flickable |
2277 | 71 | 48 | ||
2278 | 72 | /* Hide the scrollbar if there is less than a page of results */ | 49 | /* Hide the scrollbar if there is less than a page of results */ |
2279 | 73 | opacity: targetFlickable.visibleArea.heightRatio < 1.0 ? 1.0 : 0.0 | 50 | opacity: targetFlickable.visibleArea.heightRatio < 1.0 ? 1.0 : 0.0 |
2280 | 74 | 51 | ||
2281 | === modified file 'places/PlaceEntryView.qml' | |||
2282 | --- places/PlaceEntryView.qml 2011-06-23 17:08:53 +0000 | |||
2283 | +++ places/PlaceEntryView.qml 2011-07-27 15:02:42 +0000 | |||
2284 | @@ -19,7 +19,7 @@ | |||
2285 | 19 | import QtQuick 1.0 | 19 | import QtQuick 1.0 |
2286 | 20 | import Unity2d 1.0 /* Necessary for SortFilterProxyModel */ | 20 | import Unity2d 1.0 /* Necessary for SortFilterProxyModel */ |
2287 | 21 | 21 | ||
2289 | 22 | Item { | 22 | FocusScope { |
2290 | 23 | id: placeEntryView | 23 | id: placeEntryView |
2291 | 24 | 24 | ||
2292 | 25 | /* An instance of PlaceEntryModel */ | 25 | /* An instance of PlaceEntryModel */ |
2293 | @@ -31,9 +31,9 @@ | |||
2294 | 31 | ('firstGroupModel') is used to filter the search results per group. | 31 | ('firstGroupModel') is used to filter the search results per group. |
2295 | 32 | */ | 32 | */ |
2296 | 33 | var placeEntry, i | 33 | var placeEntry, i |
2298 | 34 | for (i=0; i<placeEntryView.model.entryGroupsModel.count(); i=i+1) { | 34 | for (i=0; i<placeEntryView.model.entryGroupsModel.count; i=i+1) { |
2299 | 35 | firstGroupModel.groupId = i | 35 | firstGroupModel.groupId = i |
2301 | 36 | if (firstGroupModel.count() != 0) { | 36 | if (firstGroupModel.count != 0) { |
2302 | 37 | var firstResult = firstGroupModel.get(0) | 37 | var firstResult = firstGroupModel.get(0) |
2303 | 38 | /* Places give back the uri of the item in 'column_0' per specification */ | 38 | /* Places give back the uri of the item in 'column_0' per specification */ |
2304 | 39 | var uri = firstResult.column_0 | 39 | var uri = firstResult.column_0 |
2305 | @@ -62,6 +62,7 @@ | |||
2306 | 62 | ListViewWithScrollbar { | 62 | ListViewWithScrollbar { |
2307 | 63 | id: results | 63 | id: results |
2308 | 64 | 64 | ||
2309 | 65 | focus: true | ||
2310 | 65 | anchors.fill: parent | 66 | anchors.fill: parent |
2311 | 66 | 67 | ||
2312 | 67 | /* The group's delegate is chosen dynamically depending on what | 68 | /* The group's delegate is chosen dynamically depending on what |
2313 | @@ -74,10 +75,10 @@ | |||
2314 | 74 | If groupRenderer == 'UnityShowcaseRenderer' then it will look for | 75 | If groupRenderer == 'UnityShowcaseRenderer' then it will look for |
2315 | 75 | the file 'UnityShowcaseRenderer.qml' and use it to render the group. | 76 | the file 'UnityShowcaseRenderer.qml' and use it to render the group. |
2316 | 76 | */ | 77 | */ |
2321 | 77 | list.delegate: Loader { | 78 | bodyDelegate: Loader { |
2322 | 78 | property string groupRenderer: column_0 | 79 | property string groupRenderer: model.column_0 |
2323 | 79 | property string displayName: column_1 | 80 | property string displayName: model.column_1 |
2324 | 80 | property string iconHint: column_2 | 81 | property string iconHint: model.column_2 |
2325 | 81 | property int groupId: index | 82 | property int groupId: index |
2326 | 82 | 83 | ||
2327 | 83 | source: groupRenderer ? groupRenderer+".qml" : "" | 84 | source: groupRenderer ? groupRenderer+".qml" : "" |
2328 | @@ -86,12 +87,8 @@ | |||
2329 | 86 | console.log("Failed to load renderer", groupRenderer) | 87 | console.log("Failed to load renderer", groupRenderer) |
2330 | 87 | } | 88 | } |
2331 | 88 | 89 | ||
2332 | 89 | width: ListView.view.width | ||
2333 | 90 | |||
2334 | 91 | /* Model that will be used by the group's delegate */ | 90 | /* Model that will be used by the group's delegate */ |
2338 | 92 | SortFilterProxyModel { | 91 | property variant group_model: SortFilterProxyModel { |
2336 | 93 | id: group_model | ||
2337 | 94 | |||
2339 | 95 | model: placeEntryView.model.entryResultsModel | 92 | model: placeEntryView.model.entryResultsModel |
2340 | 96 | 93 | ||
2341 | 97 | /* resultsModel contains data for all the groups of a given Place. | 94 | /* resultsModel contains data for all the groups of a given Place. |
2342 | @@ -102,16 +99,37 @@ | |||
2343 | 102 | filterRegExp: RegExp("^%1$".arg(groupId)) /* exact match */ | 99 | filterRegExp: RegExp("^%1$".arg(groupId)) /* exact match */ |
2344 | 103 | } | 100 | } |
2345 | 104 | 101 | ||
2357 | 105 | onLoaded: { | 102 | /* Required by ListViewWithHeaders when the loaded Renderer is a Flickable. |
2358 | 106 | item.parentListView = results.list | 103 | In that case the list view scrolls the Flickable appropriately. |
2359 | 107 | item.displayName = displayName | 104 | */ |
2360 | 108 | item.iconHint = iconHint | 105 | property int totalHeight: item.totalHeight != undefined ? item.totalHeight : 0 |
2361 | 109 | item.groupId = groupId | 106 | property int contentY |
2362 | 110 | item.model = group_model | 107 | Binding { target: item; property: "contentY"; value: contentY } |
2363 | 111 | item.placeEntryModel = placeEntryView.model | 108 | property bool focusable: group_model.count > 0 |
2364 | 112 | } | 109 | property variant currentItem: item.currentItem |
2365 | 113 | } | 110 | |
2366 | 114 | 111 | Binding { target: item; property: "displayName"; value: displayName } | |
2367 | 115 | list.model: placeEntryView.model != undefined ? placeEntryView.model.entryGroupsModel : undefined | 112 | Binding { target: item; property: "iconHint"; value: iconHint } |
2368 | 113 | Binding { target: item; property: "groupId"; value: groupId } | ||
2369 | 114 | Binding { target: item; property: "group_model"; value: group_model } | ||
2370 | 115 | Binding { target: item; property: "placeEntryModel"; value: placeEntryView.model } | ||
2371 | 116 | |||
2372 | 117 | onLoaded: item.focus = true | ||
2373 | 118 | } | ||
2374 | 119 | |||
2375 | 120 | headerDelegate: GroupHeader { | ||
2376 | 121 | visible: body.item.needHeader && body.focusable | ||
2377 | 122 | height: visible ? 32 : 0 | ||
2378 | 123 | |||
2379 | 124 | property bool foldable: body.item.folded != undefined | ||
2380 | 125 | availableCount: foldable ? body.group_model.count - body.item.cellsPerRow : 0 | ||
2381 | 126 | folded: foldable ? body.item.folded : false | ||
2382 | 127 | onClicked: if(foldable) body.item.folded = !body.item.folded | ||
2383 | 128 | |||
2384 | 129 | icon: body.iconHint | ||
2385 | 130 | label: body.displayName | ||
2386 | 131 | } | ||
2387 | 132 | |||
2388 | 133 | model: placeEntryView.model != undefined ? placeEntryView.model.entryGroupsModel : undefined | ||
2389 | 116 | } | 134 | } |
2390 | 117 | } | 135 | } |
2391 | 118 | 136 | ||
2392 | === modified file 'places/Renderer.qml' | |||
2393 | --- places/Renderer.qml 2011-06-23 17:08:53 +0000 | |||
2394 | +++ places/Renderer.qml 2011-07-27 15:02:42 +0000 | |||
2395 | @@ -26,11 +26,11 @@ | |||
2396 | 26 | itself. A typical renderer is the UnityDefaultRender that lays out the items | 26 | itself. A typical renderer is the UnityDefaultRender that lays out the items |
2397 | 27 | in a grid of icons with the item's title underneath it. | 27 | in a grid of icons with the item's title underneath it. |
2398 | 28 | */ | 28 | */ |
2400 | 29 | Item { | 29 | FocusScope { |
2401 | 30 | property string displayName /* Name of the group typically displayed in the header */ | 30 | property string displayName /* Name of the group typically displayed in the header */ |
2402 | 31 | property string iconHint /* Icon id of the group */ | 31 | property string iconHint /* Icon id of the group */ |
2403 | 32 | property int groupId /* Index of the group */ | 32 | property int groupId /* Index of the group */ |
2405 | 33 | property variant model /* List model containing the items to be displayed by the renderer */ | 33 | property variant group_model /* List model containing the items to be displayed by the renderer */ |
2406 | 34 | property variant placeEntryModel /* Reference to the place entry the group belongs to */ | 34 | property variant placeEntryModel /* Reference to the place entry the group belongs to */ |
2408 | 35 | property variant parentListView /* Reference to the ListView the renderer is nested into */ | 35 | property bool needHeader: false /* Whether or not the renderer requires a header to be displayed */ |
2409 | 36 | } | 36 | } |
2410 | 37 | 37 | ||
2411 | === modified file 'places/RendererGrid.qml' | |||
2412 | --- places/RendererGrid.qml 2011-06-23 17:08:53 +0000 | |||
2413 | +++ places/RendererGrid.qml 2011-07-27 15:02:42 +0000 | |||
2414 | @@ -28,6 +28,11 @@ | |||
2415 | 28 | Renderer { | 28 | Renderer { |
2416 | 29 | id: renderer | 29 | id: renderer |
2417 | 30 | 30 | ||
2418 | 31 | needHeader: true | ||
2419 | 32 | property alias cellsPerRow: results.cellsPerRow | ||
2420 | 33 | property alias contentY: results.contentY | ||
2421 | 34 | property alias currentItem: results.currentItem | ||
2422 | 35 | |||
2423 | 31 | property variant cellRenderer | 36 | property variant cellRenderer |
2424 | 32 | property bool folded | 37 | property bool folded |
2425 | 33 | folded: { | 38 | folded: { |
2426 | @@ -44,99 +49,35 @@ | |||
2427 | 44 | property int horizontalSpacing: 26 | 49 | property int horizontalSpacing: 26 |
2428 | 45 | property int verticalSpacing: 26 | 50 | property int verticalSpacing: 26 |
2429 | 46 | 51 | ||
2455 | 47 | /* Using results.contentHeight produces binding loop warnings and potential | 52 | /* FIXME: using results_layout.anchors.topMargin in the following expression |
2456 | 48 | rendering issues. We compute the height manually. | 53 | causes QML to think they might be an anchor loop. */ |
2457 | 49 | */ | 54 | property int totalHeight: results.count > 0 ? results_layout.anchors.topMargin + results.totalHeight : 0 |
2433 | 50 | /* FIXME: tricking the system by making the delegate of height 0 and with | ||
2434 | 51 | an invisible header is no good: the item in the model still | ||
2435 | 52 | exists and some things such as keyboard selection break. | ||
2436 | 53 | */ | ||
2437 | 54 | height: results.count > 0 ? header.height + results_layout.anchors.topMargin + results.totalHeight : 0 | ||
2438 | 55 | //Behavior on height {NumberAnimation {duration: 200}} | ||
2439 | 56 | |||
2440 | 57 | GroupHeader { | ||
2441 | 58 | id: header | ||
2442 | 59 | |||
2443 | 60 | visible: results.count > 0 | ||
2444 | 61 | availableCount: results.count - results.cellsPerRow | ||
2445 | 62 | folded: parent.folded | ||
2446 | 63 | anchors.top: parent.top | ||
2447 | 64 | anchors.left: parent.left | ||
2448 | 65 | anchors.right: parent.right | ||
2449 | 66 | height: 32 | ||
2450 | 67 | icon: parent.iconHint | ||
2451 | 68 | label: parent.displayName | ||
2452 | 69 | |||
2453 | 70 | onClicked: parent.folded = !parent.folded | ||
2454 | 71 | } | ||
2458 | 72 | 55 | ||
2459 | 73 | Item { | 56 | Item { |
2460 | 74 | id: results_layout | 57 | id: results_layout |
2461 | 75 | 58 | ||
2465 | 76 | anchors.top: header.bottom | 59 | anchors.fill: parent |
2466 | 77 | anchors.topMargin: 22 | 60 | anchors.topMargin: 12 |
2464 | 78 | anchors.left: parent.left | ||
2467 | 79 | anchors.leftMargin: 2 | 61 | anchors.leftMargin: 2 |
2468 | 80 | anchors.right: parent.right | ||
2469 | 81 | anchors.bottom: parent.bottom | ||
2470 | 82 | 62 | ||
2471 | 83 | CenteredGridView { | 63 | CenteredGridView { |
2472 | 84 | id: results | 64 | id: results |
2473 | 85 | 65 | ||
2518 | 86 | /* FIXME: this is a gross hack compensating for the lack of sections | 66 | focus: true |
2519 | 87 | in GridView (see ListView.section). | 67 | |
2520 | 88 | 68 | anchors.fill: parent | |
2521 | 89 | We nest GridViews inside a ListView and add headers manually | 69 | |
2522 | 90 | (GroupHeader). The total height of each Group is computed | 70 | property int totalHeight: results.cellHeight*Math.ceil(count/cellsPerRow) |
2479 | 91 | manually and given back to the ListView. However that size cannot | ||
2480 | 92 | be used by the individual GridViews because it would make them | ||
2481 | 93 | load all of their delegates at once using far too much memory and | ||
2482 | 94 | processing power. Instead we constrain the height of the GridViews | ||
2483 | 95 | and compute their position manually to compensate for the position | ||
2484 | 96 | changes when flicking the ListView. | ||
2485 | 97 | |||
2486 | 98 | We assume that renderer.parentListView is the ListView we nest our | ||
2487 | 99 | GridView into. | ||
2488 | 100 | */ | ||
2489 | 101 | property variant flickable: renderer.parentListView.contentItem | ||
2490 | 102 | |||
2491 | 103 | /* flickable.contentY*0 is equal to 0 but is necessary in order to | ||
2492 | 104 | have the entire expression being evaluated at the right moment. | ||
2493 | 105 | */ | ||
2494 | 106 | property int inFlickableY: flickable.contentY*0+parent.mapToItem(flickable, 0, 0).y | ||
2495 | 107 | /* note: testing for flickable.height < 0 is probably useless since it is | ||
2496 | 108 | unlikely flickable.height will ever be negative. | ||
2497 | 109 | */ | ||
2498 | 110 | property int compensateY: inFlickableY > 0 || flickable.height < 0 || totalHeight < flickable.height ? 0 : -inFlickableY | ||
2499 | 111 | |||
2500 | 112 | /* Synchronise the position and content's position of the GridView | ||
2501 | 113 | with the current position of flickable's visibleArea */ | ||
2502 | 114 | function synchronisePosition() { | ||
2503 | 115 | y = compensateY | ||
2504 | 116 | contentY = compensateY | ||
2505 | 117 | } | ||
2506 | 118 | |||
2507 | 119 | onCompensateYChanged: synchronisePosition() | ||
2508 | 120 | /* Any change in content needs to trigger a synchronisation */ | ||
2509 | 121 | onCountChanged: synchronisePosition() | ||
2510 | 122 | onModelChanged: synchronisePosition() | ||
2511 | 123 | |||
2512 | 124 | width: flickable.width | ||
2513 | 125 | height: Math.min(totalHeight, flickable.height) | ||
2514 | 126 | |||
2515 | 127 | /* Only display one line of items when folded */ | ||
2516 | 128 | property int displayedCount: folded ? cellsPerRow : count | ||
2517 | 129 | property int totalHeight: results.cellHeight*Math.ceil(displayedCount/cellsPerRow) | ||
2523 | 130 | 71 | ||
2524 | 131 | minHorizontalSpacing: renderer.horizontalSpacing | 72 | minHorizontalSpacing: renderer.horizontalSpacing |
2525 | 132 | minVerticalSpacing: renderer.verticalSpacing | 73 | minVerticalSpacing: renderer.verticalSpacing |
2526 | 133 | delegateWidth: renderer.cellWidth | 74 | delegateWidth: renderer.cellWidth |
2527 | 134 | delegateHeight: renderer.cellHeight | 75 | delegateHeight: renderer.cellHeight |
2528 | 135 | 76 | ||
2530 | 136 | interactive: false | 77 | // interactive: false |
2531 | 137 | clip: true | 78 | clip: true |
2532 | 138 | 79 | ||
2534 | 139 | delegate: Item { | 80 | delegate: FocusScope { |
2535 | 140 | 81 | ||
2536 | 141 | width: results.cellWidth | 82 | width: results.cellWidth |
2537 | 142 | height: results.cellHeight | 83 | height: results.cellHeight |
2538 | @@ -157,6 +98,7 @@ | |||
2539 | 157 | height: results.delegateHeight | 98 | height: results.delegateHeight |
2540 | 158 | anchors.horizontalCenter: parent.horizontalCenter | 99 | anchors.horizontalCenter: parent.horizontalCenter |
2541 | 159 | 100 | ||
2542 | 101 | focus: true | ||
2543 | 160 | sourceComponent: cellRenderer | 102 | sourceComponent: cellRenderer |
2544 | 161 | onLoaded: { | 103 | onLoaded: { |
2545 | 162 | item.uri = uri | 104 | item.uri = uri |
2546 | @@ -164,11 +106,16 @@ | |||
2547 | 164 | item.mimetype = mimetype | 106 | item.mimetype = mimetype |
2548 | 165 | item.displayName = displayName | 107 | item.displayName = displayName |
2549 | 166 | item.comment = comment | 108 | item.comment = comment |
2550 | 109 | item.focus = true | ||
2551 | 167 | } | 110 | } |
2552 | 168 | } | 111 | } |
2553 | 169 | } | 112 | } |
2554 | 170 | 113 | ||
2556 | 171 | model: renderer.model | 114 | /* Only display one line of items when folded */ |
2557 | 115 | model: SortFilterProxyModel { | ||
2558 | 116 | model: renderer.group_model != undefined ? renderer.group_model : null | ||
2559 | 117 | limit: folded ? results.cellsPerRow : -1 | ||
2560 | 118 | } | ||
2561 | 172 | } | 119 | } |
2562 | 173 | } | 120 | } |
2563 | 174 | } | 121 | } |
2564 | 175 | 122 | ||
2565 | === modified file 'places/Scrollbar.qml' | |||
2566 | --- places/Scrollbar.qml 2011-06-23 17:08:53 +0000 | |||
2567 | +++ places/Scrollbar.qml 2011-07-27 15:02:42 +0000 | |||
2568 | @@ -72,12 +72,18 @@ | |||
2569 | 72 | anchors.left: parent.left | 72 | anchors.left: parent.left |
2570 | 73 | anchors.right: parent.right | 73 | anchors.right: parent.right |
2571 | 74 | 74 | ||
2576 | 75 | y: { | 75 | Binding { |
2577 | 76 | var clampedYPosition = Math.max(0, Math.min(1-targetFlickable.visibleArea.heightRatio, | 76 | target: slider |
2578 | 77 | targetFlickable.visibleArea.yPosition)) | 77 | property: "y" |
2579 | 78 | return clampedYPosition * scrollbar.height | 78 | value: { |
2580 | 79 | var clampedYPosition = Math.max(0, Math.min(1-targetFlickable.visibleArea.heightRatio, | ||
2581 | 80 | targetFlickable.visibleArea.yPosition)) | ||
2582 | 81 | return clampedYPosition * scrollbar.height | ||
2583 | 82 | } | ||
2584 | 83 | when: !dragMouseArea.drag.active | ||
2585 | 79 | } | 84 | } |
2587 | 80 | height: Math.max(minimalHeight, targetFlickable.visibleArea.heightRatio * scrollbar.height) | 85 | |
2588 | 86 | height: Math.min(scrollbar.height, Math.max(minimalHeight, targetFlickable.visibleArea.heightRatio * scrollbar.height)) | ||
2589 | 81 | 87 | ||
2590 | 82 | Behavior on height {NumberAnimation {duration: 200; easing.type: Easing.InOutQuad}} | 88 | Behavior on height {NumberAnimation {duration: 200; easing.type: Easing.InOutQuad}} |
2591 | 83 | 89 | ||
2592 | 84 | 90 | ||
2593 | === modified file 'places/SearchEntry.qml' | |||
2594 | --- places/SearchEntry.qml 2011-06-23 17:08:53 +0000 | |||
2595 | +++ places/SearchEntry.qml 2011-07-27 15:02:42 +0000 | |||
2596 | @@ -19,7 +19,7 @@ | |||
2597 | 19 | import QtQuick 1.0 | 19 | import QtQuick 1.0 |
2598 | 20 | import Effects 1.0 | 20 | import Effects 1.0 |
2599 | 21 | 21 | ||
2601 | 22 | FocusScope { | 22 | AbstractButton { |
2602 | 23 | property string searchQuery | 23 | property string searchQuery |
2603 | 24 | 24 | ||
2604 | 25 | /* Cancels current search when the dash becomes invisible */ | 25 | /* Cancels current search when the dash becomes invisible */ |
2605 | @@ -37,6 +37,8 @@ | |||
2606 | 37 | /* Keys forwarded to the search entry are forwarded to the text input. */ | 37 | /* Keys forwarded to the search entry are forwarded to the text input. */ |
2607 | 38 | Keys.forwardTo: [search_input] | 38 | Keys.forwardTo: [search_input] |
2608 | 39 | 39 | ||
2609 | 40 | opacity: state == "selected" ? 1.0 : 0.7 | ||
2610 | 41 | |||
2611 | 40 | BorderImage { | 42 | BorderImage { |
2612 | 41 | anchors.fill: parent | 43 | anchors.fill: parent |
2613 | 42 | source: "artwork/search_background.sci" | 44 | source: "artwork/search_background.sci" |
2614 | 43 | 45 | ||
2615 | === modified file 'places/SearchRefine.qml' | |||
2616 | --- places/SearchRefine.qml 2011-06-23 17:08:53 +0000 | |||
2617 | +++ places/SearchRefine.qml 2011-07-27 15:02:42 +0000 | |||
2618 | @@ -49,6 +49,8 @@ | |||
2619 | 49 | 49 | ||
2620 | 50 | focus: true | 50 | focus: true |
2621 | 51 | 51 | ||
2622 | 52 | KeyNavigation.down: options | ||
2623 | 53 | |||
2624 | 52 | anchors.left: parent.left | 54 | anchors.left: parent.left |
2625 | 53 | anchors.right: parent.right | 55 | anchors.right: parent.right |
2626 | 54 | anchors.top: parent.top | 56 | anchors.top: parent.top |
2627 | @@ -61,6 +63,7 @@ | |||
2628 | 61 | text: u2d.tr("Refine search") | 63 | text: u2d.tr("Refine search") |
2629 | 62 | font.bold: true | 64 | font.bold: true |
2630 | 63 | font.pixelSize: 16 | 65 | font.pixelSize: 16 |
2631 | 66 | font.underline: parent.state == "selected" | ||
2632 | 64 | 67 | ||
2633 | 65 | anchors.top: parent.top | 68 | anchors.top: parent.top |
2634 | 66 | anchors.left: parent.left | 69 | anchors.left: parent.left |
2635 | @@ -92,6 +95,8 @@ | |||
2636 | 92 | opacity: folded ? 0.0 : 1.0 | 95 | opacity: folded ? 0.0 : 1.0 |
2637 | 93 | Behavior on opacity {NumberAnimation {duration: 100; easing.type: Easing.InOutQuad}} | 96 | Behavior on opacity {NumberAnimation {duration: 100; easing.type: Easing.InOutQuad}} |
2638 | 94 | 97 | ||
2639 | 98 | KeyNavigation.up: header | ||
2640 | 99 | |||
2641 | 95 | anchors.left: parent.left | 100 | anchors.left: parent.left |
2642 | 96 | anchors.right: parent.right | 101 | anchors.right: parent.right |
2643 | 97 | anchors.top: header.bottom | 102 | anchors.top: header.bottom |
2644 | 98 | 103 | ||
2645 | === modified file 'places/SearchRefineOptionType.qml' | |||
2646 | --- places/SearchRefineOptionType.qml 2011-06-23 17:08:53 +0000 | |||
2647 | +++ places/SearchRefineOptionType.qml 2011-07-27 15:02:42 +0000 | |||
2648 | @@ -21,9 +21,11 @@ | |||
2649 | 21 | SearchRefineOption { | 21 | SearchRefineOption { |
2650 | 22 | id: searchRefineOption | 22 | id: searchRefineOption |
2651 | 23 | 23 | ||
2653 | 24 | AbstractButton { | 24 | Item { |
2654 | 25 | id: header | 25 | id: header |
2655 | 26 | 26 | ||
2656 | 27 | KeyNavigation.down: filters | ||
2657 | 28 | |||
2658 | 27 | focus: true | 29 | focus: true |
2659 | 28 | anchors.top: parent.top | 30 | anchors.top: parent.top |
2660 | 29 | anchors.left: parent.left | 31 | anchors.left: parent.left |
2661 | @@ -39,6 +41,7 @@ | |||
2662 | 39 | text: searchRefineOption.title | 41 | text: searchRefineOption.title |
2663 | 40 | font.pixelSize: 16 | 42 | font.pixelSize: 16 |
2664 | 41 | font.bold: true | 43 | font.bold: true |
2665 | 44 | font.underline: parent.state == "selected" | ||
2666 | 42 | } | 45 | } |
2667 | 43 | } | 46 | } |
2668 | 44 | 47 | ||
2669 | @@ -63,6 +66,7 @@ | |||
2670 | 63 | 66 | ||
2671 | 64 | /* Make sure the first item is selected when getting the focus for the first time */ | 67 | /* Make sure the first item is selected when getting the focus for the first time */ |
2672 | 65 | currentIndex: 0 | 68 | currentIndex: 0 |
2673 | 69 | KeyNavigation.up: header | ||
2674 | 66 | 70 | ||
2675 | 67 | delegate: TickBox { | 71 | delegate: TickBox { |
2676 | 68 | height: filters.cellHeight | 72 | height: filters.cellHeight |
2677 | @@ -70,7 +74,7 @@ | |||
2678 | 70 | /* Not checking for placeEntryModel != undefined leads to a segfault | 74 | /* Not checking for placeEntryModel != undefined leads to a segfault |
2679 | 71 | when switching places */ | 75 | when switching places */ |
2680 | 72 | text: placeEntryModel != undefined ? column_0 : "" | 76 | text: placeEntryModel != undefined ? column_0 : "" |
2682 | 73 | ticked: dash.currentPage.model.activeSection == model.index | 77 | checked: dash.currentPage.model.activeSection == model.index |
2683 | 74 | 78 | ||
2684 | 75 | onClicked: placeEntryModel.activeSection = model.index | 79 | onClicked: placeEntryModel.activeSection = model.index |
2685 | 76 | } | 80 | } |
2686 | 77 | 81 | ||
2687 | === modified file 'places/TickBox.qml' | |||
2688 | --- places/TickBox.qml 2011-06-23 17:08:53 +0000 | |||
2689 | +++ places/TickBox.qml 2011-07-27 15:02:42 +0000 | |||
2690 | @@ -22,8 +22,8 @@ | |||
2691 | 22 | id: tickBox | 22 | id: tickBox |
2692 | 23 | 23 | ||
2693 | 24 | property string text | 24 | property string text |
2696 | 25 | property bool ticked: false | 25 | property bool checked: false |
2697 | 26 | property bool canUntick: true | 26 | property bool canUncheck: true |
2698 | 27 | 27 | ||
2699 | 28 | width: childrenRect.width | 28 | width: childrenRect.width |
2700 | 29 | height: childrenRect.height | 29 | height: childrenRect.height |
2701 | @@ -43,7 +43,7 @@ | |||
2702 | 43 | Image { | 43 | Image { |
2703 | 44 | id: box | 44 | id: box |
2704 | 45 | 45 | ||
2706 | 46 | opacity: !canUntick && ticked ? 0 : 1 | 46 | opacity: !canUncheck && checked ? 0 : 1 |
2707 | 47 | anchors.top: parent.top | 47 | anchors.top: parent.top |
2708 | 48 | anchors.left: parent.left | 48 | anchors.left: parent.left |
2709 | 49 | source: "artwork/tick_box.png" | 49 | source: "artwork/tick_box.png" |
2710 | @@ -58,7 +58,7 @@ | |||
2711 | 58 | anchors.topMargin: 2 | 58 | anchors.topMargin: 2 |
2712 | 59 | anchors.left: box.left | 59 | anchors.left: box.left |
2713 | 60 | anchors.leftMargin: 3 | 60 | anchors.leftMargin: 3 |
2715 | 61 | opacity: ticked ? 1.0 : parent.state == "selected" ? 0.4 : 0.0 | 61 | opacity: checked ? 1.0 : parent.state == "selected" ? 0.4 : 0.0 |
2716 | 62 | source: "artwork/tick.png" | 62 | source: "artwork/tick.png" |
2717 | 63 | width: sourceSize.width | 63 | width: sourceSize.width |
2718 | 64 | height: sourceSize.height | 64 | height: sourceSize.height |
2719 | 65 | 65 | ||
2720 | === modified file 'places/UnityEmptySearchRenderer.qml' | |||
2721 | --- places/UnityEmptySearchRenderer.qml 2011-06-23 17:08:53 +0000 | |||
2722 | +++ places/UnityEmptySearchRenderer.qml 2011-07-27 15:02:42 +0000 | |||
2723 | @@ -40,7 +40,7 @@ | |||
2724 | 40 | boundsBehavior: ListView.StopAtBounds | 40 | boundsBehavior: ListView.StopAtBounds |
2725 | 41 | orientation: ListView.Vertical | 41 | orientation: ListView.Vertical |
2726 | 42 | 42 | ||
2728 | 43 | model: renderer.model | 43 | model: renderer.group_model |
2729 | 44 | delegate: Button { | 44 | delegate: Button { |
2730 | 45 | property string uri: column_0 | 45 | property string uri: column_0 |
2731 | 46 | property string iconHint: column_1 | 46 | property string iconHint: column_1 |
2732 | 47 | 47 | ||
2733 | === modified file 'places/app/CMakeLists.txt' | |||
2734 | --- places/app/CMakeLists.txt 2011-03-08 09:20:02 +0000 | |||
2735 | +++ places/app/CMakeLists.txt 2011-07-27 15:02:42 +0000 | |||
2736 | @@ -1,7 +1,5 @@ | |||
2737 | 1 | # Dependencies | 1 | # Dependencies |
2738 | 2 | find_package(X11 REQUIRED) | ||
2739 | 3 | pkg_check_modules(QTGCONF REQUIRED libqtgconf) | 2 | pkg_check_modules(QTGCONF REQUIRED libqtgconf) |
2740 | 4 | pkg_check_modules(GTK REQUIRED gtk+-2.0) | ||
2741 | 5 | 3 | ||
2742 | 6 | # Sources | 4 | # Sources |
2743 | 7 | set(places_SRCS | 5 | set(places_SRCS |
2744 | 8 | 6 | ||
2745 | === modified file 'places/app/places.cpp' | |||
2746 | --- places/app/places.cpp 2011-06-27 13:43:05 +0000 | |||
2747 | +++ places/app/places.cpp 2011-07-27 15:02:42 +0000 | |||
2748 | @@ -31,9 +31,8 @@ | |||
2749 | 31 | 31 | ||
2750 | 32 | #include <X11/Xlib.h> | 32 | #include <X11/Xlib.h> |
2751 | 33 | 33 | ||
2752 | 34 | #include <gtk/gtk.h> | ||
2753 | 35 | |||
2754 | 36 | // unity-2d | 34 | // unity-2d |
2755 | 35 | #include <unity2dapplication.h> | ||
2756 | 37 | #include <unity2ddebug.h> | 36 | #include <unity2ddebug.h> |
2757 | 38 | 37 | ||
2758 | 39 | #include "dashdeclarativeview.h" | 38 | #include "dashdeclarativeview.h" |
2759 | @@ -41,23 +40,8 @@ | |||
2760 | 41 | 40 | ||
2761 | 42 | int main(int argc, char *argv[]) | 41 | int main(int argc, char *argv[]) |
2762 | 43 | { | 42 | { |
2780 | 44 | /* gtk needs to be inited, otherwise we get an assert failure in gdk */ | 43 | Unity2dApplication::earlySetup(argc, argv); |
2781 | 45 | gtk_init(&argc, &argv); | 44 | Unity2dApplication application(argc, argv); |
2765 | 46 | Unity2dDebug::installHandlers(); | ||
2766 | 47 | |||
2767 | 48 | /* When the environment variable QT_GRAPHICSSYSTEM is not set, | ||
2768 | 49 | force graphics system to 'raster' instead of the default 'native' | ||
2769 | 50 | which on X11 is 'XRender'. | ||
2770 | 51 | 'XRender' defaults to using a TrueColor visual. We do _not_ mimick that | ||
2771 | 52 | behaviour with 'raster' by calling QApplication::setColorSpec because | ||
2772 | 53 | of a bug where some pixmaps become blueish: | ||
2773 | 54 | |||
2774 | 55 | https://bugs.launchpad.net/unity-2d/+bug/689877 | ||
2775 | 56 | */ | ||
2776 | 57 | if(getenv("QT_GRAPHICSSYSTEM") == 0) { | ||
2777 | 58 | QApplication::setGraphicsSystem("raster"); | ||
2778 | 59 | } | ||
2779 | 60 | QApplication application(argc, argv); | ||
2782 | 61 | QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments()); | 45 | QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments()); |
2783 | 62 | 46 | ||
2784 | 63 | qmlRegisterType<DashDeclarativeView>("Unity2d", 1, 0, "DashDeclarativeView"); | 47 | qmlRegisterType<DashDeclarativeView>("Unity2d", 1, 0, "DashDeclarativeView"); |
2785 | 64 | 48 | ||
2786 | === modified file 'places/dash.qml' | |||
2787 | --- places/dash.qml 2011-07-05 19:01:18 +0000 | |||
2788 | +++ places/dash.qml 2011-07-27 15:02:42 +0000 | |||
2789 | @@ -31,6 +31,9 @@ | |||
2790 | 31 | } | 31 | } |
2791 | 32 | 32 | ||
2792 | 33 | function activatePage(page) { | 33 | function activatePage(page) { |
2793 | 34 | /* Always give the focus to the search entry when switching pages */ | ||
2794 | 35 | search_entry.focus = true | ||
2795 | 36 | |||
2796 | 34 | if (page == currentPage) { | 37 | if (page == currentPage) { |
2797 | 35 | return | 38 | return |
2798 | 36 | } | 39 | } |
2799 | @@ -40,12 +43,6 @@ | |||
2800 | 40 | } | 43 | } |
2801 | 41 | currentPage = page | 44 | currentPage = page |
2802 | 42 | currentPage.visible = true | 45 | currentPage.visible = true |
2803 | 43 | /* FIXME: For some reason currentPage gets the focus when it becomes | ||
2804 | 44 | visible. Reset the focus to the search_bar instead. | ||
2805 | 45 | It could be due to Qt bug QTBUG-13380: | ||
2806 | 46 | "Listview gets focus when it becomes visible" | ||
2807 | 47 | */ | ||
2808 | 48 | search_entry.focus = true | ||
2809 | 49 | } | 46 | } |
2810 | 50 | 47 | ||
2811 | 51 | function activatePlaceEntry(fileName, groupName, section) { | 48 | function activatePlaceEntry(fileName, groupName, section) { |
2812 | @@ -121,13 +118,18 @@ | |||
2813 | 121 | /* Unhandled keys will always be forwarded to the search bar. That way | 118 | /* Unhandled keys will always be forwarded to the search bar. That way |
2814 | 122 | the user can type and search from anywhere in the interface without | 119 | the user can type and search from anywhere in the interface without |
2815 | 123 | necessarily focusing the search bar first. */ | 120 | necessarily focusing the search bar first. */ |
2817 | 124 | Keys.forwardTo: [search_entry] | 121 | //Keys.forwardTo: [search_entry] |
2818 | 125 | 122 | ||
2819 | 126 | 123 | ||
2820 | 127 | SearchEntry { | 124 | SearchEntry { |
2821 | 128 | id: search_entry | 125 | id: search_entry |
2822 | 129 | 126 | ||
2823 | 130 | focus: true | 127 | focus: true |
2824 | 128 | /* FIXME: check on visible necessary; fixed in Qt Quick 1.1 | ||
2825 | 129 | ref: http://bugreports.qt.nokia.com/browse/QTBUG-15862 | ||
2826 | 130 | */ | ||
2827 | 131 | KeyNavigation.right: refine_search.visible ? refine_search : search_entry | ||
2828 | 132 | KeyNavigation.down: pageLoader | ||
2829 | 131 | 133 | ||
2830 | 132 | anchors.top: parent.top | 134 | anchors.top: parent.top |
2831 | 133 | anchors.topMargin: 10 | 135 | anchors.topMargin: 10 |
2832 | @@ -142,6 +144,8 @@ | |||
2833 | 142 | SearchRefine { | 144 | SearchRefine { |
2834 | 143 | id: refine_search | 145 | id: refine_search |
2835 | 144 | 146 | ||
2836 | 147 | KeyNavigation.left: search_entry | ||
2837 | 148 | |||
2838 | 145 | /* SearchRefine is only to be displayed for places, not in the home page */ | 149 | /* SearchRefine is only to be displayed for places, not in the home page */ |
2839 | 146 | visible: dashView.activePlaceEntry != "" | 150 | visible: dashView.activePlaceEntry != "" |
2840 | 147 | placeEntryModel: visible && currentPage != undefined ? currentPage.model : undefined | 151 | placeEntryModel: visible && currentPage != undefined ? currentPage.model : undefined |
2841 | @@ -158,6 +162,12 @@ | |||
2842 | 158 | Loader { | 162 | Loader { |
2843 | 159 | id: pageLoader | 163 | id: pageLoader |
2844 | 160 | 164 | ||
2845 | 165 | /* FIXME: check on visible necessary; fixed in Qt Quick 1.1 | ||
2846 | 166 | ref: http://bugreports.qt.nokia.com/browse/QTBUG-15862 | ||
2847 | 167 | */ | ||
2848 | 168 | KeyNavigation.right: refine_search.visible && !refine_search.folded ? refine_search : pageLoader | ||
2849 | 169 | KeyNavigation.up: search_entry | ||
2850 | 170 | |||
2851 | 161 | anchors.top: search_entry.bottom | 171 | anchors.top: search_entry.bottom |
2852 | 162 | anchors.topMargin: 2 | 172 | anchors.topMargin: 2 |
2853 | 163 | anchors.bottom: parent.bottom | 173 | anchors.bottom: parent.bottom |
2854 | @@ -165,6 +175,7 @@ | |||
2855 | 165 | anchors.leftMargin: 20 | 175 | anchors.leftMargin: 20 |
2856 | 166 | anchors.right: !refine_search.visible || refine_search.folded ? parent.right : refine_search.left | 176 | anchors.right: !refine_search.visible || refine_search.folded ? parent.right : refine_search.left |
2857 | 167 | anchors.rightMargin: !refine_search.visible || refine_search.folded ? 0 : 15 | 177 | anchors.rightMargin: !refine_search.visible || refine_search.folded ? 0 : 15 |
2858 | 178 | onLoaded: item.focus = true | ||
2859 | 168 | } | 179 | } |
2860 | 169 | } | 180 | } |
2861 | 170 | 181 | ||
2862 | 171 | 182 | ||
2863 | === modified file 'spread/app/CMakeLists.txt' | |||
2864 | --- spread/app/CMakeLists.txt 2011-03-07 14:52:11 +0000 | |||
2865 | +++ spread/app/CMakeLists.txt 2011-07-27 15:02:42 +0000 | |||
2866 | @@ -1,7 +1,3 @@ | |||
2867 | 1 | # Dependencies | ||
2868 | 2 | pkg_check_modules(GTK REQUIRED gtk+-2.0) | ||
2869 | 3 | find_package(X11 REQUIRED) | ||
2870 | 4 | |||
2871 | 5 | # Sources | 1 | # Sources |
2872 | 6 | set(spread_SRCS | 2 | set(spread_SRCS |
2873 | 7 | spread.cpp | 3 | spread.cpp |
2874 | 8 | 4 | ||
2875 | === modified file 'spread/app/spread.cpp' | |||
2876 | --- spread/app/spread.cpp 2011-06-22 08:33:52 +0000 | |||
2877 | +++ spread/app/spread.cpp 2011-07-27 15:02:42 +0000 | |||
2878 | @@ -18,7 +18,6 @@ | |||
2879 | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2880 | 19 | */ | 19 | */ |
2881 | 20 | 20 | ||
2882 | 21 | #include <gtk/gtk.h> | ||
2883 | 22 | #include <QApplication> | 21 | #include <QApplication> |
2884 | 23 | #include <QDesktopWidget> | 22 | #include <QDesktopWidget> |
2885 | 24 | #include <QDeclarativeEngine> | 23 | #include <QDeclarativeEngine> |
2886 | @@ -28,31 +27,14 @@ | |||
2887 | 28 | #include "spreadcontrol.h" | 27 | #include "spreadcontrol.h" |
2888 | 29 | #include "launcherclient.h" | 28 | #include "launcherclient.h" |
2889 | 30 | 29 | ||
2891 | 31 | #include <unity2ddebug.h> | 30 | #include <unity2dapplication.h> |
2892 | 32 | 31 | ||
2893 | 33 | #include "config.h" | 32 | #include "config.h" |
2894 | 34 | 33 | ||
2895 | 35 | int main(int argc, char *argv[]) | 34 | int main(int argc, char *argv[]) |
2896 | 36 | { | 35 | { |
2916 | 37 | /* Unity2d plugin uses GTK APIs to retrieve theme icons | 36 | Unity2dApplication::earlySetup(argc, argv); |
2917 | 38 | (gtk_icon_theme_get_default) and requires a call to gtk_init */ | 37 | Unity2dApplication application(argc, argv); |
2899 | 39 | gtk_init(&argc, &argv); | ||
2900 | 40 | |||
2901 | 41 | Unity2dDebug::installHandlers(); | ||
2902 | 42 | |||
2903 | 43 | /* When the environment variable QT_GRAPHICSSYSTEM is not set, | ||
2904 | 44 | force graphics system to 'raster' instead of the default 'native' | ||
2905 | 45 | which on X11 is 'XRender'. | ||
2906 | 46 | 'XRender' defaults to using a TrueColor visual. We do _not_ mimick that | ||
2907 | 47 | behaviour with 'raster' by calling QApplication::setColorSpec because | ||
2908 | 48 | of a bug where some pixmaps become blueish: | ||
2909 | 49 | |||
2910 | 50 | https://bugs.launchpad.net/unity-2d/+bug/689877 | ||
2911 | 51 | */ | ||
2912 | 52 | if(getenv("QT_GRAPHICSSYSTEM") == 0) { | ||
2913 | 53 | QApplication::setGraphicsSystem("raster"); | ||
2914 | 54 | } | ||
2915 | 55 | QApplication application(argc, argv); | ||
2918 | 56 | QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments()); | 38 | QSet<QString> arguments = QSet<QString>::fromList(QCoreApplication::arguments()); |
2919 | 57 | 39 | ||
2920 | 58 | SpreadView view; | 40 | SpreadView view; |