diff --git a/src/EditProfileDialog.cpp b/src/EditProfileDialog.cpp index cf3417145..a2e8c3240 100644 --- a/src/EditProfileDialog.cpp +++ b/src/EditProfileDialog.cpp @@ -142,17 +142,28 @@ void EditProfileDialog::setupGeneralPage(const Profile* info) _ui->remoteTabTitleEdit->setText( info->property(Profile::RemoteTabTitleFormat).value()); - // tab mode + // tab options int tabMode = info->property(Profile::TabBarMode).value(); + int tabPosition = info->property(Profile::TabBarPosition).value(); - 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() ); @@ -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); diff --git a/src/EditProfileDialog.h b/src/EditProfileDialog.h index 139ac9ba8..c6ddc3349 100644 --- a/src/EditProfileDialog.h +++ b/src/EditProfileDialog.h @@ -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); diff --git a/src/EditProfileDialog.ui b/src/EditProfileDialog.ui index 583c2d747..b5c53eb8e 100644 --- a/src/EditProfileDialog.ui +++ b/src/EditProfileDialog.ui @@ -5,8 +5,8 @@ 0 0 - 505 - 524 + 581 + 679 @@ -37,126 +37,138 @@ General - - - - - Profile name: + + + + + Basic Profile Options - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + true + + + + + Profile name: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + A descriptive name for the profile + + + + + + + Command: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + The command to execute when new terminal sessions are created using this profile + + + + + + + Initial directory: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + The initial working directory for new terminal sessions using this profile + + + + + + + Browse for initial directory + + + ... + + + + + + + Icon: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + 0 + 0 + + + + + 64 + 64 + + + + + 0 + 0 + + + + Select the icon displayed on tabs using this profile + + + + + + + 48 + 48 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - - - A descriptive name for the profile - - - - - - - Command: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - The command to execute when new terminal sessions are created using this profile - - - - - - - Initial directory: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - The initial working directory for new terminal sessions using this profile - - - - - - - Browse for initial directory - - - ... - - - - - - - Icon: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 64 - 64 - - - - - 0 - 0 - - - - Select the icon displayed on tabs using this profile - - - - - - - 48 - 48 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - + Tab Titles @@ -222,7 +234,7 @@ - + Window && Tab Bar Options @@ -230,8 +242,8 @@ true - - + + Show or hide the menu bar in terminal windows using this profile @@ -241,48 +253,52 @@ - - - - Never show the tab bar - + + - Always hide tab bar + Tab bar display: - - - - Hide or show the tab bar automatically depending on the number of tabs open - - - Show tab bar when more than one tab is open + + + + + 1 + 0 + - - - - Always show the tab bar - + + - Always show tab bar + Tab bar position: + + + + + + + + 1 + 0 + - + Qt::Vertical - 20 - 40 + 95 + 61 @@ -468,63 +484,75 @@ Keyboard Setup - - - - - - - - Create a new key bindings list based upon the selected bindings + + + + + Key Bindings - - New... + + true + + + + + + + + Create a new key bindings list based upon the selected bindings + + + New... + + + + + + + Edit the selected key bindings list + + + Edit... + + + + + + + Delete the selected key bindings list + + + Remove + + + + + + + Use the selected key bindings list in this profile + + + Select + + + + + + + Qt::Vertical + + + + 71 + 101 + + + + + - - - - Edit the selected key bindings list - - - Edit... - - - - - - - Delete the selected key bindings list - - - Remove - - - - - - - Use the selected key bindings list in this profile - - - Select - - - - - - - Qt::Vertical - - - - 75 - 331 - - - - diff --git a/src/Profile.cpp b/src/Profile.cpp index 0a60ebe15..7354f83c5 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -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(general,"RemoteTabTitleFormat",profile,Profile::RemoteTabTitleFormat); readStandardElement(general,"TabBarMode",profile,Profile::TabBarMode); + readStandardElement(general,"TabBarPosition",profile,Profile::TabBarPosition); readStandardElement(general,"ShowMenuBar",profile,Profile::ShowMenuBar); // keyboard diff --git a/src/Profile.h b/src/Profile.h index 8d27a35f6..7c104562c 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -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 }; /** diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp index 765fa39be..2bad7fb34 100644 --- a/src/ViewContainer.cpp +++ b/src/ViewContainer.cpp @@ -460,14 +460,25 @@ QList 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); diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp index 3a2781e0c..14ce4b8fc 100644 --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -302,7 +302,7 @@ void ViewManager::splitView(Qt::Orientation orientation) // container and create a new view for that session in a new container QListIterator 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(); + + 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 tabBarPosition = info->property(Profile::TabBarPosition).value(); + 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()); diff --git a/src/ViewManager.h b/src/ViewManager.h index e77cf69c8..3d860906c 100644 --- a/src/ViewManager.h +++ b/src/ViewManager.h @@ -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);