-rw-r--r-- | core/launcher/startmenu.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/core/launcher/startmenu.cpp b/core/launcher/startmenu.cpp index f17c7f8..b84eed8 100644 --- a/core/launcher/startmenu.cpp +++ b/core/launcher/startmenu.cpp | |||
@@ -103,102 +103,104 @@ void StartMenu::createMenu() | |||
103 | void StartMenu::refreshMenu() | 103 | void StartMenu::refreshMenu() |
104 | { | 104 | { |
105 | Config cfg( "StartMenu" ); | 105 | Config cfg( "StartMenu" ); |
106 | cfg.setGroup( "Menu" ); | 106 | cfg.setGroup( "Menu" ); |
107 | bool ltabs = cfg.readBoolEntry( "LauncherTabs", TRUE ); | 107 | bool ltabs = cfg.readBoolEntry( "LauncherTabs", TRUE ); |
108 | bool lot = cfg.readBoolEntry( "LauncherOther", TRUE ); | 108 | bool lot = cfg.readBoolEntry( "LauncherOther", TRUE ); |
109 | useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE ); | 109 | useWidePopupMenu = cfg.readBoolEntry( "LauncherSubPopup", TRUE ); |
110 | 110 | ||
111 | if ( launchMenu && !(ltabs || lot) ) return; // nothing to do | 111 | if ( launchMenu && !(ltabs || lot) ) return; // nothing to do |
112 | 112 | ||
113 | createMenu(); | 113 | createMenu(); |
114 | } | 114 | } |
115 | 115 | ||
116 | void StartMenu::itemSelected( int id ) | 116 | void StartMenu::itemSelected( int id ) |
117 | { | 117 | { |
118 | if ( id == NO_ID ) return; | 118 | if ( id == NO_ID ) return; |
119 | 119 | ||
120 | if ( id < 0 ) { | 120 | if ( id < 0 ) { |
121 | MenuApplet *applet = menuApplets.find( id ); | 121 | MenuApplet *applet = menuApplets.find( id ); |
122 | if ( applet ) { | 122 | if ( applet ) { |
123 | applet->iface->activated(); | 123 | applet->iface->activated(); |
124 | } | 124 | } |
125 | } else if ( id >= APPLNK_ID_OFFSET ) { | 125 | } else if ( id >= APPLNK_ID_OFFSET ) { |
126 | AppLnk * appLnk = appLnks.find( id ); | 126 | AppLnk * appLnk = appLnks.find( id ); |
127 | if ( appLnk ) { | 127 | if ( appLnk ) { |
128 | appLnk->execute(); | 128 | appLnk->execute(); |
129 | } | 129 | } |
130 | } else { | 130 | } else { |
131 | QString *tabName = tabNames.find( id ); | 131 | QString *tabName = tabNames.find( id ); |
132 | if ( tabName ) { | 132 | if ( tabName ) { |
133 | emit tabSelected( *tabName ); | 133 | emit tabSelected( *tabName ); |
134 | } | 134 | } |
135 | } | 135 | } |
136 | } | 136 | } |
137 | 137 | ||
138 | void StartMenu::createAppEntry( QPopupMenu *menu, QDir dir, QString file ) | 138 | void StartMenu::createAppEntry( QPopupMenu *menu, QDir dir, QString file ) |
139 | { | 139 | { |
140 | if ( file.right(8) == ".desktop" ) { | 140 | if ( file.right(8) == ".desktop" ) { |
141 | AppLnk* applnk = new AppLnk( dir.path() + "/" + file ); | 141 | AppLnk* applnk = new AppLnk( dir.path() + "/" + file ); |
142 | if ( !applnk->isValid() ) { | 142 | if ( !applnk->isValid() ) { |
143 | delete applnk; | 143 | delete applnk; |
144 | return; | 144 | return; |
145 | } | 145 | } |
146 | 146 | ||
147 | if ( applnk->type() == "Separator" ) { // No tr | 147 | if ( applnk->type() == "Separator" ) { // No tr |
148 | menu->insertSeparator(); | 148 | menu->insertSeparator(); |
149 | delete applnk; | 149 | delete applnk; |
150 | } else { | 150 | } else { |
151 | QPixmap test; | 151 | QPixmap test; |
152 | test.convertFromImage( | 152 | QImage img = Resource::loadImage( applnk->icon() ); |
153 | Resource::loadImage( applnk->icon() ).smoothScale( | 153 | if(!img.isNull() ) |
154 | AppLnk::smallIconSize(), AppLnk::smallIconSize() ), 0 ); | 154 | test.convertFromImage( |
155 | 155 | img.smoothScale( | |
156 | menu->insertItem( test, applnk->name(), | 156 | AppLnk::smallIconSize(), AppLnk::smallIconSize() ), 0 ); |
157 | |||
158 | menu->insertItem( test, applnk->name(), | ||
157 | currentItem + APPLNK_ID_OFFSET ); | 159 | currentItem + APPLNK_ID_OFFSET ); |
158 | appLnks.insert( currentItem + APPLNK_ID_OFFSET, applnk ); | 160 | appLnks.insert( currentItem + APPLNK_ID_OFFSET, applnk ); |
159 | currentItem++; | 161 | currentItem++; |
160 | } | 162 | } |
161 | } | 163 | } |
162 | 164 | ||
163 | } | 165 | } |
164 | 166 | ||
165 | void StartMenu::createDirEntry( QPopupMenu *menu, QDir dir, QString file, bool lot ) | 167 | void StartMenu::createDirEntry( QPopupMenu *menu, QDir dir, QString file, bool lot ) |
166 | { | 168 | { |
167 | // do some sanity checks and collect information | 169 | // do some sanity checks and collect information |
168 | 170 | ||
169 | if ( file == "." || file == ".." ) return; | 171 | if ( file == "." || file == ".." ) return; |
170 | 172 | ||
171 | Config cfg( dir.path() + "/" + file + "/.directory", Config::File ); | 173 | Config cfg( dir.path() + "/" + file + "/.directory", Config::File ); |
172 | if ( !cfg.isValid() ) return; | 174 | if ( !cfg.isValid() ) return; |
173 | 175 | ||
174 | QString name = cfg.readEntry( "Name" ); | 176 | QString name = cfg.readEntry( "Name" ); |
175 | QString icon = cfg.readEntry( "Icon" ); | 177 | QString icon = cfg.readEntry( "Icon" ); |
176 | if ( !name || !icon ) return; | 178 | if ( !name || !icon ) return; |
177 | 179 | ||
178 | QDir subdir = QDir( dir ); | 180 | QDir subdir = QDir( dir ); |
179 | subdir.cd( file ); | 181 | subdir.cd( file ); |
180 | subdir.setFilter( QDir::Files ); | 182 | subdir.setFilter( QDir::Files ); |
181 | subdir.setNameFilter( "*.desktop" ); | 183 | subdir.setNameFilter( "*.desktop" ); |
182 | // we don' t show the menu if there are no entries | 184 | // we don' t show the menu if there are no entries |
183 | // perhaps one should check if there exist subsubdirs with entries... | 185 | // perhaps one should check if there exist subsubdirs with entries... |
184 | if ( subdir.entryList().isEmpty() ) return; | 186 | if ( subdir.entryList().isEmpty() ) return; |
185 | 187 | ||
186 | // checks were ok | 188 | // checks were ok |
187 | 189 | ||
188 | QPixmap test; | 190 | QPixmap test; |
189 | test.convertFromImage( Resource::loadImage( icon ).smoothScale( | 191 | test.convertFromImage( Resource::loadImage( icon ).smoothScale( |
190 | AppLnk::smallIconSize(), AppLnk::smallIconSize() ), 0 ); | 192 | AppLnk::smallIconSize(), AppLnk::smallIconSize() ), 0 ); |
191 | 193 | ||
192 | if ( useWidePopupMenu ) { | 194 | if ( useWidePopupMenu ) { |
193 | // generate submenu | 195 | // generate submenu |
194 | QPopupMenu *submenu = new QPopupMenu( menu ); | 196 | QPopupMenu *submenu = new QPopupMenu( menu ); |
195 | connect( submenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); | 197 | connect( submenu, SIGNAL(activated(int)), SLOT(itemSelected(int)) ); |
196 | menu->insertItem( test, name, submenu, NO_ID ); | 198 | menu->insertItem( test, name, submenu, NO_ID ); |
197 | 199 | ||
198 | // ltabs is true cause else we wouldn't stuck around.. | 200 | // ltabs is true cause else we wouldn't stuck around.. |
199 | createMenuEntries( submenu, subdir, true, lot ); | 201 | createMenuEntries( submenu, subdir, true, lot ); |
200 | } else { | 202 | } else { |
201 | // no submenus - just bring corresponding tab to front | 203 | // no submenus - just bring corresponding tab to front |
202 | menu->insertItem( test, name, currentItem ); | 204 | menu->insertItem( test, name, currentItem ); |
203 | tabNames.insert( currentItem, new QString( file ) ); | 205 | tabNames.insert( currentItem, new QString( file ) ); |
204 | currentItem++; | 206 | currentItem++; |