Changeset View
Changeset View
Standalone View
Standalone View
src/ViewContainer.cpp
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Line(s) | 63 | { | |||
---|---|---|---|---|---|
83 | 83 | | |||
84 | connect(tabBar(), &QTabBar::tabBarDoubleClicked, this, | 84 | connect(tabBar(), &QTabBar::tabBarDoubleClicked, this, | ||
85 | &Konsole::TabbedViewContainer::tabDoubleClicked); | 85 | &Konsole::TabbedViewContainer::tabDoubleClicked); | ||
86 | connect(tabBar(), &QTabBar::customContextMenuRequested, this, | 86 | connect(tabBar(), &QTabBar::customContextMenuRequested, this, | ||
87 | &Konsole::TabbedViewContainer::openTabContextMenu); | 87 | &Konsole::TabbedViewContainer::openTabContextMenu); | ||
88 | connect(tabBarWidget, &DetachableTabBar::detachTab, this, [this](int idx) { | 88 | connect(tabBarWidget, &DetachableTabBar::detachTab, this, [this](int idx) { | ||
89 | emit detachTab(this, widget(idx)); | 89 | emit detachTab(this, widget(idx)); | ||
90 | }); | 90 | }); | ||
91 | connect(this, &TabbedViewContainer::currentChanged, this, [this](int index) { | 91 | connect(this, &TabbedViewContainer::currentChanged, this, &TabbedViewContainer::currentTabChanged); | ||
92 | if (index != -1) { | | |||
93 | QWidget *view = widget(index); | | |||
94 | view->setFocus(); | | |||
95 | updateTabHistory(view); | | |||
96 | } else { | | |||
97 | deleteLater(); | | |||
98 | } | | |||
99 | }); | | |||
100 | 92 | | |||
101 | // The context menu of tab bar | 93 | // The context menu of tab bar | ||
102 | _contextPopupMenu = new QMenu(tabBar()); | 94 | _contextPopupMenu = new QMenu(tabBar()); | ||
103 | connect(_contextPopupMenu, &QMenu::aboutToHide, this, [this]() { | 95 | connect(_contextPopupMenu, &QMenu::aboutToHide, this, [this]() { | ||
104 | // Remove the read-only action when the popup closes | 96 | // Remove the read-only action when the popup closes | ||
105 | for (auto &action : _contextPopupMenu->actions()) { | 97 | for (auto &action : _contextPopupMenu->actions()) { | ||
106 | if (action->objectName() == QStringLiteral("view-readonly")) { | 98 | if (action->objectName() == QStringLiteral("view-readonly")) { | ||
107 | _contextPopupMenu->removeAction(action); | 99 | _contextPopupMenu->removeAction(action); | ||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | |||||
156 | { | 148 | { | ||
157 | const int id = viewProperties(widget(index))->identifier(); | 149 | const int id = viewProperties(widget(index))->identifier(); | ||
158 | // This one line here will be removed as soon as I finish my new split handling. | 150 | // This one line here will be removed as soon as I finish my new split handling. | ||
159 | // it's hacky but it works. | 151 | // it's hacky but it works. | ||
160 | const auto widgets = window->findChildren<TabbedViewContainer*>(); | 152 | const auto widgets = window->findChildren<TabbedViewContainer*>(); | ||
161 | const auto currentPos = QCursor::pos(); | 153 | const auto currentPos = QCursor::pos(); | ||
162 | for(const auto dropWidget : widgets) { | 154 | for(const auto dropWidget : widgets) { | ||
163 | if (dropWidget->rect().contains(dropWidget->mapFromGlobal(currentPos))) { | 155 | if (dropWidget->rect().contains(dropWidget->mapFromGlobal(currentPos))) { | ||
164 | emit dropWidget->moveViewRequest(-1, id, this); | 156 | emit dropWidget->moveViewRequest(-1, id); | ||
165 | removeView(widget(index)); | 157 | removeView(widget(index)); | ||
166 | } | 158 | } | ||
167 | } | 159 | } | ||
168 | } | 160 | } | ||
169 | 161 | | |||
170 | void TabbedViewContainer::konsoleConfigChanged() | 162 | void TabbedViewContainer::konsoleConfigChanged() | ||
171 | { | 163 | { | ||
172 | // don't show tabs if we are in KParts mode. | 164 | // don't show tabs if we are in KParts mode. | ||
▲ Show 20 Lines • Show All 271 Lines • ▼ Show 20 Line(s) | 422 | if (sessionController != nullptr) { | |||
444 | } | 436 | } | ||
445 | } | 437 | } | ||
446 | 438 | | |||
447 | _contextPopupMenu->exec(tabBar()->mapToGlobal(point)); | 439 | _contextPopupMenu->exec(tabBar()->mapToGlobal(point)); | ||
448 | } | 440 | } | ||
449 | 441 | | |||
450 | void TabbedViewContainer::currentTabChanged(int index) | 442 | void TabbedViewContainer::currentTabChanged(int index) | ||
451 | { | 443 | { | ||
452 | setCurrentIndex(index); | 444 | if (index != -1) { | ||
453 | if (widget(index) != nullptr) { | 445 | QWidget *view = widget(index); | ||
454 | emit activeViewChanged(widget(index)); | 446 | view->setFocus(); | ||
455 | } | 447 | updateTabHistory(view); | ||
456 | 448 | emit activeViewChanged(view); | |||
457 | // clear activity indicators | | |||
458 | setTabActivity(index, false); | 449 | setTabActivity(index, false); | ||
450 | } else { | ||||
451 | deleteLater(); | ||||
452 | } | ||||
459 | } | 453 | } | ||
460 | 454 | | |||
461 | void TabbedViewContainer::wheelScrolled(int delta) | 455 | void TabbedViewContainer::wheelScrolled(int delta) | ||
462 | { | 456 | { | ||
463 | if (delta < 0) { | 457 | if (delta < 0) { | ||
464 | activateNextView(); | 458 | activateNextView(); | ||
465 | } else { | 459 | } else { | ||
466 | activatePreviousView(); | 460 | activatePreviousView(); | ||
▲ Show 20 Lines • Show All 75 Lines • Show Last 20 Lines |