* Add option to show new tab button with delayed popup menu on tab bar.

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
This commit is contained in:
Robert Knight
2008-05-02 00:59:47 +00:00
parent c5bfff3db3
commit 34a9e7ec42
15 changed files with 238 additions and 55 deletions

View File

@@ -28,7 +28,6 @@
#include <QtGui/QLineEdit>
#include <QtGui/QBrush>
#include <QtGui/QListWidget>
#include <QtGui/QPushButton>
#include <QtGui/QSplitter>
#include <QtGui/QStackedWidget>
#include <QtGui/QTabBar>
@@ -74,7 +73,10 @@ ViewContainer::~ViewContainer()
emit destroyed(this);
}
void ViewContainer::moveViewWidget( int , int ) {}
void ViewContainer::setFeatures(Features features)
{ _features = features; }
ViewContainer::Features ViewContainer::features() const
{ return _features; }
void ViewContainer::moveActiveView( MoveDirection direction )
{
const int currentIndex = _views.indexOf( activeView() ) ;
@@ -613,17 +615,33 @@ TabbedViewContainerV2::TabbedViewContainerV2(NavigationPosition position , QObje
_stackWidget = new QStackedWidget();
_tabBar = new ViewContainerTabBar(_containerWidget,this);
_tabBar->setDrawBase(true);
_newTabButton = new KPushButton(KIcon("tab-new"),QString(),_containerWidget);
// The button width here is hard coded, it would be better to use the value from
// the current style (see QTabWidget::setUpLayout())
_newTabButton->setFixedWidth(50);
_newTabButton->setFlat(true);
// new tab button is initially hidden, it will be shown when setFeatures() is called
// with the QuickNewView flag enabled
_newTabButton->setHidden(true);
connect( _tabBar , SIGNAL(currentChanged(int)) , this , SLOT(currentTabChanged(int)) );
connect( _tabBar , SIGNAL(tabDoubleClicked(int)) , this , SLOT(tabDoubleClicked(int)) );
connect( _tabBar , SIGNAL(newTabRequest()) , this , SIGNAL(newViewRequest()) );
connect( _tabBar , SIGNAL(wheelDelta(int)) , this , SLOT(wheelScrolled(int)) );
connect( _tabBar , SIGNAL(mouseMiddleClick(int)) , this , SLOT(closeTab(int)) );
connect( _tabBar , SIGNAL(closeRequest(int)) , this , SLOT(closeTab(int)) );
connect( _tabBar , SIGNAL(initiateDrag(int)) , this , SLOT(startTabDrag(int)) );
connect( _newTabButton , SIGNAL(clicked()) , this , SIGNAL(newViewRequest()) );
_layout = new TabbedViewContainerV2Layout;
_layout->setSpacing(0);
_layout->setMargin(0);
_tabBarLayout = new QHBoxLayout;
_tabBarLayout->setSpacing(0);
_tabBarLayout->setMargin(0);
_tabBarLayout->addWidget(_newTabButton);
_tabBarLayout->addWidget(_tabBar);
_tabBarSpacer = new QSpacerItem(0,TabBarSpace);
@@ -631,13 +649,13 @@ TabbedViewContainerV2::TabbedViewContainerV2(NavigationPosition position , QObje
if ( position == NavigationPositionTop )
{
_layout->insertWidget(0,_tabBar);
_layout->insertLayout(0,_tabBarLayout);
_layout->insertItemAt(0,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedNorth);
}
else if ( position == NavigationPositionBottom )
{
_layout->insertWidget(-1,_tabBar);
_layout->insertLayout(-1,_tabBarLayout);
_layout->insertItemAt(-1,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedSouth);
}
@@ -646,14 +664,38 @@ TabbedViewContainerV2::TabbedViewContainerV2(NavigationPosition position , QObje
_containerWidget->setLayout(_layout);
}
void TabbedViewContainerV2::setNewViewMenu(QMenu* menu)
{ _newTabButton->setDelayedMenu(menu); }
ViewContainer::Features TabbedViewContainerV2::supportedFeatures() const
{ return QuickNewView; }
void TabbedViewContainerV2::setFeatures(Features features)
{
ViewContainer::setFeatures(features);
if (features & QuickNewView)
{
_newTabButton->setHidden(false);
_newTabButton->show();
}
else
_newTabButton->setHidden(true);
if (features & QuickCloseView)
_tabBar->setCloseButtonEnabled(true);
else
_tabBar->setCloseButtonEnabled(false);
}
void TabbedViewContainerV2::closeTab(int tab)
{
Q_ASSERT(tab >= 0 && tab < _stackWidget->count());
removeView(_stackWidget->widget(tab));
if (viewProperties(_stackWidget->widget(tab))->confirmClose())
removeView(_stackWidget->widget(tab));
}
void TabbedViewContainerV2::setTabBarVisible(bool visible)
{
_tabBar->setVisible(visible);
_newTabButton->setVisible(visible);
if ( visible )
{
_tabBarSpacer->changeSize(0,TabBarSpace);
@@ -679,20 +721,20 @@ void TabbedViewContainerV2::navigationPositionChanged(NavigationPosition positio
if ( position == NavigationPositionTop
&& _layout->indexOf(_stackWidget) == StackIndexWithTabBottom )
{
_layout->removeWidget(_tabBar);
_layout->removeItem(_tabBarLayout);
_layout->removeItem(_tabBarSpacer);
_layout->insertWidget(0,_tabBar);
_layout->insertLayout(0,_tabBarLayout);
_layout->insertItemAt(0,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedNorth);
}
else if ( position == NavigationPositionBottom
&& _layout->indexOf(_stackWidget) != StackIndexWithTabBottom )
{
_layout->removeWidget(_tabBar);
_layout->removeItem(_tabBarLayout);
_layout->removeItem(_tabBarSpacer);
_layout->insertWidget(-1,_tabBar);
_layout->insertLayout(-1,_tabBarLayout);
_layout->insertItemAt(-1,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedSouth);
}