Don't show the default profile in list when no others are listed.

When user selects only 1 profile to be listed in menu, it makes the
'New Tab->' list unnecessary.  No profile will listed if the only
selected profile is the default one.

Patch by Francesco Cecconi <francesco.cecconi@gmail.com>

BUG: 245478
REVIEW: 102670
FIXED-IN: 4.8
wilder-portage
Kurt Hindenburg 15 years ago
parent 3e75622bd8
commit 127c2b523e
  1. 48
      src/MainWindow.cpp

@ -329,23 +329,43 @@ void MainWindow::setSessionList(ProfileList* list)
void MainWindow::sessionListChanged(const QList<QAction*>& actions)
{
// Update the 'New Tab' KActionMenu
KMenu *newTabMenu = _newTabMenuAction->menu();
newTabMenu->clear();
foreach (QAction *action, actions) {
newTabMenu->addAction(action);
// NOTE: _defaultProfile seems to not work here, sigh.
Profile::Ptr profile = SessionManager::instance()->defaultProfile();
if (profile && profile->name() == action->text()) {
action->setIcon(KIcon(profile->icon(), NULL, QStringList("emblem-favorite")));
newTabMenu->setDefaultAction(action);
QFont font = action->font();
font.setBold(true);
action->setFont(font);
// If only 1 profile is to be shown in the menu, only display
// it if it is the non-default profile.
if (actions.size() > 2)
{
// Update the 'New Tab' KActionMenu
KMenu *newTabMenu = _newTabMenuAction->menu();
newTabMenu->clear();
foreach (QAction *action, actions) {
newTabMenu->addAction(action);
// NOTE: _defaultProfile seems to not work here, sigh.
Profile::Ptr profile = SessionManager::instance()->defaultProfile();
if (profile && profile->name() == action->text().remove('&')) {
action->setIcon(KIcon(profile->icon(), NULL, QStringList("emblem-favorite")));
newTabMenu->setDefaultAction(action);
QFont font = action->font();
font.setBold(true);
action->setFont(font);
}
}
}
else
{
KMenu *newTabMenu = _newTabMenuAction->menu();
newTabMenu->clear();
Profile::Ptr profile = SessionManager::instance()->defaultProfile();
// NOTE: Compare names w/o any '&'
if (actions.size() == 2 && actions[1]->text().remove('&') != profile->name())
{
newTabMenu->addAction(actions[1]);
}
else
{
delete newTabMenu;
}
}
}
QString MainWindow::activeSessionDir() const

Loading…
Cancel
Save