-rw-r--r-- | core/launcher/startmenu.cpp | 4 |
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 | |||
@@ -222,169 +222,169 @@ void StartMenu::createMenuEntries( QPopupMenu *menu, QDir dir, bool ltabs, bool | |||
222 | dirs.sort(); | 222 | dirs.sort(); |
223 | 223 | ||
224 | for ( QStringList::Iterator it = dirs.begin(); it != dirs.end(); it++ ) { | 224 | for ( QStringList::Iterator it = dirs.begin(); it != dirs.end(); it++ ) { |
225 | createDirEntry( menu, dir, *it, lot ); | 225 | createDirEntry( menu, dir, *it, lot ); |
226 | } | 226 | } |
227 | } | 227 | } |
228 | } | 228 | } |
229 | 229 | ||
230 | bool StartMenu::loadMenu( QPopupMenu *menu ) | 230 | bool StartMenu::loadMenu( QPopupMenu *menu ) |
231 | { | 231 | { |
232 | Config cfg("StartMenu"); | 232 | Config cfg("StartMenu"); |
233 | cfg.setGroup("Menu"); | 233 | cfg.setGroup("Menu"); |
234 | 234 | ||
235 | bool ltabs = cfg.readBoolEntry("LauncherTabs", TRUE); | 235 | bool ltabs = cfg.readBoolEntry("LauncherTabs", TRUE); |
236 | bool lot = cfg.readBoolEntry("LauncherOther", TRUE); | 236 | bool lot = cfg.readBoolEntry("LauncherOther", TRUE); |
237 | useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE ); | 237 | useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE ); |
238 | bool sepfirst = !ltabs && !lot; | 238 | bool sepfirst = !ltabs && !lot; |
239 | 239 | ||
240 | currentItem = 0; | 240 | currentItem = 0; |
241 | launchMenu->clear(); | 241 | launchMenu->clear(); |
242 | 242 | ||
243 | appLnks.setAutoDelete( true ); | 243 | appLnks.setAutoDelete( true ); |
244 | tabNames.setAutoDelete( true ); | 244 | tabNames.setAutoDelete( true ); |
245 | appLnks.clear(); | 245 | appLnks.clear(); |
246 | tabNames.clear(); | 246 | tabNames.clear(); |
247 | appLnks.setAutoDelete( false ); | 247 | appLnks.setAutoDelete( false ); |
248 | tabNames.setAutoDelete( false ); | 248 | tabNames.setAutoDelete( false ); |
249 | 249 | ||
250 | QDir dir( MimeType::appsFolderName(), QString::null, QDir::Name ); | 250 | QDir dir( MimeType::appsFolderName(), QString::null, QDir::Name ); |
251 | createMenuEntries( menu, dir, ltabs, lot ); | 251 | createMenuEntries( menu, dir, ltabs, lot ); |
252 | 252 | ||
253 | if ( !menu->count() ) sepfirst = TRUE; | 253 | if ( !menu->count() ) sepfirst = TRUE; |
254 | 254 | ||
255 | launchMenu->setName( sepfirst ? "accessories" : "accessories_need_sep" ); // No tr | 255 | launchMenu->setName( sepfirst ? "accessories" : "accessories_need_sep" ); // No tr |
256 | 256 | ||
257 | return currentItem; | 257 | return currentItem; |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | void StartMenu::launch() | 261 | void StartMenu::launch() |
262 | { | 262 | { |
263 | int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); | 263 | int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); |
264 | 264 | ||
265 | if ( launchMenu->isVisible() ) | 265 | if ( launchMenu->isVisible() ) |
266 | launchMenu->hide(); | 266 | launchMenu->hide(); |
267 | else | 267 | else |
268 | launchMenu->popup( QPoint( 1, y ) ); | 268 | launchMenu->popup( QPoint( 1, y ) ); |
269 | } | 269 | } |
270 | 270 | ||
271 | 271 | ||
272 | 272 | ||
273 | 273 | ||
274 | static int compareAppletPositions(const void *b, const void *a) | 274 | static 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 | ||
283 | void StartMenu::clearApplets() | 283 | void 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 | ||
305 | void StartMenu::loadApplets() | 305 | void 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 | */ |
368 | void StartMenu::addApplets(QPopupMenu* pop) { | 368 | void 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 */ |
386 | menuApplets.setAutoDelete( true ); | 386 | menuApplets.setAutoDelete( true ); |
387 | menuApplets.clear(); | 387 | menuApplets.clear(); |
388 | menuApplets.setAutoDelete( false ); | 388 | menuApplets.setAutoDelete( false ); |
389 | menuApplets = dict; | 389 | menuApplets = dict; |
390 | } | 390 | } |