summaryrefslogtreecommitdiff
path: root/core/launcher/startmenu.cpp
authoreilers <eilers>2003-11-03 16:52:18 (UTC)
committer eilers <eilers>2003-11-03 16:52:18 (UTC)
commitd34dc773591a2d467c68875a68a671d6a809f861 (patch) (unidiff)
treeb57e5ae15c51e3d87ca95d57aedfd1ca3db57bfe /core/launcher/startmenu.cpp
parentce84f2d8bdd65c438821f0457cdad6bbbfa73380 (diff)
downloadopie-d34dc773591a2d467c68875a68a671d6a809f861.zip
opie-d34dc773591a2d467c68875a68a671d6a809f861.tar.gz
opie-d34dc773591a2d467c68875a68a671d6a809f861.tar.bz2
Porting Opie to MacOS-X.
The base system and all platform independent applications and platforms should work. Please see $OPIEDIR/development/macosx for details
Diffstat (limited to 'core/launcher/startmenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/startmenu.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp
index 014418d..08ae885 100644
--- a/core/launcher/startmenu.cpp
+++ b/core/launcher/startmenu.cpp
@@ -163,171 +163,175 @@ bool StartMenu::loadMenu( QPopupMenu *menu )
163 if ( cfg.isValid() ) { 163 if ( cfg.isValid() ) {
164 QString nm = cfg.readEntry("Name"); 164 QString nm = cfg.readEntry("Name");
165 QString ic = cfg.readEntry("Icon"); 165 QString ic = cfg.readEntry("Icon");
166 if ( !!nm && !!ic ) { 166 if ( !!nm && !!ic ) {
167 tabs.append(d); 167 tabs.append(d);
168 menu->insertItem( Resource::loadIconSet(ic), nm, ntabs++ ); 168 menu->insertItem( Resource::loadIconSet(ic), nm, ntabs++ );
169 } 169 }
170 } else if ( lot && d.right(8)==".desktop") { 170 } else if ( lot && d.right(8)==".desktop") {
171 AppLnk* applnk = new AppLnk(dir.path()+"/"+d); 171 AppLnk* applnk = new AppLnk(dir.path()+"/"+d);
172 if ( applnk->isValid() ) { 172 if ( applnk->isValid() ) {
173 if ( applnk->type() == "Separator" ) { // No tr 173 if ( applnk->type() == "Separator" ) { // No tr
174 if ( lot ) { 174 if ( lot ) {
175 menu->insertSeparator(); 175 menu->insertSeparator();
176 sepfirst = f && !ltabs; 176 sepfirst = f && !ltabs;
177 } 177 }
178 delete applnk; 178 delete applnk;
179 } else { 179 } else {
180 f = FALSE; 180 f = FALSE;
181 other.append(applnk); 181 other.append(applnk);
182 menu->insertItem( Resource::loadIconSet(applnk->icon()), 182 menu->insertItem( Resource::loadIconSet(applnk->icon()),
183 applnk->name(), 20+nother++ ); 183 applnk->name(), 20+nother++ );
184 } 184 }
185 } else { 185 } else {
186 delete applnk; 186 delete applnk;
187 } 187 }
188 } 188 }
189 } 189 }
190 190
191 if ( !menu->count() ) 191 if ( !menu->count() )
192 sepfirst = TRUE; 192 sepfirst = TRUE;
193 } 193 }
194 194
195 launchMenu->setName(sepfirst ? "accessories" : "accessories_need_sep"); // No tr 195 launchMenu->setName(sepfirst ? "accessories" : "accessories_need_sep"); // No tr
196 196
197 return (nother || ntabs ); 197 return (nother || ntabs );
198} 198}
199 199
200 200
201void StartMenu::launch() 201void StartMenu::launch()
202{ 202{
203 int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height(); 203 int y = mapToGlobal( QPoint() ).y() - launchMenu->sizeHint().height();
204 204
205 if ( launchMenu->isVisible() ) 205 if ( launchMenu->isVisible() )
206 launchMenu->hide(); 206 launchMenu->hide();
207 else 207 else
208 launchMenu->popup( QPoint( 1, y ) ); 208 launchMenu->popup( QPoint( 1, y ) );
209} 209}
210 210
211 211
212 212
213 213
214static int compareAppletPositions(const void *a, const void *b) 214static int compareAppletPositions(const void *a, const void *b)
215{ 215{
216 const MenuApplet* aa = *(const MenuApplet**)a; 216 const MenuApplet* aa = *(const MenuApplet**)a;
217 const MenuApplet* ab = *(const MenuApplet**)b; 217 const MenuApplet* ab = *(const MenuApplet**)b;
218 int d = aa->iface->position() - ab->iface->position(); 218 int d = aa->iface->position() - ab->iface->position();
219 if ( d ) return d; 219 if ( d ) return d;
220 return QString::compare(aa->library->library(),ab->library->library()); 220 return QString::compare(aa->library->library(),ab->library->library());
221} 221}
222 222
223void StartMenu::clearApplets() 223void StartMenu::clearApplets()
224{ 224{
225 if (launchMenu ) 225 if (launchMenu )
226 launchMenu-> hide(); 226 launchMenu-> hide();
227 227
228 for ( QIntDictIterator<MenuApplet> it ( m_applets ); it. current ( ); ++it ) { 228 for ( QIntDictIterator<MenuApplet> it ( m_applets ); it. current ( ); ++it ) {
229 MenuApplet *applet = it. current ( ); 229 MenuApplet *applet = it. current ( );
230 if ( launchMenu ) { 230 if ( launchMenu ) {
231 launchMenu-> removeItem ( applet-> id ); 231 launchMenu-> removeItem ( applet-> id );
232 delete applet-> popup; 232 delete applet-> popup;
233 } 233 }
234 234
235 applet-> iface-> release(); 235 applet-> iface-> release();
236 applet-> library-> unload(); 236 applet-> library-> unload();
237 delete applet-> library; 237 delete applet-> library;
238 } 238 }
239 m_applets.clear(); 239 m_applets.clear();
240} 240}
241 241
242 242
243 243
244 244
245void StartMenu::loadApplets() 245void StartMenu::loadApplets()
246{ 246{
247 Config cfg( "StartMenu" ); 247 Config cfg( "StartMenu" );
248 cfg.setGroup( "Applets" ); 248 cfg.setGroup( "Applets" );
249 249
250 // SafeMode causes too much problems, so we disable it for now -- 250 // SafeMode causes too much problems, so we disable it for now --
251 // 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 252 // removed in the remerge PluginManager could handle it
253 // we don't currently use it -zecke 253 // we don't currently use it -zecke
254 254
255 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' ); 255 QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' );
256 256
257 QString lang = getenv( "LANG" ); 257 QString lang = getenv( "LANG" );
258 QString path = QPEApplication::qpeDir() + "/plugins/applets"; 258 QString path = QPEApplication::qpeDir() + "/plugins/applets";
259#ifdef Q_OS_MACX
260 QDir dir( path, "lib*.dylib" );
261#else
259 QDir dir( path, "lib*.so" ); 262 QDir dir( path, "lib*.so" );
263#endif /* Q_OS_MACX */
260 QStringList list = dir.entryList(); 264 QStringList list = dir.entryList();
261 QStringList::Iterator it; 265 QStringList::Iterator it;
262 int napplets=0; 266 int napplets=0;
263 MenuApplet* *xapplets = new MenuApplet*[list.count()]; 267 MenuApplet* *xapplets = new MenuApplet*[list.count()];
264 for ( it = list.begin(); it != list.end(); ++it ) { 268 for ( it = list.begin(); it != list.end(); ++it ) {
265 if ( exclude.find( *it ) != exclude.end() ) 269 if ( exclude.find( *it ) != exclude.end() )
266 continue; 270 continue;
267 MenuAppletInterface *iface = 0; 271 MenuAppletInterface *iface = 0;
268 QLibrary *lib = new QLibrary( path + "/" + *it ); 272 QLibrary *lib = new QLibrary( path + "/" + *it );
269 if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) { 273 if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) {
270 MenuApplet *applet = new MenuApplet; 274 MenuApplet *applet = new MenuApplet;
271 xapplets[napplets++] = applet; 275 xapplets[napplets++] = applet;
272 applet->library = lib; 276 applet->library = lib;
273 applet->iface = iface; 277 applet->iface = iface;
274 278
275 QTranslator *trans = new QTranslator(qApp); 279 QTranslator *trans = new QTranslator(qApp);
276 QString type = (*it).left( (*it).find(".") ); 280 QString type = (*it).left( (*it).find(".") );
277 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm"; 281 QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
278 if ( trans->load( tfn )) 282 if ( trans->load( tfn ))
279 qApp->installTranslator( trans ); 283 qApp->installTranslator( trans );
280 else 284 else
281 delete trans; 285 delete trans;
282 } else { 286 } else {
283 exclude += *it; 287 exclude += *it;
284 delete lib; 288 delete lib;
285 } 289 }
286 } 290 }
287 cfg.writeEntry( "ExcludeApplets", exclude, ',' ); 291 cfg.writeEntry( "ExcludeApplets", exclude, ',' );
288 qsort(xapplets,napplets,sizeof(m_applets[0]),compareAppletPositions); 292 qsort(xapplets,napplets,sizeof(m_applets[0]),compareAppletPositions);
289 293
290 294
291 int foo = ( launchMenu-> count ( )) ? launchMenu-> insertSeparator ( ) : 0; 295 int foo = ( launchMenu-> count ( )) ? launchMenu-> insertSeparator ( ) : 0;
292 296
293 while (napplets--) { 297 while (napplets--) {
294 MenuApplet *applet = xapplets[napplets]; 298 MenuApplet *applet = xapplets[napplets];
295 299
296 applet-> popup = applet-> iface-> popup ( this ); 300 applet-> popup = applet-> iface-> popup ( this );
297 301
298 if ( applet-> popup ) 302 if ( applet-> popup )
299 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup ); 303 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup );
300 else 304 else
301 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) ); 305 applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) );
302 306
303 307
304 m_applets.insert ( applet-> id, new MenuApplet(*applet)); 308 m_applets.insert ( applet-> id, new MenuApplet(*applet));
305 } 309 }
306 delete [] xapplets; 310 delete [] xapplets;
307 311
308} 312}
309 313
310 314
311/* 315/*
312 * Launcher calls loadMenu too often fix that 316 * Launcher calls loadMenu too often fix that
313 */ 317 */
314void StartMenu::addApplets(QPopupMenu* pop) { 318void StartMenu::addApplets(QPopupMenu* pop) {
315 QIntDict<MenuApplet> dict; 319 QIntDict<MenuApplet> dict;
316 if( pop-> count ( )) 320 if( pop-> count ( ))
317 pop-> insertSeparator ( ); 321 pop-> insertSeparator ( );
318 322
319 for ( QIntDictIterator<MenuApplet> it ( m_applets ); it. current ( ); ++it ) { 323 for ( QIntDictIterator<MenuApplet> it ( m_applets ); it. current ( ); ++it ) {
320 MenuApplet *applet = it. current ( ); 324 MenuApplet *applet = it. current ( );
321 if ( applet-> popup ) 325 if ( applet-> popup )
322 applet-> id = pop-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup ); 326 applet-> id = pop-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup );
323 else 327 else
324 applet-> id = pop-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) ); 328 applet-> id = pop-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) );
325 329
326 dict.insert( applet->id, new MenuApplet(*applet) ); 330 dict.insert( applet->id, new MenuApplet(*applet) );
327 } 331 }
328 /* need to update the key */ 332 /* need to update the key */
329 m_applets.setAutoDelete( true ); 333 m_applets.setAutoDelete( true );
330 m_applets.clear(); 334 m_applets.clear();
331 m_applets.setAutoDelete( false ); 335 m_applets.setAutoDelete( false );
332 m_applets = dict; 336 m_applets = dict;
333} 337}