summaryrefslogtreecommitdiff
path: root/core/launcher/startmenu.cpp
Side-by-side diff
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
@@ -211,97 +211,101 @@ void StartMenu::launch()
static int compareAppletPositions(const void *a, const void *b)
{
const MenuApplet* aa = *(const MenuApplet**)a;
const MenuApplet* ab = *(const MenuApplet**)b;
int d = aa->iface->position() - ab->iface->position();
if ( d ) return d;
return QString::compare(aa->library->library(),ab->library->library());
}
void StartMenu::clearApplets()
{
if (launchMenu )
launchMenu-> hide();
for ( QIntDictIterator<MenuApplet> it ( m_applets ); it. current ( ); ++it ) {
MenuApplet *applet = it. current ( );
if ( launchMenu ) {
launchMenu-> removeItem ( applet-> id );
delete applet-> popup;
}
applet-> iface-> release();
applet-> library-> unload();
delete applet-> library;
}
m_applets.clear();
}
void StartMenu::loadApplets()
{
Config cfg( "StartMenu" );
cfg.setGroup( "Applets" );
// SafeMode causes too much problems, so we disable it for now --
// maybe we should reenable it for OPIE 1.0 - sandman 26.09.02
// removed in the remerge PluginManager could handle it
// we don't currently use it -zecke
QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' );
QString lang = getenv( "LANG" );
QString path = QPEApplication::qpeDir() + "/plugins/applets";
+#ifdef Q_OS_MACX
+ QDir dir( path, "lib*.dylib" );
+#else
QDir dir( path, "lib*.so" );
+#endif /* Q_OS_MACX */
QStringList list = dir.entryList();
QStringList::Iterator it;
int napplets=0;
MenuApplet* *xapplets = new MenuApplet*[list.count()];
for ( it = list.begin(); it != list.end(); ++it ) {
if ( exclude.find( *it ) != exclude.end() )
continue;
MenuAppletInterface *iface = 0;
QLibrary *lib = new QLibrary( path + "/" + *it );
if (( lib->queryInterface( IID_MenuApplet, (QUnknownInterface**)&iface ) == QS_OK ) && iface ) {
MenuApplet *applet = new MenuApplet;
xapplets[napplets++] = applet;
applet->library = lib;
applet->iface = iface;
QTranslator *trans = new QTranslator(qApp);
QString type = (*it).left( (*it).find(".") );
QString tfn = QPEApplication::qpeDir()+"/i18n/"+lang+"/"+type+".qm";
if ( trans->load( tfn ))
qApp->installTranslator( trans );
else
delete trans;
} else {
exclude += *it;
delete lib;
}
}
cfg.writeEntry( "ExcludeApplets", exclude, ',' );
qsort(xapplets,napplets,sizeof(m_applets[0]),compareAppletPositions);
int foo = ( launchMenu-> count ( )) ? launchMenu-> insertSeparator ( ) : 0;
while (napplets--) {
MenuApplet *applet = xapplets[napplets];
applet-> popup = applet-> iface-> popup ( this );
if ( applet-> popup )
applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ), applet-> popup );
else
applet-> id = launchMenu-> insertItem ( applet-> iface-> icon ( ), applet-> iface-> text ( ) );
m_applets.insert ( applet-> id, new MenuApplet(*applet));
}
delete [] xapplets;