Changeset View
Changeset View
Standalone View
Standalone View
src/ViewManager.cpp
Show All 38 Lines | |||||
39 | #include "ColorSchemeManager.h" | 39 | #include "ColorSchemeManager.h" | ||
40 | #include "Session.h" | 40 | #include "Session.h" | ||
41 | #include "TerminalDisplay.h" | 41 | #include "TerminalDisplay.h" | ||
42 | #include "SessionController.h" | 42 | #include "SessionController.h" | ||
43 | #include "SessionManager.h" | 43 | #include "SessionManager.h" | ||
44 | #include "ProfileManager.h" | 44 | #include "ProfileManager.h" | ||
45 | #include "ViewSplitter.h" | 45 | #include "ViewSplitter.h" | ||
46 | #include "Enumeration.h" | 46 | #include "Enumeration.h" | ||
47 | #include "ViewContainer.h" | ||||
47 | 48 | | |||
48 | using namespace Konsole; | 49 | using namespace Konsole; | ||
49 | 50 | | |||
50 | int ViewManager::lastManagerId = 0; | 51 | int ViewManager::lastManagerId = 0; | ||
51 | 52 | | |||
52 | ViewManager::ViewManager(QObject *parent, KActionCollection *collection) : | 53 | ViewManager::ViewManager(QObject *parent, KActionCollection *collection) : | ||
53 | QObject(parent), | 54 | QObject(parent), | ||
54 | _viewSplitter(nullptr), | 55 | _viewSplitter(nullptr), | ||
55 | _pluggedController(nullptr), | 56 | _pluggedController(nullptr), | ||
56 | _sessionMap(QHash<TerminalDisplay *, Session *>()), | 57 | _sessionMap(QHash<TerminalDisplay *, Session *>()), | ||
57 | _actionCollection(collection), | 58 | _actionCollection(collection), | ||
58 | _navigationMethod(TabbedNavigation), | | |||
59 | _navigationVisibility(ViewContainer::AlwaysShowNavigation), | | |||
60 | _navigationPosition(ViewContainer::NavigationPositionTop), | | |||
61 | _showQuickButtons(false), | | |||
62 | _navigationTabWidthExpanding(true), | | |||
63 | _newTabBehavior(PutNewTabAtTheEnd), | | |||
64 | _navigationStyleSheet(QString()), | | |||
65 | _managerId(0) | 59 | _managerId(0) | ||
66 | { | 60 | { | ||
67 | // create main view area | 61 | // create main view area | ||
68 | _viewSplitter = new ViewSplitter(nullptr); | 62 | _viewSplitter = new ViewSplitter(nullptr); | ||
69 | KAcceleratorManager::setNoAccel(_viewSplitter); | 63 | KAcceleratorManager::setNoAccel(_viewSplitter); | ||
70 | 64 | | |||
71 | // the ViewSplitter class supports both recursive and non-recursive splitting, | 65 | // the ViewSplitter class supports both recursive and non-recursive splitting, | ||
72 | // in non-recursive mode, all containers are inserted into the same top-level splitter | 66 | // in non-recursive mode, all containers are inserted into the same top-level splitter | ||
Show All 31 Lines | |||||
104 | 98 | | |||
105 | int ViewManager::managerId() const | 99 | int ViewManager::managerId() const | ||
106 | { | 100 | { | ||
107 | return _managerId; | 101 | return _managerId; | ||
108 | } | 102 | } | ||
109 | 103 | | |||
110 | QWidget *ViewManager::activeView() const | 104 | QWidget *ViewManager::activeView() const | ||
111 | { | 105 | { | ||
112 | ViewContainer *container = _viewSplitter->activeContainer(); | 106 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
113 | if (container != nullptr) { | 107 | if (container != nullptr) { | ||
114 | return container->activeView(); | 108 | return container->currentWidget(); | ||
115 | } else { | 109 | } else { | ||
116 | return nullptr; | 110 | return nullptr; | ||
117 | } | 111 | } | ||
118 | } | 112 | } | ||
119 | 113 | | |||
120 | QWidget *ViewManager::widget() const | 114 | QWidget *ViewManager::widget() const | ||
121 | { | 115 | { | ||
122 | return _viewSplitter; | 116 | return _viewSplitter; | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 190 | collection->setDefaultShortcut(shrinkActiveAction, | |||
197 | Konsole::ACCEL + Qt::SHIFT + Qt::Key_BracketLeft); | 191 | Konsole::ACCEL + Qt::SHIFT + Qt::Key_BracketLeft); | ||
198 | shrinkActiveAction->setEnabled(false); | 192 | shrinkActiveAction->setEnabled(false); | ||
199 | collection->addAction(QStringLiteral("shrink-active-view"), shrinkActiveAction); | 193 | collection->addAction(QStringLiteral("shrink-active-view"), shrinkActiveAction); | ||
200 | connect(shrinkActiveAction, &QAction::triggered, this, | 194 | connect(shrinkActiveAction, &QAction::triggered, this, | ||
201 | &Konsole::ViewManager::shrinkActiveContainer); | 195 | &Konsole::ViewManager::shrinkActiveContainer); | ||
202 | 196 | | |||
203 | multiViewOnlyActions << shrinkActiveAction; | 197 | multiViewOnlyActions << shrinkActiveAction; | ||
204 | 198 | | |||
205 | #if defined(ENABLE_DETACHING) | | |||
206 | QAction *detachViewAction = collection->addAction(QStringLiteral("detach-view")); | 199 | QAction *detachViewAction = collection->addAction(QStringLiteral("detach-view")); | ||
200 | // Crashes on Mac. | ||||
201 | detachViewAction->setEnabled(QOperatingSystemVersion::currentType() != QOperatingSystemVersion::MacOS); | ||||
207 | detachViewAction->setIcon(QIcon::fromTheme(QStringLiteral("tab-detach"))); | 202 | detachViewAction->setIcon(QIcon::fromTheme(QStringLiteral("tab-detach"))); | ||
208 | detachViewAction->setText(i18nc("@action:inmenu", "D&etach Current Tab")); | 203 | detachViewAction->setText(i18nc("@action:inmenu", "D&etach Current Tab")); | ||
209 | // Ctrl+Shift+D is not used as a shortcut by default because it is too close | 204 | // Ctrl+Shift+D is not used as a shortcut by default because it is too close | ||
210 | // to Ctrl+D - which will terminate the session in many cases | 205 | // to Ctrl+D - which will terminate the session in many cases | ||
211 | collection->setDefaultShortcut(detachViewAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_H); | 206 | collection->setDefaultShortcut(detachViewAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_H); | ||
212 | 207 | | |||
213 | connect(this, &Konsole::ViewManager::splitViewToggle, this, | 208 | connect(this, &Konsole::ViewManager::splitViewToggle, this, | ||
214 | &Konsole::ViewManager::updateDetachViewState); | 209 | &Konsole::ViewManager::updateDetachViewState); | ||
215 | connect(detachViewAction, &QAction::triggered, this, &Konsole::ViewManager::detachActiveView); | 210 | connect(detachViewAction, &QAction::triggered, this, &Konsole::ViewManager::detachActiveView); | ||
216 | #endif | | |||
217 | 211 | | |||
218 | // Next / Previous View , Next Container | 212 | // Next / Previous View , Next Container | ||
219 | collection->addAction(QStringLiteral("next-view"), nextViewAction); | 213 | collection->addAction(QStringLiteral("next-view"), nextViewAction); | ||
220 | collection->addAction(QStringLiteral("previous-view"), previousViewAction); | 214 | collection->addAction(QStringLiteral("previous-view"), previousViewAction); | ||
221 | collection->addAction(QStringLiteral("last-tab"), lastViewAction); | 215 | collection->addAction(QStringLiteral("last-tab"), lastViewAction); | ||
222 | collection->addAction(QStringLiteral("next-container"), nextContainerAction); | 216 | collection->addAction(QStringLiteral("next-container"), nextContainerAction); | ||
223 | collection->addAction(QStringLiteral("move-view-left"), moveViewLeftAction); | 217 | collection->addAction(QStringLiteral("move-view-left"), moveViewLeftAction); | ||
224 | collection->addAction(QStringLiteral("move-view-right"), moveViewRightAction); | 218 | collection->addAction(QStringLiteral("move-view-right"), moveViewRightAction); | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 266 | #endif | |||
275 | _viewSplitter->addAction(moveViewRightAction); | 269 | _viewSplitter->addAction(moveViewRightAction); | ||
276 | 270 | | |||
277 | connect(lastViewAction, &QAction::triggered, this, &Konsole::ViewManager::lastView); | 271 | connect(lastViewAction, &QAction::triggered, this, &Konsole::ViewManager::lastView); | ||
278 | _viewSplitter->addAction(lastViewAction); | 272 | _viewSplitter->addAction(lastViewAction); | ||
279 | } | 273 | } | ||
280 | 274 | | |||
281 | void ViewManager::switchToView(int index) | 275 | void ViewManager::switchToView(int index) | ||
282 | { | 276 | { | ||
283 | Q_ASSERT(index >= 0); | 277 | _viewSplitter->activeContainer()->setCurrentIndex(index); | ||
284 | ViewContainer *container = _viewSplitter->activeContainer(); | | |||
285 | Q_ASSERT(container); | | |||
286 | QList<QWidget *> containerViews = container->views(); | | |||
287 | if (index >= containerViews.count()) { | | |||
288 | return; | | |||
289 | } | | |||
290 | container->setActiveView(containerViews.at(index)); | | |||
291 | } | 278 | } | ||
292 | 279 | | |||
293 | void ViewManager::updateDetachViewState() | 280 | void ViewManager::updateDetachViewState() | ||
294 | { | 281 | { | ||
295 | Q_ASSERT(_actionCollection); | 282 | Q_ASSERT(_actionCollection); | ||
296 | if (_actionCollection == nullptr) { | 283 | if (_actionCollection == nullptr) { | ||
297 | return; | 284 | return; | ||
298 | } | 285 | } | ||
299 | 286 | | |||
300 | const bool splitView = _viewSplitter->containers().count() >= 2; | 287 | const bool splitView = _viewSplitter->containers().count() >= 2; | ||
301 | auto activeContainer = _viewSplitter->activeContainer(); | 288 | auto activeContainer = _viewSplitter->activeContainer(); | ||
302 | const bool shouldEnable = splitView | 289 | const bool shouldEnable = splitView | ||
303 | || ((activeContainer != nullptr) | 290 | || ((activeContainer != nullptr) | ||
304 | && activeContainer->views().count() >= 2); | 291 | && activeContainer->count() >= 2); | ||
305 | 292 | | |||
306 | QAction *detachAction = _actionCollection->action(QStringLiteral("detach-view")); | 293 | QAction *detachAction = _actionCollection->action(QStringLiteral("detach-view")); | ||
307 | 294 | | |||
308 | if ((detachAction != nullptr) && shouldEnable != detachAction->isEnabled()) { | 295 | if ((detachAction != nullptr) && shouldEnable != detachAction->isEnabled()) { | ||
309 | detachAction->setEnabled(shouldEnable); | 296 | detachAction->setEnabled(shouldEnable); | ||
310 | } | 297 | } | ||
311 | } | 298 | } | ||
312 | 299 | | |||
313 | void ViewManager::moveActiveViewLeft() | 300 | void ViewManager::moveActiveViewLeft() | ||
314 | { | 301 | { | ||
315 | ViewContainer *container = _viewSplitter->activeContainer(); | 302 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
316 | Q_ASSERT(container); | 303 | Q_ASSERT(container); | ||
317 | container->moveActiveView(ViewContainer::MoveViewLeft); | 304 | container->moveActiveView(TabbedViewContainer::MoveViewLeft); | ||
318 | } | 305 | } | ||
319 | 306 | | |||
320 | void ViewManager::moveActiveViewRight() | 307 | void ViewManager::moveActiveViewRight() | ||
321 | { | 308 | { | ||
322 | ViewContainer *container = _viewSplitter->activeContainer(); | 309 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
323 | Q_ASSERT(container); | 310 | Q_ASSERT(container); | ||
324 | container->moveActiveView(ViewContainer::MoveViewRight); | 311 | container->moveActiveView(TabbedViewContainer::MoveViewRight); | ||
325 | } | 312 | } | ||
326 | 313 | | |||
327 | void ViewManager::nextContainer() | 314 | void ViewManager::nextContainer() | ||
328 | { | 315 | { | ||
329 | _viewSplitter->activateNextContainer(); | 316 | _viewSplitter->activateNextContainer(); | ||
330 | } | 317 | } | ||
331 | 318 | | |||
332 | void ViewManager::nextView() | 319 | void ViewManager::nextView() | ||
333 | { | 320 | { | ||
334 | ViewContainer *container = _viewSplitter->activeContainer(); | 321 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
335 | | ||||
336 | Q_ASSERT(container); | 322 | Q_ASSERT(container); | ||
337 | | ||||
338 | container->activateNextView(); | 323 | container->activateNextView(); | ||
339 | } | 324 | } | ||
340 | 325 | | |||
341 | void ViewManager::previousView() | 326 | void ViewManager::previousView() | ||
342 | { | 327 | { | ||
343 | ViewContainer *container = _viewSplitter->activeContainer(); | 328 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
344 | | ||||
345 | Q_ASSERT(container); | 329 | Q_ASSERT(container); | ||
346 | | ||||
347 | container->activatePreviousView(); | 330 | container->activatePreviousView(); | ||
348 | } | 331 | } | ||
349 | 332 | | |||
350 | void ViewManager::lastView() | 333 | void ViewManager::lastView() | ||
351 | { | 334 | { | ||
352 | ViewContainer *container = _viewSplitter->activeContainer(); | 335 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
353 | | ||||
354 | Q_ASSERT(container); | 336 | Q_ASSERT(container); | ||
355 | | ||||
356 | container->activateLastView(); | 337 | container->activateLastView(); | ||
357 | } | 338 | } | ||
358 | 339 | | |||
359 | void ViewManager::detachActiveView() | 340 | void ViewManager::detachActiveView() | ||
360 | { | 341 | { | ||
361 | // find the currently active view and remove it from its container | 342 | // find the currently active view and remove it from its container | ||
362 | ViewContainer *container = _viewSplitter->activeContainer(); | 343 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
363 | 344 | detachView(container, container->currentWidget()); | |||
364 | detachView(container, container->activeView()); | | |||
365 | } | 345 | } | ||
366 | 346 | | |||
367 | void ViewManager::detachView(ViewContainer *container, QWidget *view) | 347 | void ViewManager::detachView(TabbedViewContainer *container, QWidget *view) | ||
368 | { | 348 | { | ||
369 | #if !defined(ENABLE_DETACHING) | 349 | #if !defined(ENABLE_DETACHING) | ||
370 | return; | 350 | return; | ||
371 | #endif | 351 | #endif | ||
372 | 352 | | |||
373 | TerminalDisplay *viewToDetach = qobject_cast<TerminalDisplay *>(view); | 353 | TerminalDisplay *viewToDetach = qobject_cast<TerminalDisplay *>(view); | ||
374 | 354 | | |||
375 | if (viewToDetach == nullptr) { | 355 | if (viewToDetach == nullptr) { | ||
Show All 12 Lines | |||||
388 | // remove the view from this window | 368 | // remove the view from this window | ||
389 | container->removeView(viewToDetach); | 369 | container->removeView(viewToDetach); | ||
390 | viewToDetach->deleteLater(); | 370 | viewToDetach->deleteLater(); | ||
391 | 371 | | |||
392 | // if the container from which the view was removed is now empty then it can be deleted, | 372 | // if the container from which the view was removed is now empty then it can be deleted, | ||
393 | // unless it is the only container in the window, in which case it is left empty | 373 | // unless it is the only container in the window, in which case it is left empty | ||
394 | // so that there is always an active container | 374 | // so that there is always an active container | ||
395 | if (_viewSplitter->containers().count() > 1 | 375 | if (_viewSplitter->containers().count() > 1 | ||
396 | && container->views().count() == 0) { | 376 | && container->count() == 0) { | ||
397 | removeContainer(container); | 377 | removeContainer(container); | ||
398 | } | 378 | } | ||
399 | } | 379 | } | ||
400 | 380 | | |||
401 | void ViewManager::sessionFinished() | 381 | void ViewManager::sessionFinished() | ||
402 | { | 382 | { | ||
403 | // if this slot is called after the view manager's main widget | 383 | // if this slot is called after the view manager's main widget | ||
404 | // has been destroyed, do nothing | 384 | // has been destroyed, do nothing | ||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Line(s) | |||||
446 | 426 | | |||
447 | void ViewManager::splitTopBottom() | 427 | void ViewManager::splitTopBottom() | ||
448 | { | 428 | { | ||
449 | splitView(Qt::Vertical); | 429 | splitView(Qt::Vertical); | ||
450 | } | 430 | } | ||
451 | 431 | | |||
452 | void ViewManager::splitView(Qt::Orientation orientation) | 432 | void ViewManager::splitView(Qt::Orientation orientation) | ||
453 | { | 433 | { | ||
454 | ViewContainer *container = createContainer(); | 434 | TabbedViewContainer *container = createContainer(); | ||
455 | 435 | | |||
456 | // iterate over each session which has a view in the current active | 436 | // iterate over each session which has a view in the current active | ||
457 | // container and create a new view for that session in a new container | 437 | // container and create a new view for that session in a new container | ||
458 | foreach (QWidget *view, _viewSplitter->activeContainer()->views()) { | 438 | for(int i = 0, end = _viewSplitter->activeContainer()->count(); i < end; i++) { | ||
439 | auto view = _viewSplitter->activeContainer()->widget(i); | ||||
459 | Session *session = _sessionMap[qobject_cast<TerminalDisplay *>(view)]; | 440 | Session *session = _sessionMap[qobject_cast<TerminalDisplay *>(view)]; | ||
460 | TerminalDisplay *display = createTerminalDisplay(session); | 441 | TerminalDisplay *display = createTerminalDisplay(session); | ||
461 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | 442 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | ||
462 | applyProfileToView(display, profile); | 443 | applyProfileToView(display, profile); | ||
463 | ViewProperties *properties = createController(session, display); | 444 | ViewProperties *properties = createController(session, display); | ||
464 | 445 | | |||
465 | _sessionMap[display] = session; | 446 | _sessionMap[display] = session; | ||
466 | 447 | | |||
467 | container->addView(display, properties); | 448 | container->addView(display, properties); | ||
468 | session->addView(display); | 449 | session->addView(display); | ||
469 | } | 450 | } | ||
470 | 451 | | |||
471 | _viewSplitter->addContainer(container, orientation); | 452 | _viewSplitter->addContainer(container, orientation); | ||
472 | emit splitViewToggle(_viewSplitter->containers().count() > 0); | 453 | emit splitViewToggle(_viewSplitter->containers().count() > 0); | ||
473 | 454 | | |||
474 | // focus the new container | 455 | // focus the new container | ||
475 | container->containerWidget()->setFocus(); | 456 | container->currentWidget()->setFocus(); | ||
476 | 457 | | |||
477 | // ensure that the active view is focused after the split / unsplit | 458 | // ensure that the active view is focused after the split / unsplit | ||
478 | ViewContainer *activeContainer = _viewSplitter->activeContainer(); | 459 | TabbedViewContainer *activeContainer = _viewSplitter->activeContainer(); | ||
479 | QWidget *activeView = activeContainer != nullptr ? activeContainer->activeView() : nullptr; | 460 | QWidget *activeView = activeContainer != nullptr ? activeContainer->currentWidget() : nullptr; | ||
480 | 461 | | |||
481 | if (activeView != nullptr) { | 462 | if (activeView != nullptr) { | ||
482 | activeView->setFocus(Qt::OtherFocusReason); | 463 | activeView->setFocus(Qt::OtherFocusReason); | ||
483 | } | 464 | } | ||
484 | } | 465 | } | ||
485 | 466 | | |||
486 | void ViewManager::removeContainer(ViewContainer *container) | 467 | void ViewManager::removeContainer(TabbedViewContainer *container) | ||
487 | { | 468 | { | ||
488 | // remove session map entries for views in this container | 469 | // remove session map entries for views in this container | ||
489 | foreach (QWidget *view, container->views()) { | 470 | for(int i = 0, end = container->count(); i < end; i++) { | ||
471 | auto view = container->widget(i); | ||||
490 | TerminalDisplay *display = qobject_cast<TerminalDisplay *>(view); | 472 | TerminalDisplay *display = qobject_cast<TerminalDisplay *>(view); | ||
491 | Q_ASSERT(display); | 473 | Q_ASSERT(display); | ||
492 | _sessionMap.remove(display); | 474 | _sessionMap.remove(display); | ||
493 | } | 475 | } | ||
494 | 476 | | |||
495 | _viewSplitter->removeContainer(container); | 477 | _viewSplitter->removeContainer(container); | ||
496 | container->deleteLater(); | 478 | container->deleteLater(); | ||
497 | 479 | | |||
Show All 9 Lines | |||||
507 | { | 489 | { | ||
508 | _viewSplitter->adjustContainerSize(_viewSplitter->activeContainer(), -10); | 490 | _viewSplitter->adjustContainerSize(_viewSplitter->activeContainer(), -10); | ||
509 | } | 491 | } | ||
510 | 492 | | |||
511 | void ViewManager::closeActiveContainer() | 493 | void ViewManager::closeActiveContainer() | ||
512 | { | 494 | { | ||
513 | // only do something if there is more than one container active | 495 | // only do something if there is more than one container active | ||
514 | if (_viewSplitter->containers().count() > 1) { | 496 | if (_viewSplitter->containers().count() > 1) { | ||
515 | ViewContainer *container = _viewSplitter->activeContainer(); | 497 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
516 | 498 | | |||
517 | removeContainer(container); | 499 | removeContainer(container); | ||
518 | 500 | | |||
519 | // focus next container so that user can continue typing | 501 | // focus next container so that user can continue typing | ||
520 | // without having to manually focus it themselves | 502 | // without having to manually focus it themselves | ||
521 | nextContainer(); | 503 | nextContainer(); | ||
522 | } | 504 | } | ||
523 | } | 505 | } | ||
524 | 506 | | |||
525 | void ViewManager::closeOtherContainers() | 507 | void ViewManager::closeOtherContainers() | ||
526 | { | 508 | { | ||
527 | ViewContainer *active = _viewSplitter->activeContainer(); | 509 | TabbedViewContainer *active = _viewSplitter->activeContainer(); | ||
528 | 510 | | |||
529 | foreach (ViewContainer *container, _viewSplitter->containers()) { | 511 | foreach (TabbedViewContainer *container, _viewSplitter->containers()) { | ||
530 | if (container != active) { | 512 | if (container != active) { | ||
531 | removeContainer(container); | 513 | removeContainer(container); | ||
532 | } | 514 | } | ||
533 | } | 515 | } | ||
534 | } | 516 | } | ||
535 | 517 | | |||
536 | SessionController *ViewManager::createController(Session *session, TerminalDisplay *view) | 518 | SessionController *ViewManager::createController(Session *session, TerminalDisplay *view) | ||
537 | { | 519 | { | ||
Show All 31 Lines | 543 | { | |||
569 | emit activeViewChanged(controller); | 551 | emit activeViewChanged(controller); | ||
570 | } | 552 | } | ||
571 | 553 | | |||
572 | SessionController *ViewManager::activeViewController() const | 554 | SessionController *ViewManager::activeViewController() const | ||
573 | { | 555 | { | ||
574 | return _pluggedController; | 556 | return _pluggedController; | ||
575 | } | 557 | } | ||
576 | 558 | | |||
577 | IncrementalSearchBar *ViewManager::searchBar() const | 559 | void ViewManager::createView(Session *session, TabbedViewContainer *container, int index) | ||
578 | { | | |||
579 | return _viewSplitter->activeSplitter()->activeContainer()->searchBar(); | | |||
580 | } | | |||
581 | | ||||
582 | void ViewManager::createView(Session *session, ViewContainer *container, int index) | | |||
583 | { | 560 | { | ||
584 | // notify this view manager when the session finishes so that its view | 561 | // notify this view manager when the session finishes so that its view | ||
585 | // can be deleted | 562 | // can be deleted | ||
586 | // | 563 | // | ||
587 | // Use Qt::UniqueConnection to avoid duplicate connection | 564 | // Use Qt::UniqueConnection to avoid duplicate connection | ||
588 | connect(session, &Konsole::Session::finished, this, &Konsole::ViewManager::sessionFinished, | 565 | connect(session, &Konsole::Session::finished, this, &Konsole::ViewManager::sessionFinished, | ||
589 | Qt::UniqueConnection); | 566 | Qt::UniqueConnection); | ||
590 | 567 | | |||
591 | TerminalDisplay *display = createTerminalDisplay(session); | 568 | TerminalDisplay *display = createTerminalDisplay(session); | ||
592 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | 569 | const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); | ||
593 | applyProfileToView(display, profile); | 570 | applyProfileToView(display, profile); | ||
594 | 571 | | |||
595 | // set initial size | 572 | // set initial size | ||
596 | const QSize &preferredSize = session->preferredSize(); | 573 | const QSize &preferredSize = session->preferredSize(); | ||
597 | // FIXME: +1 is needed here for getting the expected rows | | |||
598 | // Note that the display shouldn't need to take into account the tabbar. | | |||
599 | // However, it appears that taking into account the tabbar is needed. | | |||
600 | // If tabbar is not visible, no +1 is needed here; however, depending on | | |||
601 | // settings/tabbar style, +2 might be needed. | | |||
602 | // 1st attempt at fixing the above: | | |||
603 | // Guess if tabbar will NOT be visible; ignore ShowNavigationAsNeeded | | |||
604 | int heightAdjustment = 0; | | |||
605 | if (_navigationVisibility != ViewContainer::AlwaysHideNavigation) { | | |||
606 | heightAdjustment = 2; | | |||
607 | } | | |||
608 | 574 | | |||
609 | display->setSize(preferredSize.width(), preferredSize.height() + heightAdjustment); | 575 | display->setSize(preferredSize.width(), preferredSize.height()); | ||
610 | ViewProperties *properties = createController(session, display); | 576 | ViewProperties *properties = createController(session, display); | ||
611 | 577 | | |||
612 | _sessionMap[display] = session; | 578 | _sessionMap[display] = session; | ||
613 | container->addView(display, properties, index); | 579 | container->addView(display, properties, index); | ||
614 | session->addView(display); | 580 | session->addView(display); | ||
615 | 581 | | |||
616 | // tell the session whether it has a light or dark background | 582 | // tell the session whether it has a light or dark background | ||
617 | session->setDarkBackground(colorSchemeForProfile(profile)->hasDarkBackground()); | 583 | session->setDarkBackground(colorSchemeForProfile(profile)->hasDarkBackground()); | ||
618 | 584 | | |||
619 | if (container == _viewSplitter->activeContainer()) { | 585 | if (container == _viewSplitter->activeContainer()) { | ||
620 | container->setActiveView(display); | 586 | container->setCurrentWidget(display); | ||
621 | display->setFocus(Qt::OtherFocusReason); | 587 | display->setFocus(Qt::OtherFocusReason); | ||
622 | } | 588 | } | ||
623 | 589 | | |||
624 | updateDetachViewState(); | 590 | updateDetachViewState(); | ||
625 | } | 591 | } | ||
626 | 592 | | |||
627 | void ViewManager::createView(Session *session) | 593 | void ViewManager::createView(Session *session) | ||
628 | { | 594 | { | ||
629 | // create the default container | 595 | // create the default container | ||
630 | if (_viewSplitter->containers().count() == 0) { | 596 | if (_viewSplitter->containers().count() == 0) { | ||
631 | ViewContainer *container = createContainer(); | 597 | TabbedViewContainer *container = createContainer(); | ||
632 | _viewSplitter->addContainer(container, Qt::Vertical); | 598 | _viewSplitter->addContainer(container, Qt::Vertical); | ||
633 | emit splitViewToggle(false); | 599 | emit splitViewToggle(false); | ||
634 | } | 600 | } | ||
635 | 601 | | |||
636 | // new tab will be put at the end by default. | 602 | // new tab will be put at the end by default. | ||
637 | int index = -1; | 603 | int index = -1; | ||
638 | 604 | | |||
639 | if (_newTabBehavior == PutNewTabAfterCurrentTab) { | | |||
640 | QWidget *view = activeView(); | | |||
641 | if (view != nullptr) { | | |||
642 | QList<QWidget *> views = _viewSplitter->activeContainer()->views(); | | |||
643 | index = views.indexOf(view) + 1; | | |||
644 | } | | |||
645 | } | | |||
646 | | ||||
647 | // iterate over the view containers owned by this view manager | 605 | // iterate over the view containers owned by this view manager | ||
648 | // and create a new terminal display for the session in each of them, along with | 606 | // and create a new terminal display for the session in each of them, along with | ||
649 | // a controller for the session/display pair | 607 | // a controller for the session/display pair | ||
650 | foreach (ViewContainer *container, _viewSplitter->containers()) { | 608 | foreach (TabbedViewContainer *container, _viewSplitter->containers()) { | ||
651 | createView(session, container, index); | 609 | createView(session, container, index); | ||
652 | } | 610 | } | ||
653 | } | 611 | } | ||
654 | 612 | | |||
655 | ViewContainer *ViewManager::createContainer() | 613 | TabbedViewContainer *ViewManager::createContainer() | ||
656 | { | 614 | { | ||
657 | 615 | | |||
658 | auto *container = new TabbedViewContainer(_navigationPosition, this, _viewSplitter); | 616 | auto *container = new TabbedViewContainer(this, _viewSplitter); | ||
659 | if (_navigationMethod == TabbedNavigation) { | 617 | //TODO: Fix Detaching. | ||
660 | connect(container, &TabbedViewContainer::detachTab, this, &ViewManager::detachView); | 618 | // connect(container, &TabbedViewContainer::detachTab, this, &ViewManager::detachView); | ||
sandsmark: remove dead code? unless this breaks something and is a valid TODO | |||||
tcanabrava: invalid. forgot to remove. | |||||
661 | connect(container, &TabbedViewContainer::closeTab, this, | | |||
662 | &ViewManager::closeTabFromContainer); | | |||
663 | } | | |||
664 | | ||||
665 | // FIXME: these code feels duplicated | | |||
666 | container->setNavigationVisibility(_navigationVisibility); | | |||
667 | container->setNavigationPosition(_navigationPosition); | | |||
668 | container->setNavigationTabWidthExpanding(_navigationTabWidthExpanding); | | |||
669 | container->setStyleSheet(_navigationStyleSheet); | | |||
670 | setContainerFeatures(container); | | |||
671 | 619 | | |||
672 | // connect signals and slots | 620 | // connect signals and slots | ||
673 | connect(container, &Konsole::ViewContainer::viewAdded, this, | 621 | connect(container, &Konsole::TabbedViewContainer::viewAdded, this, | ||
674 | [this, container]() { | 622 | [this, container]() { | ||
675 | containerViewsChanged(container); | 623 | containerViewsChanged(container); | ||
676 | }); | 624 | }); | ||
677 | 625 | | |||
678 | connect(container, &Konsole::ViewContainer::viewRemoved, this, | 626 | connect(container, &Konsole::TabbedViewContainer::viewRemoved, this, | ||
679 | [this, container]() { | 627 | [this, container]() { | ||
680 | containerViewsChanged(container); | 628 | containerViewsChanged(container); | ||
681 | }); | 629 | }); | ||
682 | 630 | | |||
683 | connect(container, | 631 | connect(container, | ||
684 | static_cast<void (ViewContainer::*)()>(&Konsole::ViewContainer::newViewRequest), this, | 632 | static_cast<void (TabbedViewContainer::*)()>(&Konsole::TabbedViewContainer::newViewRequest), this, | ||
685 | static_cast<void (ViewManager::*)()>(&Konsole::ViewManager::newViewRequest)); | 633 | static_cast<void (ViewManager::*)()>(&Konsole::ViewManager::newViewRequest)); | ||
686 | connect(container, | 634 | connect(container, | ||
687 | static_cast<void (ViewContainer::*)(Profile::Ptr)>(&Konsole::ViewContainer::newViewRequest), | 635 | static_cast<void (TabbedViewContainer::*)(Profile::Ptr)>(&Konsole::TabbedViewContainer::newViewRequest), | ||
688 | this, | 636 | this, | ||
689 | static_cast<void (ViewManager::*)(Profile::Ptr)>(&Konsole::ViewManager::newViewRequest)); | 637 | static_cast<void (ViewManager::*)(Profile::Ptr)>(&Konsole::ViewManager::newViewRequest)); | ||
690 | connect(container, &Konsole::ViewContainer::moveViewRequest, this, | 638 | connect(container, &Konsole::TabbedViewContainer::moveViewRequest, this, | ||
691 | &Konsole::ViewManager::containerMoveViewRequest); | 639 | &Konsole::ViewManager::containerMoveViewRequest); | ||
692 | connect(container, &Konsole::ViewContainer::viewRemoved, this, | 640 | connect(container, &Konsole::TabbedViewContainer::viewRemoved, this, | ||
693 | &Konsole::ViewManager::viewDestroyed); | 641 | &Konsole::ViewManager::viewDestroyed); | ||
694 | connect(container, &Konsole::ViewContainer::activeViewChanged, this, | 642 | connect(container, &Konsole::TabbedViewContainer::activeViewChanged, this, | ||
695 | &Konsole::ViewManager::viewActivated); | 643 | &Konsole::ViewManager::viewActivated); | ||
696 | 644 | | |||
697 | if (_navigationMethod != TabbedNavigation) { | | |||
698 | container->setTabBarVisible(false); | | |||
sandsmark: this breaks something in the kpart, I think? | |||||
I'v tested the kpart manyally and did not found bugs. I'll recheck. tcanabrava: I'v tested the kpart manyally and did not found bugs. I'll recheck. | |||||
699 | } | | |||
700 | | ||||
701 | return container; | 645 | return container; | ||
702 | } | 646 | } | ||
703 | 647 | | |||
704 | void ViewManager::containerMoveViewRequest(int index, int id, bool &success, | 648 | void ViewManager::containerMoveViewRequest(int index, int id, bool &success, | ||
705 | TabbedViewContainer *sourceTabbedContainer) | 649 | TabbedViewContainer *sourceTabbedContainer) | ||
706 | { | 650 | { | ||
707 | ViewContainer *container = qobject_cast<ViewContainer *>(sender()); | 651 | TabbedViewContainer *container = qobject_cast<TabbedViewContainer *>(sender()); | ||
708 | SessionController *controller = qobject_cast<SessionController *>(ViewProperties::propertiesById(id)); | 652 | SessionController *controller = qobject_cast<SessionController *>(ViewProperties::propertiesById(id)); | ||
709 | 653 | | |||
710 | if (controller == nullptr) { | 654 | if (controller == nullptr) { | ||
711 | return; | 655 | return; | ||
712 | } | 656 | } | ||
713 | 657 | | |||
714 | // do not move the last tab in a split view. | 658 | // do not move the last tab in a split view. | ||
715 | if (sourceTabbedContainer != nullptr) { | 659 | if (sourceTabbedContainer != nullptr) { | ||
716 | QPointer<ViewContainer> sourceContainer = qobject_cast<ViewContainer *>(sourceTabbedContainer); | 660 | QPointer<TabbedViewContainer> sourceContainer = qobject_cast<TabbedViewContainer *>(sourceTabbedContainer); | ||
717 | 661 | | |||
718 | if (_viewSplitter->containers().contains(sourceContainer)) { | 662 | if (_viewSplitter->containers().contains(sourceContainer)) { | ||
719 | return; | 663 | return; | ||
720 | } else { | 664 | } else { | ||
721 | ViewManager *sourceViewManager = sourceTabbedContainer->connectedViewManager(); | 665 | ViewManager *sourceViewManager = sourceTabbedContainer->connectedViewManager(); | ||
722 | 666 | | |||
723 | // do not remove the last tab on the window | 667 | // do not remove the last tab on the window | ||
724 | if (qobject_cast<ViewSplitter *>(sourceViewManager->widget())->containers().size() > 1) { | 668 | if (qobject_cast<ViewSplitter *>(sourceViewManager->widget())->containers().size() > 1) { | ||
725 | return; | 669 | return; | ||
726 | } | 670 | } | ||
727 | } | 671 | } | ||
728 | } | 672 | } | ||
729 | 673 | | |||
730 | createView(controller->session(), container, index); | 674 | createView(controller->session(), container, index); | ||
731 | controller->session()->refresh(); | 675 | controller->session()->refresh(); | ||
732 | success = true; | 676 | success = true; | ||
733 | } | 677 | } | ||
734 | 678 | | |||
735 | void ViewManager::setNavigationMethod(NavigationMethod method) | 679 | void ViewManager::setNavigationMethod(NavigationMethod method) | ||
736 | { | 680 | { | ||
737 | Q_ASSERT(_actionCollection); | 681 | Q_ASSERT(_actionCollection); | ||
738 | if (_actionCollection == nullptr) { | 682 | if (_actionCollection == nullptr) { | ||
739 | return; | 683 | return; | ||
740 | } | 684 | } | ||
741 | _navigationMethod = method; | | |||
742 | | ||||
743 | KActionCollection *collection = _actionCollection; | 685 | KActionCollection *collection = _actionCollection; | ||
744 | 686 | | |||
745 | // FIXME: The following disables certain actions for the KPart that it | 687 | // FIXME: The following disables certain actions for the KPart that it | ||
746 | // doesn't actually have a use for, to avoid polluting the action/shortcut | 688 | // doesn't actually have a use for, to avoid polluting the action/shortcut | ||
747 | // namespace of an application using the KPart (otherwise, a shortcut may | 689 | // namespace of an application using the KPart (otherwise, a shortcut may | ||
748 | // be in use twice, and the user gets to see an "ambiguous shortcut over- | 690 | // be in use twice, and the user gets to see an "ambiguous shortcut over- | ||
749 | // load" error dialog). However, this approach sucks - it's the inverse of | 691 | // load" error dialog). However, this approach sucks - it's the inverse of | ||
750 | // what it should be. Rather than disabling actions not used by the KPart, | 692 | // what it should be. Rather than disabling actions not used by the KPart, | ||
751 | // a method should be devised to only enable those that are used, perhaps | 693 | // a method should be devised to only enable those that are used, perhaps | ||
752 | // by using a separate action collection. | 694 | // by using a separate action collection. | ||
753 | 695 | | |||
754 | const bool enable = (_navigationMethod != NoNavigation); | 696 | const bool enable = (method != NoNavigation); | ||
755 | 697 | | |||
756 | auto enableAction = [&enable, &collection](const QString& actionName) { | 698 | auto enableAction = [&enable, &collection](const QString& actionName) { | ||
757 | auto *action = collection->action(actionName); | 699 | auto *action = collection->action(actionName); | ||
758 | if (action != nullptr) { | 700 | if (action != nullptr) { | ||
759 | action->setEnabled(enable); | 701 | action->setEnabled(enable); | ||
760 | } | 702 | } | ||
761 | }; | 703 | }; | ||
762 | 704 | | |||
763 | enableAction(QStringLiteral("next-view")); | 705 | enableAction(QStringLiteral("next-view")); | ||
764 | enableAction(QStringLiteral("previous-view")); | 706 | enableAction(QStringLiteral("previous-view")); | ||
765 | enableAction(QStringLiteral("last-tab")); | 707 | enableAction(QStringLiteral("last-tab")); | ||
766 | enableAction(QStringLiteral("split-view-left-right")); | 708 | enableAction(QStringLiteral("split-view-left-right")); | ||
767 | enableAction(QStringLiteral("split-view-top-bottom")); | 709 | enableAction(QStringLiteral("split-view-top-bottom")); | ||
768 | enableAction(QStringLiteral("rename-session")); | 710 | enableAction(QStringLiteral("rename-session")); | ||
769 | enableAction(QStringLiteral("move-view-left")); | 711 | enableAction(QStringLiteral("move-view-left")); | ||
770 | enableAction(QStringLiteral("move-view-right")); | 712 | enableAction(QStringLiteral("move-view-right")); | ||
771 | } | 713 | } | ||
772 | 714 | | |||
773 | ViewManager::NavigationMethod ViewManager::navigationMethod() const | 715 | ViewManager::NavigationMethod ViewManager::navigationMethod() const | ||
774 | { | 716 | { | ||
775 | return _navigationMethod; | 717 | return _navigationMethod; | ||
776 | } | 718 | } | ||
777 | 719 | | |||
778 | void ViewManager::containerViewsChanged(ViewContainer *container) | 720 | void ViewManager::containerViewsChanged(TabbedViewContainer *container) | ||
779 | { | 721 | { | ||
780 | if ((!_viewSplitter.isNull()) && container == _viewSplitter->activeContainer()) { | 722 | if ((!_viewSplitter.isNull()) && container == _viewSplitter->activeContainer()) { | ||
781 | emit viewPropertiesChanged(viewProperties()); | 723 | emit viewPropertiesChanged(viewProperties()); | ||
782 | } | 724 | } | ||
783 | } | 725 | } | ||
784 | 726 | | |||
785 | void ViewManager::viewDestroyed(QWidget *view) | 727 | void ViewManager::viewDestroyed(QWidget *view) | ||
786 | { | 728 | { | ||
▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Line(s) | 860 | while (iter.hasNext()) { | |||
926 | } | 868 | } | ||
927 | } | 869 | } | ||
928 | } | 870 | } | ||
929 | 871 | | |||
930 | QList<ViewProperties *> ViewManager::viewProperties() const | 872 | QList<ViewProperties *> ViewManager::viewProperties() const | ||
931 | { | 873 | { | ||
932 | QList<ViewProperties *> list; | 874 | QList<ViewProperties *> list; | ||
933 | 875 | | |||
934 | ViewContainer *container = _viewSplitter->activeContainer(); | 876 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
935 | 877 | | |||
936 | Q_ASSERT(container); | 878 | Q_ASSERT(container); | ||
879 | list.reserve(container->count()); | ||||
937 | 880 | | |||
938 | foreach (QWidget *view, container->views()) { | 881 | for(int i = 0, end = container->count(); i < end; i++) { | ||
882 | auto view = container->widget(i); | ||||
939 | ViewProperties *properties = container->viewProperties(view); | 883 | ViewProperties *properties = container->viewProperties(view); | ||
940 | Q_ASSERT(properties); | 884 | Q_ASSERT(properties); | ||
941 | list << properties; | 885 | list << properties; | ||
942 | } | 886 | } | ||
943 | 887 | | |||
944 | return list; | 888 | return list; | ||
945 | } | 889 | } | ||
946 | 890 | | |||
947 | void ViewManager::saveSessions(KConfigGroup &group) | 891 | void ViewManager::saveSessions(KConfigGroup &group) | ||
948 | { | 892 | { | ||
949 | // find all unique session restore IDs | 893 | // find all unique session restore IDs | ||
950 | QList<int> ids; | 894 | QList<int> ids; | ||
951 | QSet<Session *> unique; | 895 | QSet<Session *> unique; | ||
896 | int tab = 1; | ||||
sandsmark: why was this moved so far up? | |||||
it seemed logic when I did, now I'm unsure. if requested I can put it back. tcanabrava: it seemed logic when I did, now I'm unsure. if requested I can put it back. | |||||
897 | | ||||
898 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||||
899 | ids.reserve(container->count()); | ||||
952 | 900 | | |||
953 | // first: sessions in the active container, preserving the order | 901 | // first: sessions in the active container, preserving the order | ||
954 | ViewContainer *container = _viewSplitter->activeContainer(); | | |||
955 | Q_ASSERT(container); | 902 | Q_ASSERT(container); | ||
956 | if (container == nullptr) { | 903 | if (container == nullptr) { | ||
957 | return; | 904 | return; | ||
958 | } | 905 | } | ||
959 | TerminalDisplay *activeview = qobject_cast<TerminalDisplay *>(container->activeView()); | | |||
960 | 906 | | |||
961 | QListIterator<QWidget *> viewIter(container->views()); | 907 | TerminalDisplay *activeview = qobject_cast<TerminalDisplay *>(container->currentWidget()); | ||
962 | int tab = 1; | 908 | for (int i = 0, end = container->count(); i < end; i++) { | ||
963 | while (viewIter.hasNext()) { | 909 | TerminalDisplay *view = qobject_cast<TerminalDisplay *>(container->widget(i)); | ||
964 | TerminalDisplay *view = qobject_cast<TerminalDisplay *>(viewIter.next()); | | |||
965 | Q_ASSERT(view); | 910 | Q_ASSERT(view); | ||
911 | | ||||
966 | Session *session = _sessionMap[view]; | 912 | Session *session = _sessionMap[view]; | ||
967 | ids << SessionManager::instance()->getRestoreId(session); | 913 | ids << SessionManager::instance()->getRestoreId(session); | ||
968 | unique.insert(session); | 914 | unique.insert(session); | ||
969 | if (view == activeview) { | 915 | if (view == activeview) { | ||
970 | group.writeEntry("Active", tab); | 916 | group.writeEntry("Active", tab); | ||
971 | } | 917 | } | ||
972 | tab++; | 918 | tab++; | ||
973 | } | 919 | } | ||
Show All 32 Lines | 951 | if (!session->isRunning()) { | |||
1006 | session->run(); | 952 | session->run(); | ||
1007 | } | 953 | } | ||
1008 | if (tab++ == activeTab) { | 954 | if (tab++ == activeTab) { | ||
1009 | display = qobject_cast<TerminalDisplay *>(activeView()); | 955 | display = qobject_cast<TerminalDisplay *>(activeView()); | ||
1010 | } | 956 | } | ||
1011 | } | 957 | } | ||
1012 | 958 | | |||
1013 | if (display != nullptr) { | 959 | if (display != nullptr) { | ||
1014 | _viewSplitter->activeContainer()->setActiveView(display); | 960 | _viewSplitter->activeContainer()->setCurrentWidget(display); | ||
1015 | display->setFocus(Qt::OtherFocusReason); | 961 | display->setFocus(Qt::OtherFocusReason); | ||
1016 | } | 962 | } | ||
1017 | 963 | | |||
1018 | if (ids.isEmpty()) { // Session file is unusable, start default Profile | 964 | if (ids.isEmpty()) { // Session file is unusable, start default Profile | ||
1019 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | 965 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | ||
1020 | Session *session = SessionManager::instance()->createSession(profile); | 966 | Session *session = SessionManager::instance()->createSession(profile); | ||
1021 | createView(session); | 967 | createView(session); | ||
1022 | if (!session->isRunning()) { | 968 | if (!session->isRunning()) { | ||
Show All 30 Lines | 992 | { | |||
1053 | return -1; | 999 | return -1; | ||
1054 | } | 1000 | } | ||
1055 | 1001 | | |||
1056 | void ViewManager::setCurrentSession(int sessionId) | 1002 | void ViewManager::setCurrentSession(int sessionId) | ||
1057 | { | 1003 | { | ||
1058 | QHash<TerminalDisplay *, Session *>::const_iterator i; | 1004 | QHash<TerminalDisplay *, Session *>::const_iterator i; | ||
1059 | for (i = _sessionMap.constBegin(); i != _sessionMap.constEnd(); ++i) { | 1005 | for (i = _sessionMap.constBegin(); i != _sessionMap.constEnd(); ++i) { | ||
1060 | if (i.value()->sessionId() == sessionId) { | 1006 | if (i.value()->sessionId() == sessionId) { | ||
1061 | ViewContainer *container = _viewSplitter->activeContainer(); | 1007 | TabbedViewContainer *container = _viewSplitter->activeContainer(); | ||
1062 | if (container != nullptr) { | 1008 | if (container != nullptr) { | ||
1063 | container->setActiveView(i.key()); | 1009 | container->setCurrentWidget(i.key()); | ||
1064 | } | 1010 | } | ||
1065 | } | 1011 | } | ||
1066 | } | 1012 | } | ||
1067 | } | 1013 | } | ||
1068 | 1014 | | |||
1069 | int ViewManager::newSession() | 1015 | int ViewManager::newSession() | ||
1070 | { | 1016 | { | ||
1071 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | 1017 | Profile::Ptr profile = ProfileManager::instance()->defaultProfile(); | ||
▲ Show 20 Lines • Show All 76 Lines • ▼ Show 20 Line(s) | |||||
1148 | { | 1094 | { | ||
1149 | moveActiveViewLeft(); | 1095 | moveActiveViewLeft(); | ||
1150 | } | 1096 | } | ||
1151 | 1097 | | |||
1152 | void ViewManager::moveSessionRight() | 1098 | void ViewManager::moveSessionRight() | ||
1153 | { | 1099 | { | ||
1154 | moveActiveViewRight(); | 1100 | moveActiveViewRight(); | ||
1155 | } | 1101 | } | ||
1156 | | ||||
1157 | void ViewManager::setTabWidthToText(bool useTextWidth) | | |||
1158 | { | | |||
1159 | ViewContainer *container = _viewSplitter->activeContainer(); | | |||
1160 | Q_ASSERT(container); | | |||
1161 | container->setNavigationTextMode(useTextWidth); | | |||
this breaks the «expand individual tab width to full window» option in settings -> configure konsole -> tabbar. sandsmark: this breaks the «expand individual tab width to full window» option in settings -> configure… | |||||
that's something I want to remove but I know some people use like that. I'm fixing it. tcanabrava: that's something I want to remove but I know some people use like that. I'm fixing it. | |||||
1162 | } | | |||
1163 | | ||||
1164 | void ViewManager::closeTabFromContainer(ViewContainer *container, QWidget *tab) | | |||
1165 | { | | |||
1166 | SessionController *controller = qobject_cast<SessionController *>(container->viewProperties(tab)); | | |||
1167 | Q_ASSERT(controller); | | |||
1168 | if (controller != nullptr) { | | |||
1169 | controller->closeSession(); | | |||
1170 | } | | |||
1171 | } | | |||
1172 | | ||||
1173 | void ViewManager::setNavigationVisibility(int visibility) | | |||
1174 | { | | |||
1175 | _navigationVisibility = static_cast<ViewContainer::NavigationVisibility>(visibility); | | |||
1176 | | ||||
1177 | foreach (ViewContainer *container, _viewSplitter->containers()) { | | |||
1178 | container->setNavigationVisibility(_navigationVisibility); | | |||
1179 | } | | |||
1180 | } | | |||
1181 | | ||||
1182 | void ViewManager::setNavigationPosition(int position) | | |||
1183 | { | | |||
1184 | _navigationPosition = static_cast<ViewContainer::NavigationPosition>(position); | | |||
1185 | | ||||
1186 | foreach (ViewContainer *container, _viewSplitter->containers()) { | | |||
1187 | Q_ASSERT(container->supportedNavigationPositions().contains(_navigationPosition)); | | |||
1188 | container->setNavigationPosition(_navigationPosition); | | |||
1189 | } | | |||
1190 | } | | |||
1191 | | ||||
1192 | void ViewManager::setNavigationTabWidthExpanding(bool expand) | | |||
1193 | { | | |||
1194 | _navigationTabWidthExpanding = expand; | | |||
1195 | | ||||
1196 | foreach (ViewContainer *container, _viewSplitter->containers()) { | | |||
1197 | container->setNavigationTabWidthExpanding(expand); | | |||
1198 | } | | |||
1199 | } | | |||
1200 | | ||||
1201 | void ViewManager::setNavigationStyleSheet(const QString &styleSheet) | | |||
1202 | { | | |||
1203 | _navigationStyleSheet = styleSheet; | | |||
1204 | | ||||
1205 | foreach (ViewContainer *container, _viewSplitter->containers()) { | | |||
1206 | container->setStyleSheet(_navigationStyleSheet); | | |||
1207 | } | | |||
1208 | } | | |||
1209 | | ||||
1210 | void ViewManager::setContainerFeatures(ViewContainer *container) | | |||
1211 | { | | |||
1212 | if (_showQuickButtons) { | | |||
1213 | container->setFeatures(container->features() | | |||
1214 | | ViewContainer::QuickNewView | | |||
1215 | | ViewContainer::QuickCloseView); | | |||
1216 | } else { | | |||
1217 | container->setFeatures(container->features() | | |||
1218 | & ~ViewContainer::QuickNewView | | |||
1219 | & ~ViewContainer::QuickCloseView); | | |||
1220 | } | | |||
1221 | } | | |||
1222 | void ViewManager::setShowQuickButtons(bool show) | | |||
1223 | { | | |||
1224 | _showQuickButtons = show; | | |||
1225 | | ||||
1226 | for (auto *container : _viewSplitter->containers()) { | | |||
1227 | setContainerFeatures(container); | | |||
1228 | } | | |||
1229 | } | | |||
1230 | | ||||
1231 | void ViewManager::setNavigationBehavior(int behavior) | | |||
1232 | { | | |||
1233 | _newTabBehavior = static_cast<NewTabBehavior>(behavior); | | |||
1234 | } | |
remove dead code? unless this breaks something and is a valid TODO