mirror of
https://github.com/KDE/konsole.git
synced 2026-02-02 19:31:31 -05:00
Go to Settings -> Edit Current Profile -> Tabs page and tick "Show 'New tab' button in tab bar" This was added for the benefit of users with existing habits from KDE 3 and is not shown by default. * Add close buttons on tabs using the new style ppenz added to KTabBar * Add confirmation when closing via middle-click/close button if a program other than a shell or nested shell is running in the foreground of that session. BUG: 157015 Squashed commit of the following: commit 54a5db9c31a5527e44d7358b30587c28bab965bc Author: Robert Knight <robertknight@gmail.com> Date: Fri May 2 01:48:05 2008 +0100 UI text correction: 'on tab bar' -> 'in tab bar' commit ed8e70238e2cc4240f8334cd091fa2707785a908 Author: Robert Knight <robertknight@gmail.com> Date: Fri May 2 01:46:42 2008 +0100 Do not show the confirm-on-close prompt if the foreground program is another shell. commit 010370c12950a532d93c99d0983c74c47e26ad07 Author: Robert Knight <robertknight@gmail.com> Date: Fri May 2 01:40:05 2008 +0100 Add a confirmation which is displayed when closing a tab via middle-click / close button if the program has an active program running in the session (other than the shell itself). commit 49812e26e5fd8c44dd01f1a6a4c0e7271c6366fd Author: Robert Knight <robertknight@gmail.com> Date: Fri May 2 01:25:29 2008 +0100 Add confirmClose() method to ViewProperties which is can be re-implemented to prompt whether to close the session. Make the presence of the close button in the ViewContainer dependent on a QuickCloseView feature being enabled. commit ece191ad5ad550af47cd2ca0bc75a517119e7189 Author: Robert Knight <robertknight@gmail.com> Date: Fri May 2 01:09:17 2008 +0100 Show 'close' button on tabs using the new close button style added to KTabBar by ppenz. commit f975f04c993effdd2afef588c5f765192b6fab5a Author: Robert Knight <robertknight@gmail.com> Date: Fri May 2 01:03:54 2008 +0100 Better UI text for 'Show New Tab' option. commit 642c5b1d07cd2288c78446efe395da050730decb Author: Robert Knight <robertknight@gmail.com> Date: Thu May 1 21:04:47 2008 +0100 Sync 'new tab' tab bar menu actions with profile list. commit c6c556980e43afcb1bb5fdfaaa9dd7e12e524688 Author: Robert Knight <robertknight@gmail.com> Date: Wed Apr 30 23:01:34 2008 +0100 Hook up actions in new tab popup menu so a new tab is created with the right profile when an action is chosen. commit dece8a23ff101dda47d495ba38e57e55059c4e63 Author: Robert Knight <robertknight@gmail.com> Date: Wed Apr 30 22:51:28 2008 +0100 Apply ShowNewTabButton profile property to current view container. commit e244a95512dc535198fa69c3afe34b597402de15 Author: Robert Knight <robertknight@gmail.com> Date: Wed Apr 30 22:50:57 2008 +0100 Add support for enabling/disabling a 'quick new view' widget in view containers. Add an implementation of it (quick new tab button) in TabbedViewContainerV2 commit 9fdc2e450aefb9b602f8fb6b66d3508e6750531b Author: Robert Knight <robertknight@gmail.com> Date: Wed Apr 30 22:50:22 2008 +0100 Hook up 'Show new tab button' UI option. commit 7326e6dccbc095f0f784fd6f4da532f250ca5437 Author: Robert Knight <robertknight@gmail.com> Date: Wed Apr 30 22:50:04 2008 +0100 Add ShowNewTabButton profile property and set a default for it (false) commit 273f85f0d21d8b755712c67c50a939400f15a169 Author: Robert Knight <robertknight@gmail.com> Date: Wed Apr 30 21:22:09 2008 +0100 Add checkbox for toggling new tab menu button. commit 200744ce620cd6bd9a9d1791e62863c618921788 Author: Robert Knight <robertknight@gmail.com> Date: Wed Apr 30 21:21:33 2008 +0100 Formatting. Remove extra lines. svn path=/trunk/KDE/kdebase/apps/konsole/; revision=803112
184 lines
4.9 KiB
C++
184 lines
4.9 KiB
C++
/*
|
|
Copyright 2006-2008 by Robert Knight <robertknight@gmail.com>
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
|
02110-1301 USA.
|
|
*/
|
|
|
|
// Own
|
|
#include "ProfileList.h"
|
|
|
|
// Qt
|
|
#include <QtGui/QAction>
|
|
#include <QtGui/QActionGroup>
|
|
#include <KDebug>
|
|
|
|
// KDE
|
|
#include <KIcon>
|
|
#include <KLocalizedString>
|
|
|
|
// Konsole
|
|
#include "SessionManager.h"
|
|
|
|
using namespace Konsole;
|
|
|
|
ProfileList::ProfileList(bool addShortcuts , QObject* parent)
|
|
: QObject(parent)
|
|
, _addShortcuts(addShortcuts)
|
|
, _emptyListAction(0)
|
|
{
|
|
SessionManager* manager = SessionManager::instance();
|
|
|
|
// construct the list of favorite session types
|
|
_group = new QActionGroup(this);
|
|
|
|
// disabled action to be shown only when the list is empty
|
|
_emptyListAction = new QAction(i18n("No profiles available"),_group);
|
|
_emptyListAction->setEnabled(false);
|
|
|
|
// TODO Sort list in alphabetical order
|
|
QList<Profile::Ptr> list = manager->findFavorites().toList();
|
|
QListIterator<Profile::Ptr> iter(list);
|
|
|
|
while (iter.hasNext())
|
|
{
|
|
favoriteChanged(iter.next(),true);
|
|
}
|
|
|
|
connect( _group , SIGNAL(triggered(QAction*)) , this , SLOT(triggered(QAction*)) );
|
|
|
|
|
|
// listen for future changes to the session list
|
|
connect( manager , SIGNAL(favoriteStatusChanged(Profile::Ptr,bool)) , this ,
|
|
SLOT(favoriteChanged(Profile::Ptr,bool)) );
|
|
connect( manager , SIGNAL(shortcutChanged(Profile::Ptr,QKeySequence)) , this ,
|
|
SLOT(shortcutChanged(Profile::Ptr,QKeySequence)) );
|
|
connect( manager , SIGNAL(profileChanged(Profile::Ptr)) , this ,
|
|
SLOT(profileChanged(Profile::Ptr)) );
|
|
}
|
|
void ProfileList::updateEmptyAction()
|
|
{
|
|
Q_ASSERT( _group );
|
|
Q_ASSERT( _emptyListAction );
|
|
|
|
// show empty list action when it is the only action
|
|
// in the group
|
|
const bool showEmptyAction = _group->actions().count() == 1;
|
|
|
|
if ( showEmptyAction != _emptyListAction->isVisible() )
|
|
_emptyListAction->setVisible(showEmptyAction);
|
|
}
|
|
QAction* ProfileList::actionForKey(Profile::Ptr key) const
|
|
{
|
|
QListIterator<QAction*> iter(_group->actions());
|
|
while ( iter.hasNext() )
|
|
{
|
|
QAction* next = iter.next();
|
|
if ( next->data().value<Profile::Ptr>() == key )
|
|
return next;
|
|
}
|
|
return 0; // not found
|
|
}
|
|
|
|
void ProfileList::profileChanged(Profile::Ptr key)
|
|
{
|
|
QAction* action = actionForKey(key);
|
|
if ( action )
|
|
updateAction(action,key);
|
|
}
|
|
|
|
void ProfileList::updateAction(QAction* action , Profile::Ptr info)
|
|
{
|
|
Q_ASSERT(action);
|
|
Q_ASSERT(info);
|
|
|
|
action->setText(info->name());
|
|
action->setIcon(KIcon(info->icon()));
|
|
}
|
|
void ProfileList::shortcutChanged(Profile::Ptr info,const QKeySequence& sequence)
|
|
{
|
|
if ( !_addShortcuts )
|
|
return;
|
|
|
|
QAction* action = actionForKey(info);
|
|
|
|
if ( action )
|
|
{
|
|
action->setShortcut(sequence);
|
|
}
|
|
}
|
|
void ProfileList::syncWidgetActions(QWidget* widget, bool sync)
|
|
{
|
|
if (!sync)
|
|
{
|
|
_registeredWidgets.remove(widget);
|
|
return;
|
|
}
|
|
|
|
_registeredWidgets.insert(widget);
|
|
|
|
const QList<QAction*> currentActions = widget->actions();
|
|
foreach(QAction* currentAction, currentActions)
|
|
widget->removeAction(currentAction);
|
|
|
|
widget->addActions(_group->actions());
|
|
}
|
|
void ProfileList::favoriteChanged(Profile::Ptr info,bool isFavorite)
|
|
{
|
|
SessionManager* manager = SessionManager::instance();
|
|
|
|
if ( isFavorite )
|
|
{
|
|
QAction* action = new QAction(_group);
|
|
action->setData( QVariant::fromValue(info) );
|
|
|
|
if ( _addShortcuts )
|
|
{
|
|
action->setShortcut(manager->shortcut(info));
|
|
}
|
|
|
|
updateAction(action,info);
|
|
|
|
foreach(QWidget* widget,_registeredWidgets)
|
|
widget->addAction(action);
|
|
emit actionsChanged(_group->actions());
|
|
}
|
|
else
|
|
{
|
|
QAction* action = actionForKey(info);
|
|
|
|
if ( action )
|
|
{
|
|
_group->removeAction(action);
|
|
foreach(QWidget* widget,_registeredWidgets)
|
|
widget->removeAction(action);
|
|
emit actionsChanged(_group->actions());
|
|
}
|
|
}
|
|
|
|
updateEmptyAction();
|
|
}
|
|
void ProfileList::triggered(QAction* action)
|
|
{
|
|
emit profileSelected( action->data().value<Profile::Ptr>() );
|
|
}
|
|
|
|
QList<QAction*> ProfileList::actions()
|
|
{
|
|
return _group->actions();
|
|
}
|
|
|
|
#include "ProfileList.moc"
|