summaryrefslogtreecommitdiff
authorerik <erik>2007-07-09 21:58:46 (UTC)
committer erik <erik>2007-07-09 21:58:46 (UTC)
commit1ec355e1cc016edd2e322ff7d57469feaa46474b (patch) (unidiff)
tree1d3010a288c034db8ada2e5228339ce24637352e
parent485270bfabbd956946a6116af012f93e011fa718 (diff)
downloadopie-1ec355e1cc016edd2e322ff7d57469feaa46474b.zip
opie-1ec355e1cc016edd2e322ff7d57469feaa46474b.tar.gz
opie-1ec355e1cc016edd2e322ff7d57469feaa46474b.tar.bz2
Recover unused pixels for launcher tabs by orienting things at the
zero point and not at 1.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/startmenu.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp
index 24a9d7e..d03af89 100644
--- a/core/launcher/startmenu.cpp
+++ b/core/launcher/startmenu.cpp
@@ -1,396 +1,396 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3 =. (C) 2000-2002 Trolltech AS 3 =. (C) 2000-2002 Trolltech AS
4 .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org> 4 .=l. (C) 2002-2005 The Opie Team <opie-devel@handhelds.org>
5           .>+-= 5           .>+-=
6 _;:,     .>    :=|. This program is free software; you can 6 _;:,     .>    :=|. This program is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under 7.> <`_,   >  .   <= redistribute it and/or modify it under
8 :`=1 )Y*s>-.--   : the terms of the GNU Library General Public 8 :`=1 )Y*s>-.--   : the terms of the GNU Library General Public
9.="- .-=="i,     .._ License as published by the Free Software 9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; version 2 of the License. 10 - .   .-<_>     .<> Foundation; version 2 of the License.
11     ._= =}       : 11     ._= =}       :
12    .%`+i>       _;_. 12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This program is distributed in the hope that 13    .i_,=:_.      -<s. This program is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15 : ..    .:,     . . . without even the implied warranty of 15 : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
18..}^=.=       =       ; Library General Public License for more 18..}^=.=       =       ; Library General Public License for more
19++=   -.     .`     .: details. 19++=   -.     .`     .: details.
20 :     =  ...= . :.=- 20 :     =  ...= . :.=-
21 -.   .:....=;==+<; You should have received a copy of the GNU 21 -.   .:....=;==+<; You should have received a copy of the GNU
22  -_. . .   )=.  = Library General Public License along with 22  -_. . .   )=.  = Library General Public License along with
23    --        :-=` this library; see the file COPYING.LIB. 23    --        :-=` this library; see the file COPYING.LIB.
24 If not, write to the Free Software Foundation, 24 If not, write to the Free Software Foundation,
25 Inc., 59 Temple Place - Suite 330, 25 Inc., 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27*/ 27*/
28// TODO. During startup 28// TODO. During startup
29// Launcher::typeAdded 29// Launcher::typeAdded
30// is called for each new tab and calls then each time the refresh of startmenu 30// is called for each new tab and calls then each time the refresh of startmenu
31// suboptimal 31// suboptimal
32 32
33#define INCLUDE_MENUITEM_DEF 33#define INCLUDE_MENUITEM_DEF
34 34
35#include "startmenu.h" 35#include "startmenu.h"
36 36
37/* OPIE */ 37/* OPIE */
38#include <opie2/oresource.h> 38#include <opie2/oresource.h>
39using namespace Opie::Core; 39using namespace Opie::Core;
40#include <qtopia/qpeapplication.h> 40#include <qtopia/qpeapplication.h>
41#include <qtopia/config.h> 41#include <qtopia/config.h>
42#include <qtopia/mimetype.h> 42#include <qtopia/mimetype.h>
43#include <qtopia/qlibrary.h> 43#include <qtopia/qlibrary.h>
44 44
45#define APPLNK_ID_OFFSET 250 45#define APPLNK_ID_OFFSET 250
46#define NO_ID -1 46#define NO_ID -1
47 47
48 48
49void StartPopupMenu::keyPressEvent( QKeyEvent *e ) 49void StartPopupMenu::keyPressEvent( QKeyEvent *e )
50{ 50{
51 if ( e->key() == Key_F33 || e->key() == Key_Space ) { 51 if ( e->key() == Key_F33 || e->key() == Key_Space ) {
52 // "OK" button, little hacky 52 // "OK" button, little hacky
53 QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); 53 QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0);
54 QPopupMenu::keyPressEvent( &ke ); 54 QPopupMenu::keyPressEvent( &ke );
55 } else { 55 } else {
56 QPopupMenu::keyPressEvent( e ); 56 QPopupMenu::keyPressEvent( e );
57 } 57 }
58} 58}
59 59
60//--------------------------------------------------------------------------- 60//---------------------------------------------------------------------------
61 61
62StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) 62StartMenu::StartMenu(QWidget *parent) : QLabel( parent )
63{ 63{
64 startButtonPixmap = "go"; // No tr 64 startButtonPixmap = "go"; // No tr
65 65
66 int sz = AppLnk::smallIconSize()+3; 66 int sz = AppLnk::smallIconSize()+3;
67 QPixmap pm; 67 QPixmap pm;
68 pm.convertFromImage(OResource::loadImage( startButtonPixmap, OResource::NoScale ).smoothScale( sz,sz) ); 68 pm.convertFromImage(OResource::loadImage( startButtonPixmap, OResource::NoScale ).smoothScale( sz,sz) );
69 setPixmap(pm); 69 setPixmap(pm);
70 setFocusPolicy( NoFocus ); 70 setFocusPolicy( NoFocus );
71 71
72 useWidePopupMenu = true; 72 useWidePopupMenu = true;
73 launchMenu = 0; 73 launchMenu = 0;
74 currentItem = 0; 74 currentItem = 0;
75 refreshMenu(); 75 refreshMenu();
76} 76}
77 77
78 78
79void StartMenu::mousePressEvent( QMouseEvent * ) 79void StartMenu::mousePressEvent( QMouseEvent * )
80{ 80{
81 launch(); 81 launch();
82} 82}
83 83
84 84
85StartMenu::~StartMenu() 85StartMenu::~StartMenu()
86{ 86{
87 clearApplets(); 87 clearApplets();
88} 88}
89 89
90void StartMenu::createMenu() 90void StartMenu::createMenu()
91{ 91{
92 clearApplets(); 92 clearApplets();
93 delete launchMenu; 93 delete launchMenu;
94 94
95 launchMenu = new StartPopupMenu( this ); 95 launchMenu = new StartPopupMenu( this );
96 loadMenu( launchMenu ); 96 loadMenu( launchMenu );
97 loadApplets(); 97 loadApplets();
98 98
99 bool result = currentItem || menuApplets.count(); 99 bool result = currentItem || menuApplets.count();
100 if ( result ) 100 if ( result )
101 connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); 101 connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) );
102} 102}
103 103
104void StartMenu::refreshMenu() 104void StartMenu::refreshMenu()
105{ 105{
106 Config cfg( "StartMenu" ); 106 Config cfg( "StartMenu" );
107 cfg.setGroup( "Menu" ); 107 cfg.setGroup( "Menu" );
108 bool ltabs = cfg.readBoolEntry( "LauncherTabs", TRUE ); 108 bool ltabs = cfg.readBoolEntry( "LauncherTabs", TRUE );
109 bool lot = cfg.readBoolEntry( "LauncherOther", TRUE ); 109 bool lot = cfg.readBoolEntry( "LauncherOther", TRUE );
110 useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE ); 110 useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE );
111 111
112 if ( launchMenu && !(ltabs || lot) ) return; // nothing to do 112 if ( launchMenu && !(ltabs || lot) ) return; // nothing to do
113 113
114 createMenu(); 114 createMenu();
115} 115}
116 116
117void StartMenu::itemSelected( int id ) 117void StartMenu::itemSelected( int id )
118{ 118{
119 if ( id == NO_ID ) return; 119 if ( id == NO_ID ) return;
120 120
121 if ( id < 0 ) { 121 if ( id < 0 ) {
122 MenuApplet *applet = menuApplets.find( id ); 122 MenuApplet *applet = menuApplets.find( id );
123 if ( applet ) { 123 if ( applet ) {
124 applet->iface->activated(); 124 applet->iface->activated();
125 } 125 }
126 } else if ( id >= APPLNK_ID_OFFSET ) { 126 } else if ( id >= APPLNK_ID_OFFSET ) {
127 AppLnk * appLnk = appLnks.find( id ); 127 AppLnk * appLnk = appLnks.find( id );
128 if ( appLnk ) { 128 if ( appLnk ) {
129 appLnk->execute(); 129 appLnk->execute();
130 } 130 }
131 } else { 131 } else {
132 QString *tabName = tabNames.find( id ); 132 QString *tabName = tabNames.find( id );
133 if ( tabName ) { 133 if ( tabName ) {
134 emit tabSelected( *tabName ); 134 emit tabSelected( *tabName );
135 } 135 }
136 } 136 }
137} 137}
138 138
139void StartMenu::createAppEntry( QPopupMenu *menu, QDir dir, QString file ) 139void StartMenu::createAppEntry( QPopupMenu *menu, QDir dir, QString file )
140{ 140{
141 if ( file.right(8) == ".desktop" ) { 141 if ( file.right(8) == ".desktop" ) {
142 AppLnk* applnk = new AppLnk( dir.path() + "/" + file ); 142 AppLnk* applnk = new AppLnk( dir.path() + "/" + file );
143 if ( !applnk->isValid() ) { 143 if ( !applnk->isValid() ) {
144 delete applnk; 144 delete applnk;
145 return; 145 return;
146 } 146 }
147 147
148 if ( applnk->type() == "Separator" ) { // No tr 148 if ( applnk->type() == "Separator" ) { // No tr
149 menu->insertSeparator(); 149 menu->insertSeparator();
150 delete applnk; 150 delete applnk;
151 } else { 151 } else {
152 QPixmap pixmap = OResource::loadPixmap( applnk->icon(), OResource::SmallIcon ); 152 QPixmap pixmap = OResource::loadPixmap( applnk->icon(), OResource::SmallIcon );
153 // Insert items ordered lexically 153 // Insert items ordered lexically
154 int current, left = 0, right = currentItem; 154 int current, left = 0, right = currentItem;
155 while( left != right ) { 155 while( left != right ) {
156 current = ( left + right ) / 2; 156 current = ( left + right ) / 2;
157 if ( menu->text(menu->idAt( ( current ) ) ) < applnk->name() ) 157 if ( menu->text(menu->idAt( ( current ) ) ) < applnk->name() )
158 left = ++current; 158 left = ++current;
159 else 159 else
160 right = current; 160 right = current;
161 } 161 }
162 162
163 menu->insertItem( pixmap, applnk->name(), 163 menu->insertItem( pixmap, applnk->name(),
164 currentItem + APPLNK_ID_OFFSET, current ); 164 currentItem + APPLNK_ID_OFFSET, current );
165 appLnks.insert( currentItem + APPLNK_ID_OFFSET, applnk ); 165 appLnks.insert( currentItem + APPLNK_ID_OFFSET, applnk );
166 currentItem++; 166 currentItem++;
167 } 167 }
168 } 168 }
169 169
170} 170}
171 171
172void StartMenu::createDirEntry( QPopupMenu *menu, QDir dir, QString file, bool lot ) 172void StartMenu::createDirEntry( QPopupMenu *menu, QDir dir, QString file, bool lot )
173{ 173{
174 // do some sanity checks and collect information 174 // do some sanity checks and collect information
175 175
176 if ( file == "." || file == ".." ) return; 176 if ( file == "." || file == ".." ) return;
177 177
178 Config cfg( dir.path() + "/" + file + "/.directory", Config::File ); 178 Config cfg( dir.path() + "/" + file + "/.directory", Config::File );
179 if ( !cfg.isValid() ) return; 179 if ( !cfg.isValid() ) return;
180 180
181 QString name = cfg.readEntry( "Name" ); 181 QString name = cfg.readEntry( "Name" );
182 QString icon = cfg.readEntry( "Icon" ); 182 QString icon = cfg.readEntry( "Icon" );
183 if ( !name || !icon ) return; 183 if ( !name || !icon ) return;
184 184
185 QDir subdir = QDir( dir ); 185 QDir subdir = QDir( dir );
186 subdir.cd( file ); 186 subdir.cd( file );
187 subdir.setFilter( QDir::Files ); 187 subdir.setFilter( QDir::Files );
188 subdir.setNameFilter( "*.desktop" ); 188 subdir.setNameFilter( "*.desktop" );
189 // we don' t show the menu if there are no entries 189 // we don' t show the menu if there are no entries
190 // perhaps one should check if there exist subsubdirs with entries... 190 // perhaps one should check if there exist subsubdirs with entries...
191 if ( subdir.entryList().isEmpty() ) return; 191 if ( subdir.entryList().isEmpty() ) return;
192 192
193 // checks were ok 193 // checks were ok
194 194
195 QPixmap pixmap = OResource::loadPixmap( icon, OResource::SmallIcon ); 195 QPixmap pixmap = OResource::loadPixmap( icon, OResource::SmallIcon );
196 if ( useWidePopupMenu ) { 196 if ( useWidePopupMenu ) {
197 // generate submenu 197 // generate submenu
198 QPopupMenu *submenu = new QPopupMenu( menu ); 198 QPopupMenu *submenu = new QPopupMenu( menu );
199 connect( submenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); 199 connect( submenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) );
200 menu->insertItem( pixmap, name, submenu, NO_ID ); 200 menu->insertItem( pixmap, name, submenu, NO_ID );
201 201
202 // ltabs is true cause else we wouldn't stuck around.. 202 // ltabs is true cause else we wouldn't stuck around..
203 createMenuEntries( submenu, subdir, true, lot ); 203 createMenuEntries( submenu, subdir, true, lot );
204 } else { 204 } else {
205 // no submenus - just bring corresponding tab to front 205 // no submenus - just bring corresponding tab to front
206 menu->insertItem( pixmap, name, currentItem ); 206 menu->insertItem( pixmap, name, currentItem );
207 tabNames.insert( currentItem, new QString( file ) ); 207 tabNames.insert( currentItem, new QString( file ) );
208 currentItem++; 208 currentItem++;
209 } 209 }
210} 210}
211 211
212void StartMenu::createMenuEntries( QPopupMenu *menu, QDir dir, bool ltabs, bool lot ) 212void StartMenu::createMenuEntries( QPopupMenu *menu, QDir dir, bool ltabs, bool lot )
213{ 213{
214 if ( lot ) { 214 if ( lot ) {
215 dir.setFilter( QDir::Files ); 215 dir.setFilter( QDir::Files );
216 dir.setNameFilter( "*.desktop" ); 216 dir.setNameFilter( "*.desktop" );
217 QStringList files = dir.entryList(); 217 QStringList files = dir.entryList();
218 files.sort(); 218 files.sort();
219 219
220 for ( QStringList::Iterator it = files.begin(); it != files.end(); it++ ) { 220 for ( QStringList::Iterator it = files.begin(); it != files.end(); it++ ) {
221 createAppEntry( menu, dir, *it ); 221 createAppEntry( menu, dir, *it );
222 } 222 }
223 } 223 }
224 if ( ltabs ) { 224 if ( ltabs ) {
225 dir.setNameFilter( "*" ); 225 dir.setNameFilter( "*" );
226 dir.setFilter( QDir::Dirs ); 226 dir.setFilter( QDir::Dirs );
227 QStringList dirs = dir.entryList(); 227 QStringList dirs = dir.entryList();
228 dirs.sort(); 228 dirs.sort();
229 229
230 for ( QStringList::Iterator it = dirs.begin(); it != dirs.end(); it++ ) { 230 for ( QStringList::Iterator it = dirs.begin(); it != dirs.end(); it++ ) {
231 createDirEntry( menu, dir, *it, lot ); 231 createDirEntry( menu, dir, *it, lot );
232 } 232 }
233 } 233 }
234} 234}
235 235
236bool StartMenu::loadMenu( QPopupMenu *menu ) 236bool StartMenu::loadMenu( QPopupMenu *menu )
237{ 237{
238 Config cfg("StartMenu"); 238 Config cfg("StartMenu");
239 cfg.setGroup("Menu"); 239 cfg.setGroup("Menu");
240 240
241 bool ltabs = cfg.readBoolEntry("LauncherTabs", TRUE); 241 bool ltabs = cfg.readBoolEntry("LauncherTabs", TRUE);
242 bool lot = cfg.readBoolEntry("LauncherOther", TRUE); 242 bool lot = cfg.readBoolEntry("LauncherOther", TRUE);
243 useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE ); 243 useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE );
244 bool sepfirst = !ltabs && !lot; 244 bool sepfirst = !ltabs && !lot;
245 245
246 currentItem = 0; 246 currentItem = 0;
247 launchMenu->clear(); 247 launchMenu->clear();
248 248
249 appLnks.setAutoDelete( true ); 249 appLnks.setAutoDelete( true );
250 tabNames.setAutoDelete( true ); 250 tabNames.setAutoDelete( true );
251 appLnks.clear(); 251 appLnks.clear();
252 tabNames.clear(); 252 tabNames.clear();
253 appLnks.setAutoDelete( false ); 253 appLnks.setAutoDelete( false );
254 tabNames.setAutoDelete( false ); 254 tabNames.setAutoDelete( false );
255 255
256 QDir dir( MimeType::appsFolderName(), QString::null, QDir::Name ); 256 QDir dir( MimeType::appsFolderName(), QString::null, QDir::Name );
257 createMenuEntries( menu, dir, ltabs, lot ); 257 createMenuEntries( menu, dir, ltabs, lot );
258 258
259 if ( !menu->count() ) sepfirst = TRUE; 259 if ( !menu->count() ) sepfirst = TRUE;
260 260
261 launchMenu->setName( sepfirst ? "accessories" : "accessories_need_sep" ); // No tr 261 launchMenu->setName( sepfirst ? "accessories" : "accessories_need_sep" ); // No tr
262 262
263 return currentItem; 263 return currentItem;
264} 264}
265 265
266 266
267void StartMenu::launch() 267void StartMenu::launch()
268{ 268{
269 int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); 269 int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height();
270 270
271 if ( launchMenu->isVisible() ) 271 if ( launchMenu->isVisible() )
272 launchMenu->hide(); 272 launchMenu->hide();
273 else 273 else
274 launchMenu->popup( QPoint( 1, y ) ); 274 launchMenu->popup( QPoint( 0, y ) );
275} 275}
276 276
277 277
278 278
279 279
280static int compareAppletPositions(const void *b, const void *a) 280static int compareAppletPositions(const void *b, const void *a)
281{ 281{
282 const MenuApplet* aa = *(const MenuApplet**)a; 282 const MenuApplet* aa = *(const MenuApplet**)a;
283 const MenuApplet* ab = *(const MenuApplet**)b; 283 const MenuApplet* ab = *(const MenuApplet**)b;
284 int d = aa->iface->position() - ab->iface->position(); 284 int d = aa->iface->position() - ab->iface->position();
285 if ( d ) return d; 285 if ( d ) return d;
286 return QString::compare(aa->library->library(),ab->library->library()); 286 return QString::compare(aa->library->library(),ab->library->library());
287} 287}
288 288
289void StartMenu::clearApplets() 289void StartMenu::clearApplets()
290{ 290{
291 if ( launchMenu ) 291 if ( launchMenu )
292 launchMenu-> hide(); 292 launchMenu-> hide();
293 293
294 for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) { 294 for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) {
295 MenuApplet *applet = it.current(); 295 MenuApplet *applet = it.current();
296 if ( launchMenu ) { 296 if ( launchMenu ) {
297 launchMenu->removeItem( applet-> id ); 297 launchMenu->removeItem( applet-> id );
298 delete applet->popup; 298 delete applet->popup;
299 } 299 }
300 300
301 applet->iface->release(); 301 applet->iface->release();
302 applet->library->unload(); 302 applet->library->unload();
303 delete applet-> library; 303 delete applet-> library;
304 } 304 }
305 menuApplets.clear(); 305 menuApplets.clear();
306} 306}
307 307
308 308
309 309
310 310
311void StartMenu::loadApplets() 311void StartMenu::loadApplets()
312{ 312{
313 Config cfg( "StartMenu" ); 313 Config cfg( "StartMenu" );
314 cfg.setGroup( "Applets" ); 314 cfg.setGroup( "Applets" );
315 315
316 // SafeMode causes too much problems, so we disable it for now -- 316 // SafeMode causes too much problems, so we disable it for now --
317 // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 317 // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02
318 // removed in the remerge PluginManager could handle it 318 // removed in the remerge PluginManager could handle it
319 // we don't currently use it -zecke 319 // we don't currently use it -zecke
320 320
321 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); 321 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' );
322 322
323 QString lang = getenv( "LANG" ); 323 QString lang = getenv( "LANG" );
324 QString path = QPEApplication::qpeDir() + "plugins/applets"; 324 QString path = QPEApplication::qpeDir() + "plugins/applets";
325 QDir dir( path, "lib*.so" ); 325 QDir dir( path, "lib*.so" );
326 QStringList list = dir.entryList(); 326 QStringList list = dir.entryList();
327 QStringList::Iterator it; 327 QStringList::Iterator it;
328 int napplets = 0; 328 int napplets = 0;
329 MenuApplet* *xapplets = new MenuApplet*[list.count()]; 329 MenuApplet* *xapplets = new MenuApplet*[list.count()];
330 for ( it = list.begin(); it != list.end(); ++it ) { 330 for ( it = list.begin(); it != list.end(); ++it ) {
331 if ( exclude.find( *it ) != exclude.end() ) 331 if ( exclude.find( *it ) != exclude.end() )
332 continue; 332 continue;
333 MenuAppletInterface *iface = 0; 333 MenuAppletInterface *iface = 0;
334 QLibrary *lib = new QLibrary( path + "/" + *it ); 334 QLibrary *lib = new QLibrary( path + "/" + *it );
335 if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { 335 if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) {
336 MenuApplet *applet = new MenuApplet; 336 MenuApplet *applet = new MenuApplet;
337 xapplets[napplets++] = applet; 337 xapplets[napplets++] = applet;
338 applet->library = lib; 338 applet->library = lib;
339 applet->iface = iface; 339 applet->iface = iface;
340 340
341 QTranslator *trans = new QTranslator(qApp); 341 QTranslator *trans = new QTranslator(qApp);
342 QString type = (*it).left( (*it).find(".") ); 342 QString type = (*it).left( (*it).find(".") );
343 QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+type+".qm"; 343 QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+type+".qm";
344 if ( trans->load( tfn )) 344 if ( trans->load( tfn ))
345 qApp->installTranslator( trans ); 345 qApp->installTranslator( trans );
346 else 346 else
347 delete trans; 347 delete trans;
348 } else { 348 } else {
349 exclude += *it; 349 exclude += *it;
350 delete lib; 350 delete lib;
351 } 351 }
352 } 352 }
353 cfg.writeEntry( "ExcludeApplets", exclude, ',' ); 353 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
354 qsort(xapplets, napplets, sizeof(menuApplets[0]), compareAppletPositions); 354 qsort(xapplets, napplets, sizeof(menuApplets[0]), compareAppletPositions);
355 355
356 356
357 while ( napplets-- ) { 357 while ( napplets-- ) {
358 MenuApplet *applet = xapplets[napplets]; 358 MenuApplet *applet = xapplets[napplets];
359 applet->popup = applet->iface->popup( this ); 359 applet->popup = applet->iface->popup( this );
360 360
361 // menuApplets got an id < -1 361 // menuApplets got an id < -1
362 menuApplets.insert( -( currentItem + 2 ), new MenuApplet( *applet ) ); 362 menuApplets.insert( -( currentItem + 2 ), new MenuApplet( *applet ) );
363 currentItem++; 363 currentItem++;
364 } 364 }
365 delete [] xapplets; 365 delete [] xapplets;
366 366
367 addApplets( launchMenu ); 367 addApplets( launchMenu );
368} 368}
369 369
370 370
371/* 371/*
372 * Launcher calls loadMenu too often fix that 372 * Launcher calls loadMenu too often fix that
373 */ 373 */
374void StartMenu::addApplets(QPopupMenu* pop) { 374void StartMenu::addApplets(QPopupMenu* pop) {
375 QIntDict<MenuApplet> dict; 375 QIntDict<MenuApplet> dict;
376 if( pop-> count ( )) 376 if( pop-> count ( ))
377 pop-> insertSeparator ( ); 377 pop-> insertSeparator ( );
378 378
379 for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) { 379 for ( QIntDictIterator<MenuApplet> it( menuApplets ); it.current(); ++it ) {
380 MenuApplet *applet = it.current(); 380 MenuApplet *applet = it.current();
381 if ( applet->popup ) 381 if ( applet->popup )
382 applet->id = pop->insertItem( applet->iface->icon(), 382 applet->id = pop->insertItem( applet->iface->icon(),
383 applet->iface->text(), applet->popup ); 383 applet->iface->text(), applet->popup );
384 else 384 else
385 applet->id = pop->insertItem( applet->iface->icon(), 385 applet->id = pop->insertItem( applet->iface->icon(),
386 applet->iface->text() ); 386 applet->iface->text() );
387 387
388 388
389 dict.insert( applet->id, new MenuApplet( *applet ) ); 389 dict.insert( applet->id, new MenuApplet( *applet ) );
390 } 390 }
391 /* need to update the key */ 391 /* need to update the key */
392 menuApplets.setAutoDelete( true ); 392 menuApplets.setAutoDelete( true );
393 menuApplets.clear(); 393 menuApplets.clear();
394 menuApplets.setAutoDelete( false ); 394 menuApplets.setAutoDelete( false );
395 menuApplets = dict; 395 menuApplets = dict;
396} 396}