Changeset View
Changeset View
Standalone View
Standalone View
src/ViewManager.cpp
Show First 20 Lines • Show All 46 Lines • ▼ Show 20 Line(s) | |||||
47 | #include "ViewContainer.h" | 47 | #include "ViewContainer.h" | ||
48 | 48 | | |||
49 | using namespace Konsole; | 49 | using namespace Konsole; | ||
50 | 50 | | |||
51 | int ViewManager::lastManagerId = 0; | 51 | int ViewManager::lastManagerId = 0; | ||
52 | 52 | | |||
53 | ViewManager::ViewManager(QObject *parent, KActionCollection *collection) : | 53 | ViewManager::ViewManager(QObject *parent, KActionCollection *collection) : | ||
54 | QObject(parent), | 54 | QObject(parent), | ||
55 | _viewSplitter(nullptr), | 55 | _viewContainer(nullptr), | ||
56 | _pluggedController(nullptr), | 56 | _pluggedController(nullptr), | ||
57 | _sessionMap(QHash<TerminalDisplay *, Session *>()), | 57 | _sessionMap(QHash<TerminalDisplay *, Session *>()), | ||
58 | _actionCollection(collection), | 58 | _actionCollection(collection), | ||
59 | _navigationMethod(NoNavigation), | 59 | _navigationMethod(NoNavigation), | ||
60 | _navigationVisibility(NavigationNotSet), | 60 | _navigationVisibility(NavigationNotSet), | ||
61 | _newTabBehavior(PutNewTabAtTheEnd), | 61 | _newTabBehavior(PutNewTabAtTheEnd), | ||
62 | _managerId(0) | 62 | _managerId(0) | ||
63 | { | 63 | { | ||
64 | // create main view area | 64 | _viewContainer = createContainer(); | ||
65 | _viewSplitter = new ViewSplitter(nullptr); | | |||
66 | KAcceleratorManager::setNoAccel(_viewSplitter); | | |||
67 | | ||||
68 | // the ViewSplitter class supports both recursive and non-recursive splitting, | | |||
69 | // in non-recursive mode, all containers are inserted into the same top-level splitter | | |||
70 | // widget, and all the divider lines between the containers have the same orientation | | |||
71 | // | | |||
72 | // the ViewManager class is not currently able to handle a ViewSplitter in recursive-splitting | | |||
73 | // mode | | |||
74 | _viewSplitter->setRecursiveSplitting(false); | | |||
75 | _viewSplitter->setFocusPolicy(Qt::NoFocus); | | |||
76 | | ||||
77 | // setup actions which are related to the views | 65 | // setup actions which are related to the views | ||
78 | setupActions(); | 66 | setupActions(); | ||
79 | 67 | | |||
68 | /* TODO: Reconnect | ||||
80 | // emit a signal when all of the views held by this view manager are destroyed | 69 | // emit a signal when all of the views held by this view manager are destroyed | ||
81 | connect(_viewSplitter.data(), &Konsole::ViewSplitter::allContainersEmpty, | 70 | */ | ||
71 | connect(_viewContainer.data(), &Konsole::TabbedViewContainer::empty, | ||||
82 | this, &Konsole::ViewManager::empty); | 72 | this, &Konsole::ViewManager::empty); | ||
83 | connect(_viewSplitter.data(), &Konsole::ViewSplitter::empty, this, | | |||
84 | &Konsole::ViewManager::empty); | | |||
85 | 73 | | |||
86 | // listen for profile changes | 74 | // listen for profile changes | ||
87 | connect(ProfileManager::instance(), &Konsole::ProfileManager::profileChanged, | 75 | connect(ProfileManager::instance(), &Konsole::ProfileManager::profileChanged, | ||
88 | this, &Konsole::ViewManager::profileChanged); | 76 | this, &Konsole::ViewManager::profileChanged); | ||
89 | connect(SessionManager::instance(), &Konsole::SessionManager::sessionUpdated, | 77 | connect(SessionManager::instance(), &Konsole::SessionManager::sessionUpdated, | ||
90 | this, &Konsole::ViewManager::updateViewsForSession); | 78 | this, &Konsole::ViewManager::updateViewsForSession); | ||
91 | 79 | | |||
92 | //prepare DBus communication | 80 | //prepare DBus communication | ||
93 | new WindowAdaptor(this); | 81 | new WindowAdaptor(this); | ||
94 | 82 | | |||
95 | _managerId = ++lastManagerId; | 83 | _managerId = ++lastManagerId; | ||
96 | QDBusConnection::sessionBus().registerObject(QLatin1String("/Windows/") | 84 | QDBusConnection::sessionBus().registerObject(QLatin1String("/Windows/") | ||
97 | + QString::number(_managerId), this); | 85 | + QString::number(_managerId), this); | ||
98 | | ||||
99 | _viewSplitter->addContainer(createContainer(), Qt::Vertical); | | |||
100 | } | 86 | } | ||
101 | 87 | | |||
102 | ViewManager::~ViewManager() = default; | 88 | ViewManager::~ViewManager() = default; | ||
103 | 89 | | |||
104 | int ViewManager::managerId() const | 90 | int ViewManager::managerId() const | ||
105 | { | 91 | { | ||
106 | return _managerId; | 92 | return _managerId; | ||
107 | } | 93 | } | ||
108 | 94 | | |||
109 | QWidget *ViewManager::activeView() const | 95 | QWidget *ViewManager::activeView() const | ||
110 | { | 96 | { | ||
111 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | 97 | return _viewContainer->currentWidget(); | ||
112 | if (container != nullptr) { | | |||
113 | return container->currentWidget(); | | |||
114 | } else { | | |||
115 | return nullptr; | | |||
116 | } | | |||
117 | } | 98 | } | ||
118 | 99 | | |||
119 | QWidget *ViewManager::widget() const | 100 | QWidget *ViewManager::widget() const | ||
120 | { | 101 | { | ||
121 | return _viewSplitter; | 102 | return _viewContainer; | ||
122 | } | 103 | } | ||
123 | 104 | | |||
124 | void ViewManager::setupActions() | 105 | void ViewManager::setupActions() | ||
125 | { | 106 | { | ||
126 | Q_ASSERT(_actionCollection); | 107 | Q_ASSERT(_actionCollection); | ||
127 | if (_actionCollection == nullptr) { | 108 | if (_actionCollection == nullptr) { | ||
128 | return; | 109 | return; | ||
129 | } | 110 | } | ||
130 | 111 | | |||
131 | KActionCollection *collection = _actionCollection; | 112 | KActionCollection *collection = _actionCollection; | ||
132 | 113 | | |||
133 | QAction *nextViewAction = new QAction(i18nc("@action Shortcut entry", "Next Tab"), this); | 114 | // list of actions that should only be enabled when there are multiple view containers open | ||
134 | QAction *previousViewAction = new QAction(i18nc("@action Shortcut entry", "Previous Tab"), this); | | |||
135 | QAction *lastViewAction = new QAction(i18nc("@action Shortcut entry", | | |||
136 | "Switch to Last Tab"), this); | | |||
137 | QAction *lastUsedViewAction = new QAction(i18nc("@action Shortcut entry", "Last Used Tabs"), this); | | |||
138 | QAction *lastUsedViewReverseAction = new QAction(i18nc("@action Shortcut entry", | | |||
139 | "Last Used Tabs (Reverse)"), this); | | |||
140 | QAction *nextContainerAction = new QAction(i18nc("@action Shortcut entry", | | |||
141 | "Next View Container"), this); | | |||
142 | | ||||
143 | QAction *moveViewLeftAction = new QAction(i18nc("@action Shortcut entry", "Move Tab Left"), this); | | |||
144 | QAction *moveViewRightAction = new QAction(i18nc("@action Shortcut entry", | | |||
145 | "Move Tab Right"), this); | | |||
146 | | ||||
147 | // list of actions that should only be enabled when there are multiple view | | |||
148 | // containers open | | |||
149 | QList<QAction *> multiViewOnlyActions; | 115 | QList<QAction *> multiViewOnlyActions; | ||
150 | multiViewOnlyActions << nextContainerAction; | | |||
151 | | ||||
152 | QAction *splitLeftRightAction = new QAction(QIcon::fromTheme(QStringLiteral("view-split-left-right")), | | |||
153 | i18nc("@action:inmenu", "Split View Left/Right"), | | |||
154 | this); | | |||
155 | collection->setDefaultShortcut(splitLeftRightAction, Konsole::ACCEL + Qt::Key_ParenLeft); | | |||
156 | collection->addAction(QStringLiteral("split-view-left-right"), splitLeftRightAction); | | |||
157 | connect(splitLeftRightAction, &QAction::triggered, this, &Konsole::ViewManager::splitLeftRight); | | |||
158 | | ||||
159 | QAction *splitTopBottomAction = new QAction(QIcon::fromTheme(QStringLiteral("view-split-top-bottom")), | | |||
160 | i18nc("@action:inmenu", | | |||
161 | "Split View Top/Bottom"), this); | | |||
162 | collection->setDefaultShortcut(splitTopBottomAction, Konsole::ACCEL + Qt::Key_ParenRight); | | |||
163 | collection->addAction(QStringLiteral("split-view-top-bottom"), splitTopBottomAction); | | |||
164 | connect(splitTopBottomAction, &QAction::triggered, this, &Konsole::ViewManager::splitTopBottom); | | |||
165 | | ||||
166 | QAction *closeActiveAction = new QAction(i18nc("@action:inmenu Close Active View", "Close Active"), this); | | |||
167 | closeActiveAction->setIcon(QIcon::fromTheme(QStringLiteral("view-close"))); | | |||
168 | collection->setDefaultShortcut(closeActiveAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_X); | | |||
169 | closeActiveAction->setEnabled(false); | | |||
170 | collection->addAction(QStringLiteral("close-active-view"), closeActiveAction); | | |||
171 | connect(closeActiveAction, &QAction::triggered, this, | | |||
172 | &Konsole::ViewManager::closeActiveContainer); | | |||
173 | | ||||
174 | multiViewOnlyActions << closeActiveAction; | | |||
175 | | ||||
176 | QAction *closeOtherAction = new QAction(i18nc("@action:inmenu Close Other Views", | | |||
177 | "Close Others"), this); | | |||
178 | collection->setDefaultShortcut(closeOtherAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_O); | | |||
179 | closeOtherAction->setEnabled(false); | | |||
180 | collection->addAction(QStringLiteral("close-other-views"), closeOtherAction); | | |||
181 | connect(closeOtherAction, &QAction::triggered, this, | | |||
182 | &Konsole::ViewManager::closeOtherContainers); | | |||
183 | | ||||
184 | multiViewOnlyActions << closeOtherAction; | | |||
185 | | ||||
186 | // Expand & Shrink Active View | | |||
187 | QAction *expandActiveAction = new QAction(i18nc("@action:inmenu", "Expand View"), this); | | |||
188 | collection->setDefaultShortcut(expandActiveAction, | | |||
189 | Konsole::ACCEL + Qt::SHIFT + Qt::Key_BracketRight); | | |||
190 | expandActiveAction->setEnabled(false); | | |||
191 | collection->addAction(QStringLiteral("expand-active-view"), expandActiveAction); | | |||
192 | connect(expandActiveAction, &QAction::triggered, this, | | |||
193 | &Konsole::ViewManager::expandActiveContainer); | | |||
194 | | ||||
195 | multiViewOnlyActions << expandActiveAction; | | |||
196 | | ||||
197 | QAction *shrinkActiveAction = new QAction(i18nc("@action:inmenu", "Shrink View"), this); | | |||
198 | collection->setDefaultShortcut(shrinkActiveAction, | | |||
199 | Konsole::ACCEL + Qt::SHIFT + Qt::Key_BracketLeft); | | |||
200 | shrinkActiveAction->setEnabled(false); | | |||
201 | collection->addAction(QStringLiteral("shrink-active-view"), shrinkActiveAction); | | |||
202 | connect(shrinkActiveAction, &QAction::triggered, this, | | |||
203 | &Konsole::ViewManager::shrinkActiveContainer); | | |||
204 | 116 | | |||
205 | multiViewOnlyActions << shrinkActiveAction; | 117 | // Let's reuse the pointer, no need not to. | ||
118 | auto *action = new QAction(); | ||||
119 | action->setIcon(QIcon::fromTheme(QStringLiteral("view-split-left-right"))); | ||||
120 | action->setText(i18nc("@action:inmenu", "Split View Left/Right")); | ||||
121 | connect(action, &QAction::triggered, this, &ViewManager::splitLeftRight); | ||||
122 | collection->addAction(QStringLiteral("split-view-left-right"), action); | ||||
123 | collection->setDefaultShortcut(action, Konsole::ACCEL + Qt::Key_ParenLeft); | ||||
124 | | ||||
125 | action = new QAction(); | ||||
126 | action->setIcon(QIcon::fromTheme(QStringLiteral("view-split-top-bottom"))); | ||||
127 | action->setText(i18nc("@action:inmenu", "Split View Top/Bottom")); | ||||
128 | connect(action, &QAction::triggered, this, &ViewManager::splitTopBottom); | ||||
129 | collection->setDefaultShortcut(action, Konsole::ACCEL + Qt::Key_ParenRight); | ||||
130 | collection->addAction(QStringLiteral("split-view-top-bottom"), action); | ||||
131 | | ||||
132 | action = new QAction(); | ||||
133 | action->setText(i18nc("@action:inmenu", "Expand View")); | ||||
134 | action->setEnabled(false); | ||||
135 | connect(action, &QAction::triggered, this, &ViewManager::expandActiveContainer); | ||||
136 | collection->setDefaultShortcut(action, Konsole::ACCEL + Qt::SHIFT + Qt::Key_BracketRight); | ||||
137 | collection->addAction(QStringLiteral("expand-active-view"), action); | ||||
138 | multiViewOnlyActions << action; | ||||
139 | | ||||
140 | action = new QAction(); | ||||
141 | action->setText(i18nc("@action:inmenu", "Shrink View")); | ||||
142 | collection->setDefaultShortcut(action, Konsole::ACCEL + Qt::SHIFT + Qt::Key_BracketLeft); | ||||
143 | action->setEnabled(false); | ||||
144 | collection->addAction(QStringLiteral("shrink-active-view"), action); | ||||
145 | connect(action, &QAction::triggered, this, &ViewManager::shrinkActiveContainer); | ||||
146 | multiViewOnlyActions << action; | ||||
206 | 147 | | |||
207 | // Crashes on Mac. | 148 | // Crashes on Mac. | ||
208 | #if defined(ENABLE_DETACHING) | 149 | #if defined(ENABLE_DETACHING) | ||
209 | QAction *detachViewAction = collection->addAction(QStringLiteral("detach-view")); | 150 | action = collection->addAction(QStringLiteral("detach-view")); | ||
210 | detachViewAction->setEnabled(true); | 151 | action->setEnabled(true); | ||
211 | detachViewAction->setIcon(QIcon::fromTheme(QStringLiteral("tab-detach"))); | 152 | action->setIcon(QIcon::fromTheme(QStringLiteral("tab-detach"))); | ||
212 | detachViewAction->setText(i18nc("@action:inmenu", "D&etach Current Tab")); | 153 | action->setText(i18nc("@action:inmenu", "D&etach Current Tab")); | ||
154 | | ||||
155 | connect(this, &ViewManager::splitViewToggle, this, &ViewManager::updateDetachViewState); | ||||
156 | connect(action, &QAction::triggered, this, &ViewManager::detachActiveView); | ||||
157 | | ||||
213 | // Ctrl+Shift+D is not used as a shortcut by default because it is too close | 158 | // Ctrl+Shift+D is not used as a shortcut by default because it is too close | ||
214 | // to Ctrl+D - which will terminate the session in many cases | 159 | // to Ctrl+D - which will terminate the session in many cases | ||
215 | collection->setDefaultShortcut(detachViewAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_H); | 160 | collection->setDefaultShortcut(action, Konsole::ACCEL + Qt::SHIFT + Qt::Key_H); | ||
216 | | ||||
217 | connect(this, &Konsole::ViewManager::splitViewToggle, this, | | |||
218 | &Konsole::ViewManager::updateDetachViewState); | | |||
219 | connect(detachViewAction, &QAction::triggered, this, &Konsole::ViewManager::detachActiveView); | | |||
220 | #endif | 161 | #endif | ||
221 | 162 | | |||
222 | // Next / Previous View , Next Container | 163 | // keyboard shortcut only actions | ||
223 | collection->addAction(QStringLiteral("next-view"), nextViewAction); | 164 | action = new QAction(i18nc("@action Shortcut entry", "Next Tab"), this); | ||
224 | collection->addAction(QStringLiteral("previous-view"), previousViewAction); | 165 | const QList<QKeySequence> nextViewActionKeys{Qt::SHIFT + Qt::Key_Right, Qt::CTRL + Qt::Key_PageDown}; | ||
225 | collection->addAction(QStringLiteral("last-tab"), lastViewAction); | 166 | collection->setDefaultShortcuts(action, nextViewActionKeys); | ||
226 | collection->addAction(QStringLiteral("last-used-tab"), lastUsedViewAction); | 167 | collection->addAction(QStringLiteral("next-tab"), action); | ||
227 | collection->addAction(QStringLiteral("last-used-tab-reverse"), lastUsedViewReverseAction); | 168 | connect(action, &QAction::triggered, this, &ViewManager::nextView); | ||
228 | collection->addAction(QStringLiteral("next-container"), nextContainerAction); | 169 | // _viewSplitter->addAction(nextViewAction); | ||
229 | collection->addAction(QStringLiteral("move-view-left"), moveViewLeftAction); | 170 | | ||
230 | collection->addAction(QStringLiteral("move-view-right"), moveViewRightAction); | 171 | action = new QAction(i18nc("@action Shortcut entry", "Previous Tab"), this); | ||
172 | const QList<QKeySequence> previousViewActionKeys{Qt::SHIFT + Qt::Key_Left, Qt::CTRL + Qt::Key_PageUp}; | ||||
173 | collection->setDefaultShortcuts(action, previousViewActionKeys); | ||||
174 | collection->addAction(QStringLiteral("previous-tab"), action); | ||||
175 | connect(action, &QAction::triggered, this, &ViewManager::previousView); | ||||
176 | // _viewSplitter->addAction(previousViewAction); | ||||
177 | | ||||
178 | action = new QAction(i18nc("@action Shortcut entry", "Next View Container"), this); | ||||
179 | connect(action, &QAction::triggered, this, &ViewManager::focusUp); | ||||
180 | collection->addAction(QStringLiteral("next-container"), action); | ||||
181 | collection->setDefaultShortcut(action, Qt::SHIFT + Qt::CTRL + Qt::Key_Up); | ||||
182 | _viewContainer->addAction(action); | ||||
183 | multiViewOnlyActions << action; | ||||
184 | | ||||
185 | action = new QAction(QStringLiteral("Focus Down")); | ||||
186 | collection->setDefaultShortcut(action, Qt::SHIFT + Qt::CTRL + Qt::Key_Down); | ||||
187 | connect(action, &QAction::triggered, this, &ViewManager::focusDown); | ||||
188 | _viewContainer->addAction(action); | ||||
189 | | ||||
190 | action = new QAction(i18nc("@action Shortcut entry", "Move Tab Left"), this); | ||||
191 | collection->setDefaultShortcut(action, Konsole::ACCEL + Qt::SHIFT + Konsole::LEFT); | ||||
192 | connect(action, &QAction::triggered, this, &ViewManager::focusLeft); | ||||
193 | collection->addAction(QStringLiteral("move-view-left"), action); | ||||
194 | // _viewSplitter->addAction(action); | ||||
195 | | ||||
196 | action = new QAction(i18nc("@action Shortcut entry", "Move Tab Right"), this); | ||||
197 | collection->setDefaultShortcut(action, Konsole::ACCEL + Qt::SHIFT + Konsole::RIGHT); | ||||
198 | connect(action, &QAction::triggered, this, &ViewManager::focusRight); | ||||
199 | collection->addAction(QStringLiteral("move-view-right"), action); | ||||
200 | // _viewSplitter->addAction(action); | ||||
201 | | ||||
202 | action = new QAction(i18nc("@action Shortcut entry", "Switch to Last Tab"), this); | ||||
203 | connect(action, &QAction::triggered, this, &ViewManager::lastView); | ||||
204 | collection->addAction(QStringLiteral("last-tab"), action); | ||||
205 | // _viewSplitter->addAction(action); | ||||
206 | | ||||
207 | action = new QAction(i18nc("@action Shortcut entry", "Last Used Tabs"), this); | ||||
208 | connect(action, &QAction::triggered, this, &ViewManager::lastUsedView); | ||||
209 | collection->setDefaultShortcut(action, Qt::CTRL + Qt::Key_Tab); | ||||
210 | collection->addAction(QStringLiteral("last-used-tab"), action); | ||||
211 | // _viewSplitter->addAction(lastUsedViewAction); | ||||
212 | | ||||
213 | action = new QAction(i18nc("@action Shortcut entry", "Last Used Tabs (Reverse)"), this); | ||||
214 | collection->addAction(QStringLiteral("last-used-tab-reverse"), action); | ||||
215 | collection->setDefaultShortcut(action, Qt::CTRL + Qt::SHIFT + Qt::Key_Tab); | ||||
216 | connect(action, &QAction::triggered, this, &ViewManager::lastUsedViewReverse); | ||||
217 | // _viewSplitter->addAction(lastUsedViewReverseAction); | ||||
218 | | ||||
219 | action = new QAction(i18nc("@action Shortcut entry", "Maximize current Terminal"), this); | ||||
220 | collection->addAction(QStringLiteral("maximize-current-terminal"), action); | ||||
221 | collection->setDefaultShortcut(action, Qt::CTRL + Qt::SHIFT + Qt::Key_E); | ||||
222 | connect(action, &QAction::triggered, _viewContainer, &TabbedViewContainer::maximizeCurrentTerminal); | ||||
223 | _viewContainer->addAction(action); | ||||
224 | | ||||
225 | action = new QAction(i18nc("@action Shortcut entry", "Restore other terminals"), this); | ||||
226 | collection->addAction(QStringLiteral("restore-other-terminals"), action); | ||||
227 | collection->setDefaultShortcut(action, Qt::CTRL + Qt::SHIFT + Qt::Key_Minus); | ||||
228 | connect(action, &QAction::triggered, _viewContainer, &TabbedViewContainer::restoreOtherTerminals); | ||||
229 | _viewContainer->addAction(action); | ||||
231 | 230 | | |||
232 | // Switch to tab N shortcuts | 231 | // _viewSplitter->addAction(lastUsedViewReverseAction); | ||
233 | const int SWITCH_TO_TAB_COUNT = 19; | 232 | const int SWITCH_TO_TAB_COUNT = 19; | ||
234 | for (int i = 0; i < SWITCH_TO_TAB_COUNT; i++) { | 233 | for (int i = 0; i < SWITCH_TO_TAB_COUNT; i++) { | ||
235 | QAction *switchToTabAction = new QAction(i18nc("@action Shortcut entry", "Switch to Tab %1", i + 1), this); | 234 | action = new QAction(i18nc("@action Shortcut entry", "Switch to Tab %1", i + 1), this); | ||
236 | 235 | connect(action, &QAction::triggered, this, [this, i]() { switchToView(i); }); | |||
237 | connect(switchToTabAction, &QAction::triggered, this, | 236 | collection->addAction(QStringLiteral("switch-to-tab-%1").arg(i), action); | ||
238 | [this, i]() { | | |||
239 | switchToView(i); | | |||
240 | }); | | |||
241 | collection->addAction(QStringLiteral("switch-to-tab-%1").arg(i), switchToTabAction); | | |||
242 | } | 237 | } | ||
243 | 238 | | |||
244 | foreach (QAction *action, multiViewOnlyActions) { | 239 | foreach (QAction *action, multiViewOnlyActions) { | ||
245 | connect(this, &Konsole::ViewManager::splitViewToggle, action, &QAction::setEnabled); | 240 | connect(this, &ViewManager::splitViewToggle, action, &QAction::setEnabled); | ||
246 | } | 241 | } | ||
247 | | ||||
248 | // keyboard shortcut only actions | | |||
249 | const QList<QKeySequence> nextViewActionKeys{Qt::SHIFT + Qt::Key_Right, Qt::CTRL + Qt::Key_PageDown}; | | |||
250 | collection->setDefaultShortcuts(nextViewAction, nextViewActionKeys); | | |||
251 | connect(nextViewAction, &QAction::triggered, this, &Konsole::ViewManager::nextView); | | |||
252 | _viewSplitter->addAction(nextViewAction); | | |||
253 | | ||||
254 | const QList<QKeySequence> previousViewActionKeys{Qt::SHIFT + Qt::Key_Left, Qt::CTRL + Qt::Key_PageUp}; | | |||
255 | collection->setDefaultShortcuts(previousViewAction, previousViewActionKeys); | | |||
256 | connect(previousViewAction, &QAction::triggered, this, &Konsole::ViewManager::previousView); | | |||
257 | _viewSplitter->addAction(previousViewAction); | | |||
258 | | ||||
259 | collection->setDefaultShortcut(nextContainerAction, Qt::SHIFT + Qt::Key_Tab); | | |||
260 | connect(nextContainerAction, &QAction::triggered, this, &Konsole::ViewManager::nextContainer); | | |||
261 | _viewSplitter->addAction(nextContainerAction); | | |||
262 | | ||||
263 | #ifdef Q_OS_MACOS | | |||
264 | collection->setDefaultShortcut(moveViewLeftAction, | | |||
265 | Konsole::ACCEL + Qt::SHIFT + Qt::Key_BracketLeft); | | |||
266 | #else | | |||
267 | collection->setDefaultShortcut(moveViewLeftAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_Left); | | |||
268 | #endif | | |||
269 | connect(moveViewLeftAction, &QAction::triggered, this, | | |||
270 | &Konsole::ViewManager::moveActiveViewLeft); | | |||
271 | _viewSplitter->addAction(moveViewLeftAction); | | |||
272 | | ||||
273 | #ifdef Q_OS_MACOS | | |||
274 | collection->setDefaultShortcut(moveViewRightAction, | | |||
275 | Konsole::ACCEL + Qt::SHIFT + Qt::Key_BracketRight); | | |||
276 | #else | | |||
277 | collection->setDefaultShortcut(moveViewRightAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_Right); | | |||
278 | #endif | | |||
279 | connect(moveViewRightAction, &QAction::triggered, this, | | |||
280 | &Konsole::ViewManager::moveActiveViewRight); | | |||
281 | _viewSplitter->addAction(moveViewRightAction); | | |||
282 | | ||||
283 | connect(lastViewAction, &QAction::triggered, this, &Konsole::ViewManager::lastView); | | |||
284 | _viewSplitter->addAction(lastViewAction); | | |||
285 | | ||||
286 | collection->setDefaultShortcut(lastUsedViewAction, Qt::CTRL + Qt::Key_Tab); | | |||
287 | connect(lastUsedViewAction, &QAction::triggered, this, &Konsole::ViewManager::lastUsedView); | | |||
288 | _viewSplitter->addAction(lastUsedViewAction); | | |||
289 | | ||||
290 | collection->setDefaultShortcut(lastUsedViewReverseAction, Qt::CTRL + Qt::SHIFT + Qt::Key_Tab); | | |||
291 | connect(lastUsedViewReverseAction, &QAction::triggered, this, &Konsole::ViewManager::lastUsedViewReverse); | | |||
292 | _viewSplitter->addAction(lastUsedViewReverseAction); | | |||
293 | } | 242 | } | ||
294 | 243 | | |||
295 | void ViewManager::switchToView(int index) | 244 | void ViewManager::switchToView(int index) | ||
296 | { | 245 | { | ||
297 | _viewSplitter->activeContainer()->setCurrentIndex(index); | 246 | _viewContainer->setCurrentIndex(index); | ||
298 | } | 247 | } | ||
299 | 248 | | |||
300 | void ViewManager::updateDetachViewState() | 249 | void ViewManager::updateDetachViewState() | ||
301 | { | 250 | { | ||
302 | Q_ASSERT(_actionCollection); | 251 | Q_ASSERT(_actionCollection); | ||
303 | if (_actionCollection == nullptr) { | 252 | if (_actionCollection == nullptr) { | ||
304 | return; | 253 | return; | ||
305 | } | 254 | } | ||
306 | 255 | | |||
256 | #if 0 | ||||
307 | const bool splitView = _viewSplitter->containers().count() >= 2; | 257 | const bool splitView = _viewSplitter->containers().count() >= 2; | ||
maciejn: There is a method ViewSplitter::getTerminalDisplays() which is a lot more complicated than this. | |||||
tcanabrava: nice catch. that's really easy to remove. | |||||
308 | auto activeContainer = _viewSplitter->activeContainer(); | 258 | auto activeContainer = _viewSplitter->activeContainer(); | ||
309 | const bool shouldEnable = splitView | 259 | const bool shouldEnable = splitView | ||
310 | || ((activeContainer != nullptr) | 260 | || ((activeContainer != nullptr) | ||
311 | && activeContainer->count() >= 2); | 261 | && activeContainer->count() >= 2); | ||
312 | 262 | | |||
313 | QAction *detachAction = _actionCollection->action(QStringLiteral("detach-view")); | 263 | QAction *detachAction = _actionCollection->action(QStringLiteral("detach-view")); | ||
314 | 264 | | |||
315 | if ((detachAction != nullptr) && shouldEnable != detachAction->isEnabled()) { | 265 | if ((detachAction != nullptr) && shouldEnable != detachAction->isEnabled()) { | ||
316 | detachAction->setEnabled(shouldEnable); | 266 | detachAction->setEnabled(shouldEnable); | ||
317 | } | 267 | } | ||
268 | #endif | ||||
269 | } | ||||
270 | | ||||
271 | void ViewManager::focusUp() | ||||
272 | { | ||||
273 | _viewContainer->activeViewSplitter()->focusUp(); | ||||
274 | } | ||||
275 | | ||||
276 | void ViewManager::focusDown() | ||||
277 | { | ||||
278 | _viewContainer->activeViewSplitter()->focusDown(); | ||||
279 | } | ||||
280 | | ||||
281 | void ViewManager::focusLeft() | ||||
282 | { | ||||
283 | _viewContainer->activeViewSplitter()->focusLeft(); | ||||
284 | } | ||||
285 | | ||||
286 | void ViewManager::focusRight() | ||||
287 | { | ||||
288 | _viewContainer->activeViewSplitter()->focusRight(); | ||||
318 | } | 289 | } | ||
319 | 290 | | |||
320 | void ViewManager::moveActiveViewLeft() | 291 | void ViewManager::moveActiveViewLeft() | ||
321 | { | 292 | { | ||
322 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | 293 | _viewContainer->moveActiveView(TabbedViewContainer::MoveViewLeft); | ||
323 | Q_ASSERT(container); | | |||
324 | container->moveActiveView(TabbedViewContainer::MoveViewLeft); | | |||
325 | } | 294 | } | ||
326 | 295 | | |||
327 | void ViewManager::moveActiveViewRight() | 296 | void ViewManager::moveActiveViewRight() | ||
328 | { | 297 | { | ||
329 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | 298 | _viewContainer->moveActiveView(TabbedViewContainer::MoveViewRight); | ||
330 | Q_ASSERT(container); | | |||
331 | container->moveActiveView(TabbedViewContainer::MoveViewRight); | | |||
332 | } | 299 | } | ||
333 | 300 | | |||
334 | void ViewManager::nextContainer() | 301 | void ViewManager::nextContainer() | ||
335 | { | 302 | { | ||
336 | _viewSplitter->activateNextContainer(); | 303 | // _viewSplitter->activateNextContainer(); | ||
hindenburg: ? | |||||
there's no notion of 'nextContainer' anymore, so I commented that out. I need to see if the call is userfull at all or remove. tcanabrava: there's no notion of 'nextContainer' anymore, so I commented that out. I need to see if the… | |||||
337 | } | 304 | } | ||
338 | 305 | | |||
339 | void ViewManager::nextView() | 306 | void ViewManager::nextView() | ||
340 | { | 307 | { | ||
341 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | 308 | _viewContainer->activateNextView(); | ||
342 | Q_ASSERT(container); | | |||
343 | container->activateNextView(); | | |||
344 | } | 309 | } | ||
345 | 310 | | |||
346 | void ViewManager::previousView() | 311 | void ViewManager::previousView() | ||
347 | { | 312 | { | ||
348 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | 313 | _viewContainer->activatePreviousView(); | ||
349 | Q_ASSERT(container); | | |||
350 | container->activatePreviousView(); | | |||
351 | } | 314 | } | ||
352 | 315 | | |||
353 | void ViewManager::lastView() | 316 | void ViewManager::lastView() | ||
354 | { | 317 | { | ||
355 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | 318 | _viewContainer->activateLastView(); | ||
356 | Q_ASSERT(container); | | |||
357 | container->activateLastView(); | | |||
358 | } | 319 | } | ||
359 | 320 | | |||
360 | void ViewManager::lastUsedView() | 321 | void ViewManager::lastUsedView() | ||
361 | { | 322 | { | ||
362 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | 323 | _viewContainer->activateLastUsedView(false); | ||
363 | Q_ASSERT(container); | | |||
364 | container->activateLastUsedView(false); | | |||
365 | } | 324 | } | ||
366 | 325 | | |||
367 | void ViewManager::lastUsedViewReverse() | 326 | void ViewManager::lastUsedViewReverse() | ||
368 | { | 327 | { | ||
369 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | 328 | _viewContainer->activateLastUsedView(true); | ||
370 | Q_ASSERT(container); | | |||
371 | container->activateLastUsedView(true); | | |||
372 | } | 329 | } | ||
373 | 330 | | |||
374 | void ViewManager::detachActiveView() | 331 | void ViewManager::detachActiveView() | ||
375 | { | 332 | { | ||
333 | //TODO: Disable Detach temporarely. | ||||
334 | #if 0 | ||||
376 | // find the currently active view and remove it from its container | 335 | // find the currently active view and remove it from its container | ||
377 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | 336 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
378 | detachView(container, container->currentWidget()); | 337 | detachView(container, container->currentWidget()); | ||
338 | #endif | ||||
379 | } | 339 | } | ||
380 | 340 | | |||
381 | void ViewManager::detachView(TabbedViewContainer *container, QWidget *view) | 341 | void ViewManager::detachView(TabbedViewContainer *container, QWidget *view) | ||
382 | { | 342 | { | ||
383 | #if !defined(ENABLE_DETACHING) | 343 | #if !defined(ENABLE_DETACHING) | ||
384 | return; | 344 | return; | ||
385 | #endif | 345 | #endif | ||
386 | 346 | | |||
Show All 14 Lines | |||||
401 | 361 | | |||
402 | // remove the view from this window | 362 | // remove the view from this window | ||
403 | container->removeView(viewToDetach); | 363 | container->removeView(viewToDetach); | ||
404 | viewToDetach->deleteLater(); | 364 | viewToDetach->deleteLater(); | ||
405 | 365 | | |||
406 | // if the container from which the view was removed is now empty then it can be deleted, | 366 | // if the container from which the view was removed is now empty then it can be deleted, | ||
407 | // unless it is the only container in the window, in which case it is left empty | 367 | // unless it is the only container in the window, in which case it is left empty | ||
408 | // so that there is always an active container | 368 | // so that there is always an active container | ||
369 | //TODO: Verify if this is correct. | ||||
370 | #if 0 | ||||
409 | if (_viewSplitter->containers().count() > 1 | 371 | if (_viewSplitter->containers().count() > 1 | ||
410 | && container->count() == 0) { | 372 | && container->count() == 0) { | ||
411 | removeContainer(container); | 373 | removeContainer(container); | ||
412 | } | 374 | } | ||
375 | #endif | ||||
413 | } | 376 | } | ||
414 | 377 | | |||
415 | void ViewManager::sessionFinished() | 378 | void ViewManager::sessionFinished() | ||
416 | { | 379 | { | ||
417 | // if this slot is called after the view manager's main widget | 380 | // if this slot is called after the view manager's main widget | ||
418 | // has been destroyed, do nothing | 381 | // has been destroyed, do nothing | ||
419 | if (_viewSplitter.isNull()) { | 382 | if (_viewContainer.isNull()) { | ||
420 | return; | 383 | return; | ||
421 | } | 384 | } | ||
422 | 385 | | |||
423 | auto *session = qobject_cast<Session *>(sender()); | 386 | auto *session = qobject_cast<Session *>(sender()); | ||
424 | Q_ASSERT(session); | 387 | Q_ASSERT(session); | ||
425 | 388 | | |||
426 | // close attached views | 389 | auto view = _sessionMap.key(session); | ||
427 | QList<TerminalDisplay *> children = _viewSplitter->findChildren<TerminalDisplay *>(); | | |||
428 | | ||||
429 | foreach (TerminalDisplay *view, children) { | | |||
430 | if (_sessionMap[view] == session) { | | |||
431 | _sessionMap.remove(view); | 390 | _sessionMap.remove(view); | ||
391 | | ||||
392 | // Before deleting the view, let's unmaximize if it's maximized. | ||||
393 | auto splitter = qobject_cast<ViewSplitter*>(view->parentWidget()); | ||||
394 | splitter->getToplevelSplitter()->restoreOtherTerminals(); | ||||
432 | view->deleteLater(); | 395 | view->deleteLater(); | ||
433 | } | | |||
434 | } | | |||
435 | 396 | | |||
436 | // Only remove the controller from factory() if it's actually controlling | 397 | // Only remove the controller from factory() if it's actually controlling | ||
437 | // the session from the sender. | 398 | // the session from the sender. | ||
438 | // This fixes BUG: 348478 - messed up menus after a detached tab is closed | 399 | // This fixes BUG: 348478 - messed up menus after a detached tab is closed | ||
439 | if ((!_pluggedController.isNull()) && (_pluggedController->session() == session)) { | 400 | if ((!_pluggedController.isNull()) && (_pluggedController->session() == session)) { | ||
440 | // This is needed to remove this controller from factory() in | 401 | // This is needed to remove this controller from factory() in | ||
441 | // order to prevent BUG: 185466 - disappearing menu popup | 402 | // order to prevent BUG: 185466 - disappearing menu popup | ||
442 | emit unplugController(_pluggedController); | 403 | emit unplugController(_pluggedController); | ||
443 | } | 404 | } | ||
405 | | ||||
406 | focusAnotherTerminal(view); | ||||
444 | } | 407 | } | ||
445 | 408 | | |||
409 | void ViewManager::focusAnotherTerminal(TerminalDisplay *lostFocus) | ||||
410 | { | ||||
411 | auto viewSplitter = _viewContainer->activeViewSplitter(); | ||||
412 | auto terminalDisplays = viewSplitter->findChildren<TerminalDisplay*>(); | ||||
413 | for (auto terminalDisplay : terminalDisplays) { | ||||
414 | if (terminalDisplay != lostFocus) { | ||||
415 | terminalDisplay->setFocus(Qt::OtherFocusReason); | ||||
416 | return; | ||||
417 | } | ||||
418 | } | ||||
419 | } | ||||
446 | void ViewManager::viewActivated(QWidget *view) | 420 | void ViewManager::viewActivated(QWidget *view) | ||
447 | { | 421 | { | ||
448 | Q_ASSERT(view != nullptr); | 422 | Q_ASSERT(view != nullptr); | ||
449 | 423 | | |||
450 | // focus the activated view, this will cause the SessionController | 424 | // focus the activated view, this will cause the SessionController | ||
451 | // to notify the world that the view has been focused and the appropriate UI | 425 | // to notify the world that the view has been focused and the appropriate UI | ||
452 | // actions will be plugged in. | 426 | // actions will be plugged in. | ||
453 | view->setFocus(Qt::OtherFocusReason); | 427 | view->setFocus(Qt::OtherFocusReason); | ||
454 | } | 428 | } | ||
455 | 429 | | |||
456 | void ViewManager::splitLeftRight() | 430 | void ViewManager::splitLeftRight() | ||
457 | { | 431 | { | ||
458 | splitView(Qt::Horizontal); | 432 | splitView(Qt::Horizontal); | ||
459 | } | 433 | } | ||
460 | 434 | | |||
461 | void ViewManager::splitTopBottom() | 435 | void ViewManager::splitTopBottom() | ||
462 | { | 436 | { | ||
463 | splitView(Qt::Vertical); | 437 | splitView(Qt::Vertical); | ||
464 | } | 438 | } | ||
465 | 439 | | |||
466 | void ViewManager::splitView(Qt::Orientation orientation) | 440 | void ViewManager::splitView(Qt::Orientation orientation) | ||
467 | { | 441 | { | ||
468 | TabbedViewContainer *container = createContainer(); | 442 | auto viewSplitter = qobject_cast<ViewSplitter*>(_viewContainer->currentWidget()); | ||
469 | 443 | | |||
470 | if (_viewSplitter->activeContainer()->count()) { | | |||
471 | // get the currently applied profile and use it to create the new tab. | 444 | // get the currently applied profile and use it to create the new tab. | ||
472 | auto *activeContainer= _viewSplitter->activeContainer(); | 445 | auto *currentDisplay = viewSplitter->findChild<TerminalDisplay*>(); | ||
473 | auto *currentDisplay = qobject_cast<TerminalDisplay*>(activeContainer->currentWidget()); | | |||
474 | auto profile = SessionManager::instance()->sessionProfile(_sessionMap[currentDisplay]); | 446 | auto profile = SessionManager::instance()->sessionProfile(_sessionMap[currentDisplay]); | ||
475 | 447 | | |||
476 | // Create a new session with the selected profile. | 448 | // Create a new session with the selected profile. | ||
477 | auto *session = SessionManager::instance()->createSession(profile); | 449 | auto *session = SessionManager::instance()->createSession(profile); | ||
478 | session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(managerId())); | 450 | session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(managerId())); | ||
479 | 451 | | |||
480 | createView(session, container, 0); | 452 | auto terminalDisplay = createView(session); | ||
481 | } | | |||
482 | 453 | | |||
483 | _viewSplitter->addContainer(container, orientation); | 454 | viewSplitter->addTerminalDisplay(terminalDisplay, orientation); | ||
484 | emit splitViewToggle(_viewSplitter->containers().count() > 0); | 455 | emit splitViewToggle(viewSplitter->count() > 0); | ||
485 | 456 | | |||
486 | // focus the new container | 457 | // focus the new container | ||
487 | container->currentWidget()->setFocus(); | 458 | terminalDisplay->setFocus(); | ||
488 | | ||||
489 | // ensure that the active view is focused after the split / unsplit | | |||
490 | TabbedViewContainer *activeContainer = _viewSplitter->activeContainer(); | | |||
491 | QWidget *activeView = activeContainer != nullptr ? activeContainer->currentWidget() : nullptr; | | |||
492 | | ||||
493 | if (activeView != nullptr) { | | |||
494 | activeView->setFocus(Qt::OtherFocusReason); | | |||
495 | } | | |||
496 | } | 459 | } | ||
497 | 460 | | |||
498 | void ViewManager::removeContainer(TabbedViewContainer *container) | 461 | void ViewManager::removeContainer(TabbedViewContainer *container) | ||
499 | { | 462 | { | ||
463 | qDebug() << "Remove Container Called"; | ||||
464 | #if 0 | ||||
500 | // remove session map entries for views in this container | 465 | // remove session map entries for views in this container | ||
501 | for(int i = 0, end = container->count(); i < end; i++) { | 466 | for(int i = 0, end = container->count(); i < end; i++) { | ||
502 | auto view = container->widget(i); | 467 | auto view = container->widget(i); | ||
503 | auto *display = qobject_cast<TerminalDisplay *>(view); | 468 | auto *display = qobject_cast<TerminalDisplay *>(view); | ||
504 | Q_ASSERT(display); | 469 | Q_ASSERT(display); | ||
505 | _sessionMap.remove(display); | 470 | _sessionMap.remove(display); | ||
506 | } | 471 | } | ||
507 | 472 | | |||
508 | _viewSplitter->removeContainer(container); | 473 | _viewSplitter->removeContainer(container); | ||
509 | container->deleteLater(); | 474 | container->deleteLater(); | ||
510 | 475 | | |||
511 | emit splitViewToggle(_viewSplitter->containers().count() > 1); | 476 | emit splitViewToggle(_viewSplitter->containers().count() > 1); | ||
477 | #endif | ||||
512 | } | 478 | } | ||
513 | 479 | | |||
514 | void ViewManager::expandActiveContainer() | 480 | void ViewManager::expandActiveContainer() | ||
515 | { | 481 | { | ||
516 | _viewSplitter->adjustContainerSize(_viewSplitter->activeContainer(), 10); | 482 | auto activeSplitter = _viewContainer->activeViewSplitter(); | ||
483 | auto activeTerminalDisplay = activeSplitter->activeTerminalDisplay(); | ||||
484 | activeSplitter->adjustTerminalDisplaySize(activeTerminalDisplay, 10); | ||||
517 | } | 485 | } | ||
518 | 486 | | |||
519 | void ViewManager::shrinkActiveContainer() | 487 | void ViewManager::shrinkActiveContainer() | ||
520 | { | 488 | { | ||
521 | _viewSplitter->adjustContainerSize(_viewSplitter->activeContainer(), -10); | 489 | auto activeSplitter = _viewContainer->activeViewSplitter(); | ||
522 | } | 490 | auto activeTerminalDisplay = activeSplitter->activeTerminalDisplay(); | ||
523 | 491 | activeSplitter->adjustTerminalDisplaySize(activeTerminalDisplay, -10); | |||
524 | void ViewManager::closeActiveContainer() | | |||
525 | { | | |||
526 | // only do something if there is more than one container active | | |||
527 | if (_viewSplitter->containers().count() > 1) { | | |||
528 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | | |||
529 | | ||||
530 | removeContainer(container); | | |||
531 | | ||||
532 | // focus next container so that user can continue typing | | |||
533 | // without having to manually focus it themselves | | |||
534 | nextContainer(); | | |||
535 | } | | |||
536 | } | | |||
537 | | ||||
538 | void ViewManager::closeOtherContainers() | | |||
539 | { | | |||
540 | TabbedViewContainer *active = _viewSplitter->activeContainer(); | | |||
541 | | ||||
542 | foreach (TabbedViewContainer *container, _viewSplitter->containers()) { | | |||
543 | if (container != active) { | | |||
544 | removeContainer(container); | | |||
545 | } | | |||
546 | } | | |||
547 | } | 492 | } | ||
548 | 493 | | |||
549 | SessionController *ViewManager::createController(Session *session, TerminalDisplay *view) | 494 | SessionController *ViewManager::createController(Session *session, TerminalDisplay *view) | ||
550 | { | 495 | { | ||
551 | // create a new controller for the session, and ensure that this view manager | 496 | // create a new controller for the session, and ensure that this view manager | ||
552 | // is notified when the view gains the focus | 497 | // is notified when the view gains the focus | ||
553 | auto controller = new SessionController(session, view, this); | 498 | auto controller = new SessionController(session, view, this); | ||
554 | connect(controller, &Konsole::SessionController::focused, this, | 499 | connect(controller, &Konsole::SessionController::focused, this, | ||
Show All 16 Lines | |||||
571 | } | 516 | } | ||
572 | 517 | | |||
573 | void ViewManager::controllerChanged(SessionController *controller) | 518 | void ViewManager::controllerChanged(SessionController *controller) | ||
574 | { | 519 | { | ||
575 | if (controller == _pluggedController) { | 520 | if (controller == _pluggedController) { | ||
576 | return; | 521 | return; | ||
577 | } | 522 | } | ||
578 | 523 | | |||
579 | _viewSplitter->setFocusProxy(controller->view()); | 524 | //TODO: Verify This. | ||
525 | // _viewSplitter->setFocusProxy(controller->view()); | ||||
580 | 526 | | |||
anthonyfieroni: This should stay, i think. | |||||
this should actually be removed, the current way to deal with the focus is working without the proxies, also, there's no _viewSplitter anymore. tcanabrava: this should actually be removed, the current way to deal with the focus is working without the… | |||||
581 | _pluggedController = controller; | 527 | _pluggedController = controller; | ||
582 | emit activeViewChanged(controller); | 528 | emit activeViewChanged(controller); | ||
583 | } | 529 | } | ||
584 | 530 | | |||
585 | SessionController *ViewManager::activeViewController() const | 531 | SessionController *ViewManager::activeViewController() const | ||
586 | { | 532 | { | ||
587 | return _pluggedController; | 533 | return _pluggedController; | ||
588 | } | 534 | } | ||
589 | 535 | | |||
590 | void ViewManager::createView(Session *session, TabbedViewContainer *container, int index) | 536 | TerminalDisplay *ViewManager::createView(Session *session) | ||
591 | { | 537 | { | ||
592 | // notify this view manager when the session finishes so that its view | 538 | // notify this view manager when the session finishes so that its view | ||
593 | // can be deleted | 539 | // can be deleted | ||
594 | // | 540 | // | ||
595 | // Use Qt::UniqueConnection to avoid duplicate connection | 541 | // Use Qt::UniqueConnection to avoid duplicate connection | ||
596 | connect(session, &Konsole::Session::finished, this, &Konsole::ViewManager::sessionFinished, | 542 | connect(session, &Konsole::Session::finished, this, &Konsole::ViewManager::sessionFinished, | ||
597 | Qt::UniqueConnection); | 543 | Qt::UniqueConnection); | ||
598 | 544 | | |||
599 | TerminalDisplay *display = createTerminalDisplay(session); | 545 | TerminalDisplay *display = createTerminalDisplay(session); | ||
600 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | 546 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | ||
601 | applyProfileToView(display, profile); | 547 | applyProfileToView(display, profile); | ||
602 | 548 | | |||
603 | // set initial size | 549 | // set initial size | ||
604 | const QSize &preferredSize = session->preferredSize(); | 550 | const QSize &preferredSize = session->preferredSize(); | ||
605 | 551 | | |||
606 | display->setSize(preferredSize.width(), preferredSize.height()); | 552 | display->setSize(preferredSize.width(), preferredSize.height()); | ||
607 | createController(session, display); | 553 | createController(session, display); | ||
608 | 554 | | |||
609 | _sessionMap[display] = session; | 555 | _sessionMap[display] = session; | ||
610 | container->addView(display, index); | | |||
611 | session->addView(display); | 556 | session->addView(display); | ||
612 | 557 | | |||
613 | // tell the session whether it has a light or dark background | 558 | // tell the session whether it has a light or dark background | ||
614 | session->setDarkBackground(colorSchemeForProfile(profile)->hasDarkBackground()); | 559 | session->setDarkBackground(colorSchemeForProfile(profile)->hasDarkBackground()); | ||
615 | container->setCurrentWidget(display); | | |||
616 | display->setFocus(Qt::OtherFocusReason); | 560 | display->setFocus(Qt::OtherFocusReason); | ||
617 | | ||||
618 | updateDetachViewState(); | 561 | updateDetachViewState(); | ||
619 | } | 562 | return display; | ||
620 | | ||||
621 | void ViewManager::createView(TabbedViewContainer *tabWidget, Session *session) | | |||
622 | { | | |||
623 | const int index = _newTabBehavior == PutNewTabAfterCurrentTab ? | | |||
624 | _viewSplitter->activeContainer()->currentIndex() + 1 : -1; | | |||
625 | | ||||
626 | createView(session, tabWidget, index); | | |||
627 | } | 563 | } | ||
628 | 564 | | |||
629 | TabbedViewContainer *ViewManager::createContainer() | 565 | TabbedViewContainer *ViewManager::createContainer() | ||
630 | { | 566 | { | ||
631 | 567 | auto *container = new TabbedViewContainer(this, nullptr); | |||
632 | auto *container = new TabbedViewContainer(this, _viewSplitter); | | |||
633 | container->setNavigationVisibility(_navigationVisibility); | 568 | container->setNavigationVisibility(_navigationVisibility); | ||
634 | //TODO: Fix Detaching. | 569 | //TODO: Fix Detaching. | ||
635 | connect(container, &TabbedViewContainer::detachTab, this, &ViewManager::detachView); | 570 | connect(container, &TabbedViewContainer::detachTab, this, &ViewManager::detachView); | ||
636 | 571 | | |||
637 | // connect signals and slots | 572 | // connect signals and slots | ||
638 | connect(container, &Konsole::TabbedViewContainer::viewAdded, this, | 573 | connect(container, &Konsole::TabbedViewContainer::viewAdded, this, | ||
639 | [this, container]() { | 574 | [this, container]() { | ||
640 | containerViewsChanged(container); | 575 | containerViewsChanged(container); | ||
Show All 15 Lines | |||||
656 | connect(container, &Konsole::TabbedViewContainer::activeViewChanged, this, | 591 | connect(container, &Konsole::TabbedViewContainer::activeViewChanged, this, | ||
657 | &Konsole::ViewManager::viewActivated); | 592 | &Konsole::ViewManager::viewActivated); | ||
658 | 593 | | |||
659 | return container; | 594 | return container; | ||
660 | } | 595 | } | ||
661 | 596 | | |||
662 | void ViewManager::containerMoveViewRequest(int index, int id) | 597 | void ViewManager::containerMoveViewRequest(int index, int id) | ||
663 | { | 598 | { | ||
599 | Q_UNUSED(index); | ||||
600 | | ||||
664 | auto *container = qobject_cast<TabbedViewContainer *>(sender()); | 601 | auto *container = qobject_cast<TabbedViewContainer *>(sender()); | ||
665 | auto *controller = qobject_cast<SessionController *>(ViewProperties::propertiesById(id)); | 602 | auto *controller = qobject_cast<SessionController *>(ViewProperties::propertiesById(id)); | ||
666 | Q_ASSERT(container); | 603 | Q_ASSERT(container); | ||
667 | Q_ASSERT(controller); | 604 | Q_ASSERT(controller); | ||
668 | 605 | | |||
669 | createView(controller->session(), container, index); | 606 | createView(controller->session()); | ||
670 | controller->session()->refresh(); | 607 | controller->session()->refresh(); | ||
671 | container->currentWidget()->setFocus(); | 608 | container->currentWidget()->setFocus(); | ||
672 | } | 609 | } | ||
673 | 610 | | |||
674 | void ViewManager::setNavigationMethod(NavigationMethod method) | 611 | void ViewManager::setNavigationMethod(NavigationMethod method) | ||
675 | { | 612 | { | ||
676 | Q_ASSERT(_actionCollection); | 613 | Q_ASSERT(_actionCollection); | ||
677 | if (_actionCollection == nullptr) { | 614 | if (_actionCollection == nullptr) { | ||
Show All 34 Lines | |||||
712 | } | 649 | } | ||
713 | 650 | | |||
714 | ViewManager::NavigationMethod ViewManager::navigationMethod() const | 651 | ViewManager::NavigationMethod ViewManager::navigationMethod() const | ||
715 | { | 652 | { | ||
716 | return _navigationMethod; | 653 | return _navigationMethod; | ||
717 | } | 654 | } | ||
718 | 655 | | |||
719 | void ViewManager::containerViewsChanged(TabbedViewContainer *container) | 656 | void ViewManager::containerViewsChanged(TabbedViewContainer *container) | ||
720 | { | 657 | { | ||
721 | if ((!_viewSplitter.isNull()) && container == _viewSplitter->activeContainer()) { | 658 | // TODO: Verify that this is right. | ||
hindenburg: container not used | |||||
722 | emit viewPropertiesChanged(viewProperties()); | 659 | emit viewPropertiesChanged(viewProperties()); | ||
723 | } | 660 | } | ||
724 | } | | |||
725 | 661 | | |||
726 | void ViewManager::viewDestroyed(QWidget *view) | 662 | void ViewManager::viewDestroyed(QWidget *view) | ||
727 | { | 663 | { | ||
664 | qDebug() << "TerminalDisplay destroyed"; | ||||
728 | // Note: the received QWidget has already been destroyed, so | 665 | // Note: the received QWidget has already been destroyed, so | ||
729 | // using dynamic_cast<> or qobject_cast<> does not work here | 666 | // using dynamic_cast<> or qobject_cast<> does not work here | ||
730 | // We only need the pointer address to look it up below | 667 | // We only need the pointer address to look it up below | ||
731 | auto *display = reinterpret_cast<TerminalDisplay *>(view); | 668 | auto *display = reinterpret_cast<TerminalDisplay *>(view); | ||
732 | 669 | | |||
733 | // 1. detach view from session | 670 | // 1. detach view from session | ||
734 | // 2. if the session has no views left, close it | 671 | // 2. if the session has no views left, close it | ||
735 | Session *session = _sessionMap[ display ]; | 672 | Session *session = _sessionMap[ display ]; | ||
736 | _sessionMap.remove(display); | 673 | _sessionMap.remove(display); | ||
737 | if (session != nullptr) { | 674 | if (session != nullptr) { | ||
738 | if (session->views().count() == 0) { | 675 | if (session->views().count() == 0) { | ||
739 | session->close(); | 676 | session->close(); | ||
740 | } | 677 | } | ||
741 | } | 678 | } | ||
742 | //we only update the focus if the splitter is still alive | 679 | //we only update the focus if the splitter is still alive | ||
680 | // TODO: Verify. | ||||
681 | #if 0 | ||||
743 | if (!_viewSplitter.isNull()) { | 682 | if (!_viewSplitter.isNull()) { | ||
744 | updateDetachViewState(); | 683 | updateDetachViewState(); | ||
745 | } | 684 | } | ||
685 | #endif | ||||
746 | // The below causes the menus to be messed up | 686 | // The below causes the menus to be messed up | ||
747 | // Only happens when using the tab bar close button | 687 | // Only happens when using the tab bar close button | ||
748 | // if (_pluggedController) | 688 | // if (_pluggedController) | ||
749 | // emit unplugController(_pluggedController); | 689 | // emit unplugController(_pluggedController); | ||
690 | qDebug() << "End of view destroyed"; | ||||
750 | } | 691 | } | ||
751 | 692 | | |||
752 | TerminalDisplay *ViewManager::createTerminalDisplay(Session *session) | 693 | TerminalDisplay *ViewManager::createTerminalDisplay(Session *session) | ||
753 | { | 694 | { | ||
754 | auto display = new TerminalDisplay(nullptr); | 695 | auto display = new TerminalDisplay(nullptr); | ||
755 | display->setRandomSeed(session->sessionId() * 31); | 696 | display->setRandomSeed(session->sessionId() * 31); | ||
756 | 697 | | |||
757 | return display; | 698 | return display; | ||
▲ Show 20 Lines • Show All 111 Lines • ▼ Show 20 Line(s) | 802 | while (iter.hasNext()) { | |||
869 | } | 810 | } | ||
870 | } | 811 | } | ||
871 | } | 812 | } | ||
872 | 813 | | |||
873 | QList<ViewProperties *> ViewManager::viewProperties() const | 814 | QList<ViewProperties *> ViewManager::viewProperties() const | ||
874 | { | 815 | { | ||
875 | QList<ViewProperties *> list; | 816 | QList<ViewProperties *> list; | ||
876 | 817 | | |||
877 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | 818 | TabbedViewContainer *container = _viewContainer; | ||
878 | if (container == nullptr) { | 819 | if (container == nullptr) { | ||
879 | return {}; | 820 | return {}; | ||
880 | } | 821 | } | ||
881 | 822 | | |||
882 | list.reserve(container->count()); | 823 | auto terminalContainers = _viewContainer->findChildren<TerminalDisplay*>(); | ||
824 | list.reserve(terminalContainers.size()); | ||||
883 | 825 | | |||
884 | for(int i = 0, end = container->count(); i < end; i++) { | 826 | for(auto terminalDisplay : _viewContainer->findChildren<TerminalDisplay*>()) { | ||
885 | auto view = container->terminalAt(i); | 827 | list.append(terminalDisplay->sessionController()); | ||
886 | ViewProperties *properties = view->sessionController(); | | |||
887 | Q_ASSERT(properties); | | |||
888 | list << properties; | | |||
889 | } | 828 | } | ||
890 | 829 | | |||
891 | return list; | 830 | return list; | ||
892 | } | 831 | } | ||
893 | 832 | | |||
894 | void ViewManager::saveSessions(KConfigGroup &group) | 833 | void ViewManager::saveSessions(KConfigGroup &group) | ||
895 | { | 834 | { | ||
896 | // find all unique session restore IDs | 835 | // find all unique session restore IDs | ||
897 | QList<int> ids; | 836 | QList<int> ids; | ||
898 | QSet<Session *> unique; | 837 | QSet<Session *> unique; | ||
899 | int tab = 1; | 838 | int tab = 1; | ||
900 | 839 | | |||
901 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | 840 | TabbedViewContainer *container = _viewContainer; | ||
902 | 841 | | |||
903 | // first: sessions in the active container, preserving the order | 842 | // first: sessions in the active container, preserving the order | ||
904 | Q_ASSERT(container); | 843 | Q_ASSERT(container); | ||
905 | if (container == nullptr) { | 844 | if (container == nullptr) { | ||
906 | return; | 845 | return; | ||
907 | } | 846 | } | ||
908 | ids.reserve(container->count()); | 847 | ids.reserve(container->count()); | ||
909 | 848 | | |||
849 | //TODO: Handle sessions | ||||
850 | #if 0 | ||||
hindenburg: I need to test session restores w/ splits. | |||||
910 | auto *activeview = qobject_cast<TerminalDisplay *>(container->currentWidget()); | 851 | auto *activeview = qobject_cast<TerminalDisplay *>(container->currentWidget()); | ||
911 | for (int i = 0, end = container->count(); i < end; i++) { | 852 | for (int i = 0, end = container->count(); i < end; i++) { | ||
912 | auto *view = qobject_cast<TerminalDisplay *>(container->widget(i)); | 853 | auto *view = qobject_cast<TerminalDisplay *>(container->widget(i)); | ||
913 | Q_ASSERT(view); | 854 | Q_ASSERT(view); | ||
914 | 855 | | |||
915 | Session *session = _sessionMap[view]; | 856 | Session *session = _sessionMap[view]; | ||
916 | ids << SessionManager::instance()->getRestoreId(session); | 857 | ids << SessionManager::instance()->getRestoreId(session); | ||
917 | unique.insert(session); | 858 | unique.insert(session); | ||
918 | if (view == activeview) { | 859 | if (view == activeview) { | ||
919 | group.writeEntry("Active", tab); | 860 | group.writeEntry("Active", tab); | ||
920 | } | 861 | } | ||
921 | tab++; | 862 | tab++; | ||
922 | } | 863 | } | ||
864 | #endif | ||||
923 | 865 | | |||
924 | // second: all other sessions, in random order | 866 | // second: all other sessions, in random order | ||
925 | // we don't want to have sessions restored that are not connected | 867 | // we don't want to have sessions restored that are not connected | ||
926 | foreach (Session *session, _sessionMap) { | 868 | foreach (Session *session, _sessionMap) { | ||
927 | if (!unique.contains(session)) { | 869 | if (!unique.contains(session)) { | ||
928 | ids << SessionManager::instance()->getRestoreId(session); | 870 | ids << SessionManager::instance()->getRestoreId(session); | ||
929 | unique.insert(session); | 871 | unique.insert(session); | ||
930 | } | 872 | } | ||
931 | } | 873 | } | ||
932 | 874 | | |||
933 | group.writeEntry("Sessions", ids); | 875 | group.writeEntry("Sessions", ids); | ||
934 | } | 876 | } | ||
935 | 877 | | |||
936 | TabbedViewContainer *ViewManager::activeContainer() | 878 | TabbedViewContainer *ViewManager::activeContainer() | ||
937 | { | 879 | { | ||
938 | return _viewSplitter->activeContainer(); | 880 | return _viewContainer; | ||
939 | } | 881 | } | ||
940 | 882 | | |||
941 | void ViewManager::restoreSessions(const KConfigGroup &group) | 883 | void ViewManager::restoreSessions(const KConfigGroup &group) | ||
942 | { | 884 | { | ||
943 | QList<int> ids = group.readEntry("Sessions", QList<int>()); | 885 | QList<int> ids = group.readEntry("Sessions", QList<int>()); | ||
944 | int activeTab = group.readEntry("Active", 0); | 886 | int activeTab = group.readEntry("Active", 0); | ||
945 | TerminalDisplay *display = nullptr; | 887 | TerminalDisplay *display = nullptr; | ||
946 | 888 | | |||
947 | int tab = 1; | 889 | int tab = 1; | ||
948 | foreach (int id, ids) { | 890 | foreach (int id, ids) { | ||
949 | Session *session = SessionManager::instance()->idToSession(id); | 891 | Session *session = SessionManager::instance()->idToSession(id); | ||
950 | 892 | | |||
951 | if (session == nullptr) { | 893 | if (session == nullptr) { | ||
952 | qWarning() << "Unable to load session with id" << id; | 894 | qWarning() << "Unable to load session with id" << id; | ||
953 | // Force a creation of a default session below | 895 | // Force a creation of a default session below | ||
954 | ids.clear(); | 896 | ids.clear(); | ||
955 | break; | 897 | break; | ||
956 | } | 898 | } | ||
957 | 899 | | |||
958 | createView(activeContainer(), session); | 900 | createView(session); | ||
959 | if (!session->isRunning()) { | 901 | if (!session->isRunning()) { | ||
960 | session->run(); | 902 | session->run(); | ||
961 | } | 903 | } | ||
962 | if (tab++ == activeTab) { | 904 | if (tab++ == activeTab) { | ||
963 | display = qobject_cast<TerminalDisplay *>(activeView()); | 905 | display = qobject_cast<TerminalDisplay *>(activeView()); | ||
964 | } | 906 | } | ||
965 | } | 907 | } | ||
966 | 908 | | |||
967 | if (display != nullptr) { | 909 | if (display != nullptr) { | ||
968 | _viewSplitter->activeContainer()->setCurrentWidget(display); | 910 | activeContainer()->setCurrentWidget(display); | ||
969 | display->setFocus(Qt::OtherFocusReason); | 911 | display->setFocus(Qt::OtherFocusReason); | ||
970 | } | 912 | } | ||
971 | 913 | | |||
972 | if (ids.isEmpty()) { // Session file is unusable, start default Profile | 914 | if (ids.isEmpty()) { // Session file is unusable, start default Profile | ||
973 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | 915 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | ||
974 | Session *session = SessionManager::instance()->createSession(profile); | 916 | Session *session = SessionManager::instance()->createSession(profile); | ||
975 | createView(activeContainer(), session); | 917 | createView(session); | ||
976 | if (!session->isRunning()) { | 918 | if (!session->isRunning()) { | ||
977 | session->run(); | 919 | session->run(); | ||
978 | } | 920 | } | ||
979 | } | 921 | } | ||
980 | } | 922 | } | ||
981 | 923 | | |||
982 | int ViewManager::sessionCount() | 924 | int ViewManager::sessionCount() | ||
983 | { | 925 | { | ||
Show All 23 Lines | 942 | { | |||
1007 | return -1; | 949 | return -1; | ||
1008 | } | 950 | } | ||
1009 | 951 | | |||
1010 | void ViewManager::setCurrentSession(int sessionId) | 952 | void ViewManager::setCurrentSession(int sessionId) | ||
1011 | { | 953 | { | ||
1012 | QHash<TerminalDisplay *, Session *>::const_iterator i; | 954 | QHash<TerminalDisplay *, Session *>::const_iterator i; | ||
1013 | for (i = _sessionMap.constBegin(); i != _sessionMap.constEnd(); ++i) { | 955 | for (i = _sessionMap.constBegin(); i != _sessionMap.constEnd(); ++i) { | ||
1014 | if (i.value()->sessionId() == sessionId) { | 956 | if (i.value()->sessionId() == sessionId) { | ||
1015 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | 957 | TabbedViewContainer *container = activeContainer(); | ||
1016 | if (container != nullptr) { | 958 | if (container != nullptr) { | ||
1017 | container->setCurrentWidget(i.key()); | 959 | container->setCurrentWidget(i.key()); | ||
1018 | } | 960 | } | ||
1019 | } | 961 | } | ||
1020 | } | 962 | } | ||
1021 | } | 963 | } | ||
1022 | 964 | | |||
1023 | int ViewManager::newSession() | 965 | int ViewManager::newSession() | ||
1024 | { | 966 | { | ||
1025 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | 967 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | ||
1026 | Session *session = SessionManager::instance()->createSession(profile); | 968 | Session *session = SessionManager::instance()->createSession(profile); | ||
1027 | 969 | | |||
1028 | session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(managerId())); | 970 | session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(managerId())); | ||
1029 | 971 | | |||
1030 | createView(activeContainer(), session); | 972 | createView(session); | ||
1031 | session->run(); | 973 | session->run(); | ||
1032 | 974 | | |||
1033 | return session->sessionId(); | 975 | return session->sessionId(); | ||
1034 | } | 976 | } | ||
1035 | 977 | | |||
1036 | int ViewManager::newSession(const QString &profile) | 978 | int ViewManager::newSession(const QString &profile) | ||
1037 | { | 979 | { | ||
1038 | const QList<Profile::Ptr> profilelist = ProfileManager::instance()->allProfiles(); | 980 | const QList<Profile::Ptr> profilelist = ProfileManager::instance()->allProfiles(); | ||
1039 | Profile::Ptr profileptr = ProfileManager::instance()->defaultProfile(); | 981 | Profile::Ptr profileptr = ProfileManager::instance()->defaultProfile(); | ||
1040 | 982 | | |||
1041 | for (const auto &i : profilelist) { | 983 | for (const auto &i : profilelist) { | ||
1042 | if (i->name() == profile) { | 984 | if (i->name() == profile) { | ||
1043 | profileptr = i; | 985 | profileptr = i; | ||
1044 | break; | 986 | break; | ||
1045 | } | 987 | } | ||
1046 | } | 988 | } | ||
1047 | 989 | | |||
1048 | Session *session = SessionManager::instance()->createSession(profileptr); | 990 | Session *session = SessionManager::instance()->createSession(profileptr); | ||
1049 | 991 | | |||
1050 | session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(managerId())); | 992 | session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(managerId())); | ||
1051 | 993 | | |||
1052 | createView(activeContainer(), session); | 994 | createView(session); | ||
1053 | session->run(); | 995 | session->run(); | ||
1054 | 996 | | |||
1055 | return session->sessionId(); | 997 | return session->sessionId(); | ||
1056 | } | 998 | } | ||
1057 | 999 | | |||
1058 | int ViewManager::newSession(const QString &profile, const QString &directory) | 1000 | int ViewManager::newSession(const QString &profile, const QString &directory) | ||
1059 | { | 1001 | { | ||
1060 | const QList<Profile::Ptr> profilelist = ProfileManager::instance()->allProfiles(); | 1002 | const QList<Profile::Ptr> profilelist = ProfileManager::instance()->allProfiles(); | ||
1061 | Profile::Ptr profileptr = ProfileManager::instance()->defaultProfile(); | 1003 | Profile::Ptr profileptr = ProfileManager::instance()->defaultProfile(); | ||
1062 | 1004 | | |||
1063 | for (const auto &i : profilelist) { | 1005 | for (const auto &i : profilelist) { | ||
1064 | if (i->name() == profile) { | 1006 | if (i->name() == profile) { | ||
1065 | profileptr = i; | 1007 | profileptr = i; | ||
1066 | break; | 1008 | break; | ||
1067 | } | 1009 | } | ||
1068 | } | 1010 | } | ||
1069 | 1011 | | |||
1070 | Session *session = SessionManager::instance()->createSession(profileptr); | 1012 | Session *session = SessionManager::instance()->createSession(profileptr); | ||
1071 | session->setInitialWorkingDirectory(directory); | 1013 | session->setInitialWorkingDirectory(directory); | ||
1072 | 1014 | | |||
1073 | session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(managerId())); | 1015 | session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(managerId())); | ||
1074 | 1016 | | |||
1075 | createView(activeContainer(), session); | 1017 | createView(session); | ||
1076 | session->run(); | 1018 | session->run(); | ||
1077 | 1019 | | |||
1078 | return session->sessionId(); | 1020 | return session->sessionId(); | ||
1079 | } | 1021 | } | ||
1080 | 1022 | | |||
1081 | QString ViewManager::defaultProfile() | 1023 | QString ViewManager::defaultProfile() | ||
1082 | { | 1024 | { | ||
1083 | return ProfileManager::instance()->defaultProfile()->name(); | 1025 | return ProfileManager::instance()->defaultProfile()->name(); | ||
Show All 21 Lines | |||||
1105 | 1047 | | |||
1106 | void ViewManager::moveSessionRight() | 1048 | void ViewManager::moveSessionRight() | ||
1107 | { | 1049 | { | ||
1108 | moveActiveViewRight(); | 1050 | moveActiveViewRight(); | ||
1109 | } | 1051 | } | ||
1110 | 1052 | | |||
1111 | void ViewManager::setTabWidthToText(bool setTabWidthToText) | 1053 | void ViewManager::setTabWidthToText(bool setTabWidthToText) | ||
1112 | { | 1054 | { | ||
1113 | for(auto container : _viewSplitter->containers()) { | 1055 | _viewContainer->tabBar()->setExpanding(!setTabWidthToText); | ||
1114 | container->tabBar()->setExpanding(!setTabWidthToText); | 1056 | _viewContainer->tabBar()->update(); | ||
1115 | container->tabBar()->update(); | | |||
1116 | } | | |||
1117 | } | 1057 | } | ||
1118 | 1058 | | |||
1119 | void ViewManager::setNavigationVisibility(NavigationVisibility navigationVisibility) { | 1059 | void ViewManager::setNavigationVisibility(NavigationVisibility navigationVisibility) { | ||
1120 | if (_navigationVisibility != navigationVisibility) { | 1060 | if (_navigationVisibility != navigationVisibility) { | ||
1121 | _navigationVisibility = navigationVisibility; | 1061 | _navigationVisibility = navigationVisibility; | ||
1122 | for(auto *container : _viewSplitter->containers()) { | 1062 | _viewContainer->setNavigationVisibility(navigationVisibility); | ||
1123 | container->setNavigationVisibility(navigationVisibility); | | |||
1124 | } | | |||
1125 | } | 1063 | } | ||
1126 | } | 1064 | } | ||
1127 | 1065 | | |||
1128 | void ViewManager::setNavigationBehavior(int behavior) | 1066 | void ViewManager::setNavigationBehavior(int behavior) | ||
1129 | { | 1067 | { | ||
1130 | _newTabBehavior = static_cast<NewTabBehavior>(behavior); | 1068 | _newTabBehavior = static_cast<NewTabBehavior>(behavior); | ||
1131 | } | 1069 | } |
There is a method ViewSplitter::getTerminalDisplays() which is a lot more complicated than this. It should probably be simplified to this and used here or removed entirely.