Changeset View
Changeset View
Standalone View
Standalone View
src/ViewContainer.cpp
Show First 20 Lines • Show All 53 Lines • ▼ Show 20 Line(s) | |||||
54 | using namespace Konsole; | 54 | using namespace Konsole; | ||
55 | 55 | | |||
56 | ViewContainer::ViewContainer(NavigationPosition position, QObject *parent) : | 56 | ViewContainer::ViewContainer(NavigationPosition position, QObject *parent) : | ||
57 | QObject(parent), | 57 | QObject(parent), | ||
58 | _navigationVisibility(AlwaysShowNavigation), | 58 | _navigationVisibility(AlwaysShowNavigation), | ||
59 | _navigationPosition(position), | 59 | _navigationPosition(position), | ||
60 | _views(QList<QWidget *>()), | 60 | _views(QList<QWidget *>()), | ||
61 | _navigation(QHash<QWidget *, ViewProperties *>()), | 61 | _navigation(QHash<QWidget *, ViewProperties *>()), | ||
62 | _features(nullptr), | 62 | _features(nullptr) | ||
63 | _searchBar(nullptr) | | |||
64 | { | 63 | { | ||
65 | } | 64 | } | ||
66 | 65 | | |||
67 | ViewContainer::~ViewContainer() | 66 | ViewContainer::~ViewContainer() | ||
68 | { | 67 | { | ||
69 | foreach (QWidget *view, _views) { | 68 | foreach (QWidget *view, _views) { | ||
70 | disconnect(view, &QWidget::destroyed, this, &Konsole::ViewContainer::viewDestroyed); | 69 | disconnect(view, &QWidget::destroyed, this, &Konsole::ViewContainer::viewDestroyed); | ||
71 | } | 70 | } | ||
72 | 71 | | |||
73 | if (_searchBar != nullptr) { | | |||
74 | _searchBar->deleteLater(); | | |||
75 | } | | |||
76 | | ||||
77 | emit destroyed(this); | 72 | emit destroyed(this); | ||
78 | } | 73 | } | ||
79 | 74 | | |||
80 | void ViewContainer::moveViewWidget(int, int) | 75 | void ViewContainer::moveViewWidget(int, int) | ||
81 | { | 76 | { | ||
82 | } | 77 | } | ||
83 | 78 | | |||
84 | void ViewContainer::setFeatures(Features features) | 79 | void ViewContainer::setFeatures(Features features) | ||
▲ Show 20 Lines • Show All 112 Lines • ▼ Show 20 Line(s) | 189 | { | |||
197 | forgetView(view); | 192 | forgetView(view); | ||
198 | } | 193 | } | ||
199 | 194 | | |||
200 | const QList<QWidget *> ViewContainer::views() const | 195 | const QList<QWidget *> ViewContainer::views() const | ||
201 | { | 196 | { | ||
202 | return _views; | 197 | return _views; | ||
203 | } | 198 | } | ||
204 | 199 | | |||
205 | IncrementalSearchBar *ViewContainer::searchBar() | | |||
206 | { | | |||
207 | if (_searchBar == nullptr) { | | |||
208 | _searchBar = new IncrementalSearchBar(nullptr); | | |||
209 | _searchBar->setVisible(false); | | |||
210 | connect(_searchBar, &Konsole::IncrementalSearchBar::destroyed, this, | | |||
211 | &Konsole::ViewContainer::searchBarDestroyed); | | |||
212 | } | | |||
213 | return _searchBar; | | |||
214 | } | | |||
215 | | ||||
216 | void ViewContainer::searchBarDestroyed() | | |||
217 | { | | |||
218 | _searchBar = nullptr; | | |||
219 | } | | |||
220 | 200 | | |||
221 | void ViewContainer::activateNextView() | 201 | void ViewContainer::activateNextView() | ||
222 | { | 202 | { | ||
223 | QWidget *active = activeView(); | 203 | QWidget *active = activeView(); | ||
224 | 204 | | |||
225 | int index = _views.indexOf(active); | 205 | int index = _views.indexOf(active); | ||
226 | 206 | | |||
227 | if (index == -1) { | 207 | if (index == -1) { | ||
▲ Show 20 Lines • Show All 149 Lines • ▼ Show 20 Line(s) | 310 | #endif | |||
377 | // Combine tab bar and 'new/close tab' buttons | 357 | // Combine tab bar and 'new/close tab' buttons | ||
378 | _tabBarLayout = new QHBoxLayout; | 358 | _tabBarLayout = new QHBoxLayout; | ||
379 | _tabBarLayout->setSpacing(0); | 359 | _tabBarLayout->setSpacing(0); | ||
380 | _tabBarLayout->setContentsMargins(0, 0, 0, 0); | 360 | _tabBarLayout->setContentsMargins(0, 0, 0, 0); | ||
381 | _tabBarLayout->addWidget(_newTabButton); | 361 | _tabBarLayout->addWidget(_newTabButton); | ||
382 | _tabBarLayout->addWidget(_tabBar); | 362 | _tabBarLayout->addWidget(_tabBar); | ||
383 | _tabBarLayout->addWidget(_closeTabButton); | 363 | _tabBarLayout->addWidget(_closeTabButton); | ||
384 | 364 | | |||
385 | // The search bar | | |||
386 | searchBar()->setParent(_containerWidget); | | |||
387 | | ||||
388 | // The overall layout | 365 | // The overall layout | ||
389 | _layout = new QVBoxLayout; | 366 | _layout = new QVBoxLayout; | ||
390 | _layout->setSpacing(0); | 367 | _layout->setSpacing(0); | ||
391 | _layout->setContentsMargins(0, 0, 0, 0); | 368 | _layout->setContentsMargins(0, 0, 0, 0); | ||
392 | 369 | | |||
393 | setNavigationPosition(position); | 370 | setNavigationPosition(position); | ||
394 | 371 | | |||
395 | _containerWidget->setLayout(_layout); | 372 | _containerWidget->setLayout(_layout); | ||
Show All 37 Lines | |||||
433 | 410 | | |||
434 | QList<ViewContainer::NavigationPosition> TabbedViewContainer::supportedNavigationPositions() const | 411 | QList<ViewContainer::NavigationPosition> TabbedViewContainer::supportedNavigationPositions() const | ||
435 | { | 412 | { | ||
436 | return QList<NavigationPosition>() << NavigationPositionTop << NavigationPositionBottom; | 413 | return QList<NavigationPosition>() << NavigationPositionTop << NavigationPositionBottom; | ||
437 | } | 414 | } | ||
438 | 415 | | |||
439 | void TabbedViewContainer::navigationPositionChanged(NavigationPosition position) | 416 | void TabbedViewContainer::navigationPositionChanged(NavigationPosition position) | ||
440 | { | 417 | { | ||
441 | // this method assumes that there are three or zero items in the layout | 418 | // this method assumes that there are two or zero items in the layout | ||
442 | Q_ASSERT(_layout->count() == 3 || _layout->count() == 0); | 419 | Q_ASSERT(_layout->count() == 2 || _layout->count() == 0); | ||
443 | 420 | | |||
444 | // clear all existing items from the layout | 421 | // clear all existing items from the layout | ||
445 | _layout->removeItem(_tabBarLayout); | 422 | _layout->removeItem(_tabBarLayout); | ||
446 | _tabBarLayout->setParent(nullptr); // suppress the warning of "already has a parent" | 423 | _tabBarLayout->setParent(nullptr); // suppress the warning of "already has a parent" | ||
447 | _layout->removeWidget(_stackWidget); | 424 | _layout->removeWidget(_stackWidget); | ||
448 | _layout->removeWidget(searchBar()); | | |||
449 | 425 | | |||
450 | if (position == NavigationPositionTop) { | 426 | if (position == NavigationPositionTop) { | ||
451 | _layout->insertLayout(-1, _tabBarLayout); | 427 | _layout->insertLayout(-1, _tabBarLayout); | ||
452 | _layout->insertWidget(-1, _stackWidget); | 428 | _layout->insertWidget(-1, _stackWidget); | ||
453 | _layout->insertWidget(-1, searchBar()); | | |||
454 | _tabBar->setShape(QTabBar::RoundedNorth); | 429 | _tabBar->setShape(QTabBar::RoundedNorth); | ||
455 | } else if (position == NavigationPositionBottom) { | 430 | } else /* if (position == NavigationPositionBottom) */ { | ||
456 | _layout->insertWidget(-1, _stackWidget); | 431 | _layout->insertWidget(-1, _stackWidget); | ||
457 | _layout->insertWidget(-1, searchBar()); | | |||
458 | _layout->insertLayout(-1, _tabBarLayout); | 432 | _layout->insertLayout(-1, _tabBarLayout); | ||
459 | _tabBar->setShape(QTabBar::RoundedSouth); | 433 | _tabBar->setShape(QTabBar::RoundedSouth); | ||
460 | } else { | | |||
461 | Q_ASSERT(false); // should never reach here | | |||
462 | } | 434 | } | ||
463 | } | 435 | } | ||
464 | 436 | | |||
465 | void TabbedViewContainer::navigationTabWidthExpandingChanged(bool expand) | 437 | void TabbedViewContainer::navigationTabWidthExpandingChanged(bool expand) | ||
466 | { | 438 | { | ||
467 | _tabBar->setExpanding(expand); | 439 | _tabBar->setExpanding(expand); | ||
468 | } | 440 | } | ||
469 | 441 | | |||
▲ Show 20 Lines • Show All 363 Lines • Show Last 20 Lines |