summaryrefslogtreecommitdiff
authorsandman <sandman>2003-03-21 21:12:14 (UTC)
committer sandman <sandman>2003-03-21 21:12:14 (UTC)
commitd11cf5483fbfa87a7be65891df2625def351f3a4 (patch) (side-by-side diff)
tree53ec1a4fefcd7a2fc37bd64a0bae3ce378c5ef7d
parent633fbff7e3d85a5fc16bd3ed3283723c44acb2aa (diff)
downloadopie-d11cf5483fbfa87a7be65891df2625def351f3a4.zip
opie-d11cf5483fbfa87a7be65891df2625def351f3a4.tar.gz
opie-d11cf5483fbfa87a7be65891df2625def351f3a4.tar.bz2
fix for bug #647:
Programs are sorted by their internal name and not by the translated name (in the O-Menu)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/startmenu.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp
index 2871233..28c8b97 100644
--- a/core/launcher/startmenu.cpp
+++ b/core/launcher/startmenu.cpp
@@ -130,193 +130,201 @@ void StartMenu::reloadApps()
if ( launchMenu ) {
launchMenu-> hide ( );
for ( QIntDictIterator<QPopupMenu> it ( tabdict ); it. current ( ); ++it ) {
launchMenu-> removeItem ( it. currentKey ( ));
delete it.current ( );
}
tabdict. clear ( );
loadMenu(apps,launchMenu);
} else {
createMenu();
}
}
void StartMenu::reloadApplets()
{
if ( launchMenu ) {
clearApplets ( );
loadApplets ( );
}
else
createMenu ( );
}
void StartMenu::itemSelected( int id )
{
const AppLnk *app = apps->find( id );
if ( app )
app->execute();
else {
MenuApplet *applet = applets. find ( id );
if ( applet )
applet-> iface-> activated ( );
}
}
bool StartMenu::loadMenu( AppLnkSet *folder, QPopupMenu *menu )
{
bool result = FALSE;
Config cfg("StartMenu");
cfg.setGroup("Menu");
bool ltabs = cfg.readBoolEntry("LauncherTabs",TRUE);
bool lot = cfg.readBoolEntry("LauncherOther",TRUE);
tabdict. clear ( );
if ( sepId )
menu-> removeItem ( sepId );
sepId = ( menu-> count ( )) ? menu-> insertSeparator ( 0 ) : 0;
if ( ltabs || lot ) {
QDict<QPopupMenu> typpop;
QStringList typs = folder->types();
for (QStringList::Iterator tit=typs.fromLast(); ; --tit) {
if ( !(*tit).isEmpty() ) {
QPopupMenu *new_menu;
if ( ltabs ) {
new_menu = new StartPopupMenu( menu );
connect( new_menu, SIGNAL(activated(int)), SLOT(itemSelected(int)) );
int id = menu->insertItem( folder->typePixmap(*tit), folder->typeName(*tit), new_menu, -1, 0 );
tabdict. insert ( id, new_menu );
} else {
new_menu = (QPopupMenu*)1;
}
typpop.insert(*tit, new_menu);
}
if ( tit == typs. begin ( ))
break;
}
QListIterator<AppLnk> it( folder->children() );
bool f=TRUE;
for ( ; it.current(); ++it ) {
AppLnk *app = it.current();
if ( app->type() == "Separator" ) { // No tr
if ( lot ) {
menu->insertSeparator();
}
} else {
f = FALSE;
QString t = app->type();
QPopupMenu* pmenu = typpop.find(t);
if ( ltabs ) {
if ( !pmenu && lot )
pmenu = menu;
} else {
if ( !pmenu )
pmenu = menu;
else
pmenu = 0;
}
if ( pmenu ) {
QString t = app->name();
t.replace(QRegExp("&"),"&&"); // escape shortcut character
- pmenu->insertItem( app->pixmap(), t, app->id() );
+
+ int index = -1;
+
+ for ( index = 0; index < pmenu-> count ( ); index++ ) {
+ if ( pmenu-> text ( pmenu-> idAt ( index )). compare ( t ) > 0 )
+ break;
+ }
+
+ pmenu->insertItem( app->pixmap(), t, app->id(), index );
}
result=TRUE;
}
}
}
if ( sepId && ( menu-> idAt ( 0 ) == sepId )) { // no tabs entries
menu-> removeItem ( sepId );
sepId = 0;
}
if ( !menu-> count ( )) // if we don't do this QPopupMenu will insert a dummy Separator, which won't go away later
sepId = menu-> insertSeparator ( );
return result;
}
void StartMenu::launch ( )
{
int y = mapToGlobal ( QPoint ( )). y ( ) - launchMenu-> sizeHint ( ). height ( );
if ( launchMenu-> isVisible ( )) {
launchMenu-> hide ( );
}
else {
QWidget *active = qApp-> activeWindow ( );
if ( active && active-> isPopup ( ))
active-> close ( );
launchMenu-> popup ( QPoint ( 1, y ));
}
}
const AppLnk* StartMenu::execToLink(const QString& appname)
{
const AppLnk* a = apps->findExec( appname );
return a;
}
void StartPopupMenu::keyPressEvent( QKeyEvent *e )
{
if ( e->key() == Key_F33 || e->key() == Key_Space ) {
// "OK" button, little hacky
QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0);
QPopupMenu::keyPressEvent( &ke );
} else {
QPopupMenu::keyPressEvent( e );
}
}
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()
{
launchMenu-> hide();
for ( QIntDictIterator<MenuApplet> it ( 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;
}
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
bool safe = false; //cfg.readBoolEntry("SafeMode",FALSE);
if ( safe && !safety_tid )
return;
cfg.writeEntry("SafeMode",TRUE);
cfg.write();
QStringList exclude = cfg.readListEntry( "ExcludeApplets", ',' );
QString lang = getenv( "LANG" );
QString path = QPEApplication::qpeDir() + "/plugins/applets";