Commit 34a9e7ec authored by Robert Knight's avatar Robert Knight
Browse files

* 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
parent c5bfff3d
...@@ -280,12 +280,15 @@ void EditProfileDialog::setupTabsPage(const Profile::Ptr info) ...@@ -280,12 +280,15 @@ void EditProfileDialog::setupTabsPage(const Profile::Ptr info)
<< i18n("Above Terminal Displays") ); << i18n("Above Terminal Displays") );
_ui->tabBarPositionCombo->setCurrentIndex(tabPosition); _ui->tabBarPositionCombo->setCurrentIndex(tabPosition);
_ui->newTabButton->setChecked(info->property<bool>(Profile::ShowNewTabButton));
// signals and slots // signals and slots
connect( _ui->tabBarVisibilityCombo , SIGNAL(activated(int)) , this , connect( _ui->tabBarVisibilityCombo , SIGNAL(activated(int)) , this ,
SLOT(tabBarVisibilityChanged(int)) ); SLOT(tabBarVisibilityChanged(int)) );
connect( _ui->tabBarPositionCombo , SIGNAL(activated(int)) , this , connect( _ui->tabBarPositionCombo , SIGNAL(activated(int)) , this ,
SLOT(tabBarPositionChanged(int)) ); SLOT(tabBarPositionChanged(int)) );
connect( _ui->newTabButton , SIGNAL(toggled(bool)) , this ,
SLOT(showNewTabButton(bool)) );
connect(_ui->tabTitleEdit , SIGNAL(textChanged(const QString&)) , this , connect(_ui->tabTitleEdit , SIGNAL(textChanged(const QString&)) , this ,
SLOT(tabTitleFormatChanged(const QString&)) ); SLOT(tabTitleFormatChanged(const QString&)) );
...@@ -305,6 +308,8 @@ void EditProfileDialog::setupTabsPage(const Profile::Ptr info) ...@@ -305,6 +308,8 @@ void EditProfileDialog::setupTabsPage(const Profile::Ptr info)
connect( remoteTabTitleAction , SIGNAL(dynamicElementSelected(const QString&)) , connect( remoteTabTitleAction , SIGNAL(dynamicElementSelected(const QString&)) ,
this , SLOT(insertRemoteTabTitleText(const QString&)) ); this , SLOT(insertRemoteTabTitleText(const QString&)) );
} }
void EditProfileDialog::showNewTabButton(bool show)
{ _tempProfile->setProperty(Profile::ShowNewTabButton,show); }
void EditProfileDialog::tabBarVisibilityChanged(int newValue) void EditProfileDialog::tabBarVisibilityChanged(int newValue)
{ {
_tempProfile->setProperty( Profile::TabBarMode , newValue ); _tempProfile->setProperty( Profile::TabBarMode , newValue );
......
...@@ -123,6 +123,7 @@ private slots: ...@@ -123,6 +123,7 @@ private slots:
void showEnvironmentEditor(); void showEnvironmentEditor();
void tabBarVisibilityChanged(int); void tabBarVisibilityChanged(int);
void tabBarPositionChanged(int); void tabBarPositionChanged(int);
void showNewTabButton(bool);
// appearance page // appearance page
void setFontSize(int pointSize); void setFontSize(int pointSize);
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>429</width> <width>429</width>
<height>491</height> <height>476</height>
</rect> </rect>
</property> </property>
<attribute name="title" > <attribute name="title" >
...@@ -333,6 +333,9 @@ ...@@ -333,6 +333,9 @@
<property name="text" > <property name="text" >
<string>Tab bar display:</string> <string>Tab bar display:</string>
</property> </property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="1" > <item row="1" column="1" >
...@@ -353,6 +356,9 @@ ...@@ -353,6 +356,9 @@
<property name="text" > <property name="text" >
<string>Tab bar position:</string> <string>Tab bar position:</string>
</property> </property>
<property name="alignment" >
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget> </widget>
</item> </item>
<item row="2" column="1" > <item row="2" column="1" >
...@@ -365,6 +371,13 @@ ...@@ -365,6 +371,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="0" colspan="2" >
<widget class="QCheckBox" name="newTabButton" >
<property name="text" >
<string>Show 'New Tab' button in tab bar</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
...@@ -462,8 +475,7 @@ ...@@ -462,8 +475,7 @@
</spacer> </spacer>
</item> </item>
<item row="5" column="0" > <item row="5" column="0" >
<widget class="Konsole::WarningBox" native="1" name="transparencyWarningWidget" > <widget class="Konsole::WarningBox" native="1" name="transparencyWarningWidget" />
</widget>
</item> </item>
</layout> </layout>
</widget> </widget>
...@@ -573,7 +585,7 @@ ...@@ -573,7 +585,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>429</width> <width>429</width>
<height>491</height> <height>476</height>
</rect> </rect>
</property> </property>
<attribute name="title" > <attribute name="title" >
...@@ -751,7 +763,7 @@ ...@@ -751,7 +763,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>429</width> <width>429</width>
<height>491</height> <height>476</height>
</rect> </rect>
</property> </property>
<attribute name="title" > <attribute name="title" >
...@@ -841,7 +853,7 @@ ...@@ -841,7 +853,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>429</width> <width>429</width>
<height>491</height> <height>476</height>
</rect> </rect>
</property> </property>
<attribute name="title" > <attribute name="title" >
......
...@@ -78,7 +78,10 @@ MainWindow::MainWindow() ...@@ -78,7 +78,10 @@ MainWindow::MainWindow()
connect( _viewManager , SIGNAL(setMenuBarVisibleRequest(bool)) , this , connect( _viewManager , SIGNAL(setMenuBarVisibleRequest(bool)) , this ,
SLOT(setMenuBarVisibleOnce(bool)) ); SLOT(setMenuBarVisibleOnce(bool)) );
connect( _viewManager , SIGNAL(newViewRequest()) , this , SLOT(newTab()) ); connect( _viewManager , SIGNAL(newViewRequest(Profile::Ptr)) ,
this , SLOT(newFromProfile(Profile::Ptr)) );
connect( _viewManager , SIGNAL(newViewRequest()) ,
this , SLOT(newTab()));
// create main window widgets // create main window widgets
setupWidgets(); setupWidgets();
......
...@@ -79,7 +79,8 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] = ...@@ -79,7 +79,8 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] =
, { TabBarMode , "TabBarMode" , GENERAL_GROUP , QVariant::Int } , { TabBarMode , "TabBarMode" , GENERAL_GROUP , QVariant::Int }
, { TabBarPosition , "TabBarPosition" , GENERAL_GROUP , QVariant::Int } , { TabBarPosition , "TabBarPosition" , GENERAL_GROUP , QVariant::Int }
, { StartInCurrentSessionDir , "StartInCurrentSessionDir" , GENERAL_GROUP , QVariant::Bool } , { StartInCurrentSessionDir , "StartInCurrentSessionDir" , GENERAL_GROUP , QVariant::Bool }
, { ShowNewTabButton, "ShowNewTabButton" , GENERAL_GROUP , QVariant::Bool }
// Appearance // Appearance
, { Font , "Font" , APPEARANCE_GROUP , QVariant::Font } , { Font , "Font" , APPEARANCE_GROUP , QVariant::Font }
, { ColorScheme , "ColorScheme" , APPEARANCE_GROUP , QVariant::String } , { ColorScheme , "ColorScheme" , APPEARANCE_GROUP , QVariant::String }
...@@ -150,6 +151,7 @@ FallbackProfile::FallbackProfile() ...@@ -150,6 +151,7 @@ FallbackProfile::FallbackProfile()
setProperty(TabBarPosition,TabBarBottom); setProperty(TabBarPosition,TabBarBottom);
setProperty(ShowMenuBar,true); setProperty(ShowMenuBar,true);
setProperty(StartInCurrentSessionDir,true); setProperty(StartInCurrentSessionDir,true);
setProperty(ShowNewTabButton,false);
setProperty(KeyBindings,"default"); setProperty(KeyBindings,"default");
setProperty(ColorScheme,"Linux"); setProperty(ColorScheme,"Linux");
......
...@@ -188,7 +188,10 @@ public: ...@@ -188,7 +188,10 @@ public:
/** (bool) Whether new sessions should be started in the same directory as the /** (bool) Whether new sessions should be started in the same directory as the
* currently active session. */ * currently active session. */
StartInCurrentSessionDir StartInCurrentSessionDir,
/** (bool) Whether a 'New Tab' button should be shown on the tab bar */
ShowNewTabButton
}; };
/** /**
......
...@@ -119,6 +119,22 @@ void ProfileList::shortcutChanged(Profile::Ptr info,const QKeySequence& sequence ...@@ -119,6 +119,22 @@ void ProfileList::shortcutChanged(Profile::Ptr info,const QKeySequence& sequence
action->setShortcut(sequence); 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) void ProfileList::favoriteChanged(Profile::Ptr info,bool isFavorite)
{ {
SessionManager* manager = SessionManager::instance(); SessionManager* manager = SessionManager::instance();
...@@ -134,7 +150,9 @@ void ProfileList::favoriteChanged(Profile::Ptr info,bool isFavorite) ...@@ -134,7 +150,9 @@ void ProfileList::favoriteChanged(Profile::Ptr info,bool isFavorite)
} }
updateAction(action,info); updateAction(action,info);
foreach(QWidget* widget,_registeredWidgets)
widget->addAction(action);
emit actionsChanged(_group->actions()); emit actionsChanged(_group->actions());
} }
else else
...@@ -144,13 +162,14 @@ void ProfileList::favoriteChanged(Profile::Ptr info,bool isFavorite) ...@@ -144,13 +162,14 @@ void ProfileList::favoriteChanged(Profile::Ptr info,bool isFavorite)
if ( action ) if ( action )
{ {
_group->removeAction(action); _group->removeAction(action);
foreach(QWidget* widget,_registeredWidgets)
widget->removeAction(action);
emit actionsChanged(_group->actions()); emit actionsChanged(_group->actions());
} }
} }
updateEmptyAction(); updateEmptyAction();
} }
void ProfileList::triggered(QAction* action) void ProfileList::triggered(QAction* action)
{ {
emit profileSelected( action->data().value<Profile::Ptr>() ); emit profileSelected( action->data().value<Profile::Ptr>() );
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#define PROFILELIST_H #define PROFILELIST_H
#include <QtCore/QList> #include <QtCore/QList>
#include <QtCore/QSet>
#include <QtCore/QObject> #include <QtCore/QObject>
#include "Profile.h" #include "Profile.h"
...@@ -67,6 +68,8 @@ public: ...@@ -67,6 +68,8 @@ public:
*/ */
QList<QAction*> actions(); QList<QAction*> actions();
/** TODO: Document me */
void syncWidgetActions(QWidget* widget,bool sync);
signals: signals:
/** /**
* Emitted when the user selects an action from the list. * Emitted when the user selects an action from the list.
...@@ -95,6 +98,7 @@ private: ...@@ -95,6 +98,7 @@ private:
// action to show when the list is empty // action to show when the list is empty
QAction* _emptyListAction; QAction* _emptyListAction;
QSet<QWidget*> _registeredWidgets;
}; };
} }
......
...@@ -685,6 +685,36 @@ void SessionController::saveSession() ...@@ -685,6 +685,36 @@ void SessionController::saveSession()
//SaveSessionDialog dialog(_view); //SaveSessionDialog dialog(_view);
//int result = dialog.exec(); //int result = dialog.exec();
} }
bool SessionController::confirmClose() const
{
if (_session->foregroundProcessId() != _session->processId())
{
ProcessInfo* foregroundInfo = ProcessInfo::newInstance(_session->foregroundProcessId());
foregroundInfo->update();
bool ok = false;
QString title = foregroundInfo->name(&ok);
delete foregroundInfo;
// hard coded for now. In future make it possible for the user to specify which programs
// are ignored when considering whether to display a confirmation
QStringList ignoreList;
ignoreList << QString(getenv("SHELL")).section('/',-1);
if (ignoreList.contains(title))
return true;
QString question;
if (ok)
question = i18n("The program '%1' is currently running in this session."
" Are you sure you want to close it?",title);
else
question = i18n("A program is currently running in this session."
" Are you sure you want to close it?");
int result = KMessageBox::warningYesNo(_view->window(),question,i18n("Confirm Close"));
return (result == KMessageBox::Yes) ? true : false;
}
return true;
}
void SessionController::closeSession() void SessionController::closeSession()
{ {
if (_preventClose) if (_preventClose)
......
...@@ -129,6 +129,7 @@ public: ...@@ -129,6 +129,7 @@ public:
virtual KUrl url() const; virtual KUrl url() const;
virtual QString currentDir() const; virtual QString currentDir() const;
virtual void rename(); virtual void rename();
virtual bool confirmClose() const;
// Reimplemented to watch for events happening to the view // Reimplemented to watch for events happening to the view
virtual bool eventFilter(QObject* watched , QEvent* event); virtual bool eventFilter(QObject* watched , QEvent* event);
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <QtGui/QLineEdit> #include <QtGui/QLineEdit>
#include <QtGui/QBrush> #include <QtGui/QBrush>
#include <QtGui/QListWidget> #include <QtGui/QListWidget>
#include <QtGui/QPushButton>
#include <QtGui/QSplitter> #include <QtGui/QSplitter>
#include <QtGui/QStackedWidget> #include <QtGui/QStackedWidget>
#include <QtGui/QTabBar> #include <QtGui/QTabBar>
...@@ -74,7 +73,10 @@ ViewContainer::~ViewContainer() ...@@ -74,7 +73,10 @@ ViewContainer::~ViewContainer()
emit destroyed(this); emit destroyed(this);
} }
void ViewContainer::moveViewWidget( int , int ) {} void ViewContainer::moveViewWidget( int , int ) {}
void ViewContainer::setFeatures(Features features)
{ _features = features; }
ViewContainer::Features ViewContainer::features() const
{ return _features; }
void ViewContainer::moveActiveView( MoveDirection direction ) void ViewContainer::moveActiveView( MoveDirection direction )
{ {
const int currentIndex = _views.indexOf( activeView() ) ; const int currentIndex = _views.indexOf( activeView() ) ;
...@@ -613,17 +615,33 @@ TabbedViewContainerV2::TabbedViewContainerV2(NavigationPosition position , QObje ...@@ -613,17 +615,33 @@ TabbedViewContainerV2::TabbedViewContainerV2(NavigationPosition position , QObje
_stackWidget = new QStackedWidget(); _stackWidget = new QStackedWidget();
_tabBar = new ViewContainerTabBar(_containerWidget,this); _tabBar = new ViewContainerTabBar(_containerWidget,this);
_tabBar->setDrawBase(true); _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(currentChanged(int)) , this , SLOT(currentTabChanged(int)) );
connect( _tabBar , SIGNAL(tabDoubleClicked(int)) , this , SLOT(tabDoubleClicked(int)) ); connect( _tabBar , SIGNAL(tabDoubleClicked(int)) , this , SLOT(tabDoubleClicked(int)) );
connect( _tabBar , SIGNAL(newTabRequest()) , this , SIGNAL(newViewRequest()) ); connect( _tabBar , SIGNAL(newTabRequest()) , this , SIGNAL(newViewRequest()) );
connect( _tabBar , SIGNAL(wheelDelta(int)) , this , SLOT(wheelScrolled(int)) ); connect( _tabBar , SIGNAL(wheelDelta(int)) , this , SLOT(wheelScrolled(int)) );
connect( _tabBar , SIGNAL(mouseMiddleClick(int)) , this , SLOT(closeTab(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( _tabBar , SIGNAL(initiateDrag(int)) , this , SLOT(startTabDrag(int)) );
connect( _newTabButton , SIGNAL(clicked()) , this , SIGNAL(newViewRequest()) );
_layout = new TabbedViewContainerV2Layout; _layout = new TabbedViewContainerV2Layout;
_layout->setSpacing(0); _layout->setSpacing(0);
_layout->setMargin(0); _layout->setMargin(0);
_tabBarLayout = new QHBoxLayout;
_tabBarLayout->setSpacing(0);
_tabBarLayout->setMargin(0);
_tabBarLayout->addWidget(_newTabButton);
_tabBarLayout->addWidget(_tabBar);
_tabBarSpacer = new QSpacerItem(0,TabBarSpace); _tabBarSpacer = new QSpacerItem(0,TabBarSpace);
...@@ -631,13 +649,13 @@ TabbedViewContainerV2::TabbedViewContainerV2(NavigationPosition position , QObje ...@@ -631,13 +649,13 @@ TabbedViewContainerV2::TabbedViewContainerV2(NavigationPosition position , QObje
if ( position == NavigationPositionTop ) if ( position == NavigationPositionTop )
{ {
_layout->insertWidget(0,_tabBar); _layout->insertLayout(0,_tabBarLayout);
_layout->insertItemAt(0,_tabBarSpacer); _layout->insertItemAt(0,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedNorth); _tabBar->setShape(QTabBar::RoundedNorth);
} }
else if ( position == NavigationPositionBottom ) else if ( position == NavigationPositionBottom )
{ {
_layout->insertWidget(-1,_tabBar); _layout->insertLayout(-1,_tabBarLayout);
_layout->insertItemAt(-1,_tabBarSpacer); _layout->insertItemAt(-1,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedSouth); _tabBar->setShape(QTabBar::RoundedSouth);
} }
...@@ -646,14 +664,38 @@ TabbedViewContainerV2::TabbedViewContainerV2(NavigationPosition position , QObje ...@@ -646,14 +664,38 @@ TabbedViewContainerV2::TabbedViewContainerV2(NavigationPosition position , QObje
_containerWidget->setLayout(_layout); _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) void TabbedViewContainerV2::closeTab(int tab)
{ {
Q_ASSERT(tab >= 0 && tab < _stackWidget->count()); 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) void TabbedViewContainerV2::setTabBarVisible(bool visible)
{ {
_tabBar->setVisible(visible); _tabBar->setVisible(visible);
_newTabButton->setVisible(visible);
if ( visible ) if ( visible )
{ {
_tabBarSpacer->changeSize(0,TabBarSpace); _tabBarSpacer->changeSize(0,TabBarSpace);
...@@ -679,20 +721,20 @@ void TabbedViewContainerV2::navigationPositionChanged(NavigationPosition positio ...@@ -679,20 +721,20 @@ void TabbedViewContainerV2::navigationPositionChanged(NavigationPosition positio
if ( position == NavigationPositionTop if ( position == NavigationPositionTop
&& _layout->indexOf(_stackWidget) == StackIndexWithTabBottom ) && _layout->indexOf(_stackWidget) == StackIndexWithTabBottom )
{ {
_layout->removeWidget(_tabBar); _layout->removeItem(_tabBarLayout);
_layout->removeItem(_tabBarSpacer); _layout->removeItem(_tabBarSpacer);
_layout->insertWidget(0,_tabBar); _layout->insertLayout(0,_tabBarLayout);
_layout->insertItemAt(0,_tabBarSpacer); _layout->insertItemAt(0,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedNorth); _tabBar->setShape(QTabBar::RoundedNorth);
} }
else if ( position == NavigationPositionBottom else if ( position == NavigationPositionBottom
&& _layout->indexOf(_stackWidget) != StackIndexWithTabBottom ) && _layout->indexOf(_stackWidget) != StackIndexWithTabBottom )
{ {
_layout->removeWidget(_tabBar); _layout->removeItem(_tabBarLayout);
_layout->removeItem(_tabBarSpacer); _layout->removeItem(_tabBarSpacer);
_layout->insertWidget(-1,_tabBar); _layout->insertLayout(-1,_tabBarLayout);
_layout->insertItemAt(-1,_tabBarSpacer); _layout->insertItemAt(-1,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedSouth); _tabBar->setShape(QTabBar::RoundedSouth);
} }
......
...@@ -26,10 +26,11 @@ ...@@ -26,10 +26,11 @@
#include <QtCore/QObject> #include <QtCore/QObject>
#include <QtCore/QHash> #include <QtCore/QHash>
#include <QtCore/QList> #include <QtCore/QList>
#include <QtGui/QVBoxLayout> #include <QtGui/QBoxLayout>
// KDE // KDE
#include <KTabBar> #include <KTabBar>
#include <KPushButton>
class QSpacerItem; class QSpacerItem;
class QStackedWidget; class QStackedWidget;
...@@ -65,7 +66,6 @@ namespace Konsole ...@@ -65,7 +66,6 @@ namespace Konsole
* Subclasses should reimplement the addViewWidget() and removeViewWidget() functions * Subclasses should reimplement the addViewWidget() and removeViewWidget() functions
* to actually add or remove view widgets from the container widget, as well * to actually add or remove view widgets from the container widget, as well
* as updating any navigation aids. * as updating any navigation aids.
*
*/ */
class ViewContainer : public QObject class ViewContainer : public QObject
{ {
...@@ -137,9 +137,7 @@ public: ...@@ -137,9 +137,7 @@ public: