summaryrefslogtreecommitdiff
authorschurig <schurig>2003-07-09 09:45:45 (UTC)
committer schurig <schurig>2003-07-09 09:45:45 (UTC)
commitaa36a8c83f54c3380a512281e8821ed930854b4d (patch) (unidiff)
tree5a0f05181e33d1090c64793adbc1299ee33d7717
parent4cc87752584c08d1267cc389142777db5faba302 (diff)
downloadopie-aa36a8c83f54c3380a512281e8821ed930854b4d.zip
opie-aa36a8c83f54c3380a512281e8821ed930854b4d.tar.gz
opie-aa36a8c83f54c3380a512281e8821ed930854b4d.tar.bz2
forward port from branch
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/startmenu.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp
index 28c8b97..d75e8be 100644
--- a/core/launcher/startmenu.cpp
+++ b/core/launcher/startmenu.cpp
@@ -1,400 +1,401 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#define INCLUDE_MENUITEM_DEF 21#define INCLUDE_MENUITEM_DEF
22 22
23#include "startmenu.h" 23#include "startmenu.h"
24#include "sidething.h" 24#include "sidething.h"
25//#include "mrulist.h" 25//#include "mrulist.h"
26#include "info.h" 26#include "info.h"
27 27
28#include <qpe/qpeapplication.h> 28#include <qpe/qpeapplication.h>
29#include <qpe/config.h> 29#include <qpe/config.h>
30#include <qpe/applnk.h> 30#include <qpe/applnk.h>
31#include <qpe/global.h> 31#include <qpe/global.h>
32#include <qpe/resource.h> 32#include <qpe/resource.h>
33#include <qpe/qlibrary.h> 33#include <qpe/qlibrary.h>
34 34
35#include <qintdict.h> 35#include <qintdict.h>
36#include <qdir.h> 36#include <qdir.h>
37 37
38#include <stdlib.h> 38#include <stdlib.h>
39 39
40 40
41// #define USE_CONFIG_FILE 41// #define USE_CONFIG_FILE
42 42
43 43
44StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) 44StartMenu::StartMenu(QWidget *parent) : QLabel( parent )
45{ 45{
46 loadOptions(); 46 loadOptions();
47 safety_tid = 1; // disable the timer... valgrind said it.. we don't use that option either -zecke
47 48
48 int sz = AppLnk::smallIconSize()+3; 49 int sz = AppLnk::smallIconSize()+3;
49 QPixmap pm; 50 QPixmap pm;
50 pm.convertFromImage(Resource::loadImage(startButtonPixmap).smoothScale(sz,sz)); 51 pm.convertFromImage(Resource::loadImage(startButtonPixmap).smoothScale(sz,sz));
51 setPixmap(pm); 52 setPixmap(pm);
52 setFocusPolicy( NoFocus ); 53 setFocusPolicy( NoFocus );
53 //setFlat( startButtonIsFlat ); 54 //setFlat( startButtonIsFlat );
54 55
55 apps = 0; 56 apps = 0;
56 launchMenu = 0; 57 launchMenu = 0;
57 applets. setAutoDelete ( true ); 58 applets. setAutoDelete ( true );
58 sepId = 0; 59 sepId = 0;
59 60
60 reloadApps ( ); 61 reloadApps ( );
61 reloadApplets ( ); 62 reloadApplets ( );
62} 63}
63 64
64 65
65void StartMenu::mousePressEvent( QMouseEvent * ) 66void StartMenu::mousePressEvent( QMouseEvent * )
66{ 67{
67 launch(); 68 launch();
68 if (desktopInfo) 69 if (desktopInfo)
69 desktopInfo->menuClicked(); 70 desktopInfo->menuClicked();
70} 71}
71 72
72 73
73StartMenu::~StartMenu() 74StartMenu::~StartMenu()
74{ 75{
75 delete apps; 76 delete apps;
76} 77}
77 78
78 79
79void StartMenu::loadOptions() 80void StartMenu::loadOptions()
80{ 81{
81#ifdef USE_CONFIG_FILE 82#ifdef USE_CONFIG_FILE
82 // Read configuration file 83 // Read configuration file
83 Config config("StartMenu"); 84 Config config("StartMenu");
84 config.setGroup( "StartMenu" ); 85 config.setGroup( "StartMenu" );
85 QString tmpBoolString1 = config.readEntry( "UseWidePopupMenu", "FALSE" ); 86 QString tmpBoolString1 = config.readEntry( "UseWidePopupMenu", "FALSE" );
86 useWidePopupMenu = ( tmpBoolString1 == "TRUE" ) ? TRUE : FALSE; 87 useWidePopupMenu = ( tmpBoolString1 == "TRUE" ) ? TRUE : FALSE;
87 QString tmpBoolString2 = config.readEntry( "StartButtonIsFlat", "TRUE" ); 88 QString tmpBoolString2 = config.readEntry( "StartButtonIsFlat", "TRUE" );
88 startButtonIsFlat = ( tmpBoolString2 == "TRUE" ) ? TRUE : FALSE; 89 startButtonIsFlat = ( tmpBoolString2 == "TRUE" ) ? TRUE : FALSE;
89 QString tmpBoolString3 = config.readEntry( "UseMRUList", "TRUE" ); 90 QString tmpBoolString3 = config.readEntry( "UseMRUList", "TRUE" );
90 popupMenuSidePixmap = config.readEntry( "PopupMenuSidePixmap", "launcher/sidebar" ); 91 popupMenuSidePixmap = config.readEntry( "PopupMenuSidePixmap", "launcher/sidebar" );
91 startButtonPixmap = config.readEntry( "StartButtonPixmap", "go" ); 92 startButtonPixmap = config.readEntry( "StartButtonPixmap", "go" );
92#else 93#else
93 // Basically just #include the .qpe_menu.conf file settings 94 // Basically just #include the .qpe_menu.conf file settings
94 useWidePopupMenu = FALSE; 95 useWidePopupMenu = FALSE;
95 popupMenuSidePixmap = "launcher/sidebar"; 96 popupMenuSidePixmap = "launcher/sidebar";
96 startButtonIsFlat = TRUE; 97 startButtonIsFlat = TRUE;
97 startButtonPixmap = "go"; // No tr 98 startButtonPixmap = "go"; // No tr
98#endif 99#endif
99} 100}
100 101
101 102
102void StartMenu::createMenu() 103void StartMenu::createMenu()
103{ 104{
104 delete launchMenu; 105 delete launchMenu;
105 if ( useWidePopupMenu ) 106 if ( useWidePopupMenu )
106 launchMenu = new PopupWithLaunchSideThing( this, &popupMenuSidePixmap ); 107 launchMenu = new PopupWithLaunchSideThing( this, &popupMenuSidePixmap );
107 else 108 else
108 launchMenu = new StartPopupMenu( this ); 109 launchMenu = new StartPopupMenu( this );
109 110
110 loadMenu ( apps, launchMenu ); 111 loadMenu ( apps, launchMenu );
111 loadApplets ( ); 112 loadApplets ( );
112 113
113 connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); 114 connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) );
114} 115}
115 116
116void StartMenu::reloadApps() 117void StartMenu::reloadApps()
117{ 118{
118 Config cfg("StartMenu"); 119 Config cfg("StartMenu");
119 cfg.setGroup("Menu"); 120 cfg.setGroup("Menu");
120 bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); 121 bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE);
121 bool lot = cfg.readBoolEntry("LauncherOther",TRUE); 122 bool lot = cfg.readBoolEntry("LauncherOther",TRUE);
122 bool lt = ltabs || lot; 123 bool lt = ltabs || lot;
123 if ( launchMenu && apps && !lt ) 124 if ( launchMenu && apps && !lt )
124 return; // nothing to do 125 return; // nothing to do
125 126
126 if ( lt ) { 127 if ( lt ) {
127 delete apps; 128 delete apps;
128 apps = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); 129 apps = new AppLnkSet( QPEApplication::qpeDir() + "apps" );
129 } 130 }
130 if ( launchMenu ) { 131 if ( launchMenu ) {
131 launchMenu-> hide ( ); 132 launchMenu-> hide ( );
132 133
133 for ( QIntDictIterator<QPopupMenu> it ( tabdict ); it. current ( ); ++it ) { 134 for ( QIntDictIterator<QPopupMenu> it ( tabdict ); it. current ( ); ++it ) {
134 launchMenu-> removeItem ( it. currentKey ( )); 135 launchMenu-> removeItem ( it. currentKey ( ));
135 delete it.current ( ); 136 delete it.current ( );
136 } 137 }
137 tabdict. clear ( ); 138 tabdict. clear ( );
138 loadMenu(apps,launchMenu); 139 loadMenu(apps,launchMenu);
139 } else { 140 } else {
140 createMenu(); 141 createMenu();
141 } 142 }
142} 143}
143 144
144void StartMenu::reloadApplets() 145void StartMenu::reloadApplets()
145{ 146{
146 if ( launchMenu ) { 147 if ( launchMenu ) {
147 clearApplets ( ); 148 clearApplets ( );
148 loadApplets ( ); 149 loadApplets ( );
149 } 150 }
150 else 151 else
151 createMenu ( ); 152 createMenu ( );
152} 153}
153 154
154void StartMenu::itemSelected( int id ) 155void StartMenu::itemSelected( int id )
155{ 156{
156 const AppLnk *app = apps->find( id ); 157 const AppLnk *app = apps->find( id );
157 if ( app ) 158 if ( app )
158 app->execute(); 159 app->execute();
159 else { 160 else {
160 MenuApplet *applet = applets. find ( id ); 161 MenuApplet *applet = applets. find ( id );
161 162
162 if ( applet ) 163 if ( applet )
163 applet-> iface-> activated ( ); 164 applet-> iface-> activated ( );
164 } 165 }
165} 166}
166 167
167bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu ) 168bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu )
168{ 169{
169 bool result = FALSE; 170 bool result = FALSE;
170 171
171 Config cfg("StartMenu"); 172 Config cfg("StartMenu");
172 cfg.setGroup("Menu"); 173 cfg.setGroup("Menu");
173 174
174 bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); 175 bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE);
175 bool lot = cfg.readBoolEntry("LauncherOther",TRUE); 176 bool lot = cfg.readBoolEntry("LauncherOther",TRUE);
176 177
177 tabdict. clear ( ); 178 tabdict. clear ( );
178 179
179 if ( sepId ) 180 if ( sepId )
180 menu-> removeItem ( sepId ); 181 menu-> removeItem ( sepId );
181 sepId = ( menu-> count ( )) ? menu-> insertSeparator ( 0 ) : 0; 182 sepId = ( menu-> count ( )) ? menu-> insertSeparator ( 0 ) : 0;
182 183
183 if ( ltabs || lot ) { 184 if ( ltabs || lot ) {
184 QDict<QPopupMenu> typpop; 185 QDict<QPopupMenu> typpop;
185 QStringList typs = folder->types(); 186 QStringList typs = folder->types();
186 for (QStringList::Iterator tit=typs.fromLast(); ; --tit) { 187 for (QStringList::Iterator tit=typs.fromLast(); ; --tit) {
187 if ( !(*tit).isEmpty() ) { 188 if ( !(*tit).isEmpty() ) {
188 QPopupMenu *new_menu; 189 QPopupMenu *new_menu;
189 if ( ltabs ) { 190 if ( ltabs ) {
190 new_menu = new StartPopupMenu( menu ); 191 new_menu = new StartPopupMenu( menu );
191 connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); 192 connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) );
192 int id = menu->insertItem( folder->typePixmap(*tit), folder->typeName(*tit), new_menu, -1, 0 ); 193 int id = menu->insertItem( folder->typePixmap(*tit), folder->typeName(*tit), new_menu, -1, 0 );
193 tabdict. insert ( id, new_menu ); 194 tabdict. insert ( id, new_menu );
194 } else { 195 } else {
195 new_menu = (QPopupMenu*)1; 196 new_menu = (QPopupMenu*)1;
196 } 197 }
197 typpop.insert(*tit, new_menu); 198 typpop.insert(*tit, new_menu);
198 } 199 }
199 if ( tit == typs. begin ( )) 200 if ( tit == typs. begin ( ))
200 break; 201 break;
201 } 202 }
202 QListIterator<AppLnk> it( folder->children() ); 203 QListIterator<AppLnk> it( folder->children() );
203 bool f=TRUE; 204 bool f=TRUE;
204 for ( ; it.current(); ++it ) { 205 for ( ; it.current(); ++it ) {
205 AppLnk *app = it.current(); 206 AppLnk *app = it.current();
206 if ( app->type() == "Separator" ) { // No tr 207 if ( app->type() == "Separator" ) { // No tr
207 if ( lot ) { 208 if ( lot ) {
208 menu->insertSeparator(); 209 menu->insertSeparator();
209 } 210 }
210 } else { 211 } else {
211 f = FALSE; 212 f = FALSE;
212 QString t = app->type(); 213 QString t = app->type();
213 QPopupMenu* pmenu = typpop.find(t); 214 QPopupMenu* pmenu = typpop.find(t);
214 if ( ltabs ) { 215 if ( ltabs ) {
215 if ( !pmenu && lot ) 216 if ( !pmenu && lot )
216 pmenu = menu; 217 pmenu = menu;
217 } else { 218 } else {
218 if ( !pmenu ) 219 if ( !pmenu )
219 pmenu = menu; 220 pmenu = menu;
220 else 221 else
221 pmenu = 0; 222 pmenu = 0;
222 } 223 }
223 if ( pmenu ) { 224 if ( pmenu ) {
224 QString t = app->name(); 225 QString t = app->name();
225 t.replace(QRegExp("&"),"&&"); // escape shortcut character 226 t.replace(QRegExp("&"),"&&"); // escape shortcut character
226 227
227 int index = -1; 228 int index = -1;
228 229
229 for ( index = 0; index < pmenu-> count ( ); index++ ) { 230 for ( index = 0; index < pmenu-> count ( ); index++ ) {
230 if ( pmenu-> text ( pmenu-> idAt ( index )). compare ( t ) > 0 ) 231 if ( pmenu-> text ( pmenu-> idAt ( index )). compare ( t ) > 0 )
231 break; 232 break;
232 } 233 }
233 234
234 pmenu->insertItem( app->pixmap(), t, app->id(), index ); 235 pmenu->insertItem( app->pixmap(), t, app->id(), index );
235 } 236 }
236 result=TRUE; 237 result=TRUE;
237 } 238 }
238 } 239 }
239 } 240 }
240 241
241 if ( sepId && ( menu-> idAt ( 0 ) == sepId )) { // no tabs entries 242 if ( sepId && ( menu-> idAt ( 0 ) == sepId )) { // no tabs entries
242 menu-> removeItem ( sepId ); 243 menu-> removeItem ( sepId );
243 sepId = 0; 244 sepId = 0;
244 } 245 }
245 if ( !menu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later 246 if ( !menu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later
246 sepId = menu-> insertSeparator ( ); 247 sepId = menu-> insertSeparator ( );
247 248
248 return result; 249 return result;
249} 250}
250 251
251 252
252void StartMenu::launch ( ) 253void StartMenu::launch ( )
253{ 254{
254 int y = mapToGlobal ( QPoint ( )). y ( ) - launchMenu-> sizeHint ( ). height ( ); 255 int y = mapToGlobal ( QPoint ( )). y ( ) - launchMenu-> sizeHint ( ). height ( );
255 256
256 if ( launchMenu-> isVisible ( )) { 257 if ( launchMenu-> isVisible ( )) {
257 launchMenu-> hide ( ); 258 launchMenu-> hide ( );
258 } 259 }
259 else { 260 else {
260 QWidget *active = qApp-> activeWindow ( ); 261 QWidget *active = qApp-> activeWindow ( );
261 if ( active && active-> isPopup ( )) 262 if ( active && active-> isPopup ( ))
262 active-> close ( ); 263 active-> close ( );
263 264
264 launchMenu-> popup ( QPoint ( 1, y )); 265 launchMenu-> popup ( QPoint ( 1, y ));
265 } 266 }
266} 267}
267 268
268const AppLnk* StartMenu::execToLink(const QString& appname) 269const AppLnk* StartMenu::execToLink(const QString& appname)
269{ 270{
270 const AppLnk* a = apps->findExec( appname ); 271 const AppLnk* a = apps->findExec( appname );
271 return a; 272 return a;
272} 273}
273 274
274void StartPopupMenu::keyPressEvent( QKeyEvent *e ) 275void StartPopupMenu::keyPressEvent( QKeyEvent *e )
275{ 276{
276 if ( e->key() == Key_F33 || e->key() == Key_Space ) { 277 if ( e->key() == Key_F33 || e->key() == Key_Space ) {
277 // "OK" button, little hacky 278 // "OK" button, little hacky
278 QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); 279 QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0);
279 QPopupMenu::keyPressEvent( &ke ); 280 QPopupMenu::keyPressEvent( &ke );
280 } else { 281 } else {
281 QPopupMenu::keyPressEvent( e ); 282 QPopupMenu::keyPressEvent( e );
282 } 283 }
283} 284}
284 285
285static int compareAppletPositions(const void *a, const void *b) 286static int compareAppletPositions(const void *a, const void *b)
286{ 287{
287 const MenuApplet* aa = *(const MenuApplet**)a; 288 const MenuApplet* aa = *(const MenuApplet**)a;
288 const MenuApplet* ab = *(const MenuApplet**)b; 289 const MenuApplet* ab = *(const MenuApplet**)b;
289 int d = aa->iface->position() - ab->iface->position(); 290 int d = aa->iface->position() - ab->iface->position();
290 if ( d ) return d; 291 if ( d ) return d;
291 return QString::compare(aa->library->library(),ab->library->library()); 292 return QString::compare(aa->library->library(),ab->library->library());
292} 293}
293 294
294void StartMenu::clearApplets() 295void StartMenu::clearApplets()
295{ 296{
296 launchMenu-> hide(); 297 launchMenu-> hide();
297 298
298 for ( QIntDictIterator<MenuApplet> it ( applets ); it. current ( ); ++it ) { 299 for ( QIntDictIterator<MenuApplet> it ( applets ); it. current ( ); ++it ) {
299 MenuApplet *applet = it. current ( ); 300 MenuApplet *applet = it. current ( );
300 if ( launchMenu ) { 301 if ( launchMenu ) {
301 launchMenu-> removeItem ( applet-> id ); 302 launchMenu-> removeItem ( applet-> id );
302 delete applet-> popup; 303 delete applet-> popup;
303 } 304 }
304 305
305 applet-> iface-> release(); 306 applet-> iface-> release();
306 applet-> library-> unload(); 307 applet-> library-> unload();
307 delete applet-> library; 308 delete applet-> library;
308 } 309 }
309 applets.clear(); 310 applets.clear();
310} 311}
311 312
312 313
313 314
314void StartMenu::loadApplets() 315void StartMenu::loadApplets()
315{ 316{
316 Config cfg( "StartMenu" ); 317 Config cfg( "StartMenu" );
317 cfg.setGroup( "Applets" ); 318 cfg.setGroup( "Applets" );
318 319
319 // SafeMode causes too much problems, so we disable it for now -- 320 // SafeMode causes too much problems, so we disable it for now --
320 // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 321 // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02
321 322
322 bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE); 323 bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE);
323 if ( safe && !safety_tid ) 324 if ( safe && !safety_tid )
324 return; 325 return;
325 cfg.writeEntry("SafeMode",TRUE); 326 cfg.writeEntry("SafeMode",TRUE);
326 cfg.write(); 327 cfg.write();
327 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); 328 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' );
328 329
329 QString lang = getenv( "LANG" ); 330 QString lang = getenv( "LANG" );
330 QString path = QPEApplication::qpeDir() + "/plugins/applets"; 331 QString path = QPEApplication::qpeDir() + "/plugins/applets";
331 QDir dir( path, "lib*.so" ); 332 QDir dir( path, "lib*.so" );
332 QStringList list = dir.entryList(); 333 QStringList list = dir.entryList();
333 QStringList::Iterator it; 334 QStringList::Iterator it;
334 int napplets=0; 335 int napplets=0;
335 MenuApplet* *xapplets = new MenuApplet*[list.count()]; 336 MenuApplet* *xapplets = new MenuApplet*[list.count()];
336 for ( it = list.begin(); it != list.end(); ++it ) { 337 for ( it = list.begin(); it != list.end(); ++it ) {
337 if ( exclude.find( *it ) != exclude.end() ) 338 if ( exclude.find( *it ) != exclude.end() )
338 continue; 339 continue;
339 MenuAppletInterface *iface = 0; 340 MenuAppletInterface *iface = 0;
340 QLibrary *lib = new QLibrary( path + "/" + *it ); 341 QLibrary *lib = new QLibrary( path + "/" + *it );
341 if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { 342 if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) {
342 MenuApplet *applet = new MenuApplet; 343 MenuApplet *applet = new MenuApplet;
343 xapplets[napplets++] = applet; 344 xapplets[napplets++] = applet;
344 applet->library = lib; 345 applet->library = lib;
345 applet->iface = iface; 346 applet->iface = iface;
346 347
347 QTranslator *trans = new QTranslator(qApp); 348 QTranslator *trans = new QTranslator(qApp);
348 QString type = (*it).left( (*it).find(".") ); 349 QString type = (*it).left( (*it).find(".") );
349 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; 350 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
350 if ( trans->load( tfn )) 351 if ( trans->load( tfn ))
351 qApp->installTranslator( trans ); 352 qApp->installTranslator( trans );
352 else 353 else
353 delete trans; 354 delete trans;
354 } else { 355 } else {
355 exclude += *it; 356 exclude += *it;
356 delete lib; 357 delete lib;
357 } 358 }
358 } 359 }
359 cfg.writeEntry( "ExcludeApplets", exclude, ',' ); 360 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
360 qsort(xapplets,napplets,sizeof(applets[0]),compareAppletPositions); 361 qsort(xapplets,napplets,sizeof(applets[0]),compareAppletPositions);
361 362
362 if ( sepId ) 363 if ( sepId )
363 launchMenu-> removeItem ( sepId ); 364 launchMenu-> removeItem ( sepId );
364 sepId = ( launchMenu-> count ( )) ? launchMenu-> insertSeparator ( ) : 0; 365 sepId = ( launchMenu-> count ( )) ? launchMenu-> insertSeparator ( ) : 0;
365 366
366 while (napplets--) { 367 while (napplets--) {
367 MenuApplet *applet = xapplets[napplets]; 368 MenuApplet *applet = xapplets[napplets];
368 369
369 applet-> popup = applet-> iface-> popup ( this ); 370 applet-> popup = applet-> iface-> popup ( this );
370 371
371 if ( applet-> popup ) 372 if ( applet-> popup )
372 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup ); 373 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup );
373 else 374 else
374 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) ); 375 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) );
375 applets.insert ( applet-> id, new MenuApplet(*applet)); 376 applets.insert ( applet-> id, new MenuApplet(*applet));
376 } 377 }
377 delete [] xapplets; 378 delete [] xapplets;
378 379
379 if ( sepId && ( launchMenu-> idAt ( launchMenu-> count ( ) - 1 ) == sepId )) { // no applets 380 if ( sepId && ( launchMenu-> idAt ( launchMenu-> count ( ) - 1 ) == sepId )) { // no applets
380 launchMenu-> removeItem ( sepId ); 381 launchMenu-> removeItem ( sepId );
381 sepId = 0; 382 sepId = 0;
382 } 383 }
383 if ( !launchMenu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later 384 if ( !launchMenu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later
384 sepId = launchMenu-> insertSeparator ( ); 385 sepId = launchMenu-> insertSeparator ( );
385 386
386 if ( !safety_tid ) 387 if ( !safety_tid )
387 safety_tid = startTimer(2000); // TT has 5000, but this is a PITA for a developer ;) (sandman) 388 safety_tid = startTimer(2000); // TT has 5000, but this is a PITA for a developer ;) (sandman)
388} 389}
389 390
390void StartMenu::timerEvent(QTimerEvent* e) 391void StartMenu::timerEvent(QTimerEvent* e)
391{ 392{
392 if ( e->timerId() == safety_tid ) { 393 if ( e->timerId() == safety_tid ) {
393 Config cfg( "StartMenu" ); 394 Config cfg( "StartMenu" );
394 cfg.setGroup( "Applets" ); 395 cfg.setGroup( "Applets" );
395 cfg.writeEntry( "SafeMode", FALSE ); 396 cfg.writeEntry( "SafeMode", FALSE );
396 killTimer(safety_tid); 397 killTimer(safety_tid);
397 safety_tid = 0; 398 safety_tid = 0;
398 } 399 }
399} 400}
400 401