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
...@@ -147,7 +147,7 @@ void Application::detachView(Session* session) ...@@ -147,7 +147,7 @@ void Application::detachView(Session* session)
void Application::createSession(const QString& key , ViewManager* view) void Application::createSession(const QString& key , ViewManager* view)
{ {
Session* session = SessionManager::instance()->createSession(key); Session* session = SessionManager::instance()->createSession(key);
// create view before starting the session process so that the session doesn't suffer // create view before starting the session process so that the session doesn't suffer
// a change in terminal size right after the session starts. some applications such as GNU Screen // a change in terminal size right after the session starts. some applications such as GNU Screen
// and Midnight Commander don't like this happening // and Midnight Commander don't like this happening
......
...@@ -117,8 +117,8 @@ void EditProfileDialog::setupGeneralPage(const Profile* info) ...@@ -117,8 +117,8 @@ void EditProfileDialog::setupGeneralPage(const Profile* info)
int tabMode = info->property(Profile::TabBarMode).value<int>(); int tabMode = info->property(Profile::TabBarMode).value<int>();
RadioOption tabModes[] = { {_ui->alwaysHideTabBarButton,Profile::AlwaysHideTabBar,SLOT(alwaysHideTabBar())}, RadioOption tabModes[] = { {_ui->alwaysHideTabBarButton,Profile::AlwaysHideTabBar,SLOT(alwaysHideTabBar())},
{_ui->alwaysShowTabBarButton,Profile::AlwaysShowTabBar,SLOT(showTabBarAsNeeded())}, {_ui->alwaysShowTabBarButton,Profile::AlwaysShowTabBar,SLOT(alwaysShowTabBar())},
{_ui->autoShowTabBarButton,Profile::ShowTabBarAsNeeded,SLOT(alwaysShowTabBar())}, {_ui->autoShowTabBarButton,Profile::ShowTabBarAsNeeded,SLOT(showTabBarAsNeeded())},
{0,0,0} }; {0,0,0} };
setupRadio( tabModes , tabMode ); setupRadio( tabModes , tabMode );
......
...@@ -76,6 +76,9 @@ MainWindow::MainWindow() ...@@ -76,6 +76,9 @@ MainWindow::MainWindow()
connect( _viewManager , SIGNAL(viewPropertiesChanged(const QList<ViewProperties*>&)) , connect( _viewManager , SIGNAL(viewPropertiesChanged(const QList<ViewProperties*>&)) ,
bookmarkHandler() , SLOT(setViews(const QList<ViewProperties*>&)) ); bookmarkHandler() , SLOT(setViews(const QList<ViewProperties*>&)) );
connect( _viewManager , SIGNAL(setMenuBarVisible(bool)) , menuBar() ,
SLOT(setVisible(bool)) );
// create main window widgets // create main window widgets
setupWidgets(); setupWidgets();
......
...@@ -34,6 +34,7 @@ class ViewSplitter; ...@@ -34,6 +34,7 @@ class ViewSplitter;
class ViewManager; class ViewManager;
class ViewProperties; class ViewProperties;
class SessionController; class SessionController;
class Profile;
class ProfileList; class ProfileList;
class BookmarkHandler; class BookmarkHandler;
......
...@@ -49,10 +49,32 @@ ...@@ -49,10 +49,32 @@
using namespace Konsole; using namespace Konsole;
ViewContainer::ViewContainer(QObject* parent)
: QObject(parent)
, _navigationDisplayMode(AlwaysShowNavigation)
{
}
ViewContainer::~ViewContainer() ViewContainer::~ViewContainer()
{ {
emit destroyed(this); 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) void ViewContainer::addView(QWidget* view , ViewProperties* item)
{ {
_views << view; _views << view;
...@@ -383,6 +405,28 @@ TabbedViewContainerV2::TabbedViewContainerV2(QObject* parent) : ViewContainer(pa ...@@ -383,6 +405,28 @@ TabbedViewContainerV2::TabbedViewContainerV2(QObject* parent) : ViewContainer(pa
_containerWidget->setLayout(layout); _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() TabbedViewContainerV2::~TabbedViewContainerV2()
{ {
_containerWidget->deleteLater(); _containerWidget->deleteLater();
...@@ -418,6 +462,9 @@ void TabbedViewContainerV2::addViewWidget( QWidget* view ) ...@@ -418,6 +462,9 @@ void TabbedViewContainerV2::addViewWidget( QWidget* view )
connect( item , SIGNAL(titleChanged(ViewProperties*)) , this , SLOT(updateTitle(ViewProperties*))); connect( item , SIGNAL(titleChanged(ViewProperties*)) , this , SLOT(updateTitle(ViewProperties*)));
connect( item , SIGNAL(iconChanged(ViewProperties*) ) , this ,SLOT(updateIcon(ViewProperties*))); connect( item , SIGNAL(iconChanged(ViewProperties*) ) , this ,SLOT(updateIcon(ViewProperties*)));
_tabBar->addTab( item->icon() , item->title() ); _tabBar->addTab( item->icon() , item->title() );
if ( navigationDisplayMode() == ShowNavigationAsNeeded )
dynamicTabBarVisibility();
} }
void TabbedViewContainerV2::removeViewWidget( QWidget* view ) void TabbedViewContainerV2::removeViewWidget( QWidget* view )
{ {
...@@ -427,6 +474,9 @@ void TabbedViewContainerV2::removeViewWidget( QWidget* view ) ...@@ -427,6 +474,9 @@ void TabbedViewContainerV2::removeViewWidget( QWidget* view )
_stackWidget->removeWidget(view); _stackWidget->removeWidget(view);
_tabBar->removeTab(index); _tabBar->removeTab(index);
if ( navigationDisplayMode() == ShowNavigationAsNeeded )
dynamicTabBarVisibility();
} }
void TabbedViewContainerV2::updateTitle(ViewProperties* item) void TabbedViewContainerV2::updateTitle(ViewProperties* item)
......
...@@ -68,7 +68,8 @@ class ViewContainer : public QObject ...@@ -68,7 +68,8 @@ class ViewContainer : public QObject
Q_OBJECT Q_OBJECT
public: 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 * Called when the ViewContainer is destroyed. When reimplementing this in
...@@ -80,6 +81,22 @@ public: ...@@ -80,6 +81,22 @@ public:
/** Returns the widget which contains the view widgets */ /** Returns the widget which contains the view widgets */
virtual QWidget* containerWidget() const = 0; 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 */ /** Adds a new view to the container widget */
void addView(QWidget* view , ViewProperties* navigationItem); void addView(QWidget* view , ViewProperties* navigationItem);
...@@ -145,7 +162,13 @@ protected: ...@@ -145,7 +162,13 @@ protected:
* from the container widget. * from the container widget.
*/ */
virtual void removeViewWidget(QWidget* view) = 0; 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 */ /** Returns the widgets which are associated with a particular navigation item */
QList<QWidget*> widgetsForItem( ViewProperties* item ) const; QList<QWidget*> widgetsForItem( ViewProperties* item ) const;
...@@ -153,6 +176,7 @@ private slots: ...@@ -153,6 +176,7 @@ private slots:
void viewDestroyed(QObject* view); void viewDestroyed(QObject* view);
private: private:
NavigationDisplayMode _navigationDisplayMode;
QList<QWidget*> _views; QList<QWidget*> _views;
QHash<QWidget*,ViewProperties*> _navigation; QHash<QWidget*,ViewProperties*> _navigation;
}; };
...@@ -235,6 +259,7 @@ public: ...@@ -235,6 +259,7 @@ public:
protected: protected:
virtual void addViewWidget(QWidget* view); virtual void addViewWidget(QWidget* view);
virtual void removeViewWidget(QWidget* view); virtual void removeViewWidget(QWidget* view);
virtual void navigationDisplayModeChanged(NavigationDisplayMode mode);
private slots: private slots:
void updateTitle(ViewProperties* item); void updateTitle(ViewProperties* item);
...@@ -242,6 +267,8 @@ private slots: ...@@ -242,6 +267,8 @@ private slots:
void currentTabChanged(int index); void currentTabChanged(int index);
private: private:
void dynamicTabBarVisibility();
ViewContainerTabBar* _tabBar; ViewContainerTabBar* _tabBar;
QStackedWidget* _stackWidget; QStackedWidget* _stackWidget;
QWidget* _containerWidget; QWidget* _containerWidget;
......
...@@ -511,6 +511,19 @@ void ViewManager::loadViewSettings(TerminalDisplay* view , Profile* info) ...@@ -511,6 +511,19 @@ void ViewManager::loadViewSettings(TerminalDisplay* view , Profile* info)
colorScheme = ColorSchemeManager::instance()->defaultColorScheme(); colorScheme = ColorSchemeManager::instance()->defaultColorScheme();
Q_ASSERT( colorScheme ); 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 // load colour scheme
view->setColorTable(colorScheme->colorTable()); view->setColorTable(colorScheme->colorTable());
......
...@@ -131,6 +131,9 @@ signals: ...@@ -131,6 +131,9 @@ signals:
// 'multipleViews' - true if the manager has multiple containers or false otherwise // 'multipleViews' - true if the manager has multiple containers or false otherwise
void splitViewToggle(bool multipleViews); void splitViewToggle(bool multipleViews);
/** TODO: Document me. */
void setMenuBarVisible(bool);
private slots: private slots:
// called when the "Split View Left/Right" menu item is selected // called when the "Split View Left/Right" menu item is selected
void splitLeftRight(); 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