Changeset View
Changeset View
Standalone View
Standalone View
src/ViewContainer.cpp
Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Line(s) | 81 | connect(_closeTabButton, &QToolButton::clicked, this, [this]{ | |||
---|---|---|---|---|---|
82 | closeCurrentTab(); | 82 | closeCurrentTab(); | ||
83 | }); | 83 | }); | ||
84 | 84 | | |||
85 | connect(tabBar(), &QTabBar::tabBarDoubleClicked, this, | 85 | connect(tabBar(), &QTabBar::tabBarDoubleClicked, this, | ||
86 | &Konsole::TabbedViewContainer::tabDoubleClicked); | 86 | &Konsole::TabbedViewContainer::tabDoubleClicked); | ||
87 | connect(tabBar(), &QTabBar::customContextMenuRequested, this, | 87 | connect(tabBar(), &QTabBar::customContextMenuRequested, this, | ||
88 | &Konsole::TabbedViewContainer::openTabContextMenu); | 88 | &Konsole::TabbedViewContainer::openTabContextMenu); | ||
89 | 89 | | |||
90 | //TODO: Fix Detach. | 90 | connect(tabBarWidget, &DetachableTabBar::detachTab, this, [this](int idx) { | ||
91 | // connect(tabBarWidget, &DetachableTabBar::detachTab, this, [this](int idx) { | 91 | emit detachTab(this); | ||
92 | // emit detachTab(this, terminalAt(idx)); | 92 | }); | ||
93 | //}); | | |||
94 | 93 | | |||
95 | connect(this, &TabbedViewContainer::currentChanged, this, &TabbedViewContainer::currentTabChanged); | 94 | connect(this, &TabbedViewContainer::currentChanged, this, &TabbedViewContainer::currentTabChanged); | ||
96 | 95 | | |||
97 | // The context menu of tab bar | 96 | // The context menu of tab bar | ||
98 | _contextPopupMenu = new QMenu(tabBar()); | 97 | _contextPopupMenu = new QMenu(tabBar()); | ||
99 | connect(_contextPopupMenu, &QMenu::aboutToHide, this, [this]() { | 98 | connect(_contextPopupMenu, &QMenu::aboutToHide, this, [this]() { | ||
100 | // Remove the read-only action when the popup closes | 99 | // Remove the read-only action when the popup closes | ||
101 | for (auto &action : _contextPopupMenu->actions()) { | 100 | for (auto &action : _contextPopupMenu->actions()) { | ||
102 | if (action->objectName() == QStringLiteral("view-readonly")) { | 101 | if (action->objectName() == QStringLiteral("view-readonly")) { | ||
103 | _contextPopupMenu->removeAction(action); | 102 | _contextPopupMenu->removeAction(action); | ||
104 | break; | 103 | break; | ||
105 | } | 104 | } | ||
106 | } | 105 | } | ||
107 | }); | 106 | }); | ||
108 | 107 | | |||
109 | #if defined(ENABLE_DETACHING) | 108 | #if defined(ENABLE_DETACHING) | ||
110 | /* TODO FIX DETACH | | |||
111 | auto detachAction = _contextPopupMenu->addAction( | 109 | auto detachAction = _contextPopupMenu->addAction( | ||
112 | QIcon::fromTheme(QStringLiteral("tab-detach")), | 110 | QIcon::fromTheme(QStringLiteral("tab-detach")), | ||
113 | i18nc("@action:inmenu", "&Detach Tab"), this, | 111 | i18nc("@action:inmenu", "&Detach Tab"), this, | ||
114 | [this] { emit detachTab(this, terminalAt(_contextMenuTabIndex)); } | 112 | [this] { emit detachTab(this); } | ||
115 | ); | 113 | ); | ||
116 | detachAction->setObjectName(QStringLiteral("tab-detach")); | 114 | detachAction->setObjectName(QStringLiteral("tab-detach")); | ||
117 | */ | | |||
118 | #endif | 115 | #endif | ||
119 | 116 | | |||
120 | auto editAction = _contextPopupMenu->addAction( | 117 | auto editAction = _contextPopupMenu->addAction( | ||
121 | QIcon::fromTheme(QStringLiteral("edit-rename")), | 118 | QIcon::fromTheme(QStringLiteral("edit-rename")), | ||
122 | i18nc("@action:inmenu", "&Rename Tab..."), this, | 119 | i18nc("@action:inmenu", "&Rename Tab..."), this, | ||
123 | [this]{ renameTab(_contextMenuTabIndex); } | 120 | [this]{ renameTab(_contextMenuTabIndex); } | ||
124 | ); | 121 | ); | ||
125 | editAction->setObjectName(QStringLiteral("edit-rename")); | 122 | editAction->setObjectName(QStringLiteral("edit-rename")); | ||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Line(s) | 256 | if (newIndex < currentIndex) { | |||
261 | insertTab(currentIndex, swappedWidget, swappedIcon, swappedTitle); | 258 | insertTab(currentIndex, swappedWidget, swappedIcon, swappedTitle); | ||
262 | } else { | 259 | } else { | ||
263 | insertTab(currentIndex, swappedWidget, swappedIcon, swappedTitle); | 260 | insertTab(currentIndex, swappedWidget, swappedIcon, swappedTitle); | ||
264 | insertTab(newIndex, currentWidget, currentIcon, currentTitle); | 261 | insertTab(newIndex, currentWidget, currentIcon, currentTitle); | ||
265 | } | 262 | } | ||
266 | setCurrentIndex(newIndex); | 263 | setCurrentIndex(newIndex); | ||
267 | } | 264 | } | ||
268 | 265 | | |||
266 | void TabbedViewContainer::addSplitter(ViewSplitter *viewSplitter, int index) { | ||||
267 | if (index == -1) { | ||||
268 | index = addTab(viewSplitter, QString()); | ||||
269 | } else { | ||||
270 | insertTab(index, viewSplitter, QString()); | ||||
271 | } | ||||
272 | connect(viewSplitter, &ViewSplitter::destroyed, this, &TabbedViewContainer::viewDestroyed); | ||||
273 | foreach(TerminalDisplay* terminal, viewSplitter->getTerminalDisplays()) { | ||||
274 | connectTerminalDisplay(terminal); | ||||
275 | } | ||||
276 | setCurrentIndex(index); | ||||
277 | } | ||||
278 | | ||||
269 | void TabbedViewContainer::addView(TerminalDisplay *view, int index) | 279 | void TabbedViewContainer::addView(TerminalDisplay *view, int index) | ||
270 | { | 280 | { | ||
271 | auto viewSplitter = new ViewSplitter(); | 281 | auto viewSplitter = new ViewSplitter(); | ||
272 | viewSplitter->addTerminalDisplay(view, Qt::Horizontal); | 282 | viewSplitter->addTerminalDisplay(view, Qt::Horizontal); | ||
273 | auto item = view->sessionController(); | 283 | auto item = view->sessionController(); | ||
274 | if (index == -1) { | 284 | if (index == -1) { | ||
275 | index = addTab(viewSplitter, item->icon(), item->title()); | 285 | index = addTab(viewSplitter, item->icon(), item->title()); | ||
276 | } else { | 286 | } else { | ||
Show All 24 Lines | 304 | { | |||
301 | 311 | | |||
302 | connect(item, &Konsole::ViewProperties::iconChanged, this, | 312 | connect(item, &Konsole::ViewProperties::iconChanged, this, | ||
303 | &Konsole::TabbedViewContainer::updateIcon); | 313 | &Konsole::TabbedViewContainer::updateIcon); | ||
304 | 314 | | |||
305 | connect(item, &Konsole::ViewProperties::activity, this, | 315 | connect(item, &Konsole::ViewProperties::activity, this, | ||
306 | &Konsole::TabbedViewContainer::updateActivity); | 316 | &Konsole::TabbedViewContainer::updateActivity); | ||
307 | } | 317 | } | ||
308 | 318 | | |||
319 | void TabbedViewContainer::disconnectTerminalDisplay(TerminalDisplay *display) | ||||
320 | { | ||||
321 | auto item = display->sessionController(); | ||||
322 | disconnect(item, &Konsole::SessionController::focused, this, | ||||
323 | &Konsole::TabbedViewContainer::currentSessionControllerChanged); | ||||
324 | | ||||
325 | disconnect(item, &Konsole::ViewProperties::titleChanged, this, | ||||
326 | &Konsole::TabbedViewContainer::updateTitle); | ||||
327 | | ||||
328 | disconnect(item, &Konsole::ViewProperties::iconChanged, this, | ||||
329 | &Konsole::TabbedViewContainer::updateIcon); | ||||
330 | | ||||
331 | disconnect(item, &Konsole::ViewProperties::activity, this, | ||||
332 | &Konsole::TabbedViewContainer::updateActivity); | ||||
333 | } | ||||
334 | | ||||
309 | void TabbedViewContainer::viewDestroyed(QObject *view) | 335 | void TabbedViewContainer::viewDestroyed(QObject *view) | ||
310 | { | 336 | { | ||
311 | auto widget = static_cast<ViewSplitter*>(view); | 337 | auto widget = static_cast<ViewSplitter*>(view); | ||
312 | const auto idx = indexOf(widget); | 338 | const auto idx = indexOf(widget); | ||
313 | 339 | | |||
314 | removeTab(idx); | 340 | removeTab(idx); | ||
315 | forgetView(widget); | 341 | forgetView(widget); | ||
316 | } | 342 | } | ||
▲ Show 20 Lines • Show All 228 Lines • Show Last 20 Lines |