Commit 2739625d authored by Robert Knight's avatar Robert Knight

Allow the tab bar position to be specified in the profile editing dialog. ...

Allow the tab bar position to be specified in the profile editing dialog.  Other tweaks to the profile editing dialog.

svn path=/trunk/KDE/kdebase/apps/konsole/; revision=667497
parent 0ef9ea5f
......@@ -142,17 +142,28 @@ void EditProfileDialog::setupGeneralPage(const Profile* info)
_ui->remoteTabTitleEdit->setText(
info->property(Profile::RemoteTabTitleFormat).value<QString>());
// tab mode
// tab options
int tabMode = info->property(Profile::TabBarMode).value<int>();
int tabPosition = info->property(Profile::TabBarPosition).value<int>();
RadioOption tabModes[] = { {_ui->alwaysHideTabBarButton,Profile::AlwaysHideTabBar,
SLOT(alwaysHideTabBar()) },
{_ui->alwaysShowTabBarButton,Profile::AlwaysShowTabBar,
SLOT(alwaysShowTabBar()) },
{_ui->autoShowTabBarButton,Profile::ShowTabBarAsNeeded,
SLOT(showTabBarAsNeeded()) },
{0,0,0} };
setupRadio( tabModes , tabMode );
// note: Items should be in the same order as the
// Profile::TabBarModeEnum enum
_ui->tabBarVisibilityCombo->addItems( QStringList() << i18n("Always hide tab bar")
<< i18n("Show tab bar when needed")
<< i18n("Always show tab bar") );
_ui->tabBarVisibilityCombo->setCurrentIndex(tabMode);
// note: Items should be in the same order as the
// Profile::TabBarPositionEnum enum
_ui->tabBarPositionCombo->addItems( QStringList() << i18n("Below terminal displays")
<< i18n("Above terminal displays") );
_ui->tabBarPositionCombo->setCurrentIndex(tabPosition);
connect( _ui->tabBarVisibilityCombo , SIGNAL(activated(int)) , this ,
SLOT(tabBarVisibilityChanged(int)) );
connect( _ui->tabBarPositionCombo , SIGNAL(activated(int)) , this ,
SLOT(tabBarPositionChanged(int)) );
_ui->showMenuBarButton->setChecked( info->property(Profile::ShowMenuBar).value<bool>() );
......@@ -188,6 +199,14 @@ void EditProfileDialog::setupGeneralPage(const Profile* info)
connect(_ui->showMenuBarButton , SIGNAL(toggled(bool)) , this ,
SLOT(showMenuBar(bool)) );
}
void EditProfileDialog::tabBarVisibilityChanged(int newValue)
{
_tempProfile->setProperty( Profile::TabBarMode , newValue );
}
void EditProfileDialog::tabBarPositionChanged(int newValue)
{
_tempProfile->setProperty( Profile::TabBarPosition , newValue );
}
void EditProfileDialog::insertTabTitleText(const QString& text)
{
_ui->tabTitleEdit->insert(text);
......@@ -200,18 +219,6 @@ void EditProfileDialog::showMenuBar(bool show)
{
_tempProfile->setProperty(Profile::ShowMenuBar,show);
}
void EditProfileDialog::alwaysHideTabBar()
{
_tempProfile->setProperty(Profile::TabBarMode,Profile::AlwaysHideTabBar);
}
void EditProfileDialog::alwaysShowTabBar()
{
_tempProfile->setProperty(Profile::TabBarMode,Profile::AlwaysShowTabBar);
}
void EditProfileDialog::showTabBarAsNeeded()
{
_tempProfile->setProperty(Profile::TabBarMode,Profile::ShowTabBarAsNeeded);
}
void EditProfileDialog::tabTitleFormatChanged(const QString& format)
{
_tempProfile->setProperty(Profile::LocalTabTitleFormat,format);
......
......@@ -103,9 +103,8 @@ private slots:
void insertRemoteTabTitleText(const QString& text);
void showMenuBar(bool);
void alwaysHideTabBar();
void alwaysShowTabBar();
void showTabBarAsNeeded();
void tabBarVisibilityChanged(int);
void tabBarPositionChanged(int);
// appearance page
void setFontSize(int pointSize);
......
This diff is collapsed.
......@@ -51,6 +51,7 @@ FallbackProfile::FallbackProfile()
setProperty(LocalTabTitleFormat,"%d : %n");
setProperty(RemoteTabTitleFormat,"%H (%u)");
setProperty(TabBarMode,AlwaysShowTabBar);
setProperty(TabBarPosition,TabBarBottom);
setProperty(ShowMenuBar,true);
setProperty(KeyBindings,"default");
......@@ -186,6 +187,7 @@ bool KDE4ProfileWriter::writeProfile(const QString& path , const Profile* profil
// Menu and Tab Bar
writeStandardElement( general , "TabBarMode" , profile , Profile::TabBarMode );
writeStandardElement( general , "TabBarPosition" , profile , Profile::TabBarPosition );
writeStandardElement( general , "ShowMenuBar" , profile , Profile::ShowMenuBar );
// Keyboard
......@@ -260,6 +262,7 @@ bool KDE4ProfileReader::readProfile(const QString& path , Profile* profile)
readStandardElement<QString>(general,"RemoteTabTitleFormat",profile,Profile::RemoteTabTitleFormat);
readStandardElement<int>(general,"TabBarMode",profile,Profile::TabBarMode);
readStandardElement<int>(general,"TabBarPosition",profile,Profile::TabBarPosition);
readStandardElement<bool>(general,"ShowMenuBar",profile,Profile::ShowMenuBar);
// keyboard
......
......@@ -156,18 +156,34 @@ public:
/** TODO Document me */
// FIXME - Is this a duplicate of SelectWordCharacters?
WordCharacters // QString
WordCharacters, // QString
/** (TabBarPositionEnum) Position of the tab-bar relative to the terminal displays. */
TabBarPosition
};
/** This enum describes the available modes for showing or hiding the tab bar. */
/**
* This enum describes the available modes for showing or hiding the tab bar.
*/
enum TabBarModeEnum
{
/** The tab bar is never shown. */
AlwaysHideTabBar,
AlwaysHideTabBar = 0,
/** The tab bar is shown if there are multiple tabs open or hidden otherwise. */
ShowTabBarAsNeeded,
ShowTabBarAsNeeded = 1,
/** The tab bar is always shown. */
AlwaysShowTabBar
AlwaysShowTabBar = 2
};
/**
* This enum describes the available tab bar positions.
*/
enum TabBarPositionEnum
{
/** Show tab bar below displays. */
TabBarBottom = 0,
/** Show tab bar above displays. */
TabBarTop = 1
};
/**
......@@ -177,15 +193,15 @@ public:
enum HistoryModeEnum
{
/** No output is remembered. As soon as lines of text are scrolled off-screen they are lost. */
DisableHistory,
DisableHistory = 0,
/** A fixed number of lines of output are remembered. Once the limit is reached, the oldest
* lines are lost. */
FixedSizeHistory,
FixedSizeHistory = 1,
/** All output is remembered for the duration of the session.
* Typically this means that lines are recorded to
* a file as they are scrolled off-screen.
*/
UnlimitedHistory
UnlimitedHistory = 2
};
/**
......@@ -194,22 +210,22 @@ public:
enum ScrollBarPositionEnum
{
/** Show the scroll-bar on the left of the terminal display. */
ScrollBarLeft,
ScrollBarLeft = 0,
/** Show the scroll-bar on the right of the terminal display. */
ScrollBarRight,
ScrollBarRight = 1,
/** Do not show the scroll-bar. */
ScrollBarHidden
ScrollBarHidden = 2
};
/** This enum describes the shapes used to draw the cursor in terminal displays. */
enum CursorShapeEnum
{
/** Use a solid rectangular block to draw the cursor. */
BlockCursor,
BlockCursor = 0,
/** Use an 'I' shape, similar to that used in text editing applications, to draw the cursor. */
IBeamCursor,
IBeamCursor = 1,
/** Draw a line underneath the cursor's position. */
UnderlineCursor
UnderlineCursor = 2
};
/**
......
......@@ -460,14 +460,25 @@ QList<ViewContainer::NavigationPosition> TabbedViewContainerV2::supportedNavigat
}
void TabbedViewContainerV2::navigationPositionChanged(NavigationPosition position)
{
if ( position == NavigationPositionTop && _layout->indexOf(_tabBar) != 0 )
// index of tab bar in layout when it is at the top
const int TabBarTopIndex = 1;
if ( position == NavigationPositionTop
&& _layout->indexOf(_tabBar) != TabBarTopIndex )
{
_layout->removeWidget(_tabBar);
_layout->removeItem(_tabBarSpacer);
_layout->insertWidget(0,_tabBar);
_layout->insertItemAt(0,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedNorth);
}
else if ( position == NavigationPositionBottom && _layout->indexOf(_tabBar) == 0 )
else if ( position == NavigationPositionBottom
&& _layout->indexOf(_tabBar) == TabBarTopIndex )
{
_layout->removeWidget(_tabBar);
_layout->removeItem(_tabBarSpacer);
_layout->insertWidget(-1,_tabBar);
_layout->insertItemAt(-1,_tabBarSpacer);
_tabBar->setShape(QTabBar::RoundedSouth);
......
......@@ -302,7 +302,7 @@ void ViewManager::splitView(Qt::Orientation orientation)
// container and create a new view for that session in a new container
QListIterator<QWidget*> existingViewIter(_viewSplitter->activeContainer()->views());
ViewContainer* container = createContainer();
ViewContainer* container = 0;
while (existingViewIter.hasNext())
{
......@@ -313,6 +313,11 @@ void ViewManager::splitView(Qt::Orientation orientation)
_sessionMap[display] = session;
// create a container using settings from the first
// session in the previous container
if ( !container )
container = createContainer(session->profileKey());
container->addView(display,properties);
session->addView( display );
}
......@@ -387,7 +392,8 @@ void ViewManager::createView(Session* session)
// create the default container
if (_viewSplitter->containers().count() == 0)
{
_viewSplitter->addContainer( createContainer() , Qt::Vertical );
_viewSplitter->addContainer( createContainer(session->profileKey()) ,
Qt::Vertical );
emit splitViewToggle(false);
}
......@@ -426,9 +432,19 @@ void ViewManager::createView(Session* session)
}
}
ViewContainer* ViewManager::createContainer()
ViewContainer* ViewManager::createContainer(const QString& profileKey)
{
ViewContainer* container = new TabbedViewContainerV2(ViewContainer::NavigationPositionBottom,_viewSplitter);
const Profile* info = SessionManager::instance()->profile(profileKey);
Q_ASSERT( info );
const int tabPosition = info->property(Profile::TabBarPosition).value<int>();
ViewContainer::NavigationPosition position = ( tabPosition == Profile::TabBarTop ) ?
ViewContainer::NavigationPositionTop :
ViewContainer::NavigationPositionBottom;
ViewContainer* container = new TabbedViewContainerV2(position,_viewSplitter);
// connect signals and slots
connect( container , SIGNAL(viewAdded(QWidget*,ViewProperties*)) , _containerSignalMapper ,
......@@ -508,6 +524,8 @@ void ViewManager::applyProfile(TerminalDisplay* view , const QString& profileKey
// tab bar visibility
ViewContainer* container = _viewSplitter->activeContainer();
int tabBarMode = info->property(Profile::TabBarMode).value<int>();
int tabBarPosition = info->property(Profile::TabBarPosition).value<int>();
if ( tabBarMode == Profile::AlwaysHideTabBar )
container->setNavigationDisplayMode(ViewContainer::AlwaysHideNavigation);
else if ( tabBarMode == Profile::AlwaysShowTabBar )
......@@ -515,6 +533,11 @@ void ViewManager::applyProfile(TerminalDisplay* view , const QString& profileKey
else if ( tabBarMode == Profile::ShowTabBarAsNeeded )
container->setNavigationDisplayMode(ViewContainer::ShowNavigationAsNeeded);
if ( tabBarPosition == Profile::TabBarTop )
container->setNavigationPosition(ViewContainer::NavigationPositionTop);
else if ( tabBarPosition == Profile::TabBarBottom )
container->setNavigationPosition(ViewContainer::NavigationPositionBottom);
// load colour scheme
view->setColorTable(colorScheme->colorTable());
view->setOpacity(colorScheme->opacity());
......
......@@ -190,7 +190,9 @@ private:
void splitView(Qt::Orientation orientation);
// creates a new container which can hold terminal displays
ViewContainer* createContainer();
// 'key' specifies the profile to use to get initial
// settings (eg. navigation position) for the container
ViewContainer* createContainer(const QString& profileKey);
// removes a container and emits appropriate signals
void removeContainer(ViewContainer* container);
......
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