Commit 2c6b36ac authored by Robert Knight's avatar Robert Knight

Respect 'Show Menu Bar' and tab bar display mode profile settings.

svn path=/branches/work/konsole-split-view/; revision=660887
parent cda9c083
......@@ -117,8 +117,8 @@ void EditProfileDialog::setupGeneralPage(const Profile* info)
int tabMode = info->property(Profile::TabBarMode).value<int>();
RadioOption tabModes[] = { {_ui->alwaysHideTabBarButton,Profile::AlwaysHideTabBar,SLOT(alwaysHideTabBar())},
{_ui->alwaysShowTabBarButton,Profile::AlwaysShowTabBar,SLOT(showTabBarAsNeeded())},
{_ui->autoShowTabBarButton,Profile::ShowTabBarAsNeeded,SLOT(alwaysShowTabBar())},
{_ui->alwaysShowTabBarButton,Profile::AlwaysShowTabBar,SLOT(alwaysShowTabBar())},
{_ui->autoShowTabBarButton,Profile::ShowTabBarAsNeeded,SLOT(showTabBarAsNeeded())},
{0,0,0} };
setupRadio( tabModes , tabMode );
......
......@@ -76,6 +76,9 @@ MainWindow::MainWindow()
connect( _viewManager , SIGNAL(viewPropertiesChanged(const QList<ViewProperties*>&)) ,
bookmarkHandler() , SLOT(setViews(const QList<ViewProperties*>&)) );
connect( _viewManager , SIGNAL(setMenuBarVisible(bool)) , menuBar() ,
SLOT(setVisible(bool)) );
// create main window widgets
setupWidgets();
......
......@@ -34,6 +34,7 @@ class ViewSplitter;
class ViewManager;
class ViewProperties;
class SessionController;
class Profile;
class ProfileList;
class BookmarkHandler;
......
......@@ -49,10 +49,32 @@
using namespace Konsole;
ViewContainer::ViewContainer(QObject* parent)
: QObject(parent)
, _navigationDisplayMode(AlwaysShowNavigation)
{
}
ViewContainer::~ViewContainer()
{
emit destroyed(this);
}
void ViewContainer::setNavigationDisplayMode(NavigationDisplayMode mode)
{
_navigationDisplayMode = mode;
if ( mode == AlwaysShowNavigation )
qDebug() << "Always show nav";
else if ( mode == AlwaysHideNavigation )
qDebug() << "Always hide nav";
else if ( mode == ShowNavigationAsNeeded )
qDebug() << "Show nav as needed";
navigationDisplayModeChanged(mode);
}
ViewContainer::NavigationDisplayMode ViewContainer::navigationDisplayMode() const
{
return _navigationDisplayMode;
}
void ViewContainer::addView(QWidget* view , ViewProperties* item)
{
_views << view;
......@@ -383,6 +405,28 @@ TabbedViewContainerV2::TabbedViewContainerV2(QObject* parent) : ViewContainer(pa
_containerWidget->setLayout(layout);
}
void TabbedViewContainerV2::navigationDisplayModeChanged(NavigationDisplayMode mode)
{
if ( mode == AlwaysShowNavigation && _tabBar->isHidden() )
_tabBar->setVisible(true);
if ( mode == AlwaysHideNavigation && !_tabBar->isHidden() )
_tabBar->setVisible(false);
if ( mode == ShowNavigationAsNeeded )
dynamicTabBarVisibility();
}
void TabbedViewContainerV2::dynamicTabBarVisibility()
{
qDebug() << "tab bar count:" << _tabBar->count();
qDebug() << "tab var hidden:" << _tabBar->isHidden();
if ( _tabBar->count() > 1 && _tabBar->isHidden() )
_tabBar->show();
if ( _tabBar->count() < 2 && !_tabBar->isHidden() )
_tabBar->hide();
}
TabbedViewContainerV2::~TabbedViewContainerV2()
{
_containerWidget->deleteLater();
......@@ -418,6 +462,9 @@ void TabbedViewContainerV2::addViewWidget( QWidget* 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() );
if ( navigationDisplayMode() == ShowNavigationAsNeeded )
dynamicTabBarVisibility();
}
void TabbedViewContainerV2::removeViewWidget( QWidget* view )
{
......@@ -427,6 +474,9 @@ void TabbedViewContainerV2::removeViewWidget( QWidget* view )
_stackWidget->removeWidget(view);
_tabBar->removeTab(index);
if ( navigationDisplayMode() == ShowNavigationAsNeeded )
dynamicTabBarVisibility();
}
void TabbedViewContainerV2::updateTitle(ViewProperties* item)
......
......@@ -68,7 +68,8 @@ class ViewContainer : public QObject
Q_OBJECT
public:
ViewContainer(QObject* parent) : QObject(parent) {}
/** Constructs a new view container with the specified parent. */
ViewContainer(QObject* parent);
/**
* Called when the ViewContainer is destroyed. When reimplementing this in
......@@ -80,6 +81,22 @@ public:
/** Returns the widget which contains the view widgets */
virtual QWidget* containerWidget() const = 0;
/**
* This enum describes the options for showing or hiding the
* container's navigation widget.
*/
enum NavigationDisplayMode
{
AlwaysShowNavigation,
AlwaysHideNavigation,
ShowNavigationAsNeeded
};
/** TODO: Document me. */
void setNavigationDisplayMode(NavigationDisplayMode mode);
/** TODO: Document me. */
NavigationDisplayMode navigationDisplayMode() const;
/** Adds a new view to the container widget */
void addView(QWidget* view , ViewProperties* navigationItem);
......@@ -146,6 +163,12 @@ protected:
*/
virtual void removeViewWidget(QWidget* view) = 0;
/**
* Called when the navigation display mode changes.
* See setNavigationDisplayMode
*/
virtual void navigationDisplayModeChanged(NavigationDisplayMode) {};
/** Returns the widgets which are associated with a particular navigation item */
QList<QWidget*> widgetsForItem( ViewProperties* item ) const;
......@@ -153,6 +176,7 @@ private slots:
void viewDestroyed(QObject* view);
private:
NavigationDisplayMode _navigationDisplayMode;
QList<QWidget*> _views;
QHash<QWidget*,ViewProperties*> _navigation;
};
......@@ -235,6 +259,7 @@ public:
protected:
virtual void addViewWidget(QWidget* view);
virtual void removeViewWidget(QWidget* view);
virtual void navigationDisplayModeChanged(NavigationDisplayMode mode);
private slots:
void updateTitle(ViewProperties* item);
......@@ -242,6 +267,8 @@ private slots:
void currentTabChanged(int index);
private:
void dynamicTabBarVisibility();
ViewContainerTabBar* _tabBar;
QStackedWidget* _stackWidget;
QWidget* _containerWidget;
......
......@@ -511,6 +511,19 @@ void ViewManager::loadViewSettings(TerminalDisplay* view , Profile* info)
colorScheme = ColorSchemeManager::instance()->defaultColorScheme();
Q_ASSERT( colorScheme );
// menu bar visibility
emit setMenuBarVisible( info->property(Profile::ShowMenuBar).value<bool>() );
// tab bar visibility
ViewContainer* container = _viewSplitter->activeContainer();
int tabBarMode = info->property(Profile::TabBarMode).value<int>();
if ( tabBarMode == Profile::AlwaysHideTabBar )
container->setNavigationDisplayMode(ViewContainer::AlwaysHideNavigation);
else if ( tabBarMode == Profile::AlwaysShowTabBar )
container->setNavigationDisplayMode(ViewContainer::AlwaysShowNavigation);
else if ( tabBarMode == Profile::ShowTabBarAsNeeded )
container->setNavigationDisplayMode(ViewContainer::ShowNavigationAsNeeded);
// load colour scheme
view->setColorTable(colorScheme->colorTable());
......
......@@ -131,6 +131,9 @@ signals:
// 'multipleViews' - true if the manager has multiple containers or false otherwise
void splitViewToggle(bool multipleViews);
/** TODO: Document me. */
void setMenuBarVisible(bool);
private slots:
// called when the "Split View Left/Right" menu item is selected
void splitLeftRight();
......
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