Commit 2fd69ce1 authored by Robert Knight's avatar Robert Knight
Browse files

Add internal support for choosing the tab bar's position with respect to the...

Add internal support for choosing the tab bar's position with respect to the terminal display.  Currently now defaults to positioning the tabs at the bottom of the screen as in KDE 3, haven't decided on what the final default setting will be.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=666706
parent 8a81e29f
......@@ -49,7 +49,7 @@ FallbackProfile::FallbackProfile()
setProperty(Icon,"konsole");
setProperty(Arguments,QStringList() << getenv("SHELL"));
setProperty(LocalTabTitleFormat,"%d : %n");
setProperty(RemoteTabTitleFormat,"%H : %u");
setProperty(RemoteTabTitleFormat,"%H (%u)");
setProperty(TabBarMode,AlwaysShowTabBar);
setProperty(ShowMenuBar,true);
......
......@@ -1644,7 +1644,6 @@ void TerminalDisplay::mouseMoveEvent(QMouseEvent* ev)
emit isBusySelecting(false); // Ok.. we can breath again.
_screenWindow->clearSelection();
//emit clearSelectionSignal();
doDrag();
}
return;
......@@ -1862,12 +1861,10 @@ void TerminalDisplay::extendSelection( QPoint pos )
if ( _columnSelectionMode && !_lineSelectionMode && !_wordSelectionMode )
{
_screenWindow->setSelectionEnd( here.x() , here.y() );
//emit extendSelectionSignal( here.x(), here.y() );
}
else
{
_screenWindow->setSelectionEnd( here.x()+offset , here.y() );
//emit extendSelectionSignal( here.x()+offset, here.y() );
}
}
......@@ -2440,8 +2437,6 @@ void TerminalDisplay::clearImage()
}
}
// Create Image ///////////////////////////////////////////////////////
void TerminalDisplay::calcGeometry()
{
_scrollBar->resize(QApplication::style()->pixelMetric(QStyle::PM_ScrollBarExtent),
......
......@@ -32,7 +32,6 @@
#include <QtGui/QStackedWidget>
#include <QtGui/QTabBar>
#include <QtGui/QToolButton>
#include <QtGui/QBoxLayout>
#include <QtGui/QWidgetAction>
// KDE
......@@ -51,9 +50,10 @@
using namespace Konsole;
ViewContainer::ViewContainer(QObject* parent)
ViewContainer::ViewContainer(NavigationPosition position , QObject* parent)
: QObject(parent)
, _navigationDisplayMode(AlwaysShowNavigation)
, _navigationPosition(position)
{
}
ViewContainer::~ViewContainer()
......@@ -73,6 +73,23 @@ void ViewContainer::setNavigationDisplayMode(NavigationDisplayMode mode)
navigationDisplayModeChanged(mode);
}
ViewContainer::NavigationPosition ViewContainer::navigationPosition() const
{
return _navigationPosition;
}
void ViewContainer::setNavigationPosition(NavigationPosition position)
{
// assert that this position is supported
Q_ASSERT( supportedNavigationPositions().contains(position) );
_navigationPosition = position;
navigationPositionChanged(position);
}
QList<ViewContainer::NavigationPosition> ViewContainer::supportedNavigationPositions() const
{
return QList<NavigationPosition>() << NavigationPositionTop;
}
ViewContainer::NavigationDisplayMode ViewContainer::navigationDisplayMode() const
{
return _navigationDisplayMode;
......@@ -169,8 +186,8 @@ QList<QWidget*> ViewContainer::widgetsForItem(ViewProperties* item) const
return _navigation.keys(item);
}
TabbedViewContainer::TabbedViewContainer(QObject* parent) :
ViewContainer(parent)
TabbedViewContainer::TabbedViewContainer(NavigationPosition position , QObject* parent) :
ViewContainer(position,parent)
,_newSessionButton(0)
,_tabContextMenu(0)
,_tabSelectColorMenu(0)
......@@ -390,7 +407,8 @@ QSize ViewContainerTabBar::tabSizeHint(int index) const
return QTabBar::tabSizeHint(index);
}
TabbedViewContainerV2::TabbedViewContainerV2(QObject* parent) : ViewContainer(parent)
TabbedViewContainerV2::TabbedViewContainerV2(NavigationPosition position , QObject* parent)
: ViewContainer(position,parent)
{
_containerWidget = new QWidget;
_stackWidget = new QStackedWidget();
......@@ -399,17 +417,30 @@ TabbedViewContainerV2::TabbedViewContainerV2(QObject* parent) : ViewContainer(pa
connect( _tabBar , SIGNAL(currentChanged(int)) , this , SLOT(currentTabChanged(int)) );
QVBoxLayout* layout = new QVBoxLayout;
layout->setSpacing(0);
layout->setMargin(0);
_layout = new TabbedViewContainerV2Layout;
_layout->setSpacing(0);
_layout->setMargin(0);
_tabBarSpacer = new QSpacerItem(0,TabBarSpace);
layout->addItem(_tabBarSpacer);
layout->addWidget(_tabBar);
layout->addWidget(_stackWidget);
_layout->addWidget(_stackWidget);
if ( position == NavigationPositionTop )
{
_layout->insertWidget(0,_tabBar);
_layout->insertItemAt(0,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedNorth);
}
else if ( position == NavigationPositionBottom )
{
_layout->insertWidget(-1,_tabBar);
_layout->insertItemAt(-1,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedSouth);
}
else
Q_ASSERT(false); // position not supported
_containerWidget->setLayout(layout);
_containerWidget->setLayout(_layout);
}
void TabbedViewContainerV2::setTabBarVisible(bool visible)
{
......@@ -423,6 +454,25 @@ void TabbedViewContainerV2::setTabBarVisible(bool visible)
_tabBarSpacer->changeSize(0,0);
}
}
QList<ViewContainer::NavigationPosition> TabbedViewContainerV2::supportedNavigationPositions() const
{
return QList<NavigationPosition>() << NavigationPositionTop << NavigationPositionBottom;
}
void TabbedViewContainerV2::navigationPositionChanged(NavigationPosition position)
{
if ( position == NavigationPositionTop && _layout->indexOf(_tabBar) != 0 )
{
_layout->insertWidget(0,_tabBar);
_layout->insertItemAt(0,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedNorth);
}
else if ( position == NavigationPositionBottom && _layout->indexOf(_tabBar) == 0 )
{
_layout->insertWidget(-1,_tabBar);
_layout->insertItemAt(-1,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedSouth);
}
}
void TabbedViewContainerV2::navigationDisplayModeChanged(NavigationDisplayMode mode)
{
if ( mode == AlwaysShowNavigation && _tabBar->isHidden() )
......@@ -518,7 +568,8 @@ void TabbedViewContainerV2::updateIcon(ViewProperties* item)
}
}
StackedViewContainer::StackedViewContainer(QObject* parent) : ViewContainer(parent)
StackedViewContainer::StackedViewContainer(NavigationPosition position , QObject* parent)
: ViewContainer(position,parent)
{
_stackWidget = new QStackedWidget;
}
......@@ -547,8 +598,8 @@ void StackedViewContainer::removeViewWidget( QWidget* view )
_stackWidget->removeWidget(view);
}
ListViewContainer::ListViewContainer(QObject* parent)
: ViewContainer(parent)
ListViewContainer::ListViewContainer(NavigationPosition position,QObject* parent)
: ViewContainer(position,parent)
{
_splitter = new QSplitter;
_stackWidget = new QStackedWidget(_splitter);
......
......@@ -27,12 +27,12 @@
#include <QtCore/QHash>
#include <QtCore/QList>
#include <QtGui/QTabBar>
#include <QtGui/QVBoxLayout>
class QSpacerItem;
class QStackedWidget;
class QWidget;
// TabbedViewContainer
// Qt
class QAction;
......@@ -69,8 +69,30 @@ class ViewContainer : public QObject
Q_OBJECT
public:
/** Constructs a new view container with the specified parent. */
ViewContainer(QObject* parent);
/**
* This enum describes the options for positioning the
* container's navigation widget.
*/
enum NavigationPosition
{
/** Position the navigation widget above the views. */
NavigationPositionTop,
/** Position the navigation widget below the views. */
NavigationPositionBottom,
/** Position the navigation widget to the left of the views. */
NavigationPositionLeft,
/** Position the navigation widget to the right of the views. */
NavigationPositionRight
};
/**
* Constructs a new view container with the specified parent.
*
* @param position The initial position of the navigation widget
* @param parent The parent object of the container
*/
ViewContainer(NavigationPosition position , QObject* parent);
/**
* Called when the ViewContainer is destroyed. When reimplementing this in
......@@ -88,16 +110,63 @@ public:
*/
enum NavigationDisplayMode
{
/** Always show the navigation widget. */
AlwaysShowNavigation,
/** Always hide the navigation widget. */
AlwaysHideNavigation,
/** Show the navigation widget only when the container has more than one view. */
ShowNavigationAsNeeded
};
/** TODO: Document me. */
/*
* Sets the visibility of the view container's navigation widget.
*
* The ViewContainer sub-class is responsible for ensuring that this
* setting is respected as views are added or removed from the
* container.
*
* ViewContainer sub-classes should reimplement the
* navigationDisplayModeChanged() method to respond to changes
* of this property.
*/
void setNavigationDisplayMode(NavigationDisplayMode mode);
/** TODO: Document me. */
/**
* Returns the current mode for controlling the visibility of the
* the view container's navigation widget.
*/
NavigationDisplayMode navigationDisplayMode() const;
/**
* Sets the position of the navigation widget with
* respect to the main content area.
*
* Depending on the ViewContainer subclass, not all
* positions from the NavigationPosition enum may be
* supported. A list of supported positions can be
* obtained by calling supportedNavigationPositions()
*
* ViewContainer sub-classes should re-implement the
* navigationPositionChanged() method to respond
* to changes of this property.
*/
void setNavigationPosition(NavigationPosition position);
/**
* Returns the position of the navigation widget with
* respect to the main content area.
*/
NavigationPosition navigationPosition() const;
/**
* Returns the list of supported navigation positions.
* The supported positions will depend upon the type of the
* navigation widget used by the ViewContainer subclass.
*
* The base implementation returns one item, NavigationPositionTop
*/
virtual QList<NavigationPosition> supportedNavigationPositions() const;
/** Adds a new view to the container widget */
void addView(QWidget* view , ViewProperties* navigationItem);
......@@ -170,6 +239,13 @@ protected:
*/
virtual void navigationDisplayModeChanged(NavigationDisplayMode) {}
/**
* Called when the navigation position changes to re-layout
* the container and place the navigation widget in the
* specified position.
*/
virtual void navigationPositionChanged(NavigationPosition) {}
/** Returns the widgets which are associated with a particular navigation item */
QList<QWidget*> widgetsForItem( ViewProperties* item ) const;
......@@ -178,6 +254,7 @@ private slots:
private:
NavigationDisplayMode _navigationDisplayMode;
NavigationPosition _navigationPosition;
QList<QWidget*> _views;
QHash<QWidget*,ViewProperties*> _navigation;
};
......@@ -191,7 +268,7 @@ class TabbedViewContainer : public ViewContainer
Q_OBJECT
public:
TabbedViewContainer(QObject* parent);
TabbedViewContainer(NavigationPosition position , QObject* parent);
virtual ~TabbedViewContainer();
virtual QWidget* containerWidget() const;
......@@ -241,6 +318,22 @@ protected:
virtual QSize tabSizeHint(int index) const;
};
// internal
// this class provides a work-around for a problem in Qt 4.x
// where the insertItem() method only has protected access -
// and the TabbedViewContainerV2 class needs to call it.
//
// and presumably for binary compatibility reasons will
// not be fixed until Qt 5.
class TabbedViewContainerV2Layout : public QVBoxLayout
{
public:
void insertItemAt( int index , QLayoutItem* item )
{
insertItem(index,item);
}
};
/**
* An alternative tabbed view container which uses a QTabBar and QStackedWidget
* combination for navigation instead of QTabWidget
......@@ -250,17 +343,24 @@ class TabbedViewContainerV2 : public ViewContainer
Q_OBJECT
public:
TabbedViewContainerV2(QObject* parent);
/**
* Constructs a new tabbed view container. Supported positions
* are NavigationPositionTop and NavigationPositionBottom.
*/
TabbedViewContainerV2(NavigationPosition position , QObject* parent);
virtual ~TabbedViewContainerV2();
virtual QWidget* containerWidget() const;
virtual QWidget* activeView() const;
virtual void setActiveView(QWidget* view);
virtual QList<NavigationPosition> supportedNavigationPositions() const;
protected:
virtual void addViewWidget(QWidget* view);
virtual void removeViewWidget(QWidget* view);
virtual void navigationDisplayModeChanged(NavigationDisplayMode mode);
virtual void navigationPositionChanged(NavigationPosition position);
private slots:
void updateTitle(ViewProperties* item);
......@@ -275,6 +375,7 @@ private:
QStackedWidget* _stackWidget;
QWidget* _containerWidget;
QSpacerItem* _tabBarSpacer;
TabbedViewContainerV2Layout* _layout;
static const int TabBarSpace = 2;
};
......@@ -285,7 +386,7 @@ private:
class StackedViewContainer : public ViewContainer
{
public:
StackedViewContainer(QObject* parent);
StackedViewContainer(NavigationPosition position , QObject* parent);
virtual ~StackedViewContainer();
virtual QWidget* containerWidget() const;
......@@ -309,7 +410,7 @@ class ListViewContainer : public ViewContainer
Q_OBJECT
public:
ListViewContainer(QObject* parent);
ListViewContainer(NavigationPosition position , QObject* parent);
virtual ~ListViewContainer();
virtual QWidget* containerWidget() const;
......
......@@ -426,7 +426,7 @@ void ViewManager::createView(Session* session)
ViewContainer* ViewManager::createContainer()
{
ViewContainer* container = new TabbedViewContainerV2(_viewSplitter);
ViewContainer* container = new TabbedViewContainerV2(ViewContainer::NavigationPositionBottom,_viewSplitter);
// connect signals and slots
connect( container , SIGNAL(viewAdded(QWidget*,ViewProperties*)) , _containerSignalMapper ,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment