diff --git a/src/Application.h b/src/Application.h --- a/src/Application.h +++ b/src/Application.h @@ -88,7 +88,6 @@ Profile::Ptr processProfileChangeArgs(Profile::Ptr baseProfile); bool processTabsFromFileArgs(MainWindow *window); void createTabFromArgs(MainWindow *window, const QHash &); - void finalizeNewMainWindow(MainWindow *window); MainWindow *_backgroundInstance; QSharedPointer m_parser; diff --git a/src/Application.cpp b/src/Application.cpp --- a/src/Application.cpp +++ b/src/Application.cpp @@ -176,7 +176,7 @@ { MainWindow *window = newMainWindow(); window->createSession(profile, directory); - finalizeNewMainWindow(window); + window->show(); } void Application::detachView(Session *session) @@ -238,26 +238,7 @@ if (m_parser->isSet(QStringLiteral("background-mode"))) { startBackgroundMode(window); } else { - // Qt constrains top-level windows which have not been manually - // resized (via QWidget::resize()) to a maximum of 2/3rds of the - // screen size. - // - // This means that the terminal display might not get the width/ - // height it asks for. To work around this, the widget must be - // manually resized to its sizeHint(). - // - // This problem only affects the first time the application is run. - // run. After that KMainWindow will have manually resized the - // window to its saved size at this point (so the Qt::WA_Resized - // attribute will be set) - - // If not restoring size from last time or only adding new tab, - // resize window to chosen profile size (see Bug:345403) - if (createdNewMainWindow) { - finalizeNewMainWindow(window); - } else { - window->show(); - } + window->show(); } return 1; @@ -381,6 +362,8 @@ } if (!window->testAttribute(Qt::WA_Resized)) { + qDebug() << window->sizeHint(); + window->resize(window->sizeHint()); } @@ -598,11 +581,3 @@ newInstance(); } - -void Application::finalizeNewMainWindow(MainWindow *window) -{ - if (!KonsoleSettings::saveGeometryOnExit()) { - window->resize(window->sizeHint()); - } - window->show(); -} diff --git a/src/IncrementalSearchBar.cpp b/src/IncrementalSearchBar.cpp --- a/src/IncrementalSearchBar.cpp +++ b/src/IncrementalSearchBar.cpp @@ -57,10 +57,10 @@ closeButton->setIcon(QIcon::fromTheme(QStringLiteral("dialog-close"))); connect(closeButton, &QToolButton::clicked, this, &Konsole::IncrementalSearchBar::closeClicked); - QLabel *findLabel = new QLabel(i18nc("@label:textbox", "Find:"), this); _searchEdit = new QLineEdit(this); _searchEdit->setClearButtonEnabled(true); _searchEdit->installEventFilter(this); + _searchEdit->setPlaceholderText(i18nc("@label:textbox", "Find:")); _searchEdit->setObjectName(QStringLiteral("search-edit")); _searchEdit->setToolTip(i18nc("@info:tooltip", "Enter the text to search for here")); @@ -83,42 +83,48 @@ _findNextButton = new QToolButton(this); _findNextButton->setObjectName(QStringLiteral("find-next-button")); _findNextButton->setText(i18nc("@action:button Go to the next phrase", "Next")); - _findNextButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + _findNextButton->setToolButtonStyle(Qt::ToolButtonIconOnly); + _findNextButton->setAutoRaise(true); + _findNextButton->setToolTip(i18nc("@info:tooltip", "Find the next match for the current search phrase")); connect(_findNextButton, &QToolButton::clicked, this, &Konsole::IncrementalSearchBar::findNextClicked); _findPreviousButton = new QToolButton(this); + _findPreviousButton->setAutoRaise(true); + _findPreviousButton->setObjectName(QStringLiteral("find-previous-button")); _findPreviousButton->setText(i18nc("@action:button Go to the previous phrase", "Previous")); - _findPreviousButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + _findPreviousButton->setToolButtonStyle(Qt::ToolButtonIconOnly); _findPreviousButton->setToolTip(i18nc("@info:tooltip", "Find the previous match for the current search phrase")); connect(_findPreviousButton, &QToolButton::clicked, this, &Konsole::IncrementalSearchBar::findPreviousClicked); _searchFromButton = new QToolButton(this); + _searchFromButton->setAutoRaise(true); + _searchFromButton->setObjectName(QStringLiteral("search-from-button")); connect(_searchFromButton, &QToolButton::clicked, this, &Konsole::IncrementalSearchBar::searchFromClicked); auto optionsButton = new QToolButton(this); optionsButton->setObjectName(QStringLiteral("find-options-button")); - optionsButton->setText(i18nc("@action:button Display options menu", "Options")); optionsButton->setCheckable(false); optionsButton->setPopupMode(QToolButton::InstantPopup); - optionsButton->setArrowType(Qt::DownArrow); - optionsButton->setToolButtonStyle(Qt::ToolButtonTextOnly); + optionsButton->setArrowType(Qt::NoArrow); + optionsButton->setToolButtonStyle(Qt::ToolButtonIconOnly); optionsButton->setToolTip(i18nc("@info:tooltip", "Display the options menu")); + optionsButton->setIcon(QIcon::fromTheme(QStringLiteral("configure"))); + optionsButton->setAutoRaise(true); - barLayout->addWidget(closeButton); - barLayout->addWidget(findLabel); barLayout->addWidget(_searchEdit); barLayout->addWidget(_findNextButton); barLayout->addWidget(_findPreviousButton); barLayout->addWidget(_searchFromButton); barLayout->addWidget(optionsButton); + barLayout->addWidget(closeButton); // Fill the options menu auto optionsMenu = new QMenu(this); @@ -151,11 +157,14 @@ updateButtonsAccordingToReverseSearchSetting(); setOptions(); - barLayout->addStretch(); - - barLayout->setContentsMargins(4, 4, 4, 4); + barLayout->setContentsMargins(0, 0, 0, 0); + barLayout->setMargin(0); + barLayout->setSpacing(0); setLayout(barLayout); + + adjustSize(); + setAutoFillBackground(true); } void IncrementalSearchBar::notifySearchChanged() @@ -167,17 +176,18 @@ { Q_ASSERT(_reverseSearch); if (_reverseSearch->isChecked()) { - _searchFromButton->setText(i18nc("@action:button Search from bottom", "From bottom")); _searchFromButton->setToolTip(i18nc("@info:tooltip", "Search for the current search phrase from the bottom")); - _findNextButton->setIcon(QIcon::fromTheme(QStringLiteral("go-up-search"))); - _findPreviousButton->setIcon(QIcon::fromTheme(QStringLiteral("go-down-search"))); + _searchFromButton->setIcon(QIcon::fromTheme(QStringLiteral("go-bottom"))); + _findNextButton->setIcon(QIcon::fromTheme(QStringLiteral("go-previous"))); + _findPreviousButton->setIcon(QIcon::fromTheme(QStringLiteral("go-next"))); } else { - _searchFromButton->setText(i18nc("@action:button Search from top", "From top")); _searchFromButton->setToolTip(i18nc("@info:tooltip", "Search for the current search phrase from the top")); - _findNextButton->setIcon(QIcon::fromTheme(QStringLiteral("go-down-search"))); - _findPreviousButton->setIcon(QIcon::fromTheme(QStringLiteral("go-up-search"))); + _findNextButton->setIcon(QIcon::fromTheme(QStringLiteral("go-next"))); + _findPreviousButton->setIcon(QIcon::fromTheme(QStringLiteral("go-previous"))); + _searchFromButton->setIcon(QIcon::fromTheme(QStringLiteral("go-top"))); + } } diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -227,8 +227,6 @@ if (controller->isValid()) { guiFactory()->removeClient(controller); } - - controller->setSearchBar(nullptr); } void MainWindow::activeViewChanged(SessionController *controller) @@ -259,9 +257,6 @@ controller->setShowMenuAction(_toggleMenuBarAction); guiFactory()->addClient(controller); - // set the current session's search bar - controller->setSearchBar(searchBar()); - // update session title to match newly activated session activeViewTitleChanged(controller); @@ -309,11 +304,6 @@ } } -IncrementalSearchBar *MainWindow::searchBar() const -{ - return _viewManager->searchBar(); -} - void MainWindow::setupActions() { KActionCollection *collection = actionCollection(); diff --git a/src/Part.cpp b/src/Part.cpp --- a/src/Part.cpp +++ b/src/Part.cpp @@ -243,11 +243,8 @@ const char *displaySignal = SIGNAL(overrideShortcutCheck(QKeyEvent*,bool&)); const char *partSlot = SLOT(overrideTerminalShortcut(QKeyEvent*,bool&)); - disconnect(controller->view(), displaySignal, this, partSlot); - connect(controller->view(), displaySignal, this, partSlot); - - // set the current session's search bar - controller->setSearchBar(_viewManager->searchBar()); + disconnect(controller->view()->terminalDisplay(), displaySignal, this, partSlot); + connect(controller->view()->terminalDisplay(), displaySignal, this, partSlot); _pluggedController = controller; } diff --git a/src/SessionController.h b/src/SessionController.h --- a/src/SessionController.h +++ b/src/SessionController.h @@ -56,7 +56,7 @@ class Session; class SessionGroup; class ScreenWindow; -class TerminalDisplay; +class TerminalWidget; class IncrementalSearchBar; class ProfileList; class RegExpFilter; @@ -101,7 +101,7 @@ /** * Constructs a new SessionController which operates on @p session and @p view. */ - SessionController(Session *session, TerminalDisplay *view, QObject *parent); + SessionController(Session *session, TerminalWidget *view, QObject *parent); ~SessionController() Q_DECL_OVERRIDE; /** Returns the session associated with this controller */ @@ -111,7 +111,7 @@ } /** Returns the view associated with this controller */ - QPointer view() + QPointer view() { return _view; } @@ -143,7 +143,7 @@ * show() method will be called. The SessionController will then connect to the search * bar's signals to update the search when the widget's controls are pressed. */ - void setSearchBar(IncrementalSearchBar *searchBar); + void setupSearchBar(); /** * see setSearchBar() */ @@ -325,7 +325,7 @@ void updateReadOnlyActionStates(); QPointer _session; - QPointer _view; + QPointer _view; SessionGroup *_copyToGroup; ProfileList *_profileList; @@ -348,7 +348,6 @@ int _searchStartLine; int _prevSearchResultLine; - QPointer _searchBar; KCodecAction *_codecAction; diff --git a/src/SessionController.cpp b/src/SessionController.cpp --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -92,7 +92,7 @@ QSet SessionController::_allControllers; int SessionController::_lastControllerId; -SessionController::SessionController(Session* session , TerminalDisplay* view, QObject* parent) +SessionController::SessionController(Session* session , TerminalWidget* view, QObject* parent) : ViewProperties(parent) , KXMLGUIClient() , _session(session) @@ -112,7 +112,6 @@ , _interactionTimer(nullptr) , _searchStartLine(0) , _prevSearchResultLine(0) - , _searchBar(nullptr) , _codecAction(nullptr) , _switchProfileMenu(nullptr) , _webSearchMenu(nullptr) @@ -147,8 +146,8 @@ setIdentifier(++_lastControllerId); sessionAttributeChanged(); - view->installEventFilter(this); - view->setSessionController(this); + view->terminalDisplay()->installEventFilter(this); + view->terminalDisplay()->setSessionController(this); // install filter on the view to highlight URLs and files updateFilterList(SessionManager::instance()->sessionProfile(_session)); @@ -160,10 +159,10 @@ connect(_session.data(), &Konsole::Session::resizeRequest, this, &Konsole::SessionController::sessionResizeRequest); // listen for popup menu requests - connect(_view.data(), &Konsole::TerminalDisplay::configureRequest, this, &Konsole::SessionController::showDisplayContextMenu); + connect(_view->terminalDisplay(), &Konsole::TerminalDisplay::configureRequest, this, &Konsole::SessionController::showDisplayContextMenu); // move view to newest output when keystrokes occur - connect(_view.data(), &Konsole::TerminalDisplay::keyPressedSignal, this, &Konsole::SessionController::trackOutput); + connect(_view->terminalDisplay(), &Konsole::TerminalDisplay::keyPressedSignal, this, &Konsole::SessionController::trackOutput); // listen to activity / silence notifications from session connect(_session.data(), &Konsole::Session::stateChanged, this, &Konsole::SessionController::sessionStateChanged); @@ -176,8 +175,8 @@ connect(_session.data() , &Konsole::Session::currentDirectoryChanged , this , &Konsole::SessionController::currentDirectoryChanged); // listen for color changes - connect(_session.data(), &Konsole::Session::changeBackgroundColorRequest, _view.data(), &Konsole::TerminalDisplay::setBackgroundColor); - connect(_session.data(), &Konsole::Session::changeForegroundColorRequest, _view.data(), &Konsole::TerminalDisplay::setForegroundColor); + connect(_session.data(), &Konsole::Session::changeBackgroundColorRequest, _view->terminalDisplay(), &Konsole::TerminalDisplay::setBackgroundColor); + connect(_session.data(), &Konsole::Session::changeForegroundColorRequest, _view->terminalDisplay(), &Konsole::TerminalDisplay::setForegroundColor); // update the title when the session starts connect(_session.data(), &Konsole::Session::started, this, &Konsole::SessionController::snapshot); @@ -190,8 +189,8 @@ connect(_session.data(), &Konsole::Session::zmodemUploadDetected, this, &Konsole::SessionController::zmodemUpload); // listen for flow control status changes - connect(_session.data(), &Konsole::Session::flowControlEnabledChanged, _view.data(), &Konsole::TerminalDisplay::setFlowControlWarningEnabled); - _view->setFlowControlWarningEnabled(_session->flowControlEnabled()); + connect(_session.data(), &Konsole::Session::flowControlEnabledChanged, _view->terminalDisplay(), &Konsole::TerminalDisplay::setFlowControlWarningEnabled); + _view->terminalDisplay()->setFlowControlWarningEnabled(_session->flowControlEnabled()); // take a snapshot of the session state every so often when // user activity occurs @@ -202,7 +201,7 @@ _interactionTimer->setSingleShot(true); _interactionTimer->setInterval(500); connect(_interactionTimer, &QTimer::timeout, this, &Konsole::SessionController::snapshot); - connect(_view.data(), &Konsole::TerminalDisplay::keyPressedSignal, this, &Konsole::SessionController::interactionHandler); + connect(_view->terminalDisplay(), &Konsole::TerminalDisplay::keyPressedSignal, this, &Konsole::SessionController::interactionHandler); // take a snapshot of the session state periodically in the background auto backgroundTimer = new QTimer(_session); @@ -221,31 +220,34 @@ // before outputting bookmark. _bookmarkValidProgramsToClear << QStringLiteral("bash") << QStringLiteral("fish") << QStringLiteral("sh"); _bookmarkValidProgramsToClear << QStringLiteral("tcsh") << QStringLiteral("zsh"); + + setupSearchBar(); } SessionController::~SessionController() { if (!_view.isNull()) { - _view->setScreenWindow(nullptr); + _view->terminalDisplay()->setScreenWindow(nullptr); } _allControllers.remove(this); if (!_editProfileDialog.isNull()) { delete _editProfileDialog.data(); } } + void SessionController::trackOutput(QKeyEvent* event) { - Q_ASSERT(_view->screenWindow()); + Q_ASSERT(_view->terminalDisplay()->screenWindow()); // Only jump to the bottom if the user actually typed something in, // not if the user e. g. just pressed a modifier. if (event->text().isEmpty() && (event->modifiers() != 0u)) { return; } - _view->screenWindow()->setTrackOutput(true); + _view->terminalDisplay()->screenWindow()->setTrackOutput(true); } void SessionController::interactionHandler() { @@ -460,7 +462,7 @@ void SessionController::sendBackgroundColor() { - const QColor c = _view->getBackgroundColor(); + const QColor c = _view->terminalDisplay()->getBackgroundColor(); _session->reportBackgroundColor(c); } @@ -475,7 +477,7 @@ bool SessionController::eventFilter(QObject* watched , QEvent* event) { - if (event->type() == QEvent::FocusIn && watched == _view) { + if (event->type() == QEvent::FocusIn && watched == _view->terminalDisplay()) { // notify the world that the view associated with this session has been focused // used by the view manager to update the title of the MainWindow widget containing the view emit focused(this); @@ -486,7 +488,7 @@ // first, disconnect any other views which are listening for bell signals from the session disconnect(_session.data(), &Konsole::Session::bellRequest, nullptr, nullptr); // second, connect the newly focused view to listen for the session's bell signal - connect(_session.data(), &Konsole::Session::bellRequest, _view.data(), &Konsole::TerminalDisplay::bell); + connect(_session.data(), &Konsole::Session::bellRequest, _view->terminalDisplay(), &Konsole::TerminalDisplay::bell); if ((_copyInputToAllTabsAction != nullptr) && _copyInputToAllTabsAction->isChecked()) { // A session with "Copy To All Tabs" has come into focus: @@ -503,39 +505,22 @@ return; } - _view->filterChain()->removeFilter(_searchFilter); + _view->terminalDisplay()->filterChain()->removeFilter(_searchFilter); delete _searchFilter; _searchFilter = nullptr; } -void SessionController::setSearchBar(IncrementalSearchBar* searchBar) +void SessionController::setupSearchBar() { - // disconnect the existing search bar - if (!_searchBar.isNull()) { - disconnect(this, nullptr, _searchBar, nullptr); - disconnect(_searchBar, nullptr, this, nullptr); - } + connect(_view->searchBar(), &Konsole::IncrementalSearchBar::unhandledMovementKeyPressed, this, &Konsole::SessionController::movementKeyFromSearchBarReceived); + connect(_view->searchBar(), &Konsole::IncrementalSearchBar::closeClicked, this, &Konsole::SessionController::searchClosed); + connect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchFromClicked, this, &Konsole::SessionController::searchFrom); + connect(_view->searchBar(), &Konsole::IncrementalSearchBar::findNextClicked, this, &Konsole::SessionController::findNextInHistory); + connect(_view->searchBar(), &Konsole::IncrementalSearchBar::findPreviousClicked, this, &Konsole::SessionController::findPreviousInHistory); + connect(_view->searchBar(), &Konsole::IncrementalSearchBar::highlightMatchesToggled , this , &Konsole::SessionController::highlightMatches); + connect(_view->searchBar(), &Konsole::IncrementalSearchBar::matchCaseToggled, this, &Konsole::SessionController::changeSearchMatch); + connect(_view->searchBar(), &Konsole::IncrementalSearchBar::matchRegExpToggled, this, &Konsole::SessionController::changeSearchMatch); - // connect new search bar - _searchBar = searchBar; - if (!_searchBar.isNull()) { - connect(_searchBar.data(), &Konsole::IncrementalSearchBar::unhandledMovementKeyPressed, this, &Konsole::SessionController::movementKeyFromSearchBarReceived); - connect(_searchBar.data(), &Konsole::IncrementalSearchBar::closeClicked, this, &Konsole::SessionController::searchClosed); - connect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchFromClicked, this, &Konsole::SessionController::searchFrom); - connect(_searchBar.data(), &Konsole::IncrementalSearchBar::findNextClicked, this, &Konsole::SessionController::findNextInHistory); - connect(_searchBar.data(), &Konsole::IncrementalSearchBar::findPreviousClicked, this, &Konsole::SessionController::findPreviousInHistory); - connect(_searchBar.data(), &Konsole::IncrementalSearchBar::highlightMatchesToggled , this , &Konsole::SessionController::highlightMatches); - connect(_searchBar.data(), &Konsole::IncrementalSearchBar::matchCaseToggled, this, &Konsole::SessionController::changeSearchMatch); - connect(_searchBar.data(), &Konsole::IncrementalSearchBar::matchRegExpToggled, this, &Konsole::SessionController::changeSearchMatch); - - // if the search bar was previously active - // then re-enter search mode - enableSearchBar(_isSearchBarEnabled); - } -} -IncrementalSearchBar* SessionController::searchBar() const -{ - return _searchBar; } void SessionController::setShowMenuAction(QAction* action) @@ -975,24 +960,24 @@ void SessionController::copy() { - _view->copyToClipboard(); + _view->terminalDisplay()->copyToClipboard(); } void SessionController::paste() { - _view->pasteFromClipboard(); + _view->terminalDisplay()->pasteFromClipboard(); } void SessionController::pasteFromX11Selection() { - _view->pasteFromX11Selection(); + _view->terminalDisplay()->pasteFromX11Selection(); } void SessionController::selectAll() { - _view->selectAll(); + _view->terminalDisplay()->selectAll(); } void SessionController::selectLine() { - _view->selectCurrentLine(); + _view->terminalDisplay()->selectCurrentLine(); } static const KXmlGuiWindow* findWindow(const QObject* object) { @@ -1143,22 +1128,22 @@ bool underlineFiles = profile->underlineFilesEnabled(); if (!underlineFiles && (_fileFilter != nullptr)) { - _view->filterChain()->removeFilter(_fileFilter); + _view->terminalDisplay()->filterChain()->removeFilter(_fileFilter); delete _fileFilter; _fileFilter = nullptr; } else if (underlineFiles && (_fileFilter == nullptr)) { _fileFilter = new FileFilter(_session); - _view->filterChain()->addFilter(_fileFilter); + _view->terminalDisplay()->filterChain()->addFilter(_fileFilter); } bool underlineLinks = profile->underlineLinksEnabled(); if (!underlineLinks && (_urlFilter != nullptr)) { - _view->filterChain()->removeFilter(_urlFilter); + _view->terminalDisplay()->filterChain()->removeFilter(_urlFilter); delete _urlFilter; _urlFilter = nullptr; } else if (underlineLinks && (_urlFilter == nullptr)) { _urlFilter = new UrlFilter(); - _view->filterChain()->addFilter(_urlFilter); + _view->terminalDisplay()->filterChain()->addFilter(_urlFilter); } } @@ -1179,77 +1164,76 @@ return; } - connect(_view->screenWindow(), &Konsole::ScreenWindow::outputChanged, this, &Konsole::SessionController::updateSearchFilter); - connect(_view->screenWindow(), &Konsole::ScreenWindow::scrolled, this, &Konsole::SessionController::updateSearchFilter); - connect(_view->screenWindow(), &Konsole::ScreenWindow::currentResultLineChanged, _view.data(), static_cast(&Konsole::TerminalDisplay::update)); + connect(_view->terminalDisplay()->screenWindow(), &Konsole::ScreenWindow::outputChanged, + this, &Konsole::SessionController::updateSearchFilter); + connect(_view->terminalDisplay()->screenWindow(), &Konsole::ScreenWindow::scrolled, + this, &Konsole::SessionController::updateSearchFilter); + connect(_view->terminalDisplay()->screenWindow(), &Konsole::ScreenWindow::currentResultLineChanged, + _view->terminalDisplay(), static_cast(&Konsole::TerminalDisplay::update)); _listenForScreenWindowUpdates = true; } void SessionController::updateSearchFilter() { - if ((_searchFilter != nullptr) && (!_searchBar.isNull())) { - _view->processFilters(); + if (_searchFilter != nullptr) { + _view->terminalDisplay()->processFilters(); } } void SessionController::searchBarEvent() { - QString selectedText = _view->screenWindow()->selectedText(Screen::PreserveLineBreaks | Screen::TrimLeadingWhitespace | Screen::TrimTrailingWhitespace); + QString selectedText = _view->terminalDisplay()->screenWindow()->selectedText( + Screen::PreserveLineBreaks | Screen::TrimLeadingWhitespace | Screen::TrimTrailingWhitespace); + if (!selectedText.isEmpty()) { - _searchBar->setSearchText(selectedText); + _view->searchBar()->setSearchText(selectedText); } - if (_searchBar->isVisible()) { - _searchBar->focusLineEdit(); + if (_view->searchBar()->isVisible()) { + _view->searchBar()->focusLineEdit(); } else { searchHistory(true); _isSearchBarEnabled = true; } } void SessionController::enableSearchBar(bool showSearchBar) { - if (_searchBar.isNull()) { - return; - } - - if (showSearchBar && !_searchBar->isVisible()) { + if (showSearchBar && !_view->searchBar()->isVisible()) { setSearchStartToWindowCurrentLine(); } - _searchBar->setVisible(showSearchBar); + _view->searchBar()->setVisible(showSearchBar); if (showSearchBar) { - connect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchChanged, this, &Konsole::SessionController::searchTextChanged); - connect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchReturnPressed, this, &Konsole::SessionController::findPreviousInHistory); - connect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchShiftPlusReturnPressed, this, &Konsole::SessionController::findNextInHistory); + connect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchChanged, this, &Konsole::SessionController::searchTextChanged); + connect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchReturnPressed, this, &Konsole::SessionController::findPreviousInHistory); + connect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchShiftPlusReturnPressed, this, &Konsole::SessionController::findNextInHistory); } else { - disconnect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchChanged, this, + disconnect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchChanged, this, &Konsole::SessionController::searchTextChanged); - disconnect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchReturnPressed, this, + disconnect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchReturnPressed, this, &Konsole::SessionController::findPreviousInHistory); - disconnect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchShiftPlusReturnPressed, this, + disconnect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchShiftPlusReturnPressed, this, &Konsole::SessionController::findNextInHistory); - if ((!_view.isNull()) && (_view->screenWindow() != nullptr)) { - _view->screenWindow()->setCurrentResultLine(-1); + if ((!_view.isNull()) && (_view->terminalDisplay()->screenWindow() != nullptr)) { + _view->terminalDisplay()->screenWindow()->setCurrentResultLine(-1); } } } bool SessionController::reverseSearchChecked() const { - Q_ASSERT(_searchBar); - - QBitArray options = _searchBar->optionsChecked(); + QBitArray options = _view->searchBar()->optionsChecked(); return options.at(IncrementalSearchBar::ReverseSearch); } QRegularExpression SessionController::regexpFromSearchBarOptions() const { - QBitArray options = _searchBar->optionsChecked(); + QBitArray options = _view->searchBar()->optionsChecked(); - QString text(_searchBar->searchText()); + QString text(_view->searchBar()->searchText()); QRegularExpression regExp; if (options.at(IncrementalSearchBar::RegExp)) { @@ -1270,27 +1254,23 @@ void SessionController::searchHistory(bool showSearchBar) { enableSearchBar(showSearchBar); + if (showSearchBar) { + removeSearchFilter(); - if (!_searchBar.isNull()) { - if (showSearchBar) { - removeSearchFilter(); - - listenForScreenWindowUpdates(); - - _searchFilter = new RegExpFilter(); - _searchFilter->setRegExp(regexpFromSearchBarOptions()); - _view->filterChain()->addFilter(_searchFilter); - _view->processFilters(); - - setFindNextPrevEnabled(true); - } else { - setFindNextPrevEnabled(false); + listenForScreenWindowUpdates(); - removeSearchFilter(); + _searchFilter = new RegExpFilter(); + _searchFilter->setRegExp(regexpFromSearchBarOptions()); + _view->terminalDisplay()->filterChain()->addFilter(_searchFilter); + _view->terminalDisplay()->processFilters(); - _view->setFocus(Qt::ActiveWindowFocusReason); - } + setFindNextPrevEnabled(true); + } else { + setFindNextPrevEnabled(false); + removeSearchFilter(); + _view->terminalDisplay()->setFocus(Qt::ActiveWindowFocusReason); } + } void SessionController::setFindNextPrevEnabled(bool enabled) @@ -1300,118 +1280,110 @@ } void SessionController::searchTextChanged(const QString& text) { - Q_ASSERT(_view->screenWindow()); + Q_ASSERT(_view->terminalDisplay()->screenWindow()); if (_searchText == text) { return; } _searchText = text; if (text.isEmpty()) { - _view->screenWindow()->clearSelection(); - _view->screenWindow()->scrollTo(_searchStartLine); + _view->terminalDisplay()->screenWindow()->clearSelection(); + _view->terminalDisplay()->screenWindow()->scrollTo(_searchStartLine); } // update search. this is called even when the text is // empty to clear the view's filters beginSearch(text , reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); } void SessionController::searchCompleted(bool success) { - _prevSearchResultLine = _view->screenWindow()->currentResultLine(); - - if (!_searchBar.isNull()) { - _searchBar->setFoundMatch(success); - } + _prevSearchResultLine = _view->terminalDisplay()->screenWindow()->currentResultLine(); + _view->searchBar()->setFoundMatch(success); } void SessionController::beginSearch(const QString& text, Enum::SearchDirection direction) { - Q_ASSERT(_searchBar); Q_ASSERT(_searchFilter); QRegularExpression regExp = regexpFromSearchBarOptions(); _searchFilter->setRegExp(regExp); if (_searchStartLine == -1) { if (direction == Enum::ForwardsSearch) { - setSearchStartTo(_view->screenWindow()->currentLine()); + setSearchStartTo(_view->terminalDisplay()->screenWindow()->currentLine()); } else { - setSearchStartTo(_view->screenWindow()->currentLine() + _view->screenWindow()->windowLines()); + setSearchStartTo(_view->terminalDisplay()->screenWindow()->currentLine() + _view->terminalDisplay()->screenWindow()->windowLines()); } } if (!regExp.pattern().isEmpty()) { - _view->screenWindow()->setCurrentResultLine(-1); + _view->terminalDisplay()->screenWindow()->setCurrentResultLine(-1); auto task = new SearchHistoryTask(this); connect(task, &Konsole::SearchHistoryTask::completed, this, &Konsole::SessionController::searchCompleted); task->setRegExp(regExp); task->setSearchDirection(direction); task->setAutoDelete(true); task->setStartLine(_searchStartLine); - task->addScreenWindow(_session , _view->screenWindow()); + task->addScreenWindow(_session , _view->terminalDisplay()->screenWindow()); task->execute(); } else if (text.isEmpty()) { searchCompleted(false); } - _view->processFilters(); + _view->terminalDisplay()->processFilters(); } void SessionController::highlightMatches(bool highlight) { if (highlight) { - _view->filterChain()->addFilter(_searchFilter); - _view->processFilters(); + _view->terminalDisplay()->filterChain()->addFilter(_searchFilter); + _view->terminalDisplay()->processFilters(); } else { - _view->filterChain()->removeFilter(_searchFilter); + _view->terminalDisplay()->filterChain()->removeFilter(_searchFilter); } - _view->update(); + _view->terminalDisplay()->update(); } void SessionController::searchFrom() { - Q_ASSERT(_searchBar); Q_ASSERT(_searchFilter); if (reverseSearchChecked()) { - setSearchStartTo(_view->screenWindow()->lineCount()); + setSearchStartTo(_view->terminalDisplay()->screenWindow()->lineCount()); } else { setSearchStartTo(0); } - beginSearch(_searchBar->searchText(), reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); + beginSearch(_view->searchBar()->searchText(), reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); } void SessionController::findNextInHistory() { - Q_ASSERT(_searchBar); Q_ASSERT(_searchFilter); setSearchStartTo(_prevSearchResultLine); - beginSearch(_searchBar->searchText(), reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); + beginSearch(_view->searchBar()->searchText(), reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); } void SessionController::findPreviousInHistory() { - Q_ASSERT(_searchBar); Q_ASSERT(_searchFilter); setSearchStartTo(_prevSearchResultLine); - beginSearch(_searchBar->searchText(), reverseSearchChecked() ? Enum::ForwardsSearch : Enum::BackwardsSearch); + beginSearch(_view->searchBar()->searchText(), reverseSearchChecked() ? Enum::ForwardsSearch : Enum::BackwardsSearch); } void SessionController::changeSearchMatch() { - Q_ASSERT(_searchBar); Q_ASSERT(_searchFilter); // reset Selection for new case match - _view->screenWindow()->clearSelection(); - beginSearch(_searchBar->searchText(), reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); + _view->terminalDisplay()->screenWindow()->clearSelection(); + beginSearch(_view->searchBar()->searchText(), reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); } void SessionController::showHistoryOptions() { @@ -1442,7 +1414,7 @@ void SessionController::sessionResizeRequest(const QSize& size) { ////qDebug() << "View resize requested to " << size; - _view->setSize(size.width(), size.height()); + _view->terminalDisplay()->setSize(size.width(), size.height()); } void SessionController::scrollBackOptionsChanged(int mode, int lines) { @@ -1484,7 +1456,7 @@ painter.scale(scale, scale); } - _view->printContent(painter, configGroup.readEntry("PrinterFriendly", true)); + _view->terminalDisplay()->printContent(painter, configGroup.readEntry("PrinterFriendly", true)); } void SessionController::saveHistory() @@ -1498,7 +1470,7 @@ void SessionController::clearHistory() { _session->clearHistory(); - _view->updateImage(); // To reset view scrollbar + _view->terminalDisplay()->updateImage(); // To reset view scrollbar } void SessionController::clearHistoryAndReset() @@ -1515,12 +1487,12 @@ void SessionController::increaseFontSize() { - _view->increaseFontSize(); + _view->terminalDisplay()->increaseFontSize(); } void SessionController::decreaseFontSize() { - _view->decreaseFontSize(); + _view->terminalDisplay()->decreaseFontSize(); } void SessionController::monitorActivity(bool monitor) @@ -1574,7 +1546,7 @@ // Without the timer, when detaching a tab while the message widget is visible, // the size of the terminal becomes really small... QTimer::singleShot(0, this, [this, readonly]() { - _view->updateReadOnlyState(readonly); + _view->terminalDisplay()->updateReadOnlyState(readonly); }); } @@ -1620,7 +1592,7 @@ // Update all views for (TerminalDisplay* view : session()->views()) { - if (view != _view.data()) { + if (view != _view->terminalDisplay()) { view->updateReadOnlyState(isReadOnly()); } } @@ -1632,7 +1604,7 @@ // application did not merge our GUI. if (factory() == nullptr) { if (clientBuilder() == nullptr) { - setClientBuilder(new KXMLGUIBuilder(_view)); + setClientBuilder(new KXMLGUIBuilder(_view->terminalDisplay())); } auto factory = new KXMLGUIFactory(clientBuilder(), this); @@ -1645,7 +1617,7 @@ updateReadOnlyActionStates(); // prepend content-specific actions such as "Open Link", "Copy Email Address" etc. - QList contentActions = _view->filterActions(position); + QList contentActions = _view->terminalDisplay()->filterActions(position); auto contentSeparator = new QAction(popup); contentSeparator->setSeparator(true); contentActions << contentSeparator; diff --git a/src/TerminalDisplay.h b/src/TerminalDisplay.h --- a/src/TerminalDisplay.h +++ b/src/TerminalDisplay.h @@ -53,6 +53,8 @@ class FilterChain; class TerminalImageFilterChain; class SessionController; +class IncrementalSearchBar; + /** * A widget which displays output from a terminal emulation and sends input keypresses and mouse activity * to the terminal. @@ -75,6 +77,8 @@ const ColorEntry *colorTable() const; /** Sets the terminal color palette used by the display. */ void setColorTable(const ColorEntry table[]); + + QScrollBar *scrollBar() const; /** * Sets the seed used to generate random colors for the display * (in color schemes that support them). @@ -1073,6 +1077,24 @@ int _timerId; }; + +class KONSOLEPRIVATE_EXPORT TerminalWidget : public QWidget { + Q_OBJECT +public: + TerminalWidget(int sessionId, QWidget *parent = nullptr); + TerminalDisplay *terminalDisplay() const; + IncrementalSearchBar *searchBar() const; + QSize sizeHint() const override; + +protected: + void repositionSearchBar(QSize windowSize); + void resizeEvent(QResizeEvent *event) override; + void focusInEvent(QFocusEvent *event) override; +private: + TerminalDisplay *_terminalDisplay; + IncrementalSearchBar *_searchBar; +}; + } #endif // TERMINALDISPLAY_H diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -71,6 +71,7 @@ #include "SessionManager.h" #include "Session.h" #include "WindowSystemInfo.h" +#include "IncrementalSearchBar.h" using namespace Konsole; @@ -109,6 +110,7 @@ { return _screenWindow; } + void TerminalDisplay::setScreenWindow(ScreenWindow* window) { // disconnect existing screen window if any @@ -489,7 +491,6 @@ // Add the stretch item once, the KMessageWidgets are inserted at index 0. _verticalLayout->addStretch(); _verticalLayout->setSpacing(0); - setLayout(_verticalLayout); // Take the scrollbar into account and add a margin to the layout. Without the timer the scrollbar width @@ -3935,3 +3936,53 @@ return false; } +QScrollBar *TerminalDisplay::scrollBar() const { + return _scrollBar; +} + +TerminalWidget::TerminalWidget(int sessionId, QWidget *parent) : + QWidget(parent), + _terminalDisplay(new TerminalDisplay(this)), + _searchBar(new IncrementalSearchBar(this)) +{ + _searchBar->setVisible(false); + + auto *vLayout = new QVBoxLayout(); + vLayout->addWidget(_terminalDisplay); + vLayout->setSpacing(0); + vLayout->setMargin(0); + setLayout(vLayout); + _terminalDisplay->setRandomSeed(sessionId * 31); + adjustSize(); + repositionSearchBar(geometry().size()); +} + +void TerminalWidget::repositionSearchBar(QSize size) +{ + const auto width = _searchBar->geometry().width(); + const auto height = _searchBar->geometry().height(); + const auto x = size.width() - width - _terminalDisplay->scrollBar()->geometry().width(); + _searchBar->setGeometry(x, 0, width, height); +} + +void TerminalWidget::focusInEvent(QFocusEvent *event) +{ + _terminalDisplay->setFocus(); +} + +void TerminalWidget::resizeEvent(QResizeEvent *event) +{ + repositionSearchBar(event->size()); +} + +QSize TerminalWidget::sizeHint() const { + return _terminalDisplay->sizeHint(); +} + +TerminalDisplay *TerminalWidget::terminalDisplay() const { + return _terminalDisplay; +} + +IncrementalSearchBar *TerminalWidget::searchBar() const { + return _searchBar; +} diff --git a/src/ViewContainer.h b/src/ViewContainer.h --- a/src/ViewContainer.h +++ b/src/ViewContainer.h @@ -202,11 +202,6 @@ */ virtual void setActiveView(QWidget *widget) = 0; - /** - * @return the search widget for this view - */ - IncrementalSearchBar *searchBar(); - /** Changes the active view to the next view */ void activateNextView(); @@ -361,7 +356,6 @@ private Q_SLOTS: void viewDestroyed(QObject *view); - void searchBarDestroyed(); private: Q_DISABLE_COPY(ViewContainer) diff --git a/src/ViewContainer.cpp b/src/ViewContainer.cpp --- a/src/ViewContainer.cpp +++ b/src/ViewContainer.cpp @@ -59,8 +59,7 @@ _navigationPosition(position), _views(QList()), _navigation(QHash()), - _features(nullptr), - _searchBar(nullptr) + _features(nullptr) { } @@ -70,10 +69,6 @@ disconnect(view, &QWidget::destroyed, this, &Konsole::ViewContainer::viewDestroyed); } - if (_searchBar != nullptr) { - _searchBar->deleteLater(); - } - emit destroyed(this); } @@ -202,21 +197,6 @@ return _views; } -IncrementalSearchBar *ViewContainer::searchBar() -{ - if (_searchBar == nullptr) { - _searchBar = new IncrementalSearchBar(nullptr); - _searchBar->setVisible(false); - connect(_searchBar, &Konsole::IncrementalSearchBar::destroyed, this, - &Konsole::ViewContainer::searchBarDestroyed); - } - return _searchBar; -} - -void ViewContainer::searchBarDestroyed() -{ - _searchBar = nullptr; -} void ViewContainer::activateNextView() { @@ -382,9 +362,6 @@ _tabBarLayout->addWidget(_tabBar); _tabBarLayout->addWidget(_closeTabButton); - // The search bar - searchBar()->setParent(_containerWidget); - // The overall layout _layout = new QVBoxLayout; _layout->setSpacing(0); @@ -438,27 +415,22 @@ void TabbedViewContainer::navigationPositionChanged(NavigationPosition position) { - // this method assumes that there are three or zero items in the layout - Q_ASSERT(_layout->count() == 3 || _layout->count() == 0); + // this method assumes that there are two or zero items in the layout + Q_ASSERT(_layout->count() == 2 || _layout->count() == 0); // clear all existing items from the layout _layout->removeItem(_tabBarLayout); _tabBarLayout->setParent(nullptr); // suppress the warning of "already has a parent" _layout->removeWidget(_stackWidget); - _layout->removeWidget(searchBar()); if (position == NavigationPositionTop) { _layout->insertLayout(-1, _tabBarLayout); _layout->insertWidget(-1, _stackWidget); - _layout->insertWidget(-1, searchBar()); _tabBar->setShape(QTabBar::RoundedNorth); - } else if (position == NavigationPositionBottom) { + } else /* if (position == NavigationPositionBottom) */ { _layout->insertWidget(-1, _stackWidget); - _layout->insertWidget(-1, searchBar()); _layout->insertLayout(-1, _tabBarLayout); _tabBar->setShape(QTabBar::RoundedSouth); - } else { - Q_ASSERT(false); // should never reach here } } diff --git a/src/ViewManager.h b/src/ViewManager.h --- a/src/ViewManager.h +++ b/src/ViewManager.h @@ -37,7 +37,7 @@ class IncrementalSearchBar; class Session; class TerminalDisplay; - +class TerminalWidget; class SessionController; class ViewProperties; class ViewSplitter; @@ -153,11 +153,6 @@ */ SessionController *activeViewController() const; - /** - * Returns the search bar. - */ - IncrementalSearchBar *searchBar() const; - /** * Session management */ @@ -386,15 +381,10 @@ // removes a container and emits appropriate signals void removeContainer(ViewContainer *container); - // creates a new terminal display - // the 'session' is used so that the terminal display's random seed - // can be set to something which depends uniquely on that session - TerminalDisplay *createTerminalDisplay(Session *session = nullptr); - // creates a new controller for a session/display pair which provides the menu // actions associated with that view, and exposes basic information // about the session ( such as title and associated icon ) to the display. - SessionController *createController(Session *session, TerminalDisplay *view); + SessionController *createController(Session *session, TerminalWidget *view); // Sets the possible features for a container. void setContainerFeatures(ViewContainer* container); diff --git a/src/ViewManager.cpp b/src/ViewManager.cpp --- a/src/ViewManager.cpp +++ b/src/ViewManager.cpp @@ -25,6 +25,7 @@ // Qt #include #include +#include // KDE #include @@ -370,20 +371,20 @@ return; #endif - TerminalDisplay *viewToDetach = qobject_cast(view); + auto *viewToDetach = qobject_cast(view); if (viewToDetach == nullptr) { return; } // BR390736 - some instances are sending invalid session to viewDetached() - Session *sessionToDetach = _sessionMap[viewToDetach]; + Session *sessionToDetach = _sessionMap[viewToDetach->terminalDisplay()]; if (sessionToDetach == nullptr) { return; } emit viewDetached(sessionToDetach); - _sessionMap.remove(viewToDetach); + _sessionMap.remove(viewToDetach->terminalDisplay()); // remove the view from this window container->removeView(viewToDetach); @@ -410,11 +411,11 @@ Q_ASSERT(session); // close attached views - QList children = _viewSplitter->findChildren(); + QList children = _viewSplitter->findChildren(); - foreach (TerminalDisplay *view, children) { - if (_sessionMap[view] == session) { - _sessionMap.remove(view); + foreach (auto *view, children) { + if (_sessionMap[view->terminalDisplay()] == session) { + _sessionMap.remove(view->terminalDisplay()); view->deleteLater(); } } @@ -456,16 +457,19 @@ // iterate over each session which has a view in the current active // container and create a new view for that session in a new container foreach (QWidget *view, _viewSplitter->activeContainer()->views()) { - Session *session = _sessionMap[qobject_cast(view)]; - TerminalDisplay *display = createTerminalDisplay(session); + TerminalWidget *currView = qobject_cast(view); + Session *session = _sessionMap[currView->terminalDisplay()]; + + auto terminalWidget = new TerminalWidget(session->sessionId()); const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); - applyProfileToView(display, profile); - ViewProperties *properties = createController(session, display); - _sessionMap[display] = session; + applyProfileToView(terminalWidget->terminalDisplay(), profile); + ViewProperties *properties = createController(session, terminalWidget); + + _sessionMap[terminalWidget->terminalDisplay()] = session; - container->addView(display, properties); - session->addView(display); + container->addView(terminalWidget, properties); + session->addView(terminalWidget->terminalDisplay()); } _viewSplitter->addContainer(container, orientation); @@ -487,9 +491,9 @@ { // remove session map entries for views in this container foreach (QWidget *view, container->views()) { - TerminalDisplay *display = qobject_cast(view); - Q_ASSERT(display); - _sessionMap.remove(display); + TerminalWidget *currView = qobject_cast(view); + Q_ASSERT(currView); + _sessionMap.remove(currView->terminalDisplay()); } _viewSplitter->removeContainer(container); @@ -533,7 +537,7 @@ } } -SessionController *ViewManager::createController(Session *session, TerminalDisplay *view) +SessionController *ViewManager::createController(Session *session, TerminalWidget *view) { // create a new controller for the session, and ensure that this view manager // is notified when the view gains the focus @@ -574,11 +578,6 @@ return _pluggedController; } -IncrementalSearchBar *ViewManager::searchBar() const -{ - return _viewSplitter->activeSplitter()->activeContainer()->searchBar(); -} - void ViewManager::createView(Session *session, ViewContainer *container, int index) { // notify this view manager when the session finishes so that its view @@ -588,11 +587,24 @@ connect(session, &Konsole::Session::finished, this, &Konsole::ViewManager::sessionFinished, Qt::UniqueConnection); - TerminalDisplay *display = createTerminalDisplay(session); + auto *terminalWidget = new TerminalWidget(session->sessionId()); const Profile::Ptr profile = SessionManager::instance()->sessionProfile(session); - applyProfileToView(display, profile); + applyProfileToView(terminalWidget->terminalDisplay(), profile); + + ViewProperties *properties = createController(session, terminalWidget); + + _sessionMap[terminalWidget->terminalDisplay()] = session; + container->addView(terminalWidget, properties, index); + session->addView(terminalWidget->terminalDisplay()); + + // tell the session whether it has a light or dark background + session->setDarkBackground(colorSchemeForProfile(profile)->hasDarkBackground()); + + if (container == _viewSplitter->activeContainer()) { + container->setActiveView(terminalWidget); + terminalWidget->setFocus(Qt::OtherFocusReason); + } - // set initial size const QSize &preferredSize = session->preferredSize(); // FIXME: +1 is needed here for getting the expected rows // Note that the display shouldn't need to take into account the tabbar. @@ -606,20 +618,7 @@ heightAdjustment = 2; } - display->setSize(preferredSize.width(), preferredSize.height() + heightAdjustment); - ViewProperties *properties = createController(session, display); - - _sessionMap[display] = session; - container->addView(display, properties, index); - session->addView(display); - - // tell the session whether it has a light or dark background - session->setDarkBackground(colorSchemeForProfile(profile)->hasDarkBackground()); - - if (container == _viewSplitter->activeContainer()) { - container->setActiveView(display); - display->setFocus(Qt::OtherFocusReason); - } + terminalWidget->terminalDisplay()->setSize(preferredSize.width(), preferredSize.height() + heightAdjustment); updateDetachViewState(); } @@ -808,14 +807,6 @@ // emit unplugController(_pluggedController); } -TerminalDisplay *ViewManager::createTerminalDisplay(Session *session) -{ - auto display = new TerminalDisplay(nullptr); - display->setRandomSeed(session->sessionId() * 31); - - return display; -} - const ColorScheme *ViewManager::colorSchemeForProfile(const Profile::Ptr profile) { const ColorScheme *colorScheme = ColorSchemeManager::instance()-> @@ -956,14 +947,14 @@ if (container == nullptr) { return; } - TerminalDisplay *activeview = qobject_cast(container->activeView()); + auto *activeview = qobject_cast(container->activeView()); QListIterator viewIter(container->views()); int tab = 1; while (viewIter.hasNext()) { - TerminalDisplay *view = qobject_cast(viewIter.next()); + auto *view = qobject_cast(viewIter.next()); Q_ASSERT(view); - Session *session = _sessionMap[view]; + Session *session = _sessionMap[view->terminalDisplay()]; ids << SessionManager::instance()->getRestoreId(session); unique.insert(session); if (view == activeview) { @@ -988,7 +979,7 @@ { QList ids = group.readEntry("Sessions", QList()); int activeTab = group.readEntry("Active", 0); - TerminalDisplay *display = nullptr; + TerminalWidget *display = nullptr; int tab = 1; foreach (int id, ids) { @@ -1006,13 +997,13 @@ session->run(); } if (tab++ == activeTab) { - display = qobject_cast(activeView()); + display = qobject_cast(activeView()); } } if (display != nullptr) { _viewSplitter->activeContainer()->setActiveView(display); - display->setFocus(Qt::OtherFocusReason); + display->terminalDisplay()->setFocus(Qt::OtherFocusReason); } if (ids.isEmpty()) { // Session file is unusable, start default Profile