Summary: | Bizarre sort order in Terminal Sessions Menu | ||
---|---|---|---|
Product: | [Applications] konsole | Reporter: | Justin Sheckler <justin> |
Component: | general | Assignee: | Konsole Developer <konsole-devel> |
Status: | RESOLVED FIXED | ||
Severity: | normal | ||
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Slackware | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: |
Description
Justin Sheckler
2003-05-06 21:59:52 UTC
Subject: kdebase/kicker/menuext/konsole CVS commit by waba: CCMAIL: 58187-done@bugs.kde.org Bring kicker's konsole menu in sync with the one in konsole. (BR58187) M +37 -7 konsole_mnu.cpp 1.5 --- kdebase/kicker/menuext/konsole/konsole_mnu.cpp #1.4:1.5 @@ -63,13 +63,42 @@ KonsoleMenu::~KonsoleMenu() } +static void insertItemSorted(KPopupMenu *menu, const QIconSet &iconSet, const QString &txt, int id) +{ + const int defaultId = 1; // The id of the 'new' item. + int index = menu->indexOf(defaultId); + int count = menu->count(); + if (index >= 0) + { + index++; // Skip separator + while(true) + { + index++; + if (index >= count) + { + index = -1; // Insert at end + break; + } + if (menu->text(menu->idAt(index)) > txt) + break; // Insert before this item + } + } + menu->insertItem(iconSet, txt, id, index); +} + + void KonsoleMenu::initialize() { QStringList list = KGlobal::dirs()->findAllResources("data", "konsole/*.desktop", false, true); - int id = 0; + QString defaultShell = locate("data", "konsole/shell.desktop"); + list.prepend(defaultShell); + + int id = 1; sessionList.clear(); for (QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) { + if ((*it == defaultShell) && (id != 1)) + continue; KSimpleConfig conf(*it, true /* read only */); conf.setDesktopGroup(); @@ -82,9 +111,5 @@ void KonsoleMenu::initialize() } - int pos = exec.find(' '); - if (pos > 0) { - exec = exec.left(pos); - } - + exec = KRun::binaryName(exec, false); QString pexec = KGlobal::dirs()->findExe(exec); if (text.isEmpty() || conf.readEntry("Type") != "KonsoleApplication" @@ -93,10 +118,14 @@ void KonsoleMenu::initialize() continue; } - insertItem(SmallIconSet(conf.readEntry("Icon", "konsole")), text, id++); + insertItemSorted(this, SmallIconSet(conf.readEntry("Icon", "openterm")), text, id++); QFileInfo fi(*it); sessionList.append(fi.baseName()); + + if (id == 2) + insertSeparator(); } bookmarkHandlerSession = new KonsoleBookmarkHandler( this, false ); m_bookmarksSession = bookmarkHandlerSession->menu(); + insertSeparator(); insertItem(SmallIconSet("keditbookmarks"), i18n("New Session at Bookmark"), m_bookmarksSession); @@ -138,4 +167,5 @@ void KonsoleMenu::initialize() void KonsoleMenu::slotExec(int id) { + id--; if (id >= 0) { |