author | sandman <sandman> | 2003-03-21 21:12:14 (UTC) |
---|---|---|
committer | sandman <sandman> | 2003-03-21 21:12:14 (UTC) |
commit | d11cf5483fbfa87a7be65891df2625def351f3a4 (patch) (unidiff) | |
tree | 53ec1a4fefcd7a2fc37bd64a0bae3ce378c5ef7d | |
parent | 633fbff7e3d85a5fc16bd3ed3283723c44acb2aa (diff) | |
download | opie-d11cf5483fbfa87a7be65891df2625def351f3a4.zip opie-d11cf5483fbfa87a7be65891df2625def351f3a4.tar.gz opie-d11cf5483fbfa87a7be65891df2625def351f3a4.tar.bz2 |
fix for bug #647:
Programs are sorted by their internal name and not by the translated name
(in the O-Menu)
-rw-r--r-- | core/launcher/startmenu.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp index 2871233..28c8b97 100644 --- a/core/launcher/startmenu.cpp +++ b/core/launcher/startmenu.cpp | |||
@@ -98,257 +98,265 @@ void StartMenu::loadOptions() | |||
98 | #endif | 98 | #endif |
99 | } | 99 | } |
100 | 100 | ||
101 | 101 | ||
102 | void StartMenu::createMenu() | 102 | void StartMenu::createMenu() |
103 | { | 103 | { |
104 | delete launchMenu; | 104 | delete launchMenu; |
105 | if ( useWidePopupMenu ) | 105 | if ( useWidePopupMenu ) |
106 | launchMenu = new PopupWithLaunchSideThing( this, &popupMenuSidePixmap ); | 106 | launchMenu = new PopupWithLaunchSideThing( this, &popupMenuSidePixmap ); |
107 | else | 107 | else |
108 | launchMenu = new StartPopupMenu( this ); | 108 | launchMenu = new StartPopupMenu( this ); |
109 | 109 | ||
110 | loadMenu ( apps, launchMenu ); | 110 | loadMenu ( apps, launchMenu ); |
111 | loadApplets ( ); | 111 | loadApplets ( ); |
112 | 112 | ||
113 | connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); | 113 | connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); |
114 | } | 114 | } |
115 | 115 | ||
116 | void StartMenu::reloadApps() | 116 | void StartMenu::reloadApps() |
117 | { | 117 | { |
118 | Config cfg("StartMenu"); | 118 | Config cfg("StartMenu"); |
119 | cfg.setGroup("Menu"); | 119 | cfg.setGroup("Menu"); |
120 | bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); | 120 | bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); |
121 | bool lot = cfg.readBoolEntry("LauncherOther",TRUE); | 121 | bool lot = cfg.readBoolEntry("LauncherOther",TRUE); |
122 | bool lt = ltabs || lot; | 122 | bool lt = ltabs || lot; |
123 | if ( launchMenu && apps && !lt ) | 123 | if ( launchMenu && apps && !lt ) |
124 | return; // nothing to do | 124 | return; // nothing to do |
125 | 125 | ||
126 | if ( lt ) { | 126 | if ( lt ) { |
127 | delete apps; | 127 | delete apps; |
128 | apps = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); | 128 | apps = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); |
129 | } | 129 | } |
130 | if ( launchMenu ) { | 130 | if ( launchMenu ) { |
131 | launchMenu-> hide ( ); | 131 | launchMenu-> hide ( ); |
132 | 132 | ||
133 | for ( QIntDictIterator<QPopupMenu> it ( tabdict ); it. current ( ); ++it ) { | 133 | for ( QIntDictIterator<QPopupMenu> it ( tabdict ); it. current ( ); ++it ) { |
134 | launchMenu-> removeItem ( it. currentKey ( )); | 134 | launchMenu-> removeItem ( it. currentKey ( )); |
135 | delete it.current ( ); | 135 | delete it.current ( ); |
136 | } | 136 | } |
137 | tabdict. clear ( ); | 137 | tabdict. clear ( ); |
138 | loadMenu(apps,launchMenu); | 138 | loadMenu(apps,launchMenu); |
139 | } else { | 139 | } else { |
140 | createMenu(); | 140 | createMenu(); |
141 | } | 141 | } |
142 | } | 142 | } |
143 | 143 | ||
144 | void StartMenu::reloadApplets() | 144 | void StartMenu::reloadApplets() |
145 | { | 145 | { |
146 | if ( launchMenu ) { | 146 | if ( launchMenu ) { |
147 | clearApplets ( ); | 147 | clearApplets ( ); |
148 | loadApplets ( ); | 148 | loadApplets ( ); |
149 | } | 149 | } |
150 | else | 150 | else |
151 | createMenu ( ); | 151 | createMenu ( ); |
152 | } | 152 | } |
153 | 153 | ||
154 | void StartMenu::itemSelected( int id ) | 154 | void StartMenu::itemSelected( int id ) |
155 | { | 155 | { |
156 | const AppLnk *app = apps->find( id ); | 156 | const AppLnk *app = apps->find( id ); |
157 | if ( app ) | 157 | if ( app ) |
158 | app->execute(); | 158 | app->execute(); |
159 | else { | 159 | else { |
160 | MenuApplet *applet = applets. find ( id ); | 160 | MenuApplet *applet = applets. find ( id ); |
161 | 161 | ||
162 | if ( applet ) | 162 | if ( applet ) |
163 | applet-> iface-> activated ( ); | 163 | applet-> iface-> activated ( ); |
164 | } | 164 | } |
165 | } | 165 | } |
166 | 166 | ||
167 | bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu ) | 167 | bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu ) |
168 | { | 168 | { |
169 | bool result = FALSE; | 169 | bool result = FALSE; |
170 | 170 | ||
171 | Config cfg("StartMenu"); | 171 | Config cfg("StartMenu"); |
172 | cfg.setGroup("Menu"); | 172 | cfg.setGroup("Menu"); |
173 | 173 | ||
174 | bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); | 174 | bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); |
175 | bool lot = cfg.readBoolEntry("LauncherOther",TRUE); | 175 | bool lot = cfg.readBoolEntry("LauncherOther",TRUE); |
176 | 176 | ||
177 | tabdict. clear ( ); | 177 | tabdict. clear ( ); |
178 | 178 | ||
179 | if ( sepId ) | 179 | if ( sepId ) |
180 | menu-> removeItem ( sepId ); | 180 | menu-> removeItem ( sepId ); |
181 | sepId = ( menu-> count ( )) ? menu-> insertSeparator ( 0 ) : 0; | 181 | sepId = ( menu-> count ( )) ? menu-> insertSeparator ( 0 ) : 0; |
182 | 182 | ||
183 | if ( ltabs || lot ) { | 183 | if ( ltabs || lot ) { |
184 | QDict<QPopupMenu> typpop; | 184 | QDict<QPopupMenu> typpop; |
185 | QStringList typs = folder->types(); | 185 | QStringList typs = folder->types(); |
186 | for (QStringList::Iterator tit=typs.fromLast(); ; --tit) { | 186 | for (QStringList::Iterator tit=typs.fromLast(); ; --tit) { |
187 | if ( !(*tit).isEmpty() ) { | 187 | if ( !(*tit).isEmpty() ) { |
188 | QPopupMenu *new_menu; | 188 | QPopupMenu *new_menu; |
189 | if ( ltabs ) { | 189 | if ( ltabs ) { |
190 | new_menu = new StartPopupMenu( menu ); | 190 | new_menu = new StartPopupMenu( menu ); |
191 | connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); | 191 | connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); |
192 | int id = menu->insertItem( folder->typePixmap(*tit), folder->typeName(*tit), new_menu, -1, 0 ); | 192 | int id = menu->insertItem( folder->typePixmap(*tit), folder->typeName(*tit), new_menu, -1, 0 ); |
193 | tabdict. insert ( id, new_menu ); | 193 | tabdict. insert ( id, new_menu ); |
194 | } else { | 194 | } else { |
195 | new_menu = (QPopupMenu*)1; | 195 | new_menu = (QPopupMenu*)1; |
196 | } | 196 | } |
197 | typpop.insert(*tit, new_menu); | 197 | typpop.insert(*tit, new_menu); |
198 | } | 198 | } |
199 | if ( tit == typs. begin ( )) | 199 | if ( tit == typs. begin ( )) |
200 | break; | 200 | break; |
201 | } | 201 | } |
202 | QListIterator<AppLnk> it( folder->children() ); | 202 | QListIterator<AppLnk> it( folder->children() ); |
203 | bool f=TRUE; | 203 | bool f=TRUE; |
204 | for ( ; it.current(); ++it ) { | 204 | for ( ; it.current(); ++it ) { |
205 | AppLnk *app = it.current(); | 205 | AppLnk *app = it.current(); |
206 | if ( app->type() == "Separator" ) { // No tr | 206 | if ( app->type() == "Separator" ) { // No tr |
207 | if ( lot ) { | 207 | if ( lot ) { |
208 | menu->insertSeparator(); | 208 | menu->insertSeparator(); |
209 | } | 209 | } |
210 | } else { | 210 | } else { |
211 | f = FALSE; | 211 | f = FALSE; |
212 | QString t = app->type(); | 212 | QString t = app->type(); |
213 | QPopupMenu* pmenu = typpop.find(t); | 213 | QPopupMenu* pmenu = typpop.find(t); |
214 | if ( ltabs ) { | 214 | if ( ltabs ) { |
215 | if ( !pmenu && lot ) | 215 | if ( !pmenu && lot ) |
216 | pmenu = menu; | 216 | pmenu = menu; |
217 | } else { | 217 | } else { |
218 | if ( !pmenu ) | 218 | if ( !pmenu ) |
219 | pmenu = menu; | 219 | pmenu = menu; |
220 | else | 220 | else |
221 | pmenu = 0; | 221 | pmenu = 0; |
222 | } | 222 | } |
223 | if ( pmenu ) { | 223 | if ( pmenu ) { |
224 | QString t = app->name(); | 224 | QString t = app->name(); |
225 | t.replace(QRegExp("&"),"&&"); // escape shortcut character | 225 | t.replace(QRegExp("&"),"&&"); // escape shortcut character |
226 | pmenu->insertItem( app->pixmap(), t, app->id() ); | 226 | |
227 | int index = -1; | ||
228 | |||
229 | for ( index = 0; index < pmenu-> count ( ); index++ ) { | ||
230 | if ( pmenu-> text ( pmenu-> idAt ( index )). compare ( t ) > 0 ) | ||
231 | break; | ||
232 | } | ||
233 | |||
234 | pmenu->insertItem( app->pixmap(), t, app->id(), index ); | ||
227 | } | 235 | } |
228 | result=TRUE; | 236 | result=TRUE; |
229 | } | 237 | } |
230 | } | 238 | } |
231 | } | 239 | } |
232 | 240 | ||
233 | if ( sepId && ( menu-> idAt ( 0 ) == sepId )) { // no tabs entries | 241 | if ( sepId && ( menu-> idAt ( 0 ) == sepId )) { // no tabs entries |
234 | menu-> removeItem ( sepId ); | 242 | menu-> removeItem ( sepId ); |
235 | sepId = 0; | 243 | sepId = 0; |
236 | } | 244 | } |
237 | if ( !menu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later | 245 | if ( !menu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later |
238 | sepId = menu-> insertSeparator ( ); | 246 | sepId = menu-> insertSeparator ( ); |
239 | 247 | ||
240 | return result; | 248 | return result; |
241 | } | 249 | } |
242 | 250 | ||
243 | 251 | ||
244 | void StartMenu::launch ( ) | 252 | void StartMenu::launch ( ) |
245 | { | 253 | { |
246 | int y = mapToGlobal ( QPoint ( )). y ( ) - launchMenu-> sizeHint ( ). height ( ); | 254 | int y = mapToGlobal ( QPoint ( )). y ( ) - launchMenu-> sizeHint ( ). height ( ); |
247 | 255 | ||
248 | if ( launchMenu-> isVisible ( )) { | 256 | if ( launchMenu-> isVisible ( )) { |
249 | launchMenu-> hide ( ); | 257 | launchMenu-> hide ( ); |
250 | } | 258 | } |
251 | else { | 259 | else { |
252 | QWidget *active = qApp-> activeWindow ( ); | 260 | QWidget *active = qApp-> activeWindow ( ); |
253 | if ( active && active-> isPopup ( )) | 261 | if ( active && active-> isPopup ( )) |
254 | active-> close ( ); | 262 | active-> close ( ); |
255 | 263 | ||
256 | launchMenu-> popup ( QPoint ( 1, y )); | 264 | launchMenu-> popup ( QPoint ( 1, y )); |
257 | } | 265 | } |
258 | } | 266 | } |
259 | 267 | ||
260 | const AppLnk* StartMenu::execToLink(const QString& appname) | 268 | const AppLnk* StartMenu::execToLink(const QString& appname) |
261 | { | 269 | { |
262 | const AppLnk* a = apps->findExec( appname ); | 270 | const AppLnk* a = apps->findExec( appname ); |
263 | return a; | 271 | return a; |
264 | } | 272 | } |
265 | 273 | ||
266 | void StartPopupMenu::keyPressEvent( QKeyEvent *e ) | 274 | void StartPopupMenu::keyPressEvent( QKeyEvent *e ) |
267 | { | 275 | { |
268 | if ( e->key() == Key_F33 || e->key() == Key_Space ) { | 276 | if ( e->key() == Key_F33 || e->key() == Key_Space ) { |
269 | // "OK" button, little hacky | 277 | // "OK" button, little hacky |
270 | QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); | 278 | QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); |
271 | QPopupMenu::keyPressEvent( &ke ); | 279 | QPopupMenu::keyPressEvent( &ke ); |
272 | } else { | 280 | } else { |
273 | QPopupMenu::keyPressEvent( e ); | 281 | QPopupMenu::keyPressEvent( e ); |
274 | } | 282 | } |
275 | } | 283 | } |
276 | 284 | ||
277 | static int compareAppletPositions(const void *a, const void *b) | 285 | static int compareAppletPositions(const void *a, const void *b) |
278 | { | 286 | { |
279 | const MenuApplet* aa = *(const MenuApplet**)a; | 287 | const MenuApplet* aa = *(const MenuApplet**)a; |
280 | const MenuApplet* ab = *(const MenuApplet**)b; | 288 | const MenuApplet* ab = *(const MenuApplet**)b; |
281 | int d = aa->iface->position() - ab->iface->position(); | 289 | int d = aa->iface->position() - ab->iface->position(); |
282 | if ( d ) return d; | 290 | if ( d ) return d; |
283 | return QString::compare(aa->library->library(),ab->library->library()); | 291 | return QString::compare(aa->library->library(),ab->library->library()); |
284 | } | 292 | } |
285 | 293 | ||
286 | void StartMenu::clearApplets() | 294 | void StartMenu::clearApplets() |
287 | { | 295 | { |
288 | launchMenu-> hide(); | 296 | launchMenu-> hide(); |
289 | 297 | ||
290 | for ( QIntDictIterator<MenuApplet> it ( applets ); it. current ( ); ++it ) { | 298 | for ( QIntDictIterator<MenuApplet> it ( applets ); it. current ( ); ++it ) { |
291 | MenuApplet *applet = it. current ( ); | 299 | MenuApplet *applet = it. current ( ); |
292 | if ( launchMenu ) { | 300 | if ( launchMenu ) { |
293 | launchMenu-> removeItem ( applet-> id ); | 301 | launchMenu-> removeItem ( applet-> id ); |
294 | delete applet-> popup; | 302 | delete applet-> popup; |
295 | } | 303 | } |
296 | 304 | ||
297 | applet-> iface-> release(); | 305 | applet-> iface-> release(); |
298 | applet-> library-> unload(); | 306 | applet-> library-> unload(); |
299 | delete applet-> library; | 307 | delete applet-> library; |
300 | } | 308 | } |
301 | applets.clear(); | 309 | applets.clear(); |
302 | } | 310 | } |
303 | 311 | ||
304 | 312 | ||
305 | 313 | ||
306 | void StartMenu::loadApplets() | 314 | void StartMenu::loadApplets() |
307 | { | 315 | { |
308 | Config cfg( "StartMenu" ); | 316 | Config cfg( "StartMenu" ); |
309 | cfg.setGroup( "Applets" ); | 317 | cfg.setGroup( "Applets" ); |
310 | 318 | ||
311 | // SafeMode causes too much problems, so we disable it for now -- | 319 | // SafeMode causes too much problems, so we disable it for now -- |
312 | // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 | 320 | // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 |
313 | 321 | ||
314 | bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE); | 322 | bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE); |
315 | if ( safe && !safety_tid ) | 323 | if ( safe && !safety_tid ) |
316 | return; | 324 | return; |
317 | cfg.writeEntry("SafeMode",TRUE); | 325 | cfg.writeEntry("SafeMode",TRUE); |
318 | cfg.write(); | 326 | cfg.write(); |
319 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); | 327 | QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); |
320 | 328 | ||
321 | QString lang = getenv( "LANG" ); | 329 | QString lang = getenv( "LANG" ); |
322 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; | 330 | QString path = QPEApplication::qpeDir() + "/plugins/applets"; |
323 | QDir dir( path, "lib*.so" ); | 331 | QDir dir( path, "lib*.so" ); |
324 | QStringList list = dir.entryList(); | 332 | QStringList list = dir.entryList(); |
325 | QStringList::Iterator it; | 333 | QStringList::Iterator it; |
326 | int napplets=0; | 334 | int napplets=0; |
327 | MenuApplet* *xapplets = new MenuApplet*[list.count()]; | 335 | MenuApplet* *xapplets = new MenuApplet*[list.count()]; |
328 | for ( it = list.begin(); it != list.end(); ++it ) { | 336 | for ( it = list.begin(); it != list.end(); ++it ) { |
329 | if ( exclude.find( *it ) != exclude.end() ) | 337 | if ( exclude.find( *it ) != exclude.end() ) |
330 | continue; | 338 | continue; |
331 | MenuAppletInterface *iface = 0; | 339 | MenuAppletInterface *iface = 0; |
332 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 340 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
333 | if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { | 341 | if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { |
334 | MenuApplet *applet = new MenuApplet; | 342 | MenuApplet *applet = new MenuApplet; |
335 | xapplets[napplets++] = applet; | 343 | xapplets[napplets++] = applet; |
336 | applet->library = lib; | 344 | applet->library = lib; |
337 | applet->iface = iface; | 345 | applet->iface = iface; |
338 | 346 | ||
339 | QTranslator *trans = new QTranslator(qApp); | 347 | QTranslator *trans = new QTranslator(qApp); |
340 | QString type = (*it).left( (*it).find(".") ); | 348 | QString type = (*it).left( (*it).find(".") ); |
341 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; | 349 | QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; |
342 | if ( trans->load( tfn )) | 350 | if ( trans->load( tfn )) |
343 | qApp->installTranslator( trans ); | 351 | qApp->installTranslator( trans ); |
344 | else | 352 | else |
345 | delete trans; | 353 | delete trans; |
346 | } else { | 354 | } else { |
347 | exclude += *it; | 355 | exclude += *it; |
348 | delete lib; | 356 | delete lib; |
349 | } | 357 | } |
350 | } | 358 | } |
351 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); | 359 | cfg.writeEntry( "ExcludeApplets", exclude, ',' ); |
352 | qsort(xapplets,napplets,sizeof(applets[0]),compareAppletPositions); | 360 | qsort(xapplets,napplets,sizeof(applets[0]),compareAppletPositions); |
353 | 361 | ||
354 | if ( sepId ) | 362 | if ( sepId ) |