summaryrefslogtreecommitdiff
authorskyhusker <skyhusker>2005-04-24 17:50:42 (UTC)
committer skyhusker <skyhusker>2005-04-24 17:50:42 (UTC)
commit883d2f517fe0aaab83d820e1413edffc1471bb4e (patch) (unidiff)
treedc7255faf24d909bf0ca8f0afc05202459615414
parentceaea9869115287b48781fabc938bd51cb67625c (diff)
downloadopie-883d2f517fe0aaab83d820e1413edffc1471bb4e.zip
opie-883d2f517fe0aaab83d820e1413edffc1471bb4e.tar.gz
opie-883d2f517fe0aaab83d820e1413edffc1471bb4e.tar.bz2
Sort applications alphabetically. Fixes bug #1476.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/startmenu.cpp19
1 files changed, 15 insertions, 4 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 )
46{ 46{
47 if ( e->key() == Key_F33 || e->key() == Key_Space ) { 47 if ( e->key() == Key_F33 || e->key() == Key_Space ) {
48 // "OK" button, little hacky 48 // "OK" button, little hacky
49 QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0); 49 QKeyEvent ke(QEvent::KeyPress, Key_Enter, 13, 0);
50 QPopupMenu::keyPressEvent( &ke ); 50 QPopupMenu::keyPressEvent( &ke );
51 } else { 51 } else {
52 QPopupMenu::keyPressEvent( e ); 52 QPopupMenu::keyPressEvent( e );
53 } 53 }
54} 54}
55 55
56//--------------------------------------------------------------------------- 56//---------------------------------------------------------------------------
57 57
58StartMenu::StartMenu(QWidget *parent) : QLabel( parent ) 58StartMenu::StartMenu(QWidget *parent) : QLabel( parent )
59{ 59{
60 startButtonPixmap = "go"; // No tr 60 startButtonPixmap = "go"; // No tr
61 61
62 int sz = AppLnk::smallIconSize()+3; 62 int sz = AppLnk::smallIconSize()+3;
63 QPixmap pm; 63 QPixmap pm;
64 pm.convertFromImage(Resource::loadImage( startButtonPixmap).smoothScale( sz,sz) ); 64 pm.convertFromImage(Resource::loadImage( startButtonPixmap).smoothScale( sz,sz) );
65 setPixmap(pm); 65 setPixmap(pm);
66 setFocusPolicy( NoFocus ); 66 setFocusPolicy( NoFocus );
67 67
68 useWidePopupMenu = true; 68 useWidePopupMenu = true;
69 launchMenu = 0; 69 launchMenu = 0;
70 currentItem = 0;
70 refreshMenu(); 71 refreshMenu();
71} 72}
72 73
73 74
74void StartMenu::mousePressEvent( QMouseEvent * ) 75void StartMenu::mousePressEvent( QMouseEvent * )
75{ 76{
76 launch(); 77 launch();
77} 78}
78 79
79 80
80StartMenu::~StartMenu() 81StartMenu::~StartMenu()
81{ 82{
82 clearApplets(); 83 clearApplets();
83} 84}
84 85
85void StartMenu::createMenu() 86void StartMenu::createMenu()
86{ 87{
87 clearApplets(); 88 clearApplets();
88 delete launchMenu; 89 delete launchMenu;
89 90
90 launchMenu = new StartPopupMenu( this ); 91 launchMenu = new StartPopupMenu( this );
91 loadMenu( launchMenu ); 92 loadMenu( launchMenu );
92 loadApplets(); 93 loadApplets();
93 94
@@ -129,53 +130,63 @@ void StartMenu::itemSelected( int id )
129 emit tabSelected( *tabName ); 130 emit tabSelected( *tabName );
130 } 131 }
131 } 132 }
132} 133}
133 134
134void StartMenu::createAppEntry( QPopupMenu *menu, QDir dir, QString file ) 135void StartMenu::createAppEntry( QPopupMenu *menu, QDir dir, QString file )
135{ 136{
136 if ( file.right(8) == ".desktop" ) { 137 if ( file.right(8) == ".desktop" ) {
137 AppLnk* applnk = new AppLnk( dir.path() + "/" + file ); 138 AppLnk* applnk = new AppLnk( dir.path() + "/" + file );
138 if ( !applnk->isValid() ) { 139 if ( !applnk->isValid() ) {
139 delete applnk; 140 delete applnk;
140 return; 141 return;
141 } 142 }
142 143
143 if ( applnk->type() == "Separator" ) { // No tr 144 if ( applnk->type() == "Separator" ) { // No tr
144 menu->insertSeparator(); 145 menu->insertSeparator();
145 delete applnk; 146 delete applnk;
146 } else { 147 } else {
147 QPixmap test; 148 QPixmap test;
148 QImage img = Resource::loadImage( applnk->icon() ); 149 QImage img = Resource::loadImage( applnk->icon() );
149 if(!img.isNull() ) 150 if(!img.isNull() )
150 test.convertFromImage( 151 test.convertFromImage(
151 img.smoothScale( 152 img.smoothScale(
152 AppLnk::smallIconSize(), AppLnk::smallIconSize() ), 0 ); 153 AppLnk::smallIconSize(), AppLnk::smallIconSize() ), 0 );
153 154
155 // Insert items ordered lexically
156 int current, left = 0, right = currentItem;
157 while( left != right ) {
158 current = ( left + right ) / 2;
159 if ( menu->text(menu->idAt( ( current ) ) ) < applnk->name() )
160 left = ++current;
161 else
162 right = current;
163 }
164
154 menu->insertItem( test, applnk->name(), 165 menu->insertItem( test, applnk->name(),
155 currentItem + APPLNK_ID_OFFSET ); 166 currentItem + APPLNK_ID_OFFSET, current );
156 appLnks.insert( currentItem + APPLNK_ID_OFFSET, applnk ); 167 appLnks.insert( currentItem + APPLNK_ID_OFFSET, applnk );
157 currentItem++; 168 currentItem++;
158 } 169 }
159 } 170 }
160 171
161} 172}
162 173
163void StartMenu::createDirEntry( QPopupMenu *menu, QDir dir, QString file, bool lot ) 174void StartMenu::createDirEntry( QPopupMenu *menu, QDir dir, QString file, bool lot )
164{ 175{
165 // do some sanity checks and collect information 176 // do some sanity checks and collect information
166 177
167 if ( file == "." || file == ".." ) return; 178 if ( file == "." || file == ".." ) return;
168 179
169 Config cfg( dir.path() + "/" + file + "/.directory", Config::File ); 180 Config cfg( dir.path() + "/" + file + "/.directory", Config::File );
170 if ( !cfg.isValid() ) return; 181 if ( !cfg.isValid() ) return;
171 182
172 QString name = cfg.readEntry( "Name" ); 183 QString name = cfg.readEntry( "Name" );
173 QString icon = cfg.readEntry( "Icon" ); 184 QString icon = cfg.readEntry( "Icon" );
174 if ( !name || !icon ) return; 185 if ( !name || !icon ) return;
175 186
176 QDir subdir = QDir( dir ); 187 QDir subdir = QDir( dir );
177 subdir.cd( file ); 188 subdir.cd( file );
178 subdir.setFilter( QDir::Files ); 189 subdir.setFilter( QDir::Files );
179 subdir.setNameFilter( "*.desktop" ); 190 subdir.setNameFilter( "*.desktop" );
180 // we don' t show the menu if there are no entries 191 // we don' t show the menu if there are no entries
181 // perhaps one should check if there exist subsubdirs with entries... 192 // perhaps one should check if there exist subsubdirs with entries...