Commit acd37f7a authored by Jekyll Wu's avatar Jekyll Wu

Allow users to control where the newly created tab should be placed.

CCBUG:276872
REVIEW:102685
parent ee5ed877
......@@ -346,6 +346,7 @@ void EditProfileDialog::setupTabsPage(const Profile::Ptr info)
// tab options
int tabBarMode = info->property<int>(Profile::TabBarMode);
int tabBarPosition = info->property<int>(Profile::TabBarPosition);
int newTabBehavior = info->property<int>(Profile::NewTabBehavior);
// note: Items should be in the same order as the
// Profile::TabBarModeEnum enum
......@@ -358,9 +359,14 @@ void EditProfileDialog::setupTabsPage(const Profile::Ptr info)
// Profile::TabBarPositionEnum enum
_ui->tabBarPositionCombo->addItems( QStringList() << i18n("Below Terminal Displays")
<< i18n("Above Terminal Displays") );
_ui->tabBarPositionCombo->setCurrentIndex(tabBarPosition);
// note: Items should be in the same order as the
// Profile::NewTabBehaviorEnum enum
_ui->newTabBehaviorCombo->addItems( QStringList() << i18n("Put New Tab At The End")
<< i18n("Put New Tab After Current Tab") );
_ui->newTabBehaviorCombo->setCurrentIndex(newTabBehavior);
_ui->newTabButton->setChecked(info->property<bool>(Profile::ShowNewAndCloseTabButtons));
// signals and slots
......@@ -368,6 +374,8 @@ void EditProfileDialog::setupTabsPage(const Profile::Ptr info)
SLOT(tabBarVisibilityChanged(int)) );
connect( _ui->tabBarPositionCombo , SIGNAL(activated(int)) , this ,
SLOT(tabBarPositionChanged(int)) );
connect( _ui->newTabBehaviorCombo , SIGNAL(activated(int)) , this ,
SLOT(newTabBehaviorChanged(int)) );
connect( _ui->newTabButton , SIGNAL(toggled(bool)) , this ,
SLOT(showNewTabButton(bool)) );
......@@ -401,6 +409,10 @@ void EditProfileDialog::tabBarPositionChanged(int newValue)
{
updateTempProfileProperty( Profile::TabBarPosition , newValue );
}
void EditProfileDialog::newTabBehaviorChanged(int newValue)
{
updateTempProfileProperty( Profile::NewTabBehavior , newValue );
}
void EditProfileDialog::insertTabTitleText(const QString& text)
{
_ui->tabTitleEdit->insert(text);
......
......@@ -125,6 +125,7 @@ private slots:
void showEnvironmentEditor();
void tabBarVisibilityChanged(int);
void tabBarPositionChanged(int);
void newTabBehaviorChanged(int);
void showNewTabButton(bool);
// appearance page
......
......@@ -392,7 +392,27 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<item row="3" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>New tab behavior:</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="KComboBox" name="newTabBehaviorCombo">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>1</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="newTabButton">
<property name="text">
<string>Show 'New Tab' and 'Close Tab' buttons in tab bar</string>
......
......@@ -80,6 +80,7 @@ const Profile::PropertyInfo Profile::DefaultPropertyNames[] =
, { SaveGeometryOnExit , "SaveGeometryOnExit" , GENERAL_GROUP , QVariant::Bool }
, { TabBarMode , "TabBarMode" , GENERAL_GROUP , QVariant::Int }
, { TabBarPosition , "TabBarPosition" , GENERAL_GROUP , QVariant::Int }
, { NewTabBehavior , "NewTabBehavior" , GENERAL_GROUP , QVariant::Int }
, { StartInCurrentSessionDir , "StartInCurrentSessionDir" , GENERAL_GROUP , QVariant::Bool }
, { ShowNewAndCloseTabButtons, "ShowNewAndCloseTabButtons" , GENERAL_GROUP , QVariant::Bool }
, { MenuIndex, "MenuIndex" , GENERAL_GROUP , QVariant::String }
......@@ -158,6 +159,7 @@ FallbackProfile::FallbackProfile()
setProperty(RemoteTabTitleFormat,"(%u) %H");
setProperty(TabBarMode,AlwaysShowTabBar);
setProperty(TabBarPosition,TabBarBottom);
setProperty(NewTabBehavior,PutNewTabAtTheEnd);
setProperty(ShowMenuBar,true);
setProperty(ShowSizeWidget,true);
setProperty(SaveGeometryOnExit,true);
......
......@@ -176,6 +176,8 @@ public:
WordCharacters,
/** (TabBarPositionEnum) Position of the tab-bar relative to the terminal displays. */
TabBarPosition,
/** (NewTabBehaviorEnum) Specifies where the newly created tab should be placed. */
NewTabBehavior,
/** (bool) If true, the triple click selects from current word onwards. Otherwise
* selects whole line.
*/
......@@ -226,6 +228,17 @@ public:
TabBarTop = 1
};
/**
* This enum describes where newly created tab should be placed.
*/
enum NewTabBehaviorEnum
{
/** Put newly created tab at the end. */
PutNewTabAtTheEnd = 0,
/** Put newly created tab right after current tab. */
PutNewTabAfterCurrentTab = 1
};
/**
* This enum describes the modes available to remember lines of output produced
* by the terminal.
......
......@@ -616,15 +616,24 @@ void ViewManager::createView(Session* session)
emit splitViewToggle(false);
}
// new tab will be put at the end by default.
int index = -1;
// In all containers the new view will be put at the same position, i.e.,
// the position right after the active view in the active container.
QWidget* view = activeView();
if (view)
// TODO: currently, whether new tab should be put after current tab is a per
// profile setting, while in concept it should be per ViewManager or global
// setting. The current implementation is limited by the design of Profile.h
// It should be re-implmented at some appropriate time in the future.
// comment by jekyllwu
Profile::Ptr info = SessionManager::instance()->sessionProfile(session);
int newTabBehavior = info->property<int>(Profile::NewTabBehavior);
if ( newTabBehavior == Profile::PutNewTabAfterCurrentTab )
{
QList<QWidget*> views = _viewSplitter->activeContainer()->views();
index = views.indexOf(view) + 1;
QWidget* view = activeView();
if (view)
{
QList<QWidget*> views = _viewSplitter->activeContainer()->views();
index = views.indexOf(view) + 1;
}
}
// iterate over the view containers owned by this view manager
......
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