Changeset View
Changeset View
Standalone View
Standalone View
src/ViewManager.cpp
Show All 19 Lines | |||||
20 | // Own | 20 | // Own | ||
21 | #include "ViewManager.h" | 21 | #include "ViewManager.h" | ||
22 | 22 | | |||
23 | #include <config-konsole.h> | 23 | #include <config-konsole.h> | ||
24 | 24 | | |||
25 | // Qt | 25 | // Qt | ||
26 | #include <QStringList> | 26 | #include <QStringList> | ||
27 | #include <QAction> | 27 | #include <QAction> | ||
28 | #include <QTabBar> | ||||
28 | 29 | | |||
29 | // KDE | 30 | // KDE | ||
30 | #include <KAcceleratorManager> | 31 | #include <KAcceleratorManager> | ||
31 | #include <KLocalizedString> | 32 | #include <KLocalizedString> | ||
32 | #include <KActionCollection> | 33 | #include <KActionCollection> | ||
33 | #include <KConfigGroup> | 34 | #include <KConfigGroup> | ||
34 | 35 | | |||
35 | // Konsole | 36 | // Konsole | ||
36 | #include <windowadaptor.h> | 37 | #include <windowadaptor.h> | ||
37 | 38 | | |||
38 | #include "ColorScheme.h" | 39 | #include "ColorScheme.h" | ||
39 | #include "ColorSchemeManager.h" | 40 | #include "ColorSchemeManager.h" | ||
40 | #include "Session.h" | 41 | #include "Session.h" | ||
41 | #include "TerminalDisplay.h" | 42 | #include "TerminalDisplay.h" | ||
42 | #include "SessionController.h" | 43 | #include "SessionController.h" | ||
43 | #include "SessionManager.h" | 44 | #include "SessionManager.h" | ||
44 | #include "ProfileManager.h" | 45 | #include "ProfileManager.h" | ||
45 | #include "ViewSplitter.h" | 46 | #include "ViewSplitter.h" | ||
46 | #include "Enumeration.h" | 47 | #include "Enumeration.h" | ||
47 | #include "ViewContainer.h" | 48 | #include "ViewContainer.h" | ||
49 | #include "KonsoleSettings.h" | ||||
48 | 50 | | |||
49 | using namespace Konsole; | 51 | using namespace Konsole; | ||
50 | 52 | | |||
51 | int ViewManager::lastManagerId = 0; | 53 | int ViewManager::lastManagerId = 0; | ||
52 | 54 | | |||
53 | ViewManager::ViewManager(QObject *parent, KActionCollection *collection) : | 55 | ViewManager::ViewManager(QObject *parent, KActionCollection *collection) : | ||
54 | QObject(parent), | 56 | QObject(parent), | ||
55 | _viewSplitter(nullptr), | 57 | _viewSplitter(nullptr), | ||
▲ Show 20 Lines • Show All 541 Lines • ▼ Show 20 Line(s) | |||||
597 | { | 599 | { | ||
598 | // create the default container | 600 | // create the default container | ||
599 | if (_viewSplitter->containers().count() == 0) { | 601 | if (_viewSplitter->containers().count() == 0) { | ||
600 | TabbedViewContainer *container = createContainer(); | 602 | TabbedViewContainer *container = createContainer(); | ||
601 | _viewSplitter->addContainer(container, Qt::Vertical); | 603 | _viewSplitter->addContainer(container, Qt::Vertical); | ||
602 | emit splitViewToggle(false); | 604 | emit splitViewToggle(false); | ||
603 | } | 605 | } | ||
604 | 606 | | |||
605 | // new tab will be put at the end by default. | 607 | const int index = KonsoleSettings::newTabBehavior() == KonsoleSettings::PutNewTabAtTheEnd ? | ||
606 | int index = -1; | 608 | -1 : _viewSplitter->activeContainer()->currentIndex() + 1; | ||
607 | 609 | | |||
608 | // iterate over the view containers owned by this view manager | 610 | // iterate over the view containers owned by this view manager | ||
609 | // and create a new terminal display for the session in each of them, along with | 611 | // and create a new terminal display for the session in each of them, along with | ||
610 | // a controller for the session/display pair | 612 | // a controller for the session/display pair | ||
611 | foreach (TabbedViewContainer *container, _viewSplitter->containers()) { | 613 | foreach (TabbedViewContainer *container, _viewSplitter->containers()) { | ||
612 | createView(session, container, index); | 614 | createView(session, container, index); | ||
613 | } | 615 | } | ||
614 | } | 616 | } | ||
Show All 29 Lines | 619 | { | |||
644 | connect(container, &Konsole::TabbedViewContainer::viewRemoved, this, | 646 | connect(container, &Konsole::TabbedViewContainer::viewRemoved, this, | ||
645 | &Konsole::ViewManager::viewDestroyed); | 647 | &Konsole::ViewManager::viewDestroyed); | ||
646 | connect(container, &Konsole::TabbedViewContainer::activeViewChanged, this, | 648 | connect(container, &Konsole::TabbedViewContainer::activeViewChanged, this, | ||
647 | &Konsole::ViewManager::viewActivated); | 649 | &Konsole::ViewManager::viewActivated); | ||
648 | 650 | | |||
649 | return container; | 651 | return container; | ||
650 | } | 652 | } | ||
651 | 653 | | |||
652 | void ViewManager::containerMoveViewRequest(int index, int id, bool &success, | 654 | void ViewManager::containerMoveViewRequest(int index, int id, | ||
653 | TabbedViewContainer *sourceTabbedContainer) | 655 | TabbedViewContainer *sourceTabbedContainer) | ||
654 | { | 656 | { | ||
655 | TabbedViewContainer *container = qobject_cast<TabbedViewContainer *>(sender()); | 657 | TabbedViewContainer *container = qobject_cast<TabbedViewContainer *>(sender()); | ||
656 | SessionController *controller = qobject_cast<SessionController *>(ViewProperties::propertiesById(id)); | 658 | SessionController *controller = qobject_cast<SessionController *>(ViewProperties::propertiesById(id)); | ||
657 | 659 | | |||
658 | if (controller == nullptr) { | | |||
659 | return; | | |||
660 | } | | |||
661 | | ||||
662 | // do not move the last tab in a split view. | | |||
663 | if (sourceTabbedContainer != nullptr) { | | |||
664 | QPointer<TabbedViewContainer> sourceContainer = qobject_cast<TabbedViewContainer *>(sourceTabbedContainer); | | |||
665 | | ||||
666 | if (_viewSplitter->containers().contains(sourceContainer)) { | | |||
667 | return; | | |||
668 | } else { | | |||
669 | ViewManager *sourceViewManager = sourceTabbedContainer->connectedViewManager(); | | |||
670 | | ||||
671 | // do not remove the last tab on the window | | |||
672 | if (qobject_cast<ViewSplitter *>(sourceViewManager->widget())->containers().size() > 1) { | | |||
673 | return; | | |||
674 | } | | |||
675 | } | | |||
676 | } | | |||
677 | | ||||
678 | createView(controller->session(), container, index); | 660 | createView(controller->session(), container, index); | ||
679 | controller->session()->refresh(); | 661 | controller->session()->refresh(); | ||
680 | success = true; | | |||
681 | } | 662 | } | ||
682 | 663 | | |||
683 | void ViewManager::setNavigationMethod(NavigationMethod method) | 664 | void ViewManager::setNavigationMethod(NavigationMethod method) | ||
684 | { | 665 | { | ||
685 | Q_ASSERT(_actionCollection); | 666 | Q_ASSERT(_actionCollection); | ||
686 | if (_actionCollection == nullptr) { | 667 | if (_actionCollection == nullptr) { | ||
687 | return; | 668 | return; | ||
688 | } | 669 | } | ||
▲ Show 20 Lines • Show All 434 Lines • Show Last 20 Lines |