Changeset View
Changeset View
Standalone View
Standalone View
src/ViewManager.cpp
Show All 38 Lines | |||||
39 | #include "ColorSchemeManager.h" | 39 | #include "ColorSchemeManager.h" | ||
40 | #include "Session.h" | 40 | #include "Session.h" | ||
41 | #include "TerminalDisplay.h" | 41 | #include "TerminalDisplay.h" | ||
42 | #include "SessionController.h" | 42 | #include "SessionController.h" | ||
43 | #include "SessionManager.h" | 43 | #include "SessionManager.h" | ||
44 | #include "ProfileManager.h" | 44 | #include "ProfileManager.h" | ||
45 | #include "ViewSplitter.h" | 45 | #include "ViewSplitter.h" | ||
46 | #include "Enumeration.h" | 46 | #include "Enumeration.h" | ||
47 | #include "ViewContainer.h" | ||||
47 | 48 | | |||
48 | using namespace Konsole; | 49 | using namespace Konsole; | ||
49 | 50 | | |||
50 | int ViewManager::lastManagerId = 0; | 51 | int ViewManager::lastManagerId = 0; | ||
51 | 52 | | |||
52 | ViewManager::ViewManager(QObject *parent, KActionCollection *collection) : | 53 | ViewManager::ViewManager(QObject *parent, KActionCollection *collection) : | ||
53 | QObject(parent), | 54 | QObject(parent), | ||
54 | _viewSplitter(nullptr), | 55 | _viewSplitter(nullptr), | ||
55 | _pluggedController(nullptr), | 56 | _pluggedController(nullptr), | ||
56 | _sessionMap(QHash<TerminalDisplay *, Session *>()), | 57 | _sessionMap(QHash<TerminalDisplay *, Session *>()), | ||
57 | _actionCollection(collection), | 58 | _actionCollection(collection), | ||
58 | _navigationMethod(TabbedNavigation), | | |||
59 | _navigationVisibility(ViewContainer::AlwaysShowNavigation), | | |||
60 | _navigationPosition(ViewContainer::NavigationPositionTop), | | |||
61 | _showQuickButtons(false), | | |||
62 | _navigationTabWidthExpanding(true), | | |||
63 | _newTabBehavior(PutNewTabAtTheEnd), | | |||
64 | _navigationStyleSheet(QString()), | | |||
65 | _managerId(0) | 59 | _managerId(0) | ||
66 | { | 60 | { | ||
67 | // create main view area | 61 | // create main view area | ||
68 | _viewSplitter = new ViewSplitter(nullptr); | 62 | _viewSplitter = new ViewSplitter(nullptr); | ||
69 | KAcceleratorManager::setNoAccel(_viewSplitter); | 63 | KAcceleratorManager::setNoAccel(_viewSplitter); | ||
70 | 64 | | |||
71 | // the ViewSplitter class supports both recursive and non-recursive splitting, | 65 | // the ViewSplitter class supports both recursive and non-recursive splitting, | ||
72 | // in non-recursive mode, all containers are inserted into the same top-level splitter | 66 | // in non-recursive mode, all containers are inserted into the same top-level splitter | ||
Show All 31 Lines | |||||
104 | 98 | | |||
105 | int ViewManager::managerId() const | 99 | int ViewManager::managerId() const | ||
106 | { | 100 | { | ||
107 | return _managerId; | 101 | return _managerId; | ||
108 | } | 102 | } | ||
109 | 103 | | |||
110 | QWidget *ViewManager::activeView() const | 104 | QWidget *ViewManager::activeView() const | ||
111 | { | 105 | { | ||
112 | ViewContainer *container = _viewSplitter->activeContainer(); | 106 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
113 | if (container != nullptr) { | 107 | if (container != nullptr) { | ||
114 | return container->activeView(); | 108 | return container->currentWidget(); | ||
115 | } else { | 109 | } else { | ||
116 | return nullptr; | 110 | return nullptr; | ||
117 | } | 111 | } | ||
118 | } | 112 | } | ||
119 | 113 | | |||
120 | QWidget *ViewManager::widget() const | 114 | QWidget *ViewManager::widget() const | ||
121 | { | 115 | { | ||
122 | return _viewSplitter; | 116 | return _viewSplitter; | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 190 | collection->setDefaultShortcut(shrinkActiveAction, | |||
197 | Konsole::ACCEL + Qt::SHIFT + Qt::Key_BracketLeft); | 191 | Konsole::ACCEL + Qt::SHIFT + Qt::Key_BracketLeft); | ||
198 | shrinkActiveAction->setEnabled(false); | 192 | shrinkActiveAction->setEnabled(false); | ||
199 | collection->addAction(QStringLiteral("shrink-active-view"), shrinkActiveAction); | 193 | collection->addAction(QStringLiteral("shrink-active-view"), shrinkActiveAction); | ||
200 | connect(shrinkActiveAction, &QAction::triggered, this, | 194 | connect(shrinkActiveAction, &QAction::triggered, this, | ||
201 | &Konsole::ViewManager::shrinkActiveContainer); | 195 | &Konsole::ViewManager::shrinkActiveContainer); | ||
202 | 196 | | |||
203 | multiViewOnlyActions << shrinkActiveAction; | 197 | multiViewOnlyActions << shrinkActiveAction; | ||
204 | 198 | | |||
205 | #if defined(ENABLE_DETACHING) | | |||
206 | QAction *detachViewAction = collection->addAction(QStringLiteral("detach-view")); | 199 | QAction *detachViewAction = collection->addAction(QStringLiteral("detach-view")); | ||
200 | // Crashes on Mac. | ||||
201 | detachViewAction->setEnabled(QOperatingSystemVersion::currentType() != QOperatingSystemVersion::MacOS); | ||||
207 | detachViewAction->setIcon(QIcon::fromTheme(QStringLiteral("tab-detach"))); | 202 | detachViewAction->setIcon(QIcon::fromTheme(QStringLiteral("tab-detach"))); | ||
208 | detachViewAction->setText(i18nc("@action:inmenu", "D&etach Current Tab")); | 203 | detachViewAction->setText(i18nc("@action:inmenu", "D&etach Current Tab")); | ||
209 | // Ctrl+Shift+D is not used as a shortcut by default because it is too close | 204 | // Ctrl+Shift+D is not used as a shortcut by default because it is too close | ||
210 | // to Ctrl+D - which will terminate the session in many cases | 205 | // to Ctrl+D - which will terminate the session in many cases | ||
211 | collection->setDefaultShortcut(detachViewAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_H); | 206 | collection->setDefaultShortcut(detachViewAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_H); | ||
212 | 207 | | |||
213 | connect(this, &Konsole::ViewManager::splitViewToggle, this, | 208 | connect(this, &Konsole::ViewManager::splitViewToggle, this, | ||
214 | &Konsole::ViewManager::updateDetachViewState); | 209 | &Konsole::ViewManager::updateDetachViewState); | ||
215 | connect(detachViewAction, &QAction::triggered, this, &Konsole::ViewManager::detachActiveView); | 210 | connect(detachViewAction, &QAction::triggered, this, &Konsole::ViewManager::detachActiveView); | ||
216 | #endif | | |||
217 | 211 | | |||
218 | // Next / Previous View , Next Container | 212 | // Next / Previous View , Next Container | ||
219 | collection->addAction(QStringLiteral("next-view"), nextViewAction); | 213 | collection->addAction(QStringLiteral("next-view"), nextViewAction); | ||
220 | collection->addAction(QStringLiteral("previous-view"), previousViewAction); | 214 | collection->addAction(QStringLiteral("previous-view"), previousViewAction); | ||
221 | collection->addAction(QStringLiteral("last-tab"), lastViewAction); | 215 | collection->addAction(QStringLiteral("last-tab"), lastViewAction); | ||
222 | collection->addAction(QStringLiteral("next-container"), nextContainerAction); | 216 | collection->addAction(QStringLiteral("next-container"), nextContainerAction); | ||
223 | collection->addAction(QStringLiteral("move-view-left"), moveViewLeftAction); | 217 | collection->addAction(QStringLiteral("move-view-left"), moveViewLeftAction); | ||
224 | collection->addAction(QStringLiteral("move-view-right"), moveViewRightAction); | 218 | collection->addAction(QStringLiteral("move-view-right"), moveViewRightAction); | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 266 | #endif | |||
275 | _viewSplitter->addAction(moveViewRightAction); | 269 | _viewSplitter->addAction(moveViewRightAction); | ||
276 | 270 | | |||
277 | connect(lastViewAction, &QAction::triggered, this, &Konsole::ViewManager::lastView); | 271 | connect(lastViewAction, &QAction::triggered, this, &Konsole::ViewManager::lastView); | ||
278 | _viewSplitter->addAction(lastViewAction); | 272 | _viewSplitter->addAction(lastViewAction); | ||
279 | } | 273 | } | ||
280 | 274 | | |||
281 | void ViewManager::switchToView(int index) | 275 | void ViewManager::switchToView(int index) | ||
282 | { | 276 | { | ||
283 | Q_ASSERT(index >= 0); | 277 | _viewSplitter->activeContainer()->setCurrentIndex(index); | ||
284 | ViewContainer *container = _viewSplitter->activeContainer(); | | |||
285 | Q_ASSERT(container); | | |||
286 | QList<QWidget *> containerViews = container->views(); | | |||
287 | if (index >= containerViews.count()) { | | |||
288 | return; | | |||
289 | } | | |||
290 | container->setActiveView(containerViews.at(index)); | | |||
291 | } | 278 | } | ||
292 | 279 | | |||
293 | void ViewManager::updateDetachViewState() | 280 | void ViewManager::updateDetachViewState() | ||
294 | { | 281 | { | ||
295 | Q_ASSERT(_actionCollection); | 282 | Q_ASSERT(_actionCollection); | ||
296 | if (_actionCollection == nullptr) { | 283 | if (_actionCollection == nullptr) { | ||
297 | return; | 284 | return; | ||
298 | } | 285 | } | ||
299 | 286 | | |||
300 | const bool splitView = _viewSplitter->containers().count() >= 2; | 287 | const bool splitView = _viewSplitter->containers().count() >= 2; | ||
301 | auto activeContainer = _viewSplitter->activeContainer(); | 288 | auto activeContainer = _viewSplitter->activeContainer(); | ||
302 | const bool shouldEnable = splitView | 289 | const bool shouldEnable = splitView | ||
303 | || ((activeContainer != nullptr) | 290 | || ((activeContainer != nullptr) | ||
304 | && activeContainer->views().count() >= 2); | 291 | && activeContainer->count() >= 2); | ||
305 | 292 | | |||
306 | QAction *detachAction = _actionCollection->action(QStringLiteral("detach-view")); | 293 | QAction *detachAction = _actionCollection->action(QStringLiteral("detach-view")); | ||
307 | 294 | | |||
308 | if ((detachAction != nullptr) && shouldEnable != detachAction->isEnabled()) { | 295 | if ((detachAction != nullptr) && shouldEnable != detachAction->isEnabled()) { | ||
309 | detachAction->setEnabled(shouldEnable); | 296 | detachAction->setEnabled(shouldEnable); | ||
310 | } | 297 | } | ||
311 | } | 298 | } | ||
312 | 299 | | |||
313 | void ViewManager::moveActiveViewLeft() | 300 | void ViewManager::moveActiveViewLeft() | ||
314 | { | 301 | { | ||
315 | ViewContainer *container = _viewSplitter->activeContainer(); | 302 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
316 | Q_ASSERT(container); | 303 | Q_ASSERT(container); | ||
317 | container->moveActiveView(ViewContainer::MoveViewLeft); | 304 | container->moveActiveView(TabbedViewContainer::MoveViewLeft); | ||
318 | } | 305 | } | ||
319 | 306 | | |||
320 | void ViewManager::moveActiveViewRight() | 307 | void ViewManager::moveActiveViewRight() | ||
321 | { | 308 | { | ||
322 | ViewContainer *container = _viewSplitter->activeContainer(); | 309 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
323 | Q_ASSERT(container); | 310 | Q_ASSERT(container); | ||
324 | container->moveActiveView(ViewContainer::MoveViewRight); | 311 | container->moveActiveView(TabbedViewContainer::MoveViewRight); | ||
325 | } | 312 | } | ||
326 | 313 | | |||
327 | void ViewManager::nextContainer() | 314 | void ViewManager::nextContainer() | ||
328 | { | 315 | { | ||
329 | _viewSplitter->activateNextContainer(); | 316 | _viewSplitter->activateNextContainer(); | ||
330 | } | 317 | } | ||
331 | 318 | | |||
332 | void ViewManager::nextView() | 319 | void ViewManager::nextView() | ||
333 | { | 320 | { | ||
334 | ViewContainer *container = _viewSplitter->activeContainer(); | 321 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
335 | | ||||
336 | Q_ASSERT(container); | 322 | Q_ASSERT(container); | ||
337 | | ||||
338 | container->activateNextView(); | 323 | container->activateNextView(); | ||
339 | } | 324 | } | ||
340 | 325 | | |||
341 | void ViewManager::previousView() | 326 | void ViewManager::previousView() | ||
342 | { | 327 | { | ||
343 | ViewContainer *container = _viewSplitter->activeContainer(); | 328 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
344 | | ||||
345 | Q_ASSERT(container); | 329 | Q_ASSERT(container); | ||
346 | | ||||
347 | container->activatePreviousView(); | 330 | container->activatePreviousView(); | ||
348 | } | 331 | } | ||
349 | 332 | | |||
350 | void ViewManager::lastView() | 333 | void ViewManager::lastView() | ||
351 | { | 334 | { | ||
352 | ViewContainer *container = _viewSplitter->activeContainer(); | 335 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
353 | | ||||
354 | Q_ASSERT(container); | 336 | Q_ASSERT(container); | ||
355 | | ||||
356 | container->activateLastView(); | 337 | container->activateLastView(); | ||
357 | } | 338 | } | ||
358 | 339 | | |||
359 | void ViewManager::detachActiveView() | 340 | void ViewManager::detachActiveView() | ||
360 | { | 341 | { | ||
361 | // find the currently active view and remove it from its container | 342 | // find the currently active view and remove it from its container | ||
362 | ViewContainer *container = _viewSplitter->activeContainer(); | 343 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
363 | 344 | detachView(container, container->currentWidget()); | |||
364 | detachView(container, container->activeView()); | | |||
365 | } | 345 | } | ||
366 | 346 | | |||
367 | void ViewManager::detachView(ViewContainer *container, QWidget *view) | 347 | void ViewManager::detachView(TabbedViewContainer *container, QWidget *view) | ||
368 | { | 348 | { | ||
369 | #if !defined(ENABLE_DETACHING) | | |||
370 | return; | | |||
371 | #endif | | |||
372 | | ||||
373 | TerminalDisplay *viewToDetach = qobject_cast<TerminalDisplay *>(view); | 349 | TerminalDisplay *viewToDetach = qobject_cast<TerminalDisplay *>(view); | ||
374 | 350 | | |||
375 | if (viewToDetach == nullptr) { | 351 | if (viewToDetach == nullptr) { | ||
376 | return; | 352 | return; | ||
377 | } | 353 | } | ||
378 | 354 | | |||
379 | // BR390736 - some instances are sending invalid session to viewDetached() | 355 | // BR390736 - some instances are sending invalid session to viewDetached() | ||
380 | Session *sessionToDetach = _sessionMap[viewToDetach]; | 356 | Session *sessionToDetach = _sessionMap[viewToDetach]; | ||
381 | if (sessionToDetach == nullptr) { | 357 | if (sessionToDetach == nullptr) { | ||
382 | return; | 358 | return; | ||
383 | } | 359 | } | ||
384 | emit viewDetached(sessionToDetach); | 360 | emit viewDetached(sessionToDetach); | ||
385 | 361 | | |||
386 | _sessionMap.remove(viewToDetach); | 362 | _sessionMap.remove(viewToDetach); | ||
387 | 363 | | |||
388 | // remove the view from this window | 364 | // remove the view from this window | ||
389 | container->removeView(viewToDetach); | 365 | container->removeView(viewToDetach); | ||
390 | viewToDetach->deleteLater(); | 366 | viewToDetach->deleteLater(); | ||
391 | 367 | | |||
392 | // if the container from which the view was removed is now empty then it can be deleted, | 368 | // if the container from which the view was removed is now empty then it can be deleted, | ||
393 | // unless it is the only container in the window, in which case it is left empty | 369 | // unless it is the only container in the window, in which case it is left empty | ||
394 | // so that there is always an active container | 370 | // so that there is always an active container | ||
395 | if (_viewSplitter->containers().count() > 1 | 371 | if (_viewSplitter->containers().count() > 1 | ||
396 | && container->views().count() == 0) { | 372 | && container->count() == 0) { | ||
397 | removeContainer(container); | 373 | removeContainer(container); | ||
398 | } | 374 | } | ||
399 | } | 375 | } | ||
400 | 376 | | |||
401 | void ViewManager::sessionFinished() | 377 | void ViewManager::sessionFinished() | ||
402 | { | 378 | { | ||
403 | // if this slot is called after the view manager's main widget | 379 | // if this slot is called after the view manager's main widget | ||
404 | // has been destroyed, do nothing | 380 | // has been destroyed, do nothing | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
446 | 422 | | |||
447 | void ViewManager::splitTopBottom() | 423 | void ViewManager::splitTopBottom() | ||
448 | { | 424 | { | ||
449 | splitView(Qt::Vertical); | 425 | splitView(Qt::Vertical); | ||
450 | } | 426 | } | ||
451 | 427 | | |||
452 | void ViewManager::splitView(Qt::Orientation orientation) | 428 | void ViewManager::splitView(Qt::Orientation orientation) | ||
453 | { | 429 | { | ||
454 | ViewContainer *container = createContainer(); | 430 | TabbedViewContainer *container = createContainer(); | ||
455 | 431 | | |||
456 | // iterate over each session which has a view in the current active | 432 | // iterate over each session which has a view in the current active | ||
457 | // container and create a new view for that session in a new container | 433 | // container and create a new view for that session in a new container | ||
458 | foreach (QWidget *view, _viewSplitter->activeContainer()->views()) { | 434 | for(int i = 0, end = _viewSplitter->activeContainer()->count(); i < end; i++) { | ||
435 | auto view = _viewSplitter->activeContainer()->widget(i); | ||||
459 | Session *session = _sessionMap[qobject_cast<TerminalDisplay *>(view)]; | 436 | Session *session = _sessionMap[qobject_cast<TerminalDisplay *>(view)]; | ||
460 | TerminalDisplay *display = createTerminalDisplay(session); | 437 | TerminalDisplay *display = createTerminalDisplay(session); | ||
461 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | 438 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | ||
462 | applyProfileToView(display, profile); | 439 | applyProfileToView(display, profile); | ||
463 | ViewProperties *properties = createController(session, display); | 440 | ViewProperties *properties = createController(session, display); | ||
464 | 441 | | |||
465 | _sessionMap[display] = session; | 442 | _sessionMap[display] = session; | ||
466 | 443 | | |||
467 | container->addView(display, properties); | 444 | container->addView(display, properties); | ||
468 | session->addView(display); | 445 | session->addView(display); | ||
469 | } | 446 | } | ||
470 | 447 | | |||
471 | _viewSplitter->addContainer(container, orientation); | 448 | _viewSplitter->addContainer(container, orientation); | ||
472 | emit splitViewToggle(_viewSplitter->containers().count() > 0); | 449 | emit splitViewToggle(_viewSplitter->containers().count() > 0); | ||
473 | 450 | | |||
474 | // focus the new container | 451 | // focus the new container | ||
475 | container->containerWidget()->setFocus(); | 452 | container->currentWidget()->setFocus(); | ||
476 | 453 | | |||
477 | // ensure that the active view is focused after the split / unsplit | 454 | // ensure that the active view is focused after the split / unsplit | ||
478 | ViewContainer *activeContainer = _viewSplitter->activeContainer(); | 455 | TabbedViewContainer *activeContainer = _viewSplitter->activeContainer(); | ||
479 | QWidget *activeView = activeContainer != nullptr ? activeContainer->activeView() : nullptr; | 456 | QWidget *activeView = activeContainer != nullptr ? activeContainer->currentWidget() : nullptr; | ||
480 | 457 | | |||
481 | if (activeView != nullptr) { | 458 | if (activeView != nullptr) { | ||
482 | activeView->setFocus(Qt::OtherFocusReason); | 459 | activeView->setFocus(Qt::OtherFocusReason); | ||
483 | } | 460 | } | ||
484 | } | 461 | } | ||
485 | 462 | | |||
486 | void ViewManager::removeContainer(ViewContainer *container) | 463 | void ViewManager::removeContainer(TabbedViewContainer *container) | ||
487 | { | 464 | { | ||
488 | // remove session map entries for views in this container | 465 | // remove session map entries for views in this container | ||
489 | foreach (QWidget *view, container->views()) { | 466 | for(int i = 0, end = container->count(); i < end; i++) { | ||
467 | auto view = container->widget(i); | ||||
490 | TerminalDisplay *display = qobject_cast<TerminalDisplay *>(view); | 468 | TerminalDisplay *display = qobject_cast<TerminalDisplay *>(view); | ||
491 | Q_ASSERT(display); | 469 | Q_ASSERT(display); | ||
492 | _sessionMap.remove(display); | 470 | _sessionMap.remove(display); | ||
493 | } | 471 | } | ||
494 | 472 | | |||
495 | _viewSplitter->removeContainer(container); | 473 | _viewSplitter->removeContainer(container); | ||
496 | container->deleteLater(); | 474 | container->deleteLater(); | ||
497 | 475 | | |||
Show All 9 Lines | |||||
507 | { | 485 | { | ||
508 | _viewSplitter->adjustContainerSize(_viewSplitter->activeContainer(), -10); | 486 | _viewSplitter->adjustContainerSize(_viewSplitter->activeContainer(), -10); | ||
509 | } | 487 | } | ||
510 | 488 | | |||
511 | void ViewManager::closeActiveContainer() | 489 | void ViewManager::closeActiveContainer() | ||
512 | { | 490 | { | ||
513 | // only do something if there is more than one container active | 491 | // only do something if there is more than one container active | ||
514 | if (_viewSplitter->containers().count() > 1) { | 492 | if (_viewSplitter->containers().count() > 1) { | ||
515 | ViewContainer *container = _viewSplitter->activeContainer(); | 493 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
516 | 494 | | |||
517 | removeContainer(container); | 495 | removeContainer(container); | ||
518 | 496 | | |||
519 | // focus next container so that user can continue typing | 497 | // focus next container so that user can continue typing | ||
520 | // without having to manually focus it themselves | 498 | // without having to manually focus it themselves | ||
521 | nextContainer(); | 499 | nextContainer(); | ||
522 | } | 500 | } | ||
523 | } | 501 | } | ||
524 | 502 | | |||
525 | void ViewManager::closeOtherContainers() | 503 | void ViewManager::closeOtherContainers() | ||
526 | { | 504 | { | ||
527 | ViewContainer *active = _viewSplitter->activeContainer(); | 505 | TabbedViewContainer *active = _viewSplitter->activeContainer(); | ||
528 | 506 | | |||
529 | foreach (ViewContainer *container, _viewSplitter->containers()) { | 507 | foreach (TabbedViewContainer *container, _viewSplitter->containers()) { | ||
530 | if (container != active) { | 508 | if (container != active) { | ||
531 | removeContainer(container); | 509 | removeContainer(container); | ||
532 | } | 510 | } | ||
533 | } | 511 | } | ||
534 | } | 512 | } | ||
535 | 513 | | |||
536 | SessionController *ViewManager::createController(Session *session, TerminalDisplay *view) | 514 | SessionController *ViewManager::createController(Session *session, TerminalDisplay *view) | ||
537 | { | 515 | { | ||
Show All 31 Lines | 539 | { | |||
569 | emit activeViewChanged(controller); | 547 | emit activeViewChanged(controller); | ||
570 | } | 548 | } | ||
571 | 549 | | |||
572 | SessionController *ViewManager::activeViewController() const | 550 | SessionController *ViewManager::activeViewController() const | ||
573 | { | 551 | { | ||
574 | return _pluggedController; | 552 | return _pluggedController; | ||
575 | } | 553 | } | ||
576 | 554 | | |||
577 | IncrementalSearchBar *ViewManager::searchBar() const | 555 | void ViewManager::createView(Session *session, TabbedViewContainer *container, int index) | ||
578 | { | | |||
579 | return _viewSplitter->activeSplitter()->activeContainer()->searchBar(); | | |||
580 | } | | |||
581 | | ||||
582 | void ViewManager::createView(Session *session, ViewContainer *container, int index) | | |||
583 | { | 556 | { | ||
584 | // notify this view manager when the session finishes so that its view | 557 | // notify this view manager when the session finishes so that its view | ||
585 | // can be deleted | 558 | // can be deleted | ||
586 | // | 559 | // | ||
587 | // Use Qt::UniqueConnection to avoid duplicate connection | 560 | // Use Qt::UniqueConnection to avoid duplicate connection | ||
588 | connect(session, &Konsole::Session::finished, this, &Konsole::ViewManager::sessionFinished, | 561 | connect(session, &Konsole::Session::finished, this, &Konsole::ViewManager::sessionFinished, | ||
589 | Qt::UniqueConnection); | 562 | Qt::UniqueConnection); | ||
590 | 563 | | |||
591 | TerminalDisplay *display = createTerminalDisplay(session); | 564 | TerminalDisplay *display = createTerminalDisplay(session); | ||
592 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | 565 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | ||
593 | applyProfileToView(display, profile); | 566 | applyProfileToView(display, profile); | ||
594 | 567 | | |||
595 | // set initial size | 568 | // set initial size | ||
596 | const QSize &preferredSize = session->preferredSize(); | 569 | const QSize &preferredSize = session->preferredSize(); | ||
597 | // FIXME: +1 is needed here for getting the expected rows | | |||
598 | // Note that the display shouldn't need to take into account the tabbar. | | |||
599 | // However, it appears that taking into account the tabbar is needed. | | |||
600 | // If tabbar is not visible, no +1 is needed here; however, depending on | | |||
601 | // settings/tabbar style, +2 might be needed. | | |||
602 | // 1st attempt at fixing the above: | | |||
603 | // Guess if tabbar will NOT be visible; ignore ShowNavigationAsNeeded | | |||
604 | int heightAdjustment = 0; | | |||
605 | if (_navigationVisibility != ViewContainer::AlwaysHideNavigation) { | | |||
606 | heightAdjustment = 2; | | |||
607 | } | | |||
608 | 570 | | |||
609 | display->setSize(preferredSize.width(), preferredSize.height() + heightAdjustment); | 571 | display->setSize(preferredSize.width(), preferredSize.height()); | ||
610 | ViewProperties *properties = createController(session, display); | 572 | ViewProperties *properties = createController(session, display); | ||
611 | 573 | | |||
612 | _sessionMap[display] = session; | 574 | _sessionMap[display] = session; | ||
613 | container->addView(display, properties, index); | 575 | container->addView(display, properties, index); | ||
614 | session->addView(display); | 576 | session->addView(display); | ||
615 | 577 | | |||
616 | // tell the session whether it has a light or dark background | 578 | // tell the session whether it has a light or dark background | ||
617 | session->setDarkBackground(colorSchemeForProfile(profile)->hasDarkBackground()); | 579 | session->setDarkBackground(colorSchemeForProfile(profile)->hasDarkBackground()); | ||
618 | 580 | | |||
619 | if (container == _viewSplitter->activeContainer()) { | 581 | if (container == _viewSplitter->activeContainer()) { | ||
620 | container->setActiveView(display); | 582 | container->setCurrentWidget(display); | ||
621 | display->setFocus(Qt::OtherFocusReason); | 583 | display->setFocus(Qt::OtherFocusReason); | ||
622 | } | 584 | } | ||
623 | 585 | | |||
624 | updateDetachViewState(); | 586 | updateDetachViewState(); | ||
625 | } | 587 | } | ||
626 | 588 | | |||
627 | void ViewManager::createView(Session *session) | 589 | void ViewManager::createView(Session *session) | ||
628 | { | 590 | { | ||
629 | // create the default container | 591 | // create the default container | ||
630 | if (_viewSplitter->containers().count() == 0) { | 592 | if (_viewSplitter->containers().count() == 0) { | ||
631 | ViewContainer *container = createContainer(); | 593 | TabbedViewContainer *container = createContainer(); | ||
632 | _viewSplitter->addContainer(container, Qt::Vertical); | 594 | _viewSplitter->addContainer(container, Qt::Vertical); | ||
633 | emit splitViewToggle(false); | 595 | emit splitViewToggle(false); | ||
634 | } | 596 | } | ||
635 | 597 | | |||
636 | // new tab will be put at the end by default. | 598 | // new tab will be put at the end by default. | ||
637 | int index = -1; | 599 | int index = -1; | ||
638 | 600 | | |||
639 | if (_newTabBehavior == PutNewTabAfterCurrentTab) { | | |||
640 | QWidget *view = activeView(); | | |||
641 | if (view != nullptr) { | | |||
642 | QList<QWidget *> views = _viewSplitter->activeContainer()->views(); | | |||
643 | index = views.indexOf(view) + 1; | | |||
644 | } | | |||
645 | } | | |||
646 | | ||||
647 | // iterate over the view containers owned by this view manager | 601 | // iterate over the view containers owned by this view manager | ||
648 | // and create a new terminal display for the session in each of them, along with | 602 | // and create a new terminal display for the session in each of them, along with | ||
649 | // a controller for the session/display pair | 603 | // a controller for the session/display pair | ||
650 | foreach (ViewContainer *container, _viewSplitter->containers()) { | 604 | foreach (TabbedViewContainer *container, _viewSplitter->containers()) { | ||
651 | createView(session, container, index); | 605 | createView(session, container, index); | ||
652 | } | 606 | } | ||
653 | } | 607 | } | ||
654 | 608 | | |||
655 | ViewContainer *ViewManager::createContainer() | 609 | TabbedViewContainer *ViewManager::createContainer() | ||
656 | { | 610 | { | ||
657 | 611 | | |||
658 | auto *container = new TabbedViewContainer(_navigationPosition, this, _viewSplitter); | 612 | auto *container = new TabbedViewContainer(this, _viewSplitter); | ||
659 | if (_navigationMethod == TabbedNavigation) { | 613 | //TODO: Fix Detaching. | ||
660 | connect(container, &TabbedViewContainer::detachTab, this, &ViewManager::detachView); | 614 | connect(container, &TabbedViewContainer::detachTab, this, &ViewManager::detachView); | ||
sandsmark: remove dead code? unless this breaks something and is a valid TODO | |||||
tcanabrava: invalid. forgot to remove. | |||||
661 | connect(container, &TabbedViewContainer::closeTab, this, | | |||
662 | &ViewManager::closeTabFromContainer); | | |||
663 | } | | |||
664 | | ||||
665 | // FIXME: these code feels duplicated | | |||
666 | container->setNavigationVisibility(_navigationVisibility); | | |||
667 | container->setNavigationPosition(_navigationPosition); | | |||
668 | container->setNavigationTabWidthExpanding(_navigationTabWidthExpanding); | | |||
669 | container->setStyleSheet(_navigationStyleSheet); | | |||
670 | setContainerFeatures(container); | | |||
671 | 615 | | |||
672 | // connect signals and slots | 616 | // connect signals and slots | ||
673 | connect(container, &Konsole::ViewContainer::viewAdded, this, | 617 | connect(container, &Konsole::TabbedViewContainer::viewAdded, this, | ||
674 | [this, container]() { | 618 | [this, container]() { | ||
675 | containerViewsChanged(container); | 619 | containerViewsChanged(container); | ||
676 | }); | 620 | }); | ||
677 | 621 | | |||
678 | connect(container, &Konsole::ViewContainer::viewRemoved, this, | 622 | connect(container, &Konsole::TabbedViewContainer::viewRemoved, this, | ||
679 | [this, container]() { | 623 | [this, container]() { | ||
680 | containerViewsChanged(container); | 624 | containerViewsChanged(container); | ||
681 | }); | 625 | }); | ||
682 | 626 | | |||
683 | connect(container, | 627 | connect(container, | ||
684 | static_cast<void (ViewContainer::*)()>(&Konsole::ViewContainer::newViewRequest), this, | 628 | static_cast<void (TabbedViewContainer::*)()>(&Konsole::TabbedViewContainer::newViewRequest), this, | ||
685 | static_cast<void (ViewManager::*)()>(&Konsole::ViewManager::newViewRequest)); | 629 | static_cast<void (ViewManager::*)()>(&Konsole::ViewManager::newViewRequest)); | ||
686 | connect(container, | 630 | connect(container, | ||
687 | static_cast<void (ViewContainer::*)(Profile::Ptr)>(&Konsole::ViewContainer::newViewRequest), | 631 | static_cast<void (TabbedViewContainer::*)(Profile::Ptr)>(&Konsole::TabbedViewContainer::newViewRequest), | ||
688 | this, | 632 | this, | ||
689 | static_cast<void (ViewManager::*)(Profile::Ptr)>(&Konsole::ViewManager::newViewRequest)); | 633 | static_cast<void (ViewManager::*)(Profile::Ptr)>(&Konsole::ViewManager::newViewRequest)); | ||
690 | connect(container, &Konsole::ViewContainer::moveViewRequest, this, | 634 | connect(container, &Konsole::TabbedViewContainer::moveViewRequest, this, | ||
691 | &Konsole::ViewManager::containerMoveViewRequest); | 635 | &Konsole::ViewManager::containerMoveViewRequest); | ||
692 | connect(container, &Konsole::ViewContainer::viewRemoved, this, | 636 | connect(container, &Konsole::TabbedViewContainer::viewRemoved, this, | ||
693 | &Konsole::ViewManager::viewDestroyed); | 637 | &Konsole::ViewManager::viewDestroyed); | ||
694 | connect(container, &Konsole::ViewContainer::activeViewChanged, this, | 638 | connect(container, &Konsole::TabbedViewContainer::activeViewChanged, this, | ||
695 | &Konsole::ViewManager::viewActivated); | 639 | &Konsole::ViewManager::viewActivated); | ||
696 | 640 | | |||
697 | if (_navigationMethod != TabbedNavigation) { | | |||
698 | container->setTabBarVisible(false); | | |||
sandsmark: this breaks something in the kpart, I think? | |||||
I'v tested the kpart manyally and did not found bugs. I'll recheck. tcanabrava: I'v tested the kpart manyally and did not found bugs. I'll recheck. | |||||
699 | } | | |||
700 | | ||||
701 | return container; | 641 | return container; | ||
702 | } | 642 | } | ||
703 | 643 | | |||
704 | void ViewManager::containerMoveViewRequest(int index, int id, bool &success, | 644 | void ViewManager::containerMoveViewRequest(int index, int id, bool &success, | ||
705 | TabbedViewContainer *sourceTabbedContainer) | 645 | TabbedViewContainer *sourceTabbedContainer) | ||
706 | { | 646 | { | ||
707 | ViewContainer *container = qobject_cast<ViewContainer *>(sender()); | 647 | TabbedViewContainer *container = qobject_cast<TabbedViewContainer *>(sender()); | ||
708 | SessionController *controller = qobject_cast<SessionController *>(ViewProperties::propertiesById(id)); | 648 | SessionController *controller = qobject_cast<SessionController *>(ViewProperties::propertiesById(id)); | ||
709 | 649 | | |||
710 | if (controller == nullptr) { | 650 | if (controller == nullptr) { | ||
711 | return; | 651 | return; | ||
712 | } | 652 | } | ||
713 | 653 | | |||
714 | // do not move the last tab in a split view. | 654 | // do not move the last tab in a split view. | ||
715 | if (sourceTabbedContainer != nullptr) { | 655 | if (sourceTabbedContainer != nullptr) { | ||
716 | QPointer<ViewContainer> sourceContainer = qobject_cast<ViewContainer *>(sourceTabbedContainer); | 656 | QPointer<TabbedViewContainer> sourceContainer = qobject_cast<TabbedViewContainer *>(sourceTabbedContainer); | ||
717 | 657 | | |||
718 | if (_viewSplitter->containers().contains(sourceContainer)) { | 658 | if (_viewSplitter->containers().contains(sourceContainer)) { | ||
719 | return; | 659 | return; | ||
720 | } else { | 660 | } else { | ||
721 | ViewManager *sourceViewManager = sourceTabbedContainer->connectedViewManager(); | 661 | ViewManager *sourceViewManager = sourceTabbedContainer->connectedViewManager(); | ||
722 | 662 | | |||
723 | // do not remove the last tab on the window | 663 | // do not remove the last tab on the window | ||
724 | if (qobject_cast<ViewSplitter *>(sourceViewManager->widget())->containers().size() > 1) { | 664 | if (qobject_cast<ViewSplitter *>(sourceViewManager->widget())->containers().size() > 1) { | ||
725 | return; | 665 | return; | ||
726 | } | 666 | } | ||
727 | } | 667 | } | ||
728 | } | 668 | } | ||
729 | 669 | | |||
730 | createView(controller->session(), container, index); | 670 | createView(controller->session(), container, index); | ||
731 | controller->session()->refresh(); | 671 | controller->session()->refresh(); | ||
732 | success = true; | 672 | success = true; | ||
733 | } | 673 | } | ||
734 | 674 | | |||
735 | void ViewManager::setNavigationMethod(NavigationMethod method) | 675 | void ViewManager::setNavigationMethod(NavigationMethod method) | ||
736 | { | 676 | { | ||
737 | Q_ASSERT(_actionCollection); | 677 | Q_ASSERT(_actionCollection); | ||
738 | if (_actionCollection == nullptr) { | 678 | if (_actionCollection == nullptr) { | ||
739 | return; | 679 | return; | ||
740 | } | 680 | } | ||
741 | _navigationMethod = method; | | |||
742 | | ||||
743 | KActionCollection *collection = _actionCollection; | 681 | KActionCollection *collection = _actionCollection; | ||
744 | 682 | | |||
745 | // FIXME: The following disables certain actions for the KPart that it | 683 | // FIXME: The following disables certain actions for the KPart that it | ||
746 | // doesn't actually have a use for, to avoid polluting the action/shortcut | 684 | // doesn't actually have a use for, to avoid polluting the action/shortcut | ||
747 | // namespace of an application using the KPart (otherwise, a shortcut may | 685 | // namespace of an application using the KPart (otherwise, a shortcut may | ||
748 | // be in use twice, and the user gets to see an "ambiguous shortcut over- | 686 | // be in use twice, and the user gets to see an "ambiguous shortcut over- | ||
749 | // load" error dialog). However, this approach sucks - it's the inverse of | 687 | // load" error dialog). However, this approach sucks - it's the inverse of | ||
750 | // what it should be. Rather than disabling actions not used by the KPart, | 688 | // what it should be. Rather than disabling actions not used by the KPart, | ||
751 | // a method should be devised to only enable those that are used, perhaps | 689 | // a method should be devised to only enable those that are used, perhaps | ||
752 | // by using a separate action collection. | 690 | // by using a separate action collection. | ||
753 | 691 | | |||
754 | const bool enable = (_navigationMethod != NoNavigation); | 692 | const bool enable = (method != NoNavigation); | ||
755 | 693 | | |||
756 | auto enableAction = [&enable, &collection](const QString& actionName) { | 694 | auto enableAction = [&enable, &collection](const QString& actionName) { | ||
757 | auto *action = collection->action(actionName); | 695 | auto *action = collection->action(actionName); | ||
758 | if (action != nullptr) { | 696 | if (action != nullptr) { | ||
759 | action->setEnabled(enable); | 697 | action->setEnabled(enable); | ||
760 | } | 698 | } | ||
761 | }; | 699 | }; | ||
762 | 700 | | |||
763 | enableAction(QStringLiteral("next-view")); | 701 | enableAction(QStringLiteral("next-view")); | ||
764 | enableAction(QStringLiteral("previous-view")); | 702 | enableAction(QStringLiteral("previous-view")); | ||
765 | enableAction(QStringLiteral("last-tab")); | 703 | enableAction(QStringLiteral("last-tab")); | ||
766 | enableAction(QStringLiteral("split-view-left-right")); | 704 | enableAction(QStringLiteral("split-view-left-right")); | ||
767 | enableAction(QStringLiteral("split-view-top-bottom")); | 705 | enableAction(QStringLiteral("split-view-top-bottom")); | ||
768 | enableAction(QStringLiteral("rename-session")); | 706 | enableAction(QStringLiteral("rename-session")); | ||
769 | enableAction(QStringLiteral("move-view-left")); | 707 | enableAction(QStringLiteral("move-view-left")); | ||
770 | enableAction(QStringLiteral("move-view-right")); | 708 | enableAction(QStringLiteral("move-view-right")); | ||
771 | } | 709 | } | ||
772 | 710 | | |||
773 | ViewManager::NavigationMethod ViewManager::navigationMethod() const | 711 | ViewManager::NavigationMethod ViewManager::navigationMethod() const | ||
774 | { | 712 | { | ||
775 | return _navigationMethod; | 713 | return _navigationMethod; | ||
776 | } | 714 | } | ||
777 | 715 | | |||
778 | void ViewManager::containerViewsChanged(ViewContainer *container) | 716 | void ViewManager::containerViewsChanged(TabbedViewContainer *container) | ||
779 | { | 717 | { | ||
780 | if ((!_viewSplitter.isNull()) && container == _viewSplitter->activeContainer()) { | 718 | if ((!_viewSplitter.isNull()) && container == _viewSplitter->activeContainer()) { | ||
781 | emit viewPropertiesChanged(viewProperties()); | 719 | emit viewPropertiesChanged(viewProperties()); | ||
782 | } | 720 | } | ||
783 | } | 721 | } | ||
784 | 722 | | |||
785 | void ViewManager::viewDestroyed(QWidget *view) | 723 | void ViewManager::viewDestroyed(QWidget *view) | ||
786 | { | 724 | { | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 856 | while (iter.hasNext()) { | |||
926 | } | 864 | } | ||
927 | } | 865 | } | ||
928 | } | 866 | } | ||
929 | 867 | | |||
930 | QList<ViewProperties *> ViewManager::viewProperties() const | 868 | QList<ViewProperties *> ViewManager::viewProperties() const | ||
931 | { | 869 | { | ||
932 | QList<ViewProperties *> list; | 870 | QList<ViewProperties *> list; | ||
933 | 871 | | |||
934 | ViewContainer *container = _viewSplitter->activeContainer(); | 872 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
935 | 873 | | |||
936 | Q_ASSERT(container); | 874 | Q_ASSERT(container); | ||
875 | list.reserve(container->count()); | ||||
937 | 876 | | |||
938 | foreach (QWidget *view, container->views()) { | 877 | for(int i = 0, end = container->count(); i < end; i++) { | ||
878 | auto view = container->widget(i); | ||||
939 | ViewProperties *properties = container->viewProperties(view); | 879 | ViewProperties *properties = container->viewProperties(view); | ||
940 | Q_ASSERT(properties); | 880 | Q_ASSERT(properties); | ||
941 | list << properties; | 881 | list << properties; | ||
942 | } | 882 | } | ||
943 | 883 | | |||
944 | return list; | 884 | return list; | ||
945 | } | 885 | } | ||
946 | 886 | | |||
947 | void ViewManager::saveSessions(KConfigGroup &group) | 887 | void ViewManager::saveSessions(KConfigGroup &group) | ||
948 | { | 888 | { | ||
949 | // find all unique session restore IDs | 889 | // find all unique session restore IDs | ||
950 | QList<int> ids; | 890 | QList<int> ids; | ||
951 | QSet<Session *> unique; | 891 | QSet<Session *> unique; | ||
892 | int tab = 1; | ||||
sandsmark: why was this moved so far up? | |||||
it seemed logic when I did, now I'm unsure. if requested I can put it back. tcanabrava: it seemed logic when I did, now I'm unsure. if requested I can put it back. | |||||
893 | | ||||
894 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||||
895 | ids.reserve(container->count()); | ||||
952 | 896 | | |||
953 | // first: sessions in the active container, preserving the order | 897 | // first: sessions in the active container, preserving the order | ||
954 | ViewContainer *container = _viewSplitter->activeContainer(); | | |||
955 | Q_ASSERT(container); | 898 | Q_ASSERT(container); | ||
956 | if (container == nullptr) { | 899 | if (container == nullptr) { | ||
957 | return; | 900 | return; | ||
958 | } | 901 | } | ||
959 | TerminalDisplay *activeview = qobject_cast<TerminalDisplay *>(container->activeView()); | | |||
960 | 902 | | |||
961 | QListIterator<QWidget *> viewIter(container->views()); | 903 | TerminalDisplay *activeview = qobject_cast<TerminalDisplay *>(container->currentWidget()); | ||
962 | int tab = 1; | 904 | for (int i = 0, end = container->count(); i < end; i++) { | ||
963 | while (viewIter.hasNext()) { | 905 | TerminalDisplay *view = qobject_cast<TerminalDisplay *>(container->widget(i)); | ||
964 | TerminalDisplay *view = qobject_cast<TerminalDisplay *>(viewIter.next()); | | |||
965 | Q_ASSERT(view); | 906 | Q_ASSERT(view); | ||
907 | | ||||
966 | Session *session = _sessionMap[view]; | 908 | Session *session = _sessionMap[view]; | ||
967 | ids << SessionManager::instance()->getRestoreId(session); | 909 | ids << SessionManager::instance()->getRestoreId(session); | ||
968 | unique.insert(session); | 910 | unique.insert(session); | ||
969 | if (view == activeview) { | 911 | if (view == activeview) { | ||
970 | group.writeEntry("Active", tab); | 912 | group.writeEntry("Active", tab); | ||
971 | } | 913 | } | ||
972 | tab++; | 914 | tab++; | ||
973 | } | 915 | } | ||
Show All 32 Lines | 947 | if (!session->isRunning()) { | |||
1006 | session->run(); | 948 | session->run(); | ||
1007 | } | 949 | } | ||
1008 | if (tab++ == activeTab) { | 950 | if (tab++ == activeTab) { | ||
1009 | display = qobject_cast<TerminalDisplay *>(activeView()); | 951 | display = qobject_cast<TerminalDisplay *>(activeView()); | ||
1010 | } | 952 | } | ||
1011 | } | 953 | } | ||
1012 | 954 | | |||
1013 | if (display != nullptr) { | 955 | if (display != nullptr) { | ||
1014 | _viewSplitter->activeContainer()->setActiveView(display); | 956 | _viewSplitter->activeContainer()->setCurrentWidget(display); | ||
1015 | display->setFocus(Qt::OtherFocusReason); | 957 | display->setFocus(Qt::OtherFocusReason); | ||
1016 | } | 958 | } | ||
1017 | 959 | | |||
1018 | if (ids.isEmpty()) { // Session file is unusable, start default Profile | 960 | if (ids.isEmpty()) { // Session file is unusable, start default Profile | ||
1019 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | 961 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | ||
1020 | Session *session = SessionManager::instance()->createSession(profile); | 962 | Session *session = SessionManager::instance()->createSession(profile); | ||
1021 | createView(session); | 963 | createView(session); | ||
1022 | if (!session->isRunning()) { | 964 | if (!session->isRunning()) { | ||
Show All 30 Lines | 988 | { | |||
1053 | return -1; | 995 | return -1; | ||
1054 | } | 996 | } | ||
1055 | 997 | | |||
1056 | void ViewManager::setCurrentSession(int sessionId) | 998 | void ViewManager::setCurrentSession(int sessionId) | ||
1057 | { | 999 | { | ||
1058 | QHash<TerminalDisplay *, Session *>::const_iterator i; | 1000 | QHash<TerminalDisplay *, Session *>::const_iterator i; | ||
1059 | for (i = _sessionMap.constBegin(); i != _sessionMap.constEnd(); ++i) { | 1001 | for (i = _sessionMap.constBegin(); i != _sessionMap.constEnd(); ++i) { | ||
1060 | if (i.value()->sessionId() == sessionId) { | 1002 | if (i.value()->sessionId() == sessionId) { | ||
1061 | ViewContainer *container = _viewSplitter->activeContainer(); | 1003 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
1062 | if (container != nullptr) { | 1004 | if (container != nullptr) { | ||
1063 | container->setActiveView(i.key()); | 1005 | container->setCurrentWidget(i.key()); | ||
1064 | } | 1006 | } | ||
1065 | } | 1007 | } | ||
1066 | } | 1008 | } | ||
1067 | } | 1009 | } | ||
1068 | 1010 | | |||
1069 | int ViewManager::newSession() | 1011 | int ViewManager::newSession() | ||
1070 | { | 1012 | { | ||
1071 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | 1013 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | ||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | |||||
1148 | { | 1090 | { | ||
1149 | moveActiveViewLeft(); | 1091 | moveActiveViewLeft(); | ||
1150 | } | 1092 | } | ||
1151 | 1093 | | |||
1152 | void ViewManager::moveSessionRight() | 1094 | void ViewManager::moveSessionRight() | ||
1153 | { | 1095 | { | ||
1154 | moveActiveViewRight(); | 1096 | moveActiveViewRight(); | ||
1155 | } | 1097 | } | ||
1156 | | ||||
1157 | void ViewManager::setTabWidthToText(bool useTextWidth) | | |||
1158 | { | | |||
1159 | ViewContainer *container = _viewSplitter->activeContainer(); | | |||
1160 | Q_ASSERT(container); | | |||
1161 | container->setNavigationTextMode(useTextWidth); | | |||
this breaks the «expand individual tab width to full window» option in settings -> configure konsole -> tabbar. sandsmark: this breaks the «expand individual tab width to full window» option in settings -> configure… | |||||
that's something I want to remove but I know some people use like that. I'm fixing it. tcanabrava: that's something I want to remove but I know some people use like that. I'm fixing it. | |||||
1162 | } | | |||
1163 | | ||||
1164 | void ViewManager::closeTabFromContainer(ViewContainer *container, QWidget *tab) | | |||
1165 | { | | |||
1166 | SessionController *controller = qobject_cast<SessionController *>(container->viewProperties(tab)); | | |||
1167 | Q_ASSERT(controller); | | |||
1168 | if (controller != nullptr) { | | |||
1169 | controller->closeSession(); | | |||
1170 | } | | |||
1171 | } | | |||
1172 | | ||||
1173 | void ViewManager::setNavigationVisibility(int visibility) | | |||
1174 | { | | |||
1175 | _navigationVisibility = static_cast<ViewContainer::NavigationVisibility>(visibility); | | |||
1176 | | ||||
1177 | foreach (ViewContainer *container, _viewSplitter->containers()) { | | |||
1178 | container->setNavigationVisibility(_navigationVisibility); | | |||
1179 | } | | |||
1180 | } | | |||
1181 | | ||||
1182 | void ViewManager::setNavigationPosition(int position) | | |||
1183 | { | | |||
1184 | _navigationPosition = static_cast<ViewContainer::NavigationPosition>(position); | | |||
1185 | | ||||
1186 | foreach (ViewContainer *container, _viewSplitter->containers()) { | | |||
1187 | Q_ASSERT(container->supportedNavigationPositions().contains(_navigationPosition)); | | |||
1188 | container->setNavigationPosition(_navigationPosition); | | |||
1189 | } | | |||
1190 | } | | |||
1191 | | ||||
1192 | void ViewManager::setNavigationTabWidthExpanding(bool expand) | | |||
1193 | { | | |||
1194 | _navigationTabWidthExpanding = expand; | | |||
1195 | | ||||
1196 | foreach (ViewContainer *container, _viewSplitter->containers()) { | | |||
1197 | container->setNavigationTabWidthExpanding(expand); | | |||
1198 | } | | |||
1199 | } | | |||
1200 | | ||||
1201 | void ViewManager::setNavigationStyleSheet(const QString &styleSheet) | | |||
1202 | { | | |||
1203 | _navigationStyleSheet = styleSheet; | | |||
1204 | | ||||
1205 | foreach (ViewContainer *container, _viewSplitter->containers()) { | | |||
1206 | container->setStyleSheet(_navigationStyleSheet); | | |||
1207 | } | | |||
1208 | } | | |||
1209 | | ||||
1210 | void ViewManager::setContainerFeatures(ViewContainer *container) | | |||
1211 | { | | |||
1212 | if (_showQuickButtons) { | | |||
1213 | container->setFeatures(container->features() | | |||
1214 | | ViewContainer::QuickNewView | | |||
1215 | | ViewContainer::QuickCloseView); | | |||
1216 | } else { | | |||
1217 | container->setFeatures(container->features() | | |||
1218 | & ~ViewContainer::QuickNewView | | |||
1219 | & ~ViewContainer::QuickCloseView); | | |||
1220 | } | | |||
1221 | } | | |||
1222 | void ViewManager::setShowQuickButtons(bool show) | | |||
1223 | { | | |||
1224 | _showQuickButtons = show; | | |||
1225 | | ||||
1226 | for (auto *container : _viewSplitter->containers()) { | | |||
1227 | setContainerFeatures(container); | | |||
1228 | } | | |||
1229 | } | | |||
1230 | | ||||
1231 | void ViewManager::setNavigationBehavior(int behavior) | | |||
1232 | { | | |||
1233 | _newTabBehavior = static_cast<NewTabBehavior>(behavior); | | |||
1234 | } | |
remove dead code? unless this breaks something and is a valid TODO