Changeset View
Changeset View
Standalone View
Standalone View
src/ViewManager.cpp
Show First 20 Lines • Show All 459 Lines • ▼ Show 20 Line(s) | |||||
460 | { | 460 | { | ||
461 | splitView(Qt::Vertical); | 461 | splitView(Qt::Vertical); | ||
462 | } | 462 | } | ||
463 | 463 | | |||
464 | void ViewManager::splitView(Qt::Orientation orientation) | 464 | void ViewManager::splitView(Qt::Orientation orientation) | ||
465 | { | 465 | { | ||
466 | TabbedViewContainer *container = createContainer(); | 466 | TabbedViewContainer *container = createContainer(); | ||
467 | 467 | | |||
468 | // iterate over each session which has a view in the current active | 468 | if (_viewSplitter->activeContainer()->count()) { | ||
469 | // container and create a new view for that session in a new container | 469 | // get the currently applied profile and use it to create the new tab. | ||
470 | for(int i = 0, end = _viewSplitter->activeContainer()->count(); i < end; i++) { | 470 | auto *activeContainer= _viewSplitter->activeContainer(); | ||
471 | auto view = _viewSplitter->activeContainer()->widget(i); | 471 | auto *currentDisplay = qobject_cast<TerminalDisplay*>(activeContainer->currentWidget()); | ||
472 | Session *session = _sessionMap[qobject_cast<TerminalDisplay *>(view)]; | 472 | auto profile = SessionManager::instance()->sessionProfile(_sessionMap[currentDisplay]); | ||
473 | TerminalDisplay *display = createTerminalDisplay(session); | | |||
474 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | | |||
475 | applyProfileToView(display, profile); | | |||
476 | ViewProperties *properties = createController(session, display); | | |||
477 | 473 | | |||
478 | _sessionMap[display] = session; | 474 | // Create a new session with the selected profile. | ||
475 | auto *session = SessionManager::instance()->createSession(profile); | ||||
476 | session->addEnvironmentEntry(QStringLiteral("KONSOLE_DBUS_WINDOW=/Windows/%1").arg(managerId())); | ||||
479 | 477 | | |||
480 | container->addView(display, properties); | 478 | createView(session, container, 0); | ||
481 | session->addView(display); | | |||
482 | } | 479 | } | ||
483 | 480 | | |||
484 | _viewSplitter->addContainer(container, orientation); | 481 | _viewSplitter->addContainer(container, orientation); | ||
485 | emit splitViewToggle(_viewSplitter->containers().count() > 0); | 482 | emit splitViewToggle(_viewSplitter->containers().count() > 0); | ||
486 | 483 | | |||
487 | // focus the new container | 484 | // focus the new container | ||
488 | container->currentWidget()->setFocus(); | 485 | container->currentWidget()->setFocus(); | ||
489 | 486 | | |||
▲ Show 20 Lines • Show All 143 Lines • ▼ Show 20 Line(s) | 623 | { | |||
633 | 630 | | |||
634 | // new tab will be put at the end by default. | 631 | // new tab will be put at the end by default. | ||
635 | int index = -1; | 632 | int index = -1; | ||
636 | 633 | | |||
637 | if (_newTabBehavior == PutNewTabAfterCurrentTab) { | 634 | if (_newTabBehavior == PutNewTabAfterCurrentTab) { | ||
638 | index = _viewSplitter->activeContainer()->currentIndex() + 1; | 635 | index = _viewSplitter->activeContainer()->currentIndex() + 1; | ||
639 | } | 636 | } | ||
640 | 637 | | |||
641 | // iterate over the view containers owned by this view manager | 638 | createView(session, _viewSplitter->activeContainer(), index); | ||
642 | // and create a new terminal display for the session in each of them, along with | | |||
643 | // a controller for the session/display pair | | |||
644 | foreach (TabbedViewContainer *container, _viewSplitter->containers()) { | | |||
645 | createView(session, container, index); | | |||
646 | } | | |||
647 | } | 639 | } | ||
648 | 640 | | |||
649 | TabbedViewContainer *ViewManager::createContainer() | 641 | TabbedViewContainer *ViewManager::createContainer() | ||
650 | { | 642 | { | ||
651 | 643 | | |||
652 | auto *container = new TabbedViewContainer(this, _viewSplitter); | 644 | auto *container = new TabbedViewContainer(this, _viewSplitter); | ||
653 | container->setNavigationVisibility(_navigationVisibility); | 645 | container->setNavigationVisibility(_navigationVisibility); | ||
654 | //TODO: Fix Detaching. | 646 | //TODO: Fix Detaching. | ||
Show All 33 Lines | 679 | { | |||
688 | auto *container = qobject_cast<TabbedViewContainer *>(sender()); | 680 | auto *container = qobject_cast<TabbedViewContainer *>(sender()); | ||
689 | auto *controller = qobject_cast<SessionController *>(ViewProperties::propertiesById(id)); | 681 | auto *controller = qobject_cast<SessionController *>(ViewProperties::propertiesById(id)); | ||
690 | 682 | | |||
691 | if (controller == nullptr) { | 683 | if (controller == nullptr) { | ||
692 | return; | 684 | return; | ||
693 | } | 685 | } | ||
694 | 686 | | |||
695 | // do not move the last tab in a split view. | 687 | // do not move the last tab in a split view. | ||
696 | if (sourceTabbedContainer != nullptr) { | 688 | if (sourceTabbedContainer != nullptr && sourceTabbedContainer->count() <= 1) { | ||
thsurrel: sourceViewManager is unused now. | |||||
697 | QPointer<TabbedViewContainer> sourceContainer = qobject_cast<TabbedViewContainer *>(sourceTabbedContainer); | | |||
698 | | ||||
699 | if (_viewSplitter->containers().contains(sourceContainer)) { | | |||
700 | return; | 689 | return; | ||
701 | } else { | | |||
702 | ViewManager *sourceViewManager = sourceTabbedContainer->connectedViewManager(); | | |||
703 | | ||||
704 | // do not remove the last tab on the window | | |||
705 | if (qobject_cast<ViewSplitter *>(sourceViewManager->widget())->containers().size() > 1) { | | |||
706 | return; | | |||
707 | } | | |||
708 | } | | |||
709 | } | 690 | } | ||
710 | 691 | | |||
711 | createView(controller->session(), container, index); | 692 | createView(controller->session(), container, index); | ||
712 | controller->session()->refresh(); | 693 | controller->session()->refresh(); | ||
713 | } | 694 | } | ||
714 | 695 | | |||
715 | void ViewManager::setNavigationMethod(NavigationMethod method) | 696 | void ViewManager::setNavigationMethod(NavigationMethod method) | ||
716 | { | 697 | { | ||
▲ Show 20 Lines • Show All 451 Lines • Show Last 20 Lines |
sourceViewManager is unused now.