summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--core/launcher/startmenu.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp
index 66f665f..ce7840e 100644
--- a/core/launcher/startmenu.cpp
+++ b/core/launcher/startmenu.cpp
@@ -46,48 +46,49 @@ 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 );
}
}
//---------------------------------------------------------------------------
StartMenu::StartMenu(QWidget *parent) : QLabel( parent )
{
startButtonPixmap = "go"; // No tr
int sz = AppLnk::smallIconSize()+3;
QPixmap pm;
pm.convertFromImage(Resource::loadImage( startButtonPixmap).smoothScale( sz,sz) );
setPixmap(pm);
setFocusPolicy( NoFocus );
useWidePopupMenu = true;
launchMenu = 0;
+ currentItem = 0;
refreshMenu();
}
void StartMenu::mousePressEvent( QMouseEvent * )
{
launch();
}
StartMenu::~StartMenu()
{
clearApplets();
}
void StartMenu::createMenu()
{
clearApplets();
delete launchMenu;
launchMenu = new StartPopupMenu( this );
loadMenu( launchMenu );
loadApplets();
@@ -130,50 +131,60 @@ void StartMenu::itemSelected( int id )
}
}
}
void StartMenu::createAppEntry( QPopupMenu *menu, QDir dir, QString file )
{
if ( file.right(8) == ".desktop" ) {
AppLnk* applnk = new AppLnk( dir.path() + "/" + file );
if ( !applnk->isValid() ) {
delete applnk;
return;
}
if ( applnk->type() == "Separator" ) { // No tr
menu->insertSeparator();
delete applnk;
} else {
QPixmap test;
QImage img = Resource::loadImage( applnk->icon() );
if(!img.isNull() )
test.convertFromImage(
img.smoothScale(
AppLnk::smallIconSize(), AppLnk::smallIconSize() ), 0 );
+ // Insert items ordered lexically
+ int current, left = 0, right = currentItem;
+ while( left != right ) {
+ current = ( left + right ) / 2;
+ if ( menu->text(menu->idAt( ( current ) ) ) < applnk->name() )
+ left = ++current;
+ else
+ right = current;
+ }
+
menu->insertItem( test, applnk->name(),
- currentItem + APPLNK_ID_OFFSET );
+ currentItem + APPLNK_ID_OFFSET, current );
appLnks.insert( currentItem + APPLNK_ID_OFFSET, applnk );
currentItem++;
}
}
}
void StartMenu::createDirEntry( QPopupMenu *menu, QDir dir, QString file, bool lot )
{
// do some sanity checks and collect information
if ( file == "." || file == ".." ) return;
Config cfg( dir.path() + "/" + file + "/.directory", Config::File );
if ( !cfg.isValid() ) return;
QString name = cfg.readEntry( "Name" );
QString icon = cfg.readEntry( "Icon" );
if ( !name || !icon ) return;
QDir subdir = QDir( dir );
subdir.cd( file );
subdir.setFilter( QDir::Files );
subdir.setNameFilter( "*.desktop" );