Commit d0afc223 authored by Robert Knight's avatar Robert Knight

Add a view container based on QTabBar and a stack widget rather than using the...

Add a view container based on QTabBar and a stack widget rather than using the QTabWidget for experimental purposes.

svn path=/branches/work/konsole-split-view/; revision=649688
parent 2b16eb7e
......@@ -59,6 +59,7 @@ set(konsole_KDEINIT_SRCS
Filter.cpp
HistorySizeDialog.cpp
IncrementalSearchBar.cpp
KeyboardTranslator.cpp
KeyTrans.cpp
Application.cpp
BookmarkHandler.cpp
......
......@@ -140,7 +140,8 @@ public:
*/
QString userTitle() const;
/**
* Returns the title of the session for display in UI widgets (eg. window captions)
* Returns the title of the session for display in UI widgets
* (eg. window captions)
*/
QString displayTitle() const;
......
/*
This source file is part of Konsole, a terminal emulator.
Copyright (C) 2006 by Robert Knight <robertknight@gmail.com>
Copyright (C) 2006-7 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
......@@ -160,6 +160,10 @@ class SessionManager : public QObject
Q_OBJECT
public:
/**
* Constructs a new session manager and loads information about the available
* session types.
*/
SessionManager();
virtual ~SessionManager();
......
......@@ -26,7 +26,9 @@
#include <QListWidget>
#include <QSplitter>
#include <QStackedWidget>
#include <QTabBar>
#include <QToolButton>
#include <QVBoxLayout>
#include <QWidgetAction>
// KDE
......@@ -345,6 +347,61 @@ void TabbedViewContainer::selectTabColor()
_tabWidget->setTabTextColor( _contextMenuTab , color );
}
TabbedViewContainerV2::TabbedViewContainerV2(QObject* parent) : ViewContainer(parent)
{
_containerWidget = new QWidget;
_stackWidget = new QStackedWidget();
_tabBar = new QTabBar();
_tabBar->setDrawBase(true);
QVBoxLayout* layout = new QVBoxLayout;
layout->setSpacing(0);
layout->setMargin(0);
layout->addWidget(_tabBar);
layout->addWidget(_stackWidget);
_containerWidget->setLayout(layout);
}
TabbedViewContainerV2::~TabbedViewContainerV2()
{
_containerWidget->deleteLater();
}
QWidget* TabbedViewContainerV2::containerWidget() const
{
return _containerWidget;
}
QWidget* TabbedViewContainerV2::activeView() const
{
return _stackWidget->currentWidget();
}
void TabbedViewContainerV2::setActiveView(QWidget* view)
{
const int index = _stackWidget->indexOf(view);
Q_ASSERT( index != -1 );
_stackWidget->setCurrentWidget(view);
_tabBar->setCurrentTab(index);
}
void TabbedViewContainerV2::viewAdded( QWidget* view )
{
_stackWidget->addWidget(view);
ViewProperties* item = viewProperties(view);
//connect( item , SIGNAL(titleChanged(ViewProperties*)) , this , SLOT(updateTitle(ViewProperties*)));
//connect( item , SIGNAL(iconChanged(ViewProperties*) ) , this ,SLOT(updateIcon(ViewProperties*)));
_tabBar->addTab( item->icon() , item->title() );
}
void TabbedViewContainerV2::viewRemoved( QWidget* view )
{
const int index = _stackWidget->indexOf(view);
Q_ASSERT( index != -1 );
_stackWidget->removeWidget(view);
_tabBar->removeTab(index);
}
StackedViewContainer::StackedViewContainer(QObject* parent) : ViewContainer(parent)
{
_stackWidget = new QStackedWidget;
......
......@@ -44,6 +44,9 @@ class QWidget;
class KColorCells;
class KMenu;
// TabbedViewContainerV2
class QTabBar;
// ListViewContainer
class QSplitter;
class QListWidget;
......@@ -197,6 +200,32 @@ private:
int _contextMenuTab;
};
/**
* An alternative tabbed view container which uses a QTabBar and QStackedWidget
* combination for navigation instead of QTabWidget
*/
class TabbedViewContainerV2 : public ViewContainer
{
Q_OBJECT
public:
TabbedViewContainerV2(QObject* parent);
virtual ~TabbedViewContainerV2();
virtual QWidget* containerWidget() const;
virtual QWidget* activeView() const;
virtual void setActiveView(QWidget* view);
protected:
virtual void viewAdded(QWidget* view);
virtual void viewRemoved(QWidget* view);
private:
QTabBar* _tabBar;
QStackedWidget* _stackWidget;
QWidget* _containerWidget;
};
/**
* A plain view container with no navigation display
*/
......
......@@ -361,7 +361,7 @@ void ViewManager::createView(Session* session)
ViewContainer* ViewManager::createContainer()
{
ViewContainer* container = new TabbedViewContainer(_viewSplitter);
ViewContainer* container = new TabbedViewContainerV2(_viewSplitter);
/*
if ( _mainWindow->factory() )
{
......
Markdown is supported
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