|
Lines 111-116
Link Here
|
| 111 |
QStringList suppressGenericNames = _root->suppressGenericNames(); |
111 |
QStringList suppressGenericNames = _root->suppressGenericNames(); |
| 112 |
|
112 |
|
| 113 |
KServiceGroup::List::ConstIterator it = _list.begin(); |
113 |
KServiceGroup::List::ConstIterator it = _list.begin(); |
|
|
114 |
KSortableValueList<KSharedPtr<KSycocaEntry>,QCString> slist; |
| 115 |
KSortableValueList<KSharedPtr<KSycocaEntry>,QCString> glist; |
| 116 |
QMap<QString,QString> specialTitle; |
| 117 |
QMap<QString,QString> categoryIcon; |
| 118 |
|
| 114 |
bool separatorNeeded = false; |
119 |
bool separatorNeeded = false; |
| 115 |
for (; it != _list.end(); ++it) |
120 |
for (; it != _list.end(); ++it) |
| 116 |
{ |
121 |
{ |
|
Lines 118-136
Link Here
|
| 118 |
|
123 |
|
| 119 |
if (e->isType(KST_KServiceGroup)) |
124 |
if (e->isType(KST_KServiceGroup)) |
| 120 |
{ |
125 |
{ |
|
|
126 |
KServiceGroup::Ptr g(static_cast<KServiceGroup *>(e)); |
| 127 |
if ( KickerSettings::reduceMenuDepth() && g->SuSEshortMenu() ){ |
| 128 |
KServiceGroup::List l = g->entries(true, excludeNoDisplay_ ); |
| 129 |
if ( l.count() == 1 ) { |
| 130 |
// the special case, we want to short the menu. |
| 131 |
// TOFIX? : this works only for one level |
| 132 |
KServiceGroup::List::ConstIterator _it=l.begin(); |
| 133 |
KSycocaEntry *_e = *_it; |
| 134 |
if (_e->isType(KST_KService)) { |
| 135 |
KService::Ptr s(static_cast<KService *>(_e)); |
| 136 |
QString key; |
| 137 |
if ( g->SuSEgeneralDescription() ) { |
| 138 |
// we use the application name |
| 139 |
key = s->name(); |
| 140 |
if( !s->genericName().isEmpty()) { |
| 141 |
if (KickerSettings::menuEntryFormat() == KickerSettings::NameAndDescription) |
| 142 |
key = s->name() + " (" + s->genericName() + ")"; |
| 143 |
else if (KickerSettings::menuEntryFormat() == KickerSettings::DescriptionAndName) |
| 144 |
key = s->genericName() + " (" + s->name() + ")"; |
| 145 |
else if (KickerSettings::menuEntryFormat() == KickerSettings::DescriptionOnly) |
| 146 |
key = s->genericName(); |
| 147 |
} |
| 148 |
} |
| 149 |
else |
| 150 |
// we use the normal menu description |
| 151 |
key = g->caption(); |
| 152 |
specialTitle.insert( _e->name(), key ); |
| 153 |
categoryIcon.insert( _e->name(), g->icon() ); |
| 154 |
// slist.insert( key.local8Bit(), _e ); |
| 155 |
// and escape from here |
| 156 |
continue; |
| 157 |
} |
| 158 |
} |
| 159 |
} |
| 160 |
glist.insert( g->caption().local8Bit(), e ); |
| 161 |
}else if( e->isType(KST_KService)) { |
| 162 |
KService::Ptr s(static_cast<KService *>(e)); |
| 163 |
QString name = s->name(); |
| 164 |
if( !s->genericName().isEmpty()) { |
| 165 |
if (KickerSettings::menuEntryFormat() == KickerSettings::NameAndDescription) |
| 166 |
name = s->name() + " (" + s->genericName() + ")"; |
| 167 |
else if (KickerSettings::menuEntryFormat() == KickerSettings::DescriptionAndName) |
| 168 |
name = s->genericName() + " (" + s->name() + ")"; |
| 169 |
else if (KickerSettings::menuEntryFormat() == KickerSettings::DescriptionOnly) |
| 170 |
name = s->genericName(); |
| 171 |
} |
| 172 |
slist.insert( name.local8Bit(), e ); |
| 173 |
} else |
| 174 |
slist.insert( e->name().local8Bit(), e ); |
| 175 |
} |
| 176 |
|
| 177 |
_list = _root->SuSEsortEntries( slist, glist, excludeNoDisplay_, true ); |
| 178 |
it = _list.begin(); |
| 179 |
|
| 180 |
for (; it != _list.end(); ++it) { |
| 121 |
|
181 |
|
|
|
182 |
KSycocaEntry * e = *it; |
| 183 |
|
| 184 |
if (e->isType(KST_KServiceGroup)) { |
| 122 |
KServiceGroup::Ptr g(static_cast<KServiceGroup *>(e)); |
185 |
KServiceGroup::Ptr g(static_cast<KServiceGroup *>(e)); |
|
|
186 |
if ( KickerSettings::reduceMenuDepth() && g->SuSEshortMenu() ){ |
| 187 |
KServiceGroup::List l = g->entries(true, excludeNoDisplay_ ); |
| 188 |
if ( l.count() == 1 ) { |
| 189 |
// the special case, we want to short the menu. |
| 190 |
// TOFIX? : this works only for one level |
| 191 |
KServiceGroup::List::ConstIterator _it=l.begin(); |
| 192 |
KSycocaEntry *_e = *_it; |
| 193 |
if (_e->isType(KST_KService)) { |
| 194 |
KService::Ptr s(static_cast<KService *>(_e)); |
| 195 |
if ( g->SuSEgeneralDescription() ) |
| 196 |
// we use the application name |
| 197 |
insertMenuItem(s, id++, -1, 0, QString::null, QString::null, g->icon() ); |
| 198 |
else |
| 199 |
// we use the normal menu description |
| 200 |
insertMenuItem(s, id++, -1, 0, QString::null, g->caption(), g->icon() ); |
| 201 |
// and escape from here |
| 202 |
continue; |
| 203 |
} |
| 204 |
} |
| 205 |
} |
| 206 |
// standard sub menu |
| 207 |
|
| 123 |
QString groupCaption = g->caption(); |
208 |
QString groupCaption = g->caption(); |
| 124 |
|
209 |
|
| 125 |
// Avoid adding empty groups. |
210 |
// Avoid adding empty groups. |
| 126 |
KServiceGroup::Ptr subMenuRoot = KServiceGroup::group(g->relPath()); |
211 |
KServiceGroup::Ptr subMenuRoot = KServiceGroup::group(g->relPath()); |
| 127 |
|
212 |
|
| 128 |
int nbChildCount = subMenuRoot->childCount(); |
213 |
int nbChildCount = subMenuRoot->childCount(); |
| 129 |
if (nbChildCount == 0 && !g->showEmptyMenu()) |
214 |
if (nbChildCount == 0 && !g->showEmptyMenu()) |
| 130 |
{ |
215 |
{ |
| 131 |
continue; |
216 |
continue; |
| 132 |
} |
217 |
} |
| 133 |
|
218 |
|
| 134 |
QString inlineHeaderName = g->showInlineHeader() ? groupCaption : ""; |
219 |
QString inlineHeaderName = g->showInlineHeader() ? groupCaption : ""; |
| 135 |
// Item names may contain ampersands. To avoid them being converted |
220 |
// Item names may contain ampersands. To avoid them being converted |
| 136 |
// to accelerators, replace them with two ampersands. |
221 |
// to accelerators, replace them with two ampersands. |
|
Lines 214-220
Link Here
|
| 214 |
} |
299 |
} |
| 215 |
|
300 |
|
| 216 |
KService::Ptr s(static_cast<KService *>(e)); |
301 |
KService::Ptr s(static_cast<KService *>(e)); |
| 217 |
insertMenuItem(s, id++, -1, &suppressGenericNames); |
302 |
insertMenuItem(s, id++, -1, &suppressGenericNames, QString::null, specialTitle[s->name()], categoryIcon[s->name()] ); |
| 218 |
} |
303 |
} |
| 219 |
else if (e->isType(KST_KServiceSeparator)) |
304 |
else if (e->isType(KST_KServiceSeparator)) |
| 220 |
{ |
305 |
{ |
|
Lines 350-356
Link Here
|
| 350 |
void PanelServiceMenu::insertMenuItem(KService::Ptr & s, int nId, |
435 |
void PanelServiceMenu::insertMenuItem(KService::Ptr & s, int nId, |
| 351 |
int nIndex/*= -1*/, |
436 |
int nIndex/*= -1*/, |
| 352 |
const QStringList *suppressGenericNames /* = 0 */, |
437 |
const QStringList *suppressGenericNames /* = 0 */, |
| 353 |
const QString & aliasname) |
438 |
const QString & aliasname, const QString & label /*=QString::NULL*/, |
|
|
439 |
const QString & categoryIcon /*=QString::null*/) |
| 354 |
{ |
440 |
{ |
| 355 |
QString serviceName = aliasname.isEmpty() ? s->name():aliasname; |
441 |
QString serviceName = aliasname.isEmpty() ? s->name():aliasname; |
| 356 |
// add comment |
442 |
// add comment |
|
Lines 393-399
Link Here
|
| 393 |
// to accelerators, replace them with two ampersands. |
479 |
// to accelerators, replace them with two ampersands. |
| 394 |
serviceName.replace("&", "&&"); |
480 |
serviceName.replace("&", "&&"); |
| 395 |
|
481 |
|
| 396 |
int newId = insertItem(getIconSet(s->icon()), serviceName, nId, nIndex); |
482 |
QString icon = s->icon(); |
|
|
483 |
if (icon=="unknown") |
| 484 |
icon = categoryIcon; |
| 485 |
|
| 486 |
int newId; |
| 487 |
if ( label.isEmpty() ) |
| 488 |
newId = insertItem(getIconSet(icon), serviceName, nId, nIndex); |
| 489 |
else |
| 490 |
newId = insertItem(getIconSet(icon), label, nId, nIndex); |
| 397 |
entryMap_.insert(newId, static_cast<KSycocaEntry*>(s)); |
491 |
entryMap_.insert(newId, static_cast<KSycocaEntry*>(s)); |
| 398 |
} |
492 |
} |
| 399 |
|
493 |
|