Changeset View
Changeset View
Standalone View
Standalone View
src/ViewManager.cpp
Show First 20 Lines • Show All 373 Lines • ▼ Show 20 Line(s) | 373 | if (viewToDetach == nullptr) { | |||
---|---|---|---|---|---|
374 | return; | 374 | return; | ||
375 | } | 375 | } | ||
376 | 376 | | |||
377 | // BR390736 - some instances are sending invalid session to viewDetached() | 377 | // BR390736 - some instances are sending invalid session to viewDetached() | ||
378 | Session *sessionToDetach = _sessionMap[viewToDetach]; | 378 | Session *sessionToDetach = _sessionMap[viewToDetach]; | ||
379 | if (sessionToDetach == nullptr) { | 379 | if (sessionToDetach == nullptr) { | ||
380 | return; | 380 | return; | ||
381 | } | 381 | } | ||
382 | emit viewDetached(sessionToDetach); | 382 | emit viewDetached(sessionToDetach, viewToDetach); | ||
383 | 383 | | |||
384 | _sessionMap.remove(viewToDetach); | 384 | _sessionMap.remove(viewToDetach); | ||
385 | 385 | | |||
386 | // remove the view from this window | 386 | // remove the view from this window | ||
387 | container->removeView(viewToDetach); | 387 | container->removeView(viewToDetach); | ||
388 | viewToDetach->deleteLater(); | 388 | viewToDetach->deleteLater(); | ||
389 | 389 | | |||
390 | // if the container from which the view was removed is now empty then it can be deleted, | 390 | // if the container from which the view was removed is now empty then it can be deleted, | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | |||||
450 | void ViewManager::splitView(Qt::Orientation orientation) | 450 | void ViewManager::splitView(Qt::Orientation orientation) | ||
451 | { | 451 | { | ||
452 | ViewContainer *container = createContainer(); | 452 | ViewContainer *container = createContainer(); | ||
453 | 453 | | |||
454 | // iterate over each session which has a view in the current active | 454 | // iterate over each session which has a view in the current active | ||
455 | // container and create a new view for that session in a new container | 455 | // container and create a new view for that session in a new container | ||
456 | foreach (QWidget *view, _viewSplitter->activeContainer()->views()) { | 456 | foreach (QWidget *view, _viewSplitter->activeContainer()->views()) { | ||
457 | Session *session = _sessionMap[qobject_cast<TerminalDisplay *>(view)]; | 457 | Session *session = _sessionMap[qobject_cast<TerminalDisplay *>(view)]; | ||
458 | TerminalDisplay *display = createTerminalDisplay(session); | 458 | TerminalDisplay *display = createTerminalDisplay(session, qobject_cast<TerminalDisplay *>(view)); | ||
459 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | 459 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | ||
460 | applyProfileToView(display, profile); | 460 | applyProfileToView(display, profile); | ||
461 | ViewProperties *properties = createController(session, display); | 461 | ViewProperties *properties = createController(session, display); | ||
462 | 462 | | |||
463 | _sessionMap[display] = session; | 463 | _sessionMap[display] = session; | ||
464 | 464 | | |||
465 | container->addView(display, properties); | 465 | container->addView(display, properties); | ||
466 | session->addView(display); | 466 | session->addView(display); | ||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Line(s) | 571 | { | |||
572 | return _pluggedController; | 572 | return _pluggedController; | ||
573 | } | 573 | } | ||
574 | 574 | | |||
575 | IncrementalSearchBar *ViewManager::searchBar() const | 575 | IncrementalSearchBar *ViewManager::searchBar() const | ||
576 | { | 576 | { | ||
577 | return _viewSplitter->activeSplitter()->activeContainer()->searchBar(); | 577 | return _viewSplitter->activeSplitter()->activeContainer()->searchBar(); | ||
578 | } | 578 | } | ||
579 | 579 | | |||
580 | void ViewManager::createView(Session *session, ViewContainer *container, int index) | 580 | void ViewManager::createView(Session *session, ViewContainer *container, int index, TerminalDisplay *detachedView) | ||
581 | { | 581 | { | ||
582 | // notify this view manager when the session finishes so that its view | 582 | // notify this view manager when the session finishes so that its view | ||
583 | // can be deleted | 583 | // can be deleted | ||
584 | // | 584 | // | ||
585 | // Use Qt::UniqueConnection to avoid duplicate connection | 585 | // Use Qt::UniqueConnection to avoid duplicate connection | ||
586 | connect(session, &Konsole::Session::finished, this, &Konsole::ViewManager::sessionFinished, | 586 | connect(session, &Konsole::Session::finished, this, &Konsole::ViewManager::sessionFinished, | ||
587 | Qt::UniqueConnection); | 587 | Qt::UniqueConnection); | ||
588 | 588 | | |||
589 | TerminalDisplay *display = createTerminalDisplay(session); | 589 | TerminalDisplay *display = createTerminalDisplay(session, detachedView); | ||
590 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | 590 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | ||
591 | applyProfileToView(display, profile); | 591 | applyProfileToView(display, profile); | ||
592 | 592 | | |||
593 | // set initial size | 593 | // set initial size | ||
594 | const QSize &preferredSize = session->preferredSize(); | 594 | const QSize &preferredSize = session->preferredSize(); | ||
595 | // FIXME: +1 is needed here for getting the expected rows | 595 | // FIXME: +1 is needed here for getting the expected rows | ||
596 | // Note that the display shouldn't need to take into account the tabbar. | 596 | // Note that the display shouldn't need to take into account the tabbar. | ||
597 | // However, it appears that taking into account the tabbar is needed. | 597 | // However, it appears that taking into account the tabbar is needed. | ||
Show All 19 Lines | |||||
617 | if (container == _viewSplitter->activeContainer()) { | 617 | if (container == _viewSplitter->activeContainer()) { | ||
618 | container->setActiveView(display); | 618 | container->setActiveView(display); | ||
619 | display->setFocus(Qt::OtherFocusReason); | 619 | display->setFocus(Qt::OtherFocusReason); | ||
620 | } | 620 | } | ||
621 | 621 | | |||
622 | updateDetachViewState(); | 622 | updateDetachViewState(); | ||
623 | } | 623 | } | ||
624 | 624 | | |||
625 | void ViewManager::createView(Session *session) | 625 | void ViewManager::createView(Session *session, TerminalDisplay *detachedView) | ||
626 | { | 626 | { | ||
627 | // create the default container | 627 | // create the default container | ||
628 | if (_viewSplitter->containers().count() == 0) { | 628 | if (_viewSplitter->containers().count() == 0) { | ||
629 | ViewContainer *container = createContainer(); | 629 | ViewContainer *container = createContainer(); | ||
630 | _viewSplitter->addContainer(container, Qt::Vertical); | 630 | _viewSplitter->addContainer(container, Qt::Vertical); | ||
631 | emit splitViewToggle(false); | 631 | emit splitViewToggle(false); | ||
632 | } | 632 | } | ||
633 | 633 | | |||
634 | // new tab will be put at the end by default. | 634 | // new tab will be put at the end by default. | ||
635 | int index = -1; | 635 | int index = -1; | ||
636 | 636 | | |||
637 | if (_newTabBehavior == PutNewTabAfterCurrentTab) { | 637 | if (_newTabBehavior == PutNewTabAfterCurrentTab) { | ||
638 | QWidget *view = activeView(); | 638 | QWidget *view = activeView(); | ||
639 | if (view != nullptr) { | 639 | if (view != nullptr) { | ||
640 | QList<QWidget *> views = _viewSplitter->activeContainer()->views(); | 640 | QList<QWidget *> views = _viewSplitter->activeContainer()->views(); | ||
641 | index = views.indexOf(view) + 1; | 641 | index = views.indexOf(view) + 1; | ||
642 | } | 642 | } | ||
643 | } | 643 | } | ||
644 | 644 | | |||
645 | // iterate over the view containers owned by this view manager | 645 | // iterate over the view containers owned by this view manager | ||
646 | // and create a new terminal display for the session in each of them, along with | 646 | // and create a new terminal display for the session in each of them, along with | ||
647 | // a controller for the session/display pair | 647 | // a controller for the session/display pair | ||
648 | foreach (ViewContainer *container, _viewSplitter->containers()) { | 648 | foreach (ViewContainer *container, _viewSplitter->containers()) { | ||
649 | createView(session, container, index); | 649 | createView(session, container, index, detachedView); | ||
650 | } | 650 | } | ||
651 | } | 651 | } | ||
652 | 652 | | |||
653 | ViewContainer *ViewManager::createContainer() | 653 | ViewContainer *ViewManager::createContainer() | ||
654 | { | 654 | { | ||
655 | ViewContainer *container = nullptr; | 655 | ViewContainer *container = nullptr; | ||
656 | 656 | | |||
657 | switch (_navigationMethod) { | 657 | switch (_navigationMethod) { | ||
▲ Show 20 Lines • Show All 182 Lines • ▼ Show 20 Line(s) | 839 | if (_viewSplitter != nullptr) { | |||
840 | updateDetachViewState(); | 840 | updateDetachViewState(); | ||
841 | } | 841 | } | ||
842 | // The below causes the menus to be messed up | 842 | // The below causes the menus to be messed up | ||
843 | // Only happens when using the tab bar close button | 843 | // Only happens when using the tab bar close button | ||
844 | // if (_pluggedController) | 844 | // if (_pluggedController) | ||
845 | // emit unplugController(_pluggedController); | 845 | // emit unplugController(_pluggedController); | ||
846 | } | 846 | } | ||
847 | 847 | | |||
848 | TerminalDisplay *ViewManager::createTerminalDisplay(Session *session) | 848 | TerminalDisplay *ViewManager::createTerminalDisplay(Session *session, TerminalDisplay *detachedView) | ||
849 | { | 849 | { | ||
850 | auto display = new TerminalDisplay(nullptr); | 850 | auto display = new TerminalDisplay(nullptr); | ||
851 | display->setRandomSeed(session->sessionId() * 31); | 851 | display->setRandomSeed(session->sessionId() * 31); | ||
852 | 852 | | |||
853 | if (detachedView != nullptr) { | ||||
854 | if (detachedView->flowControlWarningEnabled()) { | ||||
855 | display->setFlowControlWarningEnabled(true); | ||||
856 | | ||||
857 | // Without the timer the display becomes really small | ||||
858 | QTimer::singleShot(0, this, [display]() { | ||||
859 | display->outputSuspended(true); | ||||
860 | }); | ||||
861 | } | ||||
862 | } | ||||
863 | | ||||
853 | return display; | 864 | return display; | ||
854 | } | 865 | } | ||
855 | 866 | | |||
856 | const ColorScheme *ViewManager::colorSchemeForProfile(const Profile::Ptr profile) | 867 | const ColorScheme *ViewManager::colorSchemeForProfile(const Profile::Ptr profile) | ||
857 | { | 868 | { | ||
858 | const ColorScheme *colorScheme = ColorSchemeManager::instance()-> | 869 | const ColorScheme *colorScheme = ColorSchemeManager::instance()-> | ||
859 | findColorScheme(profile->colorScheme()); | 870 | findColorScheme(profile->colorScheme()); | ||
860 | if (colorScheme == nullptr) { | 871 | if (colorScheme == nullptr) { | ||
▲ Show 20 Lines • Show All 441 Lines • Show Last 20 Lines |