summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/startmenu.cpp374
-rw-r--r--core/launcher/startmenu.h46
2 files changed, 172 insertions, 248 deletions
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp
index d75e8be..014418d 100644
--- a/core/launcher/startmenu.cpp
+++ b/core/launcher/startmenu.cpp
@@ -1,401 +1,333 @@
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
25//#include "mrulist.h" 25#include <qtopia/qpeapplication.h>
26#include "info.h" 26#include <qtopia/config.h>
27 27#include <qtopia/applnk.h>
28#include <qpe/qpeapplication.h> 28#include <qtopia/global.h>
29#include <qpe/config.h> 29#include <qtopia/resource.h>
30#include <qpe/applnk.h> 30#include <qtopia/mimetype.h>
31#include <qpe/global.h> 31#include <qtopia/qlibrary.h>
32#include <qpe/resource.h> 32
33#include <qpe/qlibrary.h> 33#include <qdict.h>
34
35#include <qintdict.h>
36#include <qdir.h> 34#include <qdir.h>
35#include <qpainter.h>
37 36
38#include <stdlib.h> 37#include <stdlib.h>
39 38
40 39
41// #define USE_CONFIG_FILE 40void StartPopupMenu::keyPressEvent( QKeyEvent *e )
41{
42 if ( e->key() == Key_F33 || e->key() == Key_Space ) {
43 // "OK" button, little hacky
44 QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0);
45 QPopupMenu::keyPressEvent( &ke );
46 } else {
47 QPopupMenu::keyPressEvent( e );
48 }
49}
42 50
51//---------------------------------------------------------------------------
43 52
44StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) 53StartMenu::StartMenu(QWidget *parent) : QLabel( parent )
45{ 54{
46 loadOptions(); 55 startButtonPixmap = "go"; // No tr
47 safety_tid = 1; // disable the timer... valgrind said it.. we don't use that option either -zecke
48 56
49 int sz = AppLnk::smallIconSize()+3; 57 int sz = AppLnk::smallIconSize()+3;
50 QPixmap pm; 58 QPixmap pm;
51 pm.convertFromImage(Resource::loadImage(startButtonPixmap).smoothScale(sz,sz)); 59 pm.convertFromImage(Resource::loadImage(startButtonPixmap).smoothScale(sz,sz));
52 setPixmap(pm); 60 setPixmap(pm);
53 setFocusPolicy( NoFocus ); 61 setFocusPolicy( NoFocus );
54 //setFlat( startButtonIsFlat );
55 62
56 apps = 0;
57 launchMenu = 0; 63 launchMenu = 0;
58 applets. setAutoDelete ( true ); 64 refreshMenu();
59 sepId = 0;
60
61 reloadApps ( );
62 reloadApplets ( );
63} 65}
64 66
65 67
66void StartMenu::mousePressEvent( QMouseEvent * ) 68void StartMenu::mousePressEvent( QMouseEvent * )
67{ 69{
68 launch(); 70 launch();
69 if (desktopInfo)
70 desktopInfo->menuClicked();
71} 71}
72 72
73 73
74StartMenu::~StartMenu() 74StartMenu::~StartMenu()
75{ 75{
76 delete apps; 76 clearApplets();
77}
78
79
80void StartMenu::loadOptions()
81{
82#ifdef USE_CONFIG_FILE
83 // Read configuration file
84 Config config("StartMenu");
85 config.setGroup( "StartMenu" );
86 QString tmpBoolString1 = config.readEntry( "UseWidePopupMenu", "FALSE" );
87 useWidePopupMenu = ( tmpBoolString1 == "TRUE" ) ? TRUE : FALSE;
88 QString tmpBoolString2 = config.readEntry( "StartButtonIsFlat", "TRUE" );
89 startButtonIsFlat = ( tmpBoolString2 == "TRUE" ) ? TRUE : FALSE;
90 QString tmpBoolString3 = config.readEntry( "UseMRUList", "TRUE" );
91 popupMenuSidePixmap = config.readEntry( "PopupMenuSidePixmap", "launcher/sidebar" );
92 startButtonPixmap = config.readEntry( "StartButtonPixmap", "go" );
93#else
94 // Basically just #include the .qpe_menu.conf file settings
95 useWidePopupMenu = FALSE;
96 popupMenuSidePixmap = "launcher/sidebar";
97 startButtonIsFlat = TRUE;
98 startButtonPixmap = "go"; // No tr
99#endif
100} 77}
101 78
102
103void StartMenu::createMenu() 79void StartMenu::createMenu()
104{ 80{
81 clearApplets();
105 delete launchMenu; 82 delete launchMenu;
106 if ( useWidePopupMenu )
107 launchMenu = new PopupWithLaunchSideThing( this, &popupMenuSidePixmap );
108 else
109 launchMenu = new StartPopupMenu( this );
110 83
111 loadMenu ( apps, launchMenu ); 84 launchMenu = new StartPopupMenu( this );
112 loadApplets ( ); 85 loadMenu( launchMenu );
86 loadApplets();
113 87
88 bool result = nother || ntabs || m_applets.count();
89 if ( result )
114 connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); 90 connect( launchMenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) );
91
115} 92}
116 93
117void StartMenu::reloadApps() 94void StartMenu::refreshMenu()
118{ 95{
119 Config cfg("StartMenu"); 96 Config cfg("Taskbar");
120 cfg.setGroup("Menu"); 97 cfg.setGroup("Menu");
121 bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); 98 bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE);
122 bool lot = cfg.readBoolEntry("LauncherOther",TRUE); 99 bool lot = cfg.readBoolEntry("LauncherOther",TRUE);
123 bool lt = ltabs || lot; 100 bool lt = ltabs || lot;
124 if ( launchMenu && apps && !lt ) 101 if ( launchMenu && !lt )
125 return; // nothing to do 102 return; // nothing to do
126 103
127 if ( lt ) {
128 delete apps;
129 apps = new AppLnkSet( QPEApplication::qpeDir() + "apps" );
130 }
131 if ( launchMenu ) { 104 if ( launchMenu ) {
132 launchMenu-> hide ( ); 105 int i;
133 106 /* find the first entry we want to remove */
134 for ( QIntDictIterator<QPopupMenu> it ( tabdict ); it. current ( ); ++it ) { 107 for (i=0; i<(int)launchMenu->count(); i++) {
135 launchMenu-> removeItem ( it. currentKey ( )); 108 QMenuItem* item = launchMenu->findItem(launchMenu->idAt(i));
136 delete it.current ( ); 109 if ( item && item->id() >= 0 && item->id() < ntabs ) {
137 } 110 break;
138 tabdict. clear ( ); 111 }
139 loadMenu(apps,launchMenu); 112 if ( item && item->isSeparator() ) {
113 i++;
114 break;
115 }
116 }
117 /* remove them */
118 while (i<(int)launchMenu->count())
119 launchMenu->removeItemAt(i);
120 loadMenu(launchMenu);
121 addApplets(launchMenu);
140 } else { 122 } else {
141 createMenu(); 123 createMenu();
142 } 124 }
143} 125}
144 126
145void StartMenu::reloadApplets()
146{
147 if ( launchMenu ) {
148 clearApplets ( );
149 loadApplets ( );
150 }
151 else
152 createMenu ( );
153}
154
155void StartMenu::itemSelected( int id ) 127void StartMenu::itemSelected( int id )
156{ 128{
157 const AppLnk *app = apps->find( id ); 129 if ( id >= 0 && id < ntabs ) {
158 if ( app ) 130 emit tabSelected(tabs[id]);
159 app->execute(); 131 } else if ( id >= 20 && id < 20+nother ) {
160 else { 132 other.at(id-20)->execute();
161 MenuApplet *applet = applets. find ( id ); 133 }else {
162 134 MenuApplet *applet = m_applets.find ( id );
163 if ( applet ) 135 if ( applet ) {
164 applet-> iface-> activated ( ); 136 qWarning("activated");
165 } 137 applet-> iface-> activated();
138 }
139 }
166} 140}
167 141
168bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu ) 142bool StartMenu::loadMenu( QPopupMenu *menu )
169{ 143{
170 bool result = FALSE; 144 Config cfg("Taskbar");
171
172 Config cfg("StartMenu");
173 cfg.setGroup("Menu"); 145 cfg.setGroup("Menu");
174 146
175 bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE); 147 bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE);
176 bool lot = cfg.readBoolEntry("LauncherOther",TRUE); 148 bool lot = cfg.readBoolEntry("LauncherOther",TRUE);
149 bool sepfirst = !ltabs && !lot;
177 150
178 tabdict. clear ( ); 151 tabs.clear();
179 152 other.setAutoDelete(TRUE);
180 if ( sepId ) 153 other.clear();
181 menu-> removeItem ( sepId ); 154 ntabs = 0;
182 sepId = ( menu-> count ( )) ? menu-> insertSeparator ( 0 ) : 0; 155 nother = 0;
183 156
157 bool f=TRUE;
184 if ( ltabs || lot ) { 158 if ( ltabs || lot ) {
185 QDict<QPopupMenu> typpop; 159 QDir dir( MimeType::appsFolderName(), QString::null, QDir::Name );
186 QStringList typs = folder->types(); 160 for (int i=0; i<(int)dir.count(); i++) {
187 for (QStringList::Iterator tit=typs.fromLast(); ; --tit) { 161 QString d = dir[i];
188 if ( !(*tit).isEmpty() ) { 162 Config cfg(dir.path()+"/"+d+"/.directory",Config::File);
189 QPopupMenu *new_menu; 163 if ( cfg.isValid() ) {
190 if ( ltabs ) { 164 QString nm = cfg.readEntry("Name");
191 new_menu = new StartPopupMenu( menu ); 165 QString ic = cfg.readEntry("Icon");
192 connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); 166 if ( !!nm && !!ic ) {
193 int id = menu->insertItem( folder->typePixmap(*tit), folder->typeName(*tit), new_menu, -1, 0 ); 167 tabs.append(d);
194 tabdict. insert ( id, new_menu ); 168 menu->insertItem( Resource::loadIconSet(ic), nm, ntabs++ );
195 } else { 169 }
196 new_menu = (QPopupMenu*)1; 170 } else if ( lot && d.right(8)==".desktop") {
197 } 171 AppLnk* applnk = new AppLnk(dir.path()+"/"+d);
198 typpop.insert(*tit, new_menu); 172 if ( applnk->isValid() ) {
199 } 173 if ( applnk->type() == "Separator" ) { // No tr
200 if ( tit == typs. begin ( )) 174 if ( lot ) {
201 break; 175 menu->insertSeparator();
202 } 176 sepfirst = f && !ltabs;
203 QListIterator<AppLnk> it( folder->children() ); 177 }
204 bool f=TRUE; 178 delete applnk;
205 for ( ; it.current(); ++it ) { 179 } else {
206 AppLnk *app = it.current(); 180 f = FALSE;
207 if ( app->type() == "Separator" ) { // No tr 181 other.append(applnk);
208 if ( lot ) { 182 menu->insertItem( Resource::loadIconSet(applnk->icon()),
209 menu->insertSeparator(); 183 applnk->name(), 20+nother++ );
210 } 184 }
211 } else { 185 } else {
212 f = FALSE; 186 delete applnk;
213 QString t = app->type(); 187 }
214 QPopupMenu* pmenu = typpop.find(t); 188 }
215 if ( ltabs ) { 189 }
216 if ( !pmenu && lot ) 190
217 pmenu = menu; 191 if ( !menu->count() )
218 } else { 192 sepfirst = TRUE;
219 if ( !pmenu )
220 pmenu = menu;
221 else
222 pmenu = 0;
223 }
224 if ( pmenu ) {
225 QString t = app->name();
226 t.replace(QRegExp("&"),"&&"); // escape shortcut character
227
228 int index = -1;
229
230 for ( index = 0; index < pmenu-> count ( ); index++ ) {
231 if ( pmenu-> text ( pmenu-> idAt ( index )). compare ( t ) > 0 )
232 break;
233 }
234
235 pmenu->insertItem( app->pixmap(), t, app->id(), index );
236 }
237 result=TRUE;
238 }
239 }
240 } 193 }
241 194
242 if ( sepId && ( menu-> idAt ( 0 ) == sepId )) { // no tabs entries 195 launchMenu->setName(sepfirst ? "accessories" : "accessories_need_sep"); // No tr
243 menu-> removeItem ( sepId );
244 sepId = 0;
245 }
246 if ( !menu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later
247 sepId = menu-> insertSeparator ( );
248 196
249 return result; 197 return (nother || ntabs );
250} 198}
251 199
252 200
253void StartMenu::launch ( ) 201void StartMenu::launch()
254{ 202{
255 int y = mapToGlobal ( QPoint ( )). y ( ) - launchMenu-> sizeHint ( ). height ( ); 203 int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height();
256 204
257 if ( launchMenu-> isVisible ( )) { 205 if ( launchMenu->isVisible() )
258 launchMenu-> hide ( ); 206 launchMenu->hide();
259 } 207 else
260 else { 208 launchMenu->popup( QPoint( 1, y ) );
261 QWidget *active = qApp-> activeWindow ( );
262 if ( active && active-> isPopup ( ))
263 active-> close ( );
264
265 launchMenu-> popup ( QPoint ( 1, y ));
266 }
267} 209}
268 210
269const AppLnk* StartMenu::execToLink(const QString& appname)
270{
271 const AppLnk* a = apps->findExec( appname );
272 return a;
273}
274 211
275void StartPopupMenu::keyPressEvent( QKeyEvent *e ) 212
276{
277 if ( e->key() == Key_F33 || e->key() == Key_Space ) {
278 // "OK" button, little hacky
279 QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0);
280 QPopupMenu::keyPressEvent( &ke );
281 } else {
282 QPopupMenu::keyPressEvent( e );
283 }
284}
285 213
286static int compareAppletPositions(const void *a, const void *b) 214static int compareAppletPositions(const void *a, const void *b)
287{ 215{
288 const MenuApplet* aa = *(const MenuApplet**)a; 216 const MenuApplet* aa = *(const MenuApplet**)a;
289 const MenuApplet* ab = *(const MenuApplet**)b; 217 const MenuApplet* ab = *(const MenuApplet**)b;
290 int d = aa->iface->position() - ab->iface->position(); 218 int d = aa->iface->position() - ab->iface->position();
291 if ( d ) return d; 219 if ( d ) return d;
292 return QString::compare(aa->library->library(),ab->library->library()); 220 return QString::compare(aa->library->library(),ab->library->library());
293} 221}
294 222
295void StartMenu::clearApplets() 223void StartMenu::clearApplets()
296{ 224{
297 launchMenu-> hide(); 225 if (launchMenu )
226 launchMenu-> hide();
298 227
299 for ( QIntDictIterator<MenuApplet> it ( applets ); it. current ( ); ++it ) { 228 for ( QIntDictIterator<MenuApplet> it ( m_applets ); it. current ( ); ++it ) {
300 MenuApplet *applet = it. current ( ); 229 MenuApplet *applet = it. current ( );
301 if ( launchMenu ) { 230 if ( launchMenu ) {
302 launchMenu-> removeItem ( applet-> id ); 231 launchMenu-> removeItem ( applet-> id );
303 delete applet-> popup; 232 delete applet-> popup;
304 } 233 }
305 234
306 applet-> iface-> release(); 235 applet-> iface-> release();
307 applet-> library-> unload(); 236 applet-> library-> unload();
308 delete applet-> library; 237 delete applet-> library;
309 } 238 }
310 applets.clear(); 239 m_applets.clear();
311} 240}
312 241
313 242
314 243
244
315void StartMenu::loadApplets() 245void StartMenu::loadApplets()
316{ 246{
317 Config cfg( "StartMenu" ); 247 Config cfg( "StartMenu" );
318 cfg.setGroup( "Applets" ); 248 cfg.setGroup( "Applets" );
319 249
320 // SafeMode causes too much problems, so we disable it for now -- 250 // SafeMode causes too much problems, so we disable it for now --
321 // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02 251 // maybe we should reenable it for OPIE 1.0 - sandman 26.09.02
252 // removed in the remerge PluginManager could handle it
253 // we don't currently use it -zecke
322 254
323 bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE);
324 if ( safe && !safety_tid )
325 return;
326 cfg.writeEntry("SafeMode",TRUE);
327 cfg.write();
328 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); 255 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' );
329 256
330 QString lang = getenv( "LANG" ); 257 QString lang = getenv( "LANG" );
331 QString path = QPEApplication::qpeDir() + "/plugins/applets"; 258 QString path = QPEApplication::qpeDir() + "/plugins/applets";
332 QDir dir( path, "lib*.so" ); 259 QDir dir( path, "lib*.so" );
333 QStringList list = dir.entryList(); 260 QStringList list = dir.entryList();
334 QStringList::Iterator it; 261 QStringList::Iterator it;
335 int napplets=0; 262 int napplets=0;
336 MenuApplet* *xapplets = new MenuApplet*[list.count()]; 263 MenuApplet* *xapplets = new MenuApplet*[list.count()];
337 for ( it = list.begin(); it != list.end(); ++it ) { 264 for ( it = list.begin(); it != list.end(); ++it ) {
338 if ( exclude.find( *it ) != exclude.end() ) 265 if ( exclude.find( *it ) != exclude.end() )
339 continue; 266 continue;
340 MenuAppletInterface *iface = 0; 267 MenuAppletInterface *iface = 0;
341 QLibrary *lib = new QLibrary( path + "/" + *it ); 268 QLibrary *lib = new QLibrary( path + "/" + *it );
342 if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { 269 if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) {
343 MenuApplet *applet = new MenuApplet; 270 MenuApplet *applet = new MenuApplet;
344 xapplets[napplets++] = applet; 271 xapplets[napplets++] = applet;
345 applet->library = lib; 272 applet->library = lib;
346 applet->iface = iface; 273 applet->iface = iface;
347 274
348 QTranslator *trans = new QTranslator(qApp); 275 QTranslator *trans = new QTranslator(qApp);
349 QString type = (*it).left( (*it).find(".") ); 276 QString type = (*it).left( (*it).find(".") );
350 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; 277 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
351 if ( trans->load( tfn )) 278 if ( trans->load( tfn ))
352 qApp->installTranslator( trans ); 279 qApp->installTranslator( trans );
353 else 280 else
354 delete trans; 281 delete trans;
355 } else { 282 } else {
356 exclude += *it; 283 exclude += *it;
357 delete lib; 284 delete lib;
358 } 285 }
359 } 286 }
360 cfg.writeEntry( "ExcludeApplets", exclude, ',' ); 287 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
361 qsort(xapplets,napplets,sizeof(applets[0]),compareAppletPositions); 288 qsort(xapplets,napplets,sizeof(m_applets[0]),compareAppletPositions);
289
362 290
363 if ( sepId ) 291 int foo = ( launchMenu-> count ( )) ? launchMenu-> insertSeparator ( ) : 0;
364 launchMenu-> removeItem ( sepId );
365 sepId = ( launchMenu-> count ( )) ? launchMenu-> insertSeparator ( ) : 0;
366 292
367 while (napplets--) { 293 while (napplets--) {
368 MenuApplet *applet = xapplets[napplets]; 294 MenuApplet *applet = xapplets[napplets];
369 295
370 applet-> popup = applet-> iface-> popup ( this ); 296 applet-> popup = applet-> iface-> popup ( this );
371 297
372 if ( applet-> popup ) 298 if ( applet-> popup )
373 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup ); 299 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup );
374 else 300 else
375 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) ); 301 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) );
376 applets.insert ( applet-> id, new MenuApplet(*applet));
377 }
378 delete [] xapplets;
379 302
380 if ( sepId && ( launchMenu-> idAt ( launchMenu-> count ( ) - 1 ) == sepId )) { // no applets 303
381 launchMenu-> removeItem ( sepId ); 304 m_applets.insert ( applet-> id, new MenuApplet(*applet));
382 sepId = 0;
383 } 305 }
384 if ( !launchMenu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later 306 delete [] xapplets;
385 sepId = launchMenu-> insertSeparator ( );
386 307
387 if ( !safety_tid )
388 safety_tid = startTimer(2000); // TT has 5000, but this is a PITA for a developer ;) (sandman)
389} 308}
390 309
391void StartMenu::timerEvent(QTimerEvent* e) 310
392{ 311/*
393 if ( e->timerId() == safety_tid ) { 312 * Launcher calls loadMenu too often fix that
394 Config cfg( "StartMenu" ); 313 */
395 cfg.setGroup( "Applets" ); 314void StartMenu::addApplets(QPopupMenu* pop) {
396 cfg.writeEntry( "SafeMode", FALSE ); 315 QIntDict<MenuApplet> dict;
397 killTimer(safety_tid); 316 if( pop-> count ( ))
398 safety_tid = 0; 317 pop-> insertSeparator ( );
318
319 for ( QIntDictIterator<MenuApplet> it ( m_applets ); it. current ( ); ++it ) {
320 MenuApplet *applet = it. current ( );
321 if ( applet-> popup )
322 applet-> id = pop-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup );
323 else
324 applet-> id = pop-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) );
325
326 dict.insert( applet->id, new MenuApplet(*applet) );
399 } 327 }
328 /* need to update the key */
329 m_applets.setAutoDelete( true );
330 m_applets.clear();
331 m_applets.setAutoDelete( false );
332 m_applets = dict;
400} 333}
401
diff --git a/core/launcher/startmenu.h b/core/launcher/startmenu.h
index 0a91bb8..99df0f0 100644
--- a/core/launcher/startmenu.h
+++ b/core/launcher/startmenu.h
@@ -1,103 +1,95 @@
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#ifndef __START_MENU_H__ 21#ifndef __START_MENU_H__
22#define __START_MENU_H__ 22#define __START_MENU_H__
23 23
24#include <qtopia/applnk.h>
25#include <qintdict.h>
24#include <qstring.h> 26#include <qstring.h>
25#include <qlist.h> 27#include <qlist.h>
26#include <qintdict.h>
27#include <qlabel.h> 28#include <qlabel.h>
28#include <qpopupmenu.h> 29#include <qpopupmenu.h>
29 30
30#include <qpe/menuappletinterface.h> 31#include <qtopia/menuappletinterface.h>
31
32class AppLnkSet;
33class AppLnk;
34 32
35class StartPopupMenu : public QPopupMenu 33class StartPopupMenu : public QPopupMenu
36{ 34{
37public: 35public:
38 StartPopupMenu( QWidget *parent ) : QPopupMenu( parent ) {} 36 StartPopupMenu( QWidget *parent ) : QPopupMenu( parent ) {}
39protected: 37protected:
40 void keyPressEvent( QKeyEvent *e ); 38 void keyPressEvent( QKeyEvent *e );
41}; 39};
42 40
43class QLibrary; 41class QLibrary;
44 42
45struct MenuApplet 43
46{ 44struct MenuApplet {
47#ifndef QT_NO_COMPONENT
48 QLibrary *library; 45 QLibrary *library;
49#endif
50 MenuAppletInterface *iface; 46 MenuAppletInterface *iface;
51 int id; 47 int id;
52 QPopupMenu *popup; 48 QPopupMenu *popup;
53}; 49};
54
55 50
56class StartMenu : public QLabel { 51class StartMenu : public QLabel {
57 Q_OBJECT 52 Q_OBJECT
58public: 53public:
59 StartMenu( QWidget * ); 54 StartMenu( QWidget * );
60 ~StartMenu(); 55 ~StartMenu();
61 56
62 const AppLnk* execToLink(const QString& appname); 57 void refreshMenu();
63 58
64public: 59public:
65 StartPopupMenu *launchMenu; 60 StartPopupMenu *launchMenu;
66 61
62signals:
63 void tabSelected(const QString&);
64
67public slots: 65public slots:
68 void launch( ); 66 void launch( );
69 void loadOptions( );
70 void createMenu( ); 67 void createMenu( );
71 void reloadApps( );
72 void reloadApplets( );
73 68
74protected slots: 69protected slots:
75 void itemSelected( int id ); 70 void itemSelected( int id );
76 71
77protected: 72protected:
78 virtual void mousePressEvent( QMouseEvent * ); 73 virtual void mousePressEvent( QMouseEvent * );
79 virtual void timerEvent ( QTimerEvent * ); 74
80
81private: 75private:
82 bool loadMenu( AppLnkSet *folder, QPopupMenu *menu ); 76 void loadApplets();
83 void loadApplets( ); 77 void clearApplets();
84 void clearApplets( ); 78 void addApplets( QPopupMenu* menu );
79 bool loadMenu( QPopupMenu *menu );
85 80
86private: 81private:
87 bool useWidePopupMenu; 82 bool useWidePopupMenu;
88 QString popupMenuSidePixmap; 83 QString popupMenuSidePixmap;
89 84
90 bool startButtonIsFlat; 85 bool startButtonIsFlat;
91 QString startButtonPixmap; 86 QString startButtonPixmap;
92 87
93 AppLnkSet *apps; 88 QStringList tabs;
94 89 QList<AppLnk> other;
95 QIntDict<MenuApplet> applets; 90 QIntDict<MenuApplet> m_applets;
96 QIntDict<QPopupMenu> tabdict; 91 int ntabs;
97 92 int nother;
98// QValueList<MenuApplet> appletList;
99 int safety_tid;
100 int sepId;
101}; 93};
102 94
103#endif // __START_MENU_H__ 95#endif // __START_MENU_H__