summaryrefslogtreecommitdiff
path: root/core/launcher/startmenu.cpp
Unidiff
Diffstat (limited to 'core/launcher/startmenu.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/startmenu.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp
index f3a7651..66f665f 100644
--- a/core/launcher/startmenu.cpp
+++ b/core/launcher/startmenu.cpp
@@ -270,116 +270,116 @@ void StartMenu::launch()
270 270
271 271
272 272
273 273
274static int compareAppletPositions(const void *b, const void *a) 274static int compareAppletPositions(const void *b, const void *a)
275{ 275{
276 const MenuApplet* aa = *(const MenuApplet**)a; 276 const MenuApplet* aa = *(const MenuApplet**)a;
277 const MenuApplet* ab = *(const MenuApplet**)b; 277 const MenuApplet* ab = *(const MenuApplet**)b;
278 int d = aa->iface->position() - ab->iface->position(); 278 int d = aa->iface->position() - ab->iface->position();
279 if ( d ) return d; 279 if ( d ) return d;
280 return QString::compare(aa->library->library(),ab->library->library()); 280 return QString::compare(aa->library->library(),ab->library->library());
281} 281}
282 282
283void StartMenu::clearApplets() 283void StartMenu::clearApplets()
284{ 284{
285 if ( launchMenu ) 285 if ( launchMenu )
286 launchMenu-> hide(); 286 launchMenu-> hide();
287 287
288 for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) { 288 for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) {
289 MenuApplet *applet = it.current(); 289 MenuApplet *applet = it.current();
290 if ( launchMenu ) { 290 if ( launchMenu ) {
291 launchMenu->removeItem( applet-> id ); 291 launchMenu->removeItem( applet-> id );
292 delete applet->popup; 292 delete applet->popup;
293 } 293 }
294 294
295 applet->iface->release(); 295 applet->iface->release();
296 applet->library->unload(); 296 applet->library->unload();
297 delete applet-> library; 297 delete applet-> library;
298 } 298 }
299 menuApplets.clear(); 299 menuApplets.clear();
300} 300}
301 301
302 302
303 303
304 304
305void StartMenu::loadApplets() 305void StartMenu::loadApplets()
306{ 306{
307 Config cfg( "StartMenu" ); 307 Config cfg( "StartMenu" );
308 cfg.setGroup( "Applets" ); 308 cfg.setGroup( "Applets" );
309 309
310 // SafeMode causes too much problems, so we disable it for now -- 310 // SafeMode causes too much problems, so we disable it for now --
311 // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 311 // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02
312 // removed in the remerge PluginManager could handle it 312 // removed in the remerge PluginManager could handle it
313 // we don't currently use it -zecke 313 // we don't currently use it -zecke
314 314
315 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); 315 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' );
316 316
317 QString lang = getenv( "LANG" ); 317 QString lang = getenv( "LANG" );
318 QString path = QPEApplication::qpeDir() + "/plugins/applets"; 318 QString path = QPEApplication::qpeDir() + "plugins/applets";
319 QDir dir( path, "lib*.so" ); 319 QDir dir( path, "lib*.so" );
320 QStringList list = dir.entryList(); 320 QStringList list = dir.entryList();
321 QStringList::Iterator it; 321 QStringList::Iterator it;
322 int napplets = 0; 322 int napplets = 0;
323 MenuApplet* *xapplets = new MenuApplet*[list.count()]; 323 MenuApplet* *xapplets = new MenuApplet*[list.count()];
324 for ( it = list.begin(); it != list.end(); ++it ) { 324 for ( it = list.begin(); it != list.end(); ++it ) {
325 if ( exclude.find( *it ) != exclude.end() ) 325 if ( exclude.find( *it ) != exclude.end() )
326 continue; 326 continue;
327 MenuAppletInterface *iface = 0; 327 MenuAppletInterface *iface = 0;
328 QLibrary *lib = new QLibrary( path + "/" + *it ); 328 QLibrary *lib = new QLibrary( path + "/" + *it );
329 if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { 329 if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) {
330 MenuApplet *applet = new MenuApplet; 330 MenuApplet *applet = new MenuApplet;
331 xapplets[napplets++] = applet; 331 xapplets[napplets++] = applet;
332 applet->library = lib; 332 applet->library = lib;
333 applet->iface = iface; 333 applet->iface = iface;
334 334
335 QTranslator *trans = new QTranslator(qApp); 335 QTranslator *trans = new QTranslator(qApp);
336 QString type = (*it).left( (*it).find(".") ); 336 QString type = (*it).left( (*it).find(".") );
337 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; 337 QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+type+".qm";
338 if ( trans->load( tfn )) 338 if ( trans->load( tfn ))
339 qApp->installTranslator( trans ); 339 qApp->installTranslator( trans );
340 else 340 else
341 delete trans; 341 delete trans;
342 } else { 342 } else {
343 exclude += *it; 343 exclude += *it;
344 delete lib; 344 delete lib;
345 } 345 }
346 } 346 }
347 cfg.writeEntry( "ExcludeApplets", exclude, ',' ); 347 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
348 qsort(xapplets, napplets, sizeof(menuApplets[0]), compareAppletPositions); 348 qsort(xapplets, napplets, sizeof(menuApplets[0]), compareAppletPositions);
349 349
350 350
351 while ( napplets-- ) { 351 while ( napplets-- ) {
352 MenuApplet *applet = xapplets[napplets]; 352 MenuApplet *applet = xapplets[napplets];
353 applet->popup = applet->iface->popup( this ); 353 applet->popup = applet->iface->popup( this );
354 354
355 // menuApplets got an id < -1 355 // menuApplets got an id < -1
356 menuApplets.insert( -( currentItem + 2 ), new MenuApplet( *applet ) ); 356 menuApplets.insert( -( currentItem + 2 ), new MenuApplet( *applet ) );
357 currentItem++; 357 currentItem++;
358 } 358 }
359 delete [] xapplets; 359 delete [] xapplets;
360 360
361 addApplets( launchMenu ); 361 addApplets( launchMenu );
362} 362}
363 363
364 364
365/* 365/*
366 * Launcher calls loadMenu too often fix that 366 * Launcher calls loadMenu too often fix that
367 */ 367 */
368void StartMenu::addApplets(QPopupMenu* pop) { 368void StartMenu::addApplets(QPopupMenu* pop) {
369 QIntDict<MenuApplet> dict; 369 QIntDict<MenuApplet> dict;
370 if( pop-> count ( )) 370 if( pop-> count ( ))
371 pop-> insertSeparator ( ); 371 pop-> insertSeparator ( );
372 372
373 for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) { 373 for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) {
374 MenuApplet *applet = it.current(); 374 MenuApplet *applet = it.current();
375 if ( applet->popup ) 375 if ( applet->popup )
376 applet->id = pop->insertItem( applet->iface->icon(), 376 applet->id = pop->insertItem( applet->iface->icon(),
377 applet->iface->text(), applet->popup ); 377 applet->iface->text(), applet->popup );
378 else 378 else
379 applet->id = pop->insertItem( applet->iface->icon(), 379 applet->id = pop->insertItem( applet->iface->icon(),
380 applet->iface->text() ); 380 applet->iface->text() );
381 381
382 382
383 dict.insert( applet->id, new MenuApplet( *applet ) ); 383 dict.insert( applet->id, new MenuApplet( *applet ) );
384 } 384 }
385 /* need to update the key */ 385 /* need to update the key */