diff --git a/src/MainWindow.h b/src/MainWindow.h --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -107,6 +107,16 @@ */ void setRemoveWindowTitleBarAndFrame(bool frameless); + /** + * This enum describes where newly created tab should be placed. + */ + enum NewTabBehavior { + /** Put newly created tab at the end. */ + PutNewTabAtTheEnd = 0, + /** Put newly created tab right after current tab. */ + PutNewTabAfterCurrentTab = 1 + }; + Q_SIGNALS: /** @@ -195,6 +205,7 @@ BookmarkHandler *_bookmarkHandler; KToggleAction *_toggleMenuBarAction; KActionMenu *_newTabMenuAction; + NewTabBehavior _newTabBehavior; QPointer _pluggedController; diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -768,7 +768,7 @@ removeMenuAccelerators(); } - _viewManager->setNavigationBehavior(KonsoleSettings::newTabBehavior()); + _viewManager->activeContainer()->setNavigationBehavior(KonsoleSettings::newTabBehavior()); setAutoSaveSettings(QStringLiteral("MainWindow"), KonsoleSettings::saveGeometryOnExit()); updateWindowCaption(); } diff --git a/src/ViewContainer.h b/src/ViewContainer.h --- a/src/ViewContainer.h +++ b/src/ViewContainer.h @@ -75,7 +75,7 @@ ~TabbedViewContainer() Q_DECL_OVERRIDE; /** Adds a new view to the container widget */ - void addView(TerminalDisplay *view, int index = -1); + void addView(TerminalDisplay *view); void addSplitter(ViewSplitter *splitter, int index = -1); /** splits the currently focused Splitter */ @@ -151,6 +151,18 @@ void moveTabLeft(); void moveTabRight(); + /** + * This enum describes where newly created tab should be placed. + */ + enum NewTabBehavior { + /** Put newly created tab at the end. */ + PutNewTabAtTheEnd = 0, + /** Put newly created tab right after current tab. */ + PutNewTabAfterCurrentTab = 1 + }; + + void setNavigationBehavior(int behavior); + Q_SIGNALS: /** Emitted when the container has no more children */ void empty(TabbedViewContainer *container); @@ -203,6 +215,7 @@ QToolButton *_closeTabButton; int _contextMenuTabIndex; ViewManager::NavigationVisibility _navigationVisibility; + NewTabBehavior _newTabBehavior; }; diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp --- a/src/ViewContainer.cpp +++ b/src/ViewContainer.cpp @@ -62,7 +62,8 @@ _newTabButton(new QToolButton(this)), _closeTabButton(new QToolButton(this)), _contextMenuTabIndex(-1), - _navigationVisibility(ViewManager::NavigationVisibility::NavigationNotSet) + _navigationVisibility(ViewManager::NavigationVisibility::NavigationNotSet), + _newTabBehavior(PutNewTabAtTheEnd) { setAcceptDrops(true); @@ -283,11 +284,12 @@ setCurrentIndex(index); } -void TabbedViewContainer::addView(TerminalDisplay *view, int index) +void TabbedViewContainer::addView(TerminalDisplay *view) { auto viewSplitter = new ViewSplitter(); viewSplitter->addTerminalDisplay(view, Qt::Horizontal); auto item = view->sessionController(); + int index = _newTabBehavior == PutNewTabAfterCurrentTab ? currentIndex() + 1 : -1; if (index == -1) { index = addTab(viewSplitter, item->icon(), item->title()); } else { @@ -564,7 +566,7 @@ activeViewSplitter()->restoreOtherTerminals(); } -void TabbedViewContainer::moveTabLeft() +void TabbedViewContainer::moveTabLeft() { if (currentIndex() == 0) { return; @@ -579,3 +581,8 @@ } tabBar()->moveTab(currentIndex(), currentIndex() + 1); } + +void TabbedViewContainer::setNavigationBehavior(int behavior) +{ + _newTabBehavior = static_cast(behavior); +} diff --git a/src/ViewManager.h b/src/ViewManager.h --- a/src/ViewManager.h +++ b/src/ViewManager.h @@ -121,16 +121,6 @@ NoNavigation }; - /** - * This enum describes where newly created tab should be placed. - */ - enum NewTabBehavior { - /** Put newly created tab at the end. */ - PutNewTabAtTheEnd = 0, - /** Put newly created tab right after current tab. */ - PutNewTabAfterCurrentTab = 1 - }; - /** * Describes the options for showing or hiding the container's navigation widget. */ @@ -180,7 +170,6 @@ void saveSessions(KConfigGroup &group); void restoreSessions(const KConfigGroup &group); - void setNavigationBehavior(int behavior); int managerId() const; /** Returns a list of sessions in this ViewManager */ @@ -433,7 +422,6 @@ NavigationMethod _navigationMethod; NavigationVisibility _navigationVisibility; - NewTabBehavior _newTabBehavior; int _managerId; static int lastManagerId; QList _terminalDisplayHistory; diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -58,7 +58,6 @@ _actionCollection(collection), _navigationMethod(NoNavigation), _navigationVisibility(NavigationNotSet), - _newTabBehavior(PutNewTabAtTheEnd), _managerId(0), _terminalDisplayHistoryIndex(-1) { @@ -1091,11 +1090,6 @@ } } -void ViewManager::setNavigationBehavior(int behavior) -{ - _newTabBehavior = static_cast(behavior); -} - void ViewManager::updateTerminalDisplayHistory(TerminalDisplay* terminalDisplay, bool remove) { if (terminalDisplay == nullptr) {