Changeset View
Changeset View
Standalone View
Standalone View
src/SessionController.cpp
Show First 20 Lines • Show All 86 Lines • ▼ Show 20 Line(s) | |||||
87 | // activity are available | 87 | // activity are available | ||
88 | Q_GLOBAL_STATIC_WITH_ARGS(QIcon, _activityIcon, (QIcon::fromTheme(QLatin1String("dialog-information")))) | 88 | Q_GLOBAL_STATIC_WITH_ARGS(QIcon, _activityIcon, (QIcon::fromTheme(QLatin1String("dialog-information")))) | ||
89 | Q_GLOBAL_STATIC_WITH_ARGS(QIcon, _silenceIcon, (QIcon::fromTheme(QLatin1String("dialog-information")))) | 89 | Q_GLOBAL_STATIC_WITH_ARGS(QIcon, _silenceIcon, (QIcon::fromTheme(QLatin1String("dialog-information")))) | ||
90 | Q_GLOBAL_STATIC_WITH_ARGS(QIcon, _broadcastIcon, (QIcon::fromTheme(QLatin1String("emblem-important")))) | 90 | Q_GLOBAL_STATIC_WITH_ARGS(QIcon, _broadcastIcon, (QIcon::fromTheme(QLatin1String("emblem-important")))) | ||
91 | 91 | | |||
92 | QSet<SessionController*> SessionController::_allControllers; | 92 | QSet<SessionController*> SessionController::_allControllers; | ||
93 | int SessionController::_lastControllerId; | 93 | int SessionController::_lastControllerId; | ||
94 | 94 | | |||
95 | SessionController::SessionController(Session* session , TerminalDisplay* view, QObject* parent) | 95 | SessionController::SessionController(Session* session , TerminalWidget* view, QObject* parent) | ||
96 | : ViewProperties(parent) | 96 | : ViewProperties(parent) | ||
97 | , KXMLGUIClient() | 97 | , KXMLGUIClient() | ||
98 | , _session(session) | 98 | , _session(session) | ||
99 | , _view(view) | 99 | , _view(view) | ||
100 | , _copyToGroup(nullptr) | 100 | , _copyToGroup(nullptr) | ||
101 | , _profileList(nullptr) | 101 | , _profileList(nullptr) | ||
102 | , _sessionIcon(QIcon()) | 102 | , _sessionIcon(QIcon()) | ||
103 | , _sessionIconName(QString()) | 103 | , _sessionIconName(QString()) | ||
104 | , _previousState(-1) | 104 | , _previousState(-1) | ||
105 | , _searchFilter(nullptr) | 105 | , _searchFilter(nullptr) | ||
106 | , _urlFilter(nullptr) | 106 | , _urlFilter(nullptr) | ||
107 | , _fileFilter(nullptr) | 107 | , _fileFilter(nullptr) | ||
108 | , _copyInputToAllTabsAction(nullptr) | 108 | , _copyInputToAllTabsAction(nullptr) | ||
109 | , _findAction(nullptr) | 109 | , _findAction(nullptr) | ||
110 | , _findNextAction(nullptr) | 110 | , _findNextAction(nullptr) | ||
111 | , _findPreviousAction(nullptr) | 111 | , _findPreviousAction(nullptr) | ||
112 | , _interactionTimer(nullptr) | 112 | , _interactionTimer(nullptr) | ||
113 | , _searchStartLine(0) | 113 | , _searchStartLine(0) | ||
114 | , _prevSearchResultLine(0) | 114 | , _prevSearchResultLine(0) | ||
115 | , _searchBar(nullptr) | | |||
116 | , _codecAction(nullptr) | 115 | , _codecAction(nullptr) | ||
117 | , _switchProfileMenu(nullptr) | 116 | , _switchProfileMenu(nullptr) | ||
118 | , _webSearchMenu(nullptr) | 117 | , _webSearchMenu(nullptr) | ||
119 | , _listenForScreenWindowUpdates(false) | 118 | , _listenForScreenWindowUpdates(false) | ||
120 | , _preventClose(false) | 119 | , _preventClose(false) | ||
121 | , _keepIconUntilInteraction(false) | 120 | , _keepIconUntilInteraction(false) | ||
122 | , _selectedText(QString()) | 121 | , _selectedText(QString()) | ||
123 | , _showMenuAction(nullptr) | 122 | , _showMenuAction(nullptr) | ||
Show All 19 Lines | 126 | { | |||
143 | foreach(QAction * action, actionCollection()->actions()) { | 142 | foreach(QAction * action, actionCollection()->actions()) { | ||
144 | action->setShortcutContext(Qt::WidgetWithChildrenShortcut); | 143 | action->setShortcutContext(Qt::WidgetWithChildrenShortcut); | ||
145 | } | 144 | } | ||
146 | 145 | | |||
147 | setIdentifier(++_lastControllerId); | 146 | setIdentifier(++_lastControllerId); | ||
148 | sessionTitleChanged(); | 147 | sessionTitleChanged(); | ||
149 | 148 | | |||
150 | view->installEventFilter(this); | 149 | view->installEventFilter(this); | ||
151 | view->setSessionController(this); | 150 | view->terminalDisplay()->setSessionController(this); | ||
152 | 151 | | |||
153 | // install filter on the view to highlight URLs and files | 152 | // install filter on the view to highlight URLs and files | ||
154 | updateFilterList(SessionManager::instance()->sessionProfile(_session)); | 153 | updateFilterList(SessionManager::instance()->sessionProfile(_session)); | ||
155 | 154 | | |||
156 | // listen for changes in session, we might need to change the enabled filters | 155 | // listen for changes in session, we might need to change the enabled filters | ||
157 | connect(ProfileManager::instance(), &Konsole::ProfileManager::profileChanged, this, &Konsole::SessionController::updateFilterList); | 156 | connect(ProfileManager::instance(), &Konsole::ProfileManager::profileChanged, this, &Konsole::SessionController::updateFilterList); | ||
158 | 157 | | |||
159 | // listen for session resize requests | 158 | // listen for session resize requests | ||
160 | connect(_session.data(), &Konsole::Session::resizeRequest, this, &Konsole::SessionController::sessionResizeRequest); | 159 | connect(_session.data(), &Konsole::Session::resizeRequest, this, &Konsole::SessionController::sessionResizeRequest); | ||
161 | 160 | | |||
162 | // listen for popup menu requests | 161 | // listen for popup menu requests | ||
163 | connect(_view.data(), &Konsole::TerminalDisplay::configureRequest, this, &Konsole::SessionController::showDisplayContextMenu); | 162 | connect(_view->terminalDisplay(), &Konsole::TerminalDisplay::configureRequest, this, &Konsole::SessionController::showDisplayContextMenu); | ||
164 | 163 | | |||
165 | // move view to newest output when keystrokes occur | 164 | // move view to newest output when keystrokes occur | ||
166 | connect(_view.data(), &Konsole::TerminalDisplay::keyPressedSignal, this, &Konsole::SessionController::trackOutput); | 165 | connect(_view->terminalDisplay(), &Konsole::TerminalDisplay::keyPressedSignal, this, &Konsole::SessionController::trackOutput); | ||
167 | 166 | | |||
168 | // listen to activity / silence notifications from session | 167 | // listen to activity / silence notifications from session | ||
169 | connect(_session.data(), &Konsole::Session::stateChanged, this, &Konsole::SessionController::sessionStateChanged); | 168 | connect(_session.data(), &Konsole::Session::stateChanged, this, &Konsole::SessionController::sessionStateChanged); | ||
170 | // listen to title and icon changes | 169 | // listen to title and icon changes | ||
171 | connect(_session.data(), &Konsole::Session::titleChanged, this, &Konsole::SessionController::sessionTitleChanged); | 170 | connect(_session.data(), &Konsole::Session::titleChanged, this, &Konsole::SessionController::sessionTitleChanged); | ||
172 | connect(_session.data(), &Konsole::Session::readOnlyChanged, this, &Konsole::SessionController::sessionReadOnlyChanged); | 171 | connect(_session.data(), &Konsole::Session::readOnlyChanged, this, &Konsole::SessionController::sessionReadOnlyChanged); | ||
173 | 172 | | |||
174 | connect(this, &Konsole::SessionController::tabRenamedByUser, _session, &Konsole::Session::tabRenamedByUser); | 173 | connect(this, &Konsole::SessionController::tabRenamedByUser, _session, &Konsole::Session::tabRenamedByUser); | ||
175 | 174 | | |||
176 | connect(_session.data() , &Konsole::Session::currentDirectoryChanged , this , &Konsole::SessionController::currentDirectoryChanged); | 175 | connect(_session.data() , &Konsole::Session::currentDirectoryChanged , this , &Konsole::SessionController::currentDirectoryChanged); | ||
177 | 176 | | |||
178 | // listen for color changes | 177 | // listen for color changes | ||
179 | connect(_session.data(), &Konsole::Session::changeBackgroundColorRequest, _view.data(), &Konsole::TerminalDisplay::setBackgroundColor); | 178 | connect(_session.data(), &Konsole::Session::changeBackgroundColorRequest, _view->terminalDisplay(), &Konsole::TerminalDisplay::setBackgroundColor); | ||
180 | connect(_session.data(), &Konsole::Session::changeForegroundColorRequest, _view.data(), &Konsole::TerminalDisplay::setForegroundColor); | 179 | connect(_session.data(), &Konsole::Session::changeForegroundColorRequest, _view->terminalDisplay(), &Konsole::TerminalDisplay::setForegroundColor); | ||
181 | 180 | | |||
182 | // update the title when the session starts | 181 | // update the title when the session starts | ||
183 | connect(_session.data(), &Konsole::Session::started, this, &Konsole::SessionController::snapshot); | 182 | connect(_session.data(), &Konsole::Session::started, this, &Konsole::SessionController::snapshot); | ||
184 | 183 | | |||
185 | // listen for output changes to set activity flag | 184 | // listen for output changes to set activity flag | ||
186 | connect(_session->emulation(), &Konsole::Emulation::outputChanged, this, &Konsole::SessionController::fireActivity); | 185 | connect(_session->emulation(), &Konsole::Emulation::outputChanged, this, &Konsole::SessionController::fireActivity); | ||
187 | 186 | | |||
188 | // listen for detection of ZModem transfer | 187 | // listen for detection of ZModem transfer | ||
189 | connect(_session.data(), &Konsole::Session::zmodemDownloadDetected, this, &Konsole::SessionController::zmodemDownload); | 188 | connect(_session.data(), &Konsole::Session::zmodemDownloadDetected, this, &Konsole::SessionController::zmodemDownload); | ||
190 | connect(_session.data(), &Konsole::Session::zmodemUploadDetected, this, &Konsole::SessionController::zmodemUpload); | 189 | connect(_session.data(), &Konsole::Session::zmodemUploadDetected, this, &Konsole::SessionController::zmodemUpload); | ||
191 | 190 | | |||
192 | // listen for flow control status changes | 191 | // listen for flow control status changes | ||
193 | connect(_session.data(), &Konsole::Session::flowControlEnabledChanged, _view.data(), &Konsole::TerminalDisplay::setFlowControlWarningEnabled); | 192 | connect(_session.data(), &Konsole::Session::flowControlEnabledChanged, _view->terminalDisplay(), &Konsole::TerminalDisplay::setFlowControlWarningEnabled); | ||
194 | _view->setFlowControlWarningEnabled(_session->flowControlEnabled()); | 193 | _view->terminalDisplay()->setFlowControlWarningEnabled(_session->flowControlEnabled()); | ||
195 | 194 | | |||
196 | // take a snapshot of the session state every so often when | 195 | // take a snapshot of the session state every so often when | ||
197 | // user activity occurs | 196 | // user activity occurs | ||
198 | // | 197 | // | ||
199 | // the timer is owned by the session so that it will be destroyed along | 198 | // the timer is owned by the session so that it will be destroyed along | ||
200 | // with the session | 199 | // with the session | ||
201 | _interactionTimer = new QTimer(_session); | 200 | _interactionTimer = new QTimer(_session); | ||
202 | _interactionTimer->setSingleShot(true); | 201 | _interactionTimer->setSingleShot(true); | ||
203 | _interactionTimer->setInterval(500); | 202 | _interactionTimer->setInterval(500); | ||
204 | connect(_interactionTimer, &QTimer::timeout, this, &Konsole::SessionController::snapshot); | 203 | connect(_interactionTimer, &QTimer::timeout, this, &Konsole::SessionController::snapshot); | ||
205 | connect(_view.data(), &Konsole::TerminalDisplay::keyPressedSignal, this, &Konsole::SessionController::interactionHandler); | 204 | connect(_view->terminalDisplay(), &Konsole::TerminalDisplay::keyPressedSignal, this, &Konsole::SessionController::interactionHandler); | ||
206 | 205 | | |||
207 | // take a snapshot of the session state periodically in the background | 206 | // take a snapshot of the session state periodically in the background | ||
208 | auto backgroundTimer = new QTimer(_session); | 207 | auto backgroundTimer = new QTimer(_session); | ||
209 | backgroundTimer->setSingleShot(false); | 208 | backgroundTimer->setSingleShot(false); | ||
210 | backgroundTimer->setInterval(2000); | 209 | backgroundTimer->setInterval(2000); | ||
211 | connect(backgroundTimer, &QTimer::timeout, this, &Konsole::SessionController::snapshot); | 210 | connect(backgroundTimer, &QTimer::timeout, this, &Konsole::SessionController::snapshot); | ||
212 | backgroundTimer->start(); | 211 | backgroundTimer->start(); | ||
213 | 212 | | |||
214 | // xterm '11;?' request | 213 | // xterm '11;?' request | ||
215 | connect(_session.data(), &Konsole::Session::getBackgroundColor, | 214 | connect(_session.data(), &Konsole::Session::getBackgroundColor, | ||
216 | this, &Konsole::SessionController::sendBackgroundColor); | 215 | this, &Konsole::SessionController::sendBackgroundColor); | ||
217 | 216 | | |||
218 | connect(_session, &Konsole::Session::primaryScreenInUse, view, &Konsole::TerminalDisplay::usingPrimaryScreen); | 217 | connect(_session, &Konsole::Session::primaryScreenInUse, view->terminalDisplay(), &Konsole::TerminalDisplay::usingPrimaryScreen); | ||
219 | 218 | | |||
220 | _allControllers.insert(this); | 219 | _allControllers.insert(this); | ||
221 | 220 | | |||
222 | // A list of programs that accept Ctrl+C to clear command line used | 221 | // A list of programs that accept Ctrl+C to clear command line used | ||
223 | // before outputting bookmark. | 222 | // before outputting bookmark. | ||
224 | _bookmarkValidProgramsToClear << QStringLiteral("bash") << QStringLiteral("fish") << QStringLiteral("sh"); | 223 | _bookmarkValidProgramsToClear << QStringLiteral("bash") << QStringLiteral("fish") << QStringLiteral("sh"); | ||
225 | _bookmarkValidProgramsToClear << QStringLiteral("tcsh") << QStringLiteral("zsh"); | 224 | _bookmarkValidProgramsToClear << QStringLiteral("tcsh") << QStringLiteral("zsh"); | ||
225 | | ||||
rizzitello: New Empty line | |||||
226 | setupSearchBar(); | ||||
226 | } | 227 | } | ||
227 | 228 | | |||
228 | SessionController::~SessionController() | 229 | SessionController::~SessionController() | ||
229 | { | 230 | { | ||
230 | if (!_view.isNull()) { | 231 | if (!_view.isNull()) { | ||
231 | _view->setScreenWindow(nullptr); | 232 | _view->terminalDisplay()->setScreenWindow(nullptr); | ||
232 | } | 233 | } | ||
233 | 234 | | |||
234 | _allControllers.remove(this); | 235 | _allControllers.remove(this); | ||
235 | 236 | | |||
236 | if (!_editProfileDialog.isNull()) { | 237 | if (!_editProfileDialog.isNull()) { | ||
237 | delete _editProfileDialog.data(); | 238 | delete _editProfileDialog.data(); | ||
238 | } | 239 | } | ||
239 | } | 240 | } | ||
241 | | ||||
240 | void SessionController::trackOutput(QKeyEvent* event) | 242 | void SessionController::trackOutput(QKeyEvent* event) | ||
241 | { | 243 | { | ||
242 | Q_ASSERT(_view->screenWindow()); | 244 | Q_ASSERT(_view->terminalDisplay()->screenWindow()); | ||
243 | 245 | | |||
244 | // Only jump to the bottom if the user actually typed something in, | 246 | // Only jump to the bottom if the user actually typed something in, | ||
245 | // not if the user e. g. just pressed a modifier. | 247 | // not if the user e. g. just pressed a modifier. | ||
246 | if (event->text().isEmpty() && (event->modifiers() != 0u)) { | 248 | if (event->text().isEmpty() && (event->modifiers() != 0u)) { | ||
247 | return; | 249 | return; | ||
248 | } | 250 | } | ||
249 | 251 | | |||
250 | _view->screenWindow()->setTrackOutput(true); | 252 | _view->terminalDisplay()->screenWindow()->setTrackOutput(true); | ||
251 | } | 253 | } | ||
252 | void SessionController::interactionHandler() | 254 | void SessionController::interactionHandler() | ||
253 | { | 255 | { | ||
254 | // This flag is used to make sure those special icons indicating interest | 256 | // This flag is used to make sure those special icons indicating interest | ||
255 | // events (activity/silence/bell?) remain in the tab until user interaction | 257 | // events (activity/silence/bell?) remain in the tab until user interaction | ||
256 | // happens. Otherwise, those special icons will quickly be replaced by | 258 | // happens. Otherwise, those special icons will quickly be replaced by | ||
257 | // normal icon when ::snapshot() is triggered | 259 | // normal icon when ::snapshot() is triggered | ||
258 | _keepIconUntilInteraction = false; | 260 | _keepIconUntilInteraction = false; | ||
▲ Show 20 Lines • Show All 198 Lines • ▼ Show 20 Line(s) | |||||
457 | void SessionController::sendSignal(QAction* action) | 459 | void SessionController::sendSignal(QAction* action) | ||
458 | { | 460 | { | ||
459 | const int signal = action->data().value<int>(); | 461 | const int signal = action->data().value<int>(); | ||
460 | _session->sendSignal(signal); | 462 | _session->sendSignal(signal); | ||
461 | } | 463 | } | ||
462 | 464 | | |||
463 | void SessionController::sendBackgroundColor() | 465 | void SessionController::sendBackgroundColor() | ||
464 | { | 466 | { | ||
465 | const QColor c = _view->getBackgroundColor(); | 467 | const QColor c = _view->terminalDisplay()->getBackgroundColor(); | ||
466 | _session->reportBackgroundColor(c); | 468 | _session->reportBackgroundColor(c); | ||
467 | } | 469 | } | ||
468 | 470 | | |||
469 | void SessionController::toggleReadOnly() | 471 | void SessionController::toggleReadOnly() | ||
470 | { | 472 | { | ||
471 | QAction *action = qobject_cast<QAction*>(sender()); | 473 | QAction *action = qobject_cast<QAction*>(sender()); | ||
472 | if (action != nullptr) { | 474 | if (action != nullptr) { | ||
473 | bool readonly = !isReadOnly(); | 475 | bool readonly = !isReadOnly(); | ||
Show All 9 Lines | 482 | if (event->type() == QEvent::FocusIn && watched == _view) { | |||
483 | emit focused(this); | 485 | emit focused(this); | ||
484 | 486 | | |||
485 | // when the view is focused, set bell events from the associated session to be delivered | 487 | // when the view is focused, set bell events from the associated session to be delivered | ||
486 | // by the focused view | 488 | // by the focused view | ||
487 | 489 | | |||
488 | // first, disconnect any other views which are listening for bell signals from the session | 490 | // first, disconnect any other views which are listening for bell signals from the session | ||
489 | disconnect(_session.data(), &Konsole::Session::bellRequest, nullptr, nullptr); | 491 | disconnect(_session.data(), &Konsole::Session::bellRequest, nullptr, nullptr); | ||
490 | // second, connect the newly focused view to listen for the session's bell signal | 492 | // second, connect the newly focused view to listen for the session's bell signal | ||
491 | connect(_session.data(), &Konsole::Session::bellRequest, _view.data(), &Konsole::TerminalDisplay::bell); | 493 | connect(_session.data(), &Konsole::Session::bellRequest, _view->terminalDisplay(), &Konsole::TerminalDisplay::bell); | ||
492 | 494 | | |||
493 | if ((_copyInputToAllTabsAction != nullptr) && _copyInputToAllTabsAction->isChecked()) { | 495 | if ((_copyInputToAllTabsAction != nullptr) && _copyInputToAllTabsAction->isChecked()) { | ||
494 | // A session with "Copy To All Tabs" has come into focus: | 496 | // A session with "Copy To All Tabs" has come into focus: | ||
495 | // Ensure that newly created sessions are included in _copyToGroup! | 497 | // Ensure that newly created sessions are included in _copyToGroup! | ||
496 | copyInputToAllTabs(); | 498 | copyInputToAllTabs(); | ||
497 | } | 499 | } | ||
498 | } | 500 | } | ||
499 | return Konsole::ViewProperties::eventFilter(watched, event); | 501 | return Konsole::ViewProperties::eventFilter(watched, event); | ||
500 | } | 502 | } | ||
501 | 503 | | |||
502 | void SessionController::removeSearchFilter() | 504 | void SessionController::removeSearchFilter() | ||
503 | { | 505 | { | ||
504 | if (_searchFilter == nullptr) { | 506 | if (_searchFilter == nullptr) { | ||
505 | return; | 507 | return; | ||
506 | } | 508 | } | ||
507 | 509 | | |||
508 | _view->filterChain()->removeFilter(_searchFilter); | 510 | _view->terminalDisplay()->filterChain()->removeFilter(_searchFilter); | ||
509 | delete _searchFilter; | 511 | delete _searchFilter; | ||
510 | _searchFilter = nullptr; | 512 | _searchFilter = nullptr; | ||
511 | } | 513 | } | ||
512 | 514 | | |||
513 | void SessionController::setSearchBar(IncrementalSearchBar* searchBar) | 515 | void SessionController::setupSearchBar() | ||
514 | { | | |||
515 | // disconnect the existing search bar | | |||
516 | if (!_searchBar.isNull()) { | | |||
517 | disconnect(this, nullptr, _searchBar, nullptr); | | |||
518 | disconnect(_searchBar, nullptr, this, nullptr); | | |||
519 | } | | |||
520 | | ||||
521 | // connect new search bar | | |||
522 | _searchBar = searchBar; | | |||
523 | if (!_searchBar.isNull()) { | | |||
524 | connect(_searchBar.data(), &Konsole::IncrementalSearchBar::unhandledMovementKeyPressed, this, &Konsole::SessionController::movementKeyFromSearchBarReceived); | | |||
525 | connect(_searchBar.data(), &Konsole::IncrementalSearchBar::closeClicked, this, &Konsole::SessionController::searchClosed); | | |||
526 | connect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchFromClicked, this, &Konsole::SessionController::searchFrom); | | |||
527 | connect(_searchBar.data(), &Konsole::IncrementalSearchBar::findNextClicked, this, &Konsole::SessionController::findNextInHistory); | | |||
528 | connect(_searchBar.data(), &Konsole::IncrementalSearchBar::findPreviousClicked, this, &Konsole::SessionController::findPreviousInHistory); | | |||
529 | connect(_searchBar.data(), &Konsole::IncrementalSearchBar::highlightMatchesToggled , this , &Konsole::SessionController::highlightMatches); | | |||
530 | connect(_searchBar.data(), &Konsole::IncrementalSearchBar::matchCaseToggled, this, &Konsole::SessionController::changeSearchMatch); | | |||
531 | connect(_searchBar.data(), &Konsole::IncrementalSearchBar::matchRegExpToggled, this, &Konsole::SessionController::changeSearchMatch); | | |||
532 | | ||||
533 | // if the search bar was previously active | | |||
534 | // then re-enter search mode | | |||
535 | enableSearchBar(_isSearchBarEnabled); | | |||
536 | } | | |||
537 | } | | |||
538 | IncrementalSearchBar* SessionController::searchBar() const | | |||
539 | { | 516 | { | ||
540 | return _searchBar; | 517 | connect(_view->searchBar(), &Konsole::IncrementalSearchBar::unhandledMovementKeyPressed, this, &Konsole::SessionController::movementKeyFromSearchBarReceived); | ||
518 | connect(_view->searchBar(), &Konsole::IncrementalSearchBar::closeClicked, this, &Konsole::SessionController::searchClosed); | ||||
519 | connect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchFromClicked, this, &Konsole::SessionController::searchFrom); | ||||
520 | connect(_view->searchBar(), &Konsole::IncrementalSearchBar::findNextClicked, this, &Konsole::SessionController::findNextInHistory); | ||||
521 | connect(_view->searchBar(), &Konsole::IncrementalSearchBar::findPreviousClicked, this, &Konsole::SessionController::findPreviousInHistory); | ||||
522 | connect(_view->searchBar(), &Konsole::IncrementalSearchBar::highlightMatchesToggled , this , &Konsole::SessionController::highlightMatches); | ||||
523 | connect(_view->searchBar(), &Konsole::IncrementalSearchBar::matchCaseToggled, this, &Konsole::SessionController::changeSearchMatch); | ||||
524 | connect(_view->searchBar(), &Konsole::IncrementalSearchBar::matchRegExpToggled, this, &Konsole::SessionController::changeSearchMatch); | ||||
525 | | ||||
541 | } | 526 | } | ||
rizzitello: New Empty line | |||||
542 | 527 | | |||
543 | void SessionController::setShowMenuAction(QAction* action) | 528 | void SessionController::setShowMenuAction(QAction* action) | ||
544 | { | 529 | { | ||
545 | _showMenuAction = action; | 530 | _showMenuAction = action; | ||
546 | } | 531 | } | ||
547 | 532 | | |||
548 | void SessionController::setupCommonActions() | 533 | void SessionController::setupCommonActions() | ||
549 | { | 534 | { | ||
▲ Show 20 Lines • Show All 422 Lines • ▼ Show 20 Line(s) | 956 | if (currentUrl.isLocalFile()) { | |||
972 | new KRun(currentUrl, QApplication::activeWindow(), true); | 957 | new KRun(currentUrl, QApplication::activeWindow(), true); | ||
973 | } else { | 958 | } else { | ||
974 | new KRun(QUrl::fromLocalFile(QDir::homePath()), QApplication::activeWindow(), true); | 959 | new KRun(QUrl::fromLocalFile(QDir::homePath()), QApplication::activeWindow(), true); | ||
975 | } | 960 | } | ||
976 | } | 961 | } | ||
977 | 962 | | |||
978 | void SessionController::copy() | 963 | void SessionController::copy() | ||
979 | { | 964 | { | ||
980 | _view->copyToClipboard(); | 965 | _view->terminalDisplay()->copyToClipboard(); | ||
981 | } | 966 | } | ||
982 | 967 | | |||
983 | void SessionController::paste() | 968 | void SessionController::paste() | ||
984 | { | 969 | { | ||
985 | _view->pasteFromClipboard(); | 970 | _view->terminalDisplay()->pasteFromClipboard(); | ||
986 | } | 971 | } | ||
987 | void SessionController::pasteFromX11Selection() | 972 | void SessionController::pasteFromX11Selection() | ||
988 | { | 973 | { | ||
989 | _view->pasteFromX11Selection(); | 974 | _view->terminalDisplay()->pasteFromX11Selection(); | ||
990 | } | 975 | } | ||
991 | void SessionController::selectAll() | 976 | void SessionController::selectAll() | ||
992 | { | 977 | { | ||
993 | _view->selectAll(); | 978 | _view->terminalDisplay()->selectAll(); | ||
994 | } | 979 | } | ||
995 | void SessionController::selectLine() | 980 | void SessionController::selectLine() | ||
996 | { | 981 | { | ||
997 | _view->selectCurrentLine(); | 982 | _view->terminalDisplay()->selectCurrentLine(); | ||
998 | } | 983 | } | ||
999 | static const KXmlGuiWindow* findWindow(const QObject* object) | 984 | static const KXmlGuiWindow* findWindow(const QObject* object) | ||
1000 | { | 985 | { | ||
1001 | // Walk up the QObject hierarchy to find a KXmlGuiWindow. | 986 | // Walk up the QObject hierarchy to find a KXmlGuiWindow. | ||
1002 | while (object != nullptr) { | 987 | while (object != nullptr) { | ||
1003 | const KXmlGuiWindow* window = qobject_cast<const KXmlGuiWindow*>(object); | 988 | const KXmlGuiWindow* window = qobject_cast<const KXmlGuiWindow*>(object); | ||
1004 | if (window != nullptr) { | 989 | if (window != nullptr) { | ||
1005 | return(window); | 990 | return(window); | ||
▲ Show 20 Lines • Show All 134 Lines • ▼ Show 20 Line(s) | |||||
1140 | { | 1125 | { | ||
1141 | if (profile != SessionManager::instance()->sessionProfile(_session)) { | 1126 | if (profile != SessionManager::instance()->sessionProfile(_session)) { | ||
1142 | return; | 1127 | return; | ||
1143 | } | 1128 | } | ||
1144 | 1129 | | |||
1145 | bool underlineFiles = profile->underlineFilesEnabled(); | 1130 | bool underlineFiles = profile->underlineFilesEnabled(); | ||
1146 | 1131 | | |||
1147 | if (!underlineFiles && (_fileFilter != nullptr)) { | 1132 | if (!underlineFiles && (_fileFilter != nullptr)) { | ||
1148 | _view->filterChain()->removeFilter(_fileFilter); | 1133 | _view->terminalDisplay()->filterChain()->removeFilter(_fileFilter); | ||
1149 | delete _fileFilter; | 1134 | delete _fileFilter; | ||
1150 | _fileFilter = nullptr; | 1135 | _fileFilter = nullptr; | ||
1151 | } else if (underlineFiles && (_fileFilter == nullptr)) { | 1136 | } else if (underlineFiles && (_fileFilter == nullptr)) { | ||
1152 | _fileFilter = new FileFilter(_session); | 1137 | _fileFilter = new FileFilter(_session); | ||
1153 | _view->filterChain()->addFilter(_fileFilter); | 1138 | _view->terminalDisplay()->filterChain()->addFilter(_fileFilter); | ||
1154 | } | 1139 | } | ||
1155 | 1140 | | |||
1156 | bool underlineLinks = profile->underlineLinksEnabled(); | 1141 | bool underlineLinks = profile->underlineLinksEnabled(); | ||
1157 | if (!underlineLinks && (_urlFilter != nullptr)) { | 1142 | if (!underlineLinks && (_urlFilter != nullptr)) { | ||
1158 | _view->filterChain()->removeFilter(_urlFilter); | 1143 | _view->terminalDisplay()->filterChain()->removeFilter(_urlFilter); | ||
1159 | delete _urlFilter; | 1144 | delete _urlFilter; | ||
1160 | _urlFilter = nullptr; | 1145 | _urlFilter = nullptr; | ||
1161 | } else if (underlineLinks && (_urlFilter == nullptr)) { | 1146 | } else if (underlineLinks && (_urlFilter == nullptr)) { | ||
1162 | _urlFilter = new UrlFilter(); | 1147 | _urlFilter = new UrlFilter(); | ||
1163 | _view->filterChain()->addFilter(_urlFilter); | 1148 | _view->terminalDisplay()->filterChain()->addFilter(_urlFilter); | ||
1164 | } | 1149 | } | ||
1165 | } | 1150 | } | ||
1166 | 1151 | | |||
1167 | void SessionController::setSearchStartToWindowCurrentLine() | 1152 | void SessionController::setSearchStartToWindowCurrentLine() | ||
1168 | { | 1153 | { | ||
1169 | setSearchStartTo(-1); | 1154 | setSearchStartTo(-1); | ||
1170 | } | 1155 | } | ||
1171 | 1156 | | |||
1172 | void SessionController::setSearchStartTo(int line) | 1157 | void SessionController::setSearchStartTo(int line) | ||
1173 | { | 1158 | { | ||
1174 | _searchStartLine = line; | 1159 | _searchStartLine = line; | ||
1175 | _prevSearchResultLine = line; | 1160 | _prevSearchResultLine = line; | ||
1176 | } | 1161 | } | ||
1177 | 1162 | | |||
1178 | void SessionController::listenForScreenWindowUpdates() | 1163 | void SessionController::listenForScreenWindowUpdates() | ||
1179 | { | 1164 | { | ||
1180 | if (_listenForScreenWindowUpdates) { | 1165 | if (_listenForScreenWindowUpdates) { | ||
1181 | return; | 1166 | return; | ||
1182 | } | 1167 | } | ||
1183 | 1168 | | |||
1184 | connect(_view->screenWindow(), &Konsole::ScreenWindow::outputChanged, this, &Konsole::SessionController::updateSearchFilter); | 1169 | connect(_view->terminalDisplay()->screenWindow(), &Konsole::ScreenWindow::outputChanged, | ||
1185 | connect(_view->screenWindow(), &Konsole::ScreenWindow::scrolled, this, &Konsole::SessionController::updateSearchFilter); | 1170 | this, &Konsole::SessionController::updateSearchFilter); | ||
1186 | connect(_view->screenWindow(), &Konsole::ScreenWindow::currentResultLineChanged, _view.data(), static_cast<void(TerminalDisplay::*)()>(&Konsole::TerminalDisplay::update)); | 1171 | connect(_view->terminalDisplay()->screenWindow(), &Konsole::ScreenWindow::scrolled, | ||
1172 | this, &Konsole::SessionController::updateSearchFilter); | ||||
1173 | connect(_view->terminalDisplay()->screenWindow(), &Konsole::ScreenWindow::currentResultLineChanged, | ||||
1174 | _view->terminalDisplay(), static_cast<void(TerminalDisplay::*)()>(&Konsole::TerminalDisplay::update)); | ||||
1187 | 1175 | | |||
1188 | _listenForScreenWindowUpdates = true; | 1176 | _listenForScreenWindowUpdates = true; | ||
1189 | } | 1177 | } | ||
1190 | 1178 | | |||
1191 | void SessionController::updateSearchFilter() | 1179 | void SessionController::updateSearchFilter() | ||
1192 | { | 1180 | { | ||
1193 | if ((_searchFilter != nullptr) && (!_searchBar.isNull())) { | 1181 | if (_searchFilter != nullptr) { | ||
1194 | _view->processFilters(); | 1182 | _view->terminalDisplay()->processFilters(); | ||
1195 | } | 1183 | } | ||
1196 | } | 1184 | } | ||
1197 | 1185 | | |||
1198 | void SessionController::searchBarEvent() | 1186 | void SessionController::searchBarEvent() | ||
1199 | { | 1187 | { | ||
1200 | QString selectedText = _view->screenWindow()->selectedText(Screen::PreserveLineBreaks | Screen::TrimLeadingWhitespace | Screen::TrimTrailingWhitespace); | 1188 | QString selectedText = _view->terminalDisplay()->screenWindow()->selectedText( | ||
1189 | Screen::PreserveLineBreaks | Screen::TrimLeadingWhitespace | Screen::TrimTrailingWhitespace); | ||||
1190 | | ||||
1201 | if (!selectedText.isEmpty()) { | 1191 | if (!selectedText.isEmpty()) { | ||
1202 | _searchBar->setSearchText(selectedText); | 1192 | _view->searchBar()->setSearchText(selectedText); | ||
1203 | } | 1193 | } | ||
1204 | 1194 | | |||
1205 | if (_searchBar->isVisible()) { | 1195 | if (_view->searchBar()->isVisible()) { | ||
1206 | _searchBar->focusLineEdit(); | 1196 | _view->searchBar()->focusLineEdit(); | ||
1207 | } else { | 1197 | } else { | ||
1208 | searchHistory(true); | 1198 | searchHistory(true); | ||
1209 | _isSearchBarEnabled = true; | 1199 | _isSearchBarEnabled = true; | ||
1210 | } | 1200 | } | ||
1211 | } | 1201 | } | ||
1212 | 1202 | | |||
1213 | void SessionController::enableSearchBar(bool showSearchBar) | 1203 | void SessionController::enableSearchBar(bool showSearchBar) | ||
1214 | { | 1204 | { | ||
1215 | if (_searchBar.isNull()) { | 1205 | if (showSearchBar && !_view->searchBar()->isVisible()) { | ||
1216 | return; | | |||
1217 | } | | |||
1218 | | ||||
1219 | if (showSearchBar && !_searchBar->isVisible()) { | | |||
1220 | setSearchStartToWindowCurrentLine(); | 1206 | setSearchStartToWindowCurrentLine(); | ||
1221 | } | 1207 | } | ||
1222 | 1208 | | |||
1223 | _searchBar->setVisible(showSearchBar); | 1209 | _view->searchBar()->setVisible(showSearchBar); | ||
1224 | if (showSearchBar) { | 1210 | if (showSearchBar) { | ||
1225 | connect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchChanged, this, &Konsole::SessionController::searchTextChanged); | 1211 | connect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchChanged, this, &Konsole::SessionController::searchTextChanged); | ||
1226 | connect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchReturnPressed, this, &Konsole::SessionController::findPreviousInHistory); | 1212 | connect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchReturnPressed, this, &Konsole::SessionController::findPreviousInHistory); | ||
1227 | connect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchShiftPlusReturnPressed, this, &Konsole::SessionController::findNextInHistory); | 1213 | connect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchShiftPlusReturnPressed, this, &Konsole::SessionController::findNextInHistory); | ||
1228 | } else { | 1214 | } else { | ||
1229 | disconnect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchChanged, this, | 1215 | disconnect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchChanged, this, | ||
1230 | &Konsole::SessionController::searchTextChanged); | 1216 | &Konsole::SessionController::searchTextChanged); | ||
1231 | disconnect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchReturnPressed, this, | 1217 | disconnect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchReturnPressed, this, | ||
1232 | &Konsole::SessionController::findPreviousInHistory); | 1218 | &Konsole::SessionController::findPreviousInHistory); | ||
1233 | disconnect(_searchBar.data(), &Konsole::IncrementalSearchBar::searchShiftPlusReturnPressed, this, | 1219 | disconnect(_view->searchBar(), &Konsole::IncrementalSearchBar::searchShiftPlusReturnPressed, this, | ||
1234 | &Konsole::SessionController::findNextInHistory); | 1220 | &Konsole::SessionController::findNextInHistory); | ||
1235 | if ((!_view.isNull()) && (_view->screenWindow() != nullptr)) { | 1221 | if ((!_view.isNull()) && (_view->terminalDisplay()->screenWindow() != nullptr)) { | ||
1236 | _view->screenWindow()->setCurrentResultLine(-1); | 1222 | _view->terminalDisplay()->screenWindow()->setCurrentResultLine(-1); | ||
1237 | } | 1223 | } | ||
1238 | } | 1224 | } | ||
1239 | } | 1225 | } | ||
1240 | 1226 | | |||
1241 | 1227 | | |||
1242 | bool SessionController::reverseSearchChecked() const | 1228 | bool SessionController::reverseSearchChecked() const | ||
1243 | { | 1229 | { | ||
1244 | Q_ASSERT(_searchBar); | 1230 | QBitArray options = _view->searchBar()->optionsChecked(); | ||
1245 | | ||||
1246 | QBitArray options = _searchBar->optionsChecked(); | | |||
1247 | return options.at(IncrementalSearchBar::ReverseSearch); | 1231 | return options.at(IncrementalSearchBar::ReverseSearch); | ||
1248 | } | 1232 | } | ||
1249 | 1233 | | |||
1250 | QRegularExpression SessionController::regexpFromSearchBarOptions() const | 1234 | QRegularExpression SessionController::regexpFromSearchBarOptions() const | ||
1251 | { | 1235 | { | ||
1252 | QBitArray options = _searchBar->optionsChecked(); | 1236 | QBitArray options = _view->searchBar()->optionsChecked(); | ||
1253 | 1237 | | |||
1254 | QString text(_searchBar->searchText()); | 1238 | QString text(_view->searchBar()->searchText()); | ||
1255 | 1239 | | |||
1256 | QRegularExpression regExp; | 1240 | QRegularExpression regExp; | ||
1257 | if (options.at(IncrementalSearchBar::RegExp)) { | 1241 | if (options.at(IncrementalSearchBar::RegExp)) { | ||
1258 | regExp.setPattern(text); | 1242 | regExp.setPattern(text); | ||
1259 | } else { | 1243 | } else { | ||
1260 | regExp.setPattern(QRegularExpression::escape(text)); | 1244 | regExp.setPattern(QRegularExpression::escape(text)); | ||
1261 | } | 1245 | } | ||
1262 | 1246 | | |||
1263 | if (!options.at(IncrementalSearchBar::MatchCase)) { | 1247 | if (!options.at(IncrementalSearchBar::MatchCase)) { | ||
1264 | regExp.setPatternOptions(QRegularExpression::CaseInsensitiveOption); | 1248 | regExp.setPatternOptions(QRegularExpression::CaseInsensitiveOption); | ||
1265 | } | 1249 | } | ||
1266 | 1250 | | |||
1267 | return regExp; | 1251 | return regExp; | ||
1268 | } | 1252 | } | ||
1269 | 1253 | | |||
1270 | // searchHistory() may be called either as a result of clicking a menu item or | 1254 | // searchHistory() may be called either as a result of clicking a menu item or | ||
1271 | // as a result of changing the search bar widget | 1255 | // as a result of changing the search bar widget | ||
1272 | void SessionController::searchHistory(bool showSearchBar) | 1256 | void SessionController::searchHistory(bool showSearchBar) | ||
1273 | { | 1257 | { | ||
1274 | enableSearchBar(showSearchBar); | 1258 | enableSearchBar(showSearchBar); | ||
1275 | | ||||
1276 | if (!_searchBar.isNull()) { | | |||
1277 | if (showSearchBar) { | 1259 | if (showSearchBar) { | ||
1278 | removeSearchFilter(); | 1260 | removeSearchFilter(); | ||
1279 | 1261 | | |||
1280 | listenForScreenWindowUpdates(); | 1262 | listenForScreenWindowUpdates(); | ||
1281 | 1263 | | |||
1282 | _searchFilter = new RegExpFilter(); | 1264 | _searchFilter = new RegExpFilter(); | ||
1283 | _searchFilter->setRegExp(regexpFromSearchBarOptions()); | 1265 | _searchFilter->setRegExp(regexpFromSearchBarOptions()); | ||
1284 | _view->filterChain()->addFilter(_searchFilter); | 1266 | _view->terminalDisplay()->filterChain()->addFilter(_searchFilter); | ||
1285 | _view->processFilters(); | 1267 | _view->terminalDisplay()->processFilters(); | ||
1286 | 1268 | | |||
1287 | setFindNextPrevEnabled(true); | 1269 | setFindNextPrevEnabled(true); | ||
1288 | } else { | 1270 | } else { | ||
1289 | setFindNextPrevEnabled(false); | 1271 | setFindNextPrevEnabled(false); | ||
1290 | | ||||
1291 | removeSearchFilter(); | 1272 | removeSearchFilter(); | ||
1292 | 1273 | _view->terminalDisplay()->setFocus(Qt::ActiveWindowFocusReason); | |||
1293 | _view->setFocus(Qt::ActiveWindowFocusReason); | | |||
1294 | } | | |||
1295 | } | 1274 | } | ||
1275 | | ||||
rizzitello: New Empty line | |||||
1296 | } | 1276 | } | ||
1297 | 1277 | | |||
1298 | void SessionController::setFindNextPrevEnabled(bool enabled) | 1278 | void SessionController::setFindNextPrevEnabled(bool enabled) | ||
1299 | { | 1279 | { | ||
1300 | _findNextAction->setEnabled(enabled); | 1280 | _findNextAction->setEnabled(enabled); | ||
1301 | _findPreviousAction->setEnabled(enabled); | 1281 | _findPreviousAction->setEnabled(enabled); | ||
1302 | } | 1282 | } | ||
1303 | void SessionController::searchTextChanged(const QString& text) | 1283 | void SessionController::searchTextChanged(const QString& text) | ||
1304 | { | 1284 | { | ||
1305 | Q_ASSERT(_view->screenWindow()); | 1285 | Q_ASSERT(_view->terminalDisplay()->screenWindow()); | ||
1306 | 1286 | | |||
1307 | if (_searchText == text) { | 1287 | if (_searchText == text) { | ||
1308 | return; | 1288 | return; | ||
1309 | } | 1289 | } | ||
1310 | 1290 | | |||
1311 | _searchText = text; | 1291 | _searchText = text; | ||
1312 | 1292 | | |||
1313 | if (text.isEmpty()) { | 1293 | if (text.isEmpty()) { | ||
1314 | _view->screenWindow()->clearSelection(); | 1294 | _view->terminalDisplay()->screenWindow()->clearSelection(); | ||
1315 | _view->screenWindow()->scrollTo(_searchStartLine); | 1295 | _view->terminalDisplay()->screenWindow()->scrollTo(_searchStartLine); | ||
1316 | } | 1296 | } | ||
1317 | 1297 | | |||
1318 | // update search. this is called even when the text is | 1298 | // update search. this is called even when the text is | ||
1319 | // empty to clear the view's filters | 1299 | // empty to clear the view's filters | ||
1320 | beginSearch(text , reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); | 1300 | beginSearch(text , reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); | ||
1321 | } | 1301 | } | ||
1322 | void SessionController::searchCompleted(bool success) | 1302 | void SessionController::searchCompleted(bool success) | ||
1323 | { | 1303 | { | ||
1324 | _prevSearchResultLine = _view->screenWindow()->currentResultLine(); | 1304 | _prevSearchResultLine = _view->terminalDisplay()->screenWindow()->currentResultLine(); | ||
1325 | 1305 | _view->searchBar()->setFoundMatch(success); | |||
1326 | if (!_searchBar.isNull()) { | | |||
1327 | _searchBar->setFoundMatch(success); | | |||
1328 | } | | |||
1329 | } | 1306 | } | ||
1330 | 1307 | | |||
1331 | void SessionController::beginSearch(const QString& text, Enum::SearchDirection direction) | 1308 | void SessionController::beginSearch(const QString& text, Enum::SearchDirection direction) | ||
1332 | { | 1309 | { | ||
1333 | Q_ASSERT(_searchBar); | | |||
1334 | Q_ASSERT(_searchFilter); | 1310 | Q_ASSERT(_searchFilter); | ||
1335 | 1311 | | |||
1336 | QRegularExpression regExp = regexpFromSearchBarOptions(); | 1312 | QRegularExpression regExp = regexpFromSearchBarOptions(); | ||
1337 | _searchFilter->setRegExp(regExp); | 1313 | _searchFilter->setRegExp(regExp); | ||
1338 | 1314 | | |||
1339 | if (_searchStartLine == -1) { | 1315 | if (_searchStartLine == -1) { | ||
1340 | if (direction == Enum::ForwardsSearch) { | 1316 | if (direction == Enum::ForwardsSearch) { | ||
1341 | setSearchStartTo(_view->screenWindow()->currentLine()); | 1317 | setSearchStartTo(_view->terminalDisplay()->screenWindow()->currentLine()); | ||
1342 | } else { | 1318 | } else { | ||
1343 | setSearchStartTo(_view->screenWindow()->currentLine() + _view->screenWindow()->windowLines()); | 1319 | setSearchStartTo(_view->terminalDisplay()->screenWindow()->currentLine() + _view->terminalDisplay()->screenWindow()->windowLines()); | ||
1344 | } | 1320 | } | ||
1345 | } | 1321 | } | ||
1346 | 1322 | | |||
1347 | if (!regExp.pattern().isEmpty()) { | 1323 | if (!regExp.pattern().isEmpty()) { | ||
1348 | _view->screenWindow()->setCurrentResultLine(-1); | 1324 | _view->terminalDisplay()->screenWindow()->setCurrentResultLine(-1); | ||
1349 | auto task = new SearchHistoryTask(this); | 1325 | auto task = new SearchHistoryTask(this); | ||
1350 | 1326 | | |||
1351 | connect(task, &Konsole::SearchHistoryTask::completed, this, &Konsole::SessionController::searchCompleted); | 1327 | connect(task, &Konsole::SearchHistoryTask::completed, this, &Konsole::SessionController::searchCompleted); | ||
1352 | 1328 | | |||
1353 | task->setRegExp(regExp); | 1329 | task->setRegExp(regExp); | ||
1354 | task->setSearchDirection(direction); | 1330 | task->setSearchDirection(direction); | ||
1355 | task->setAutoDelete(true); | 1331 | task->setAutoDelete(true); | ||
1356 | task->setStartLine(_searchStartLine); | 1332 | task->setStartLine(_searchStartLine); | ||
1357 | task->addScreenWindow(_session , _view->screenWindow()); | 1333 | task->addScreenWindow(_session , _view->terminalDisplay()->screenWindow()); | ||
1358 | task->execute(); | 1334 | task->execute(); | ||
1359 | } else if (text.isEmpty()) { | 1335 | } else if (text.isEmpty()) { | ||
1360 | searchCompleted(false); | 1336 | searchCompleted(false); | ||
1361 | } | 1337 | } | ||
1362 | 1338 | | |||
1363 | _view->processFilters(); | 1339 | _view->terminalDisplay()->processFilters(); | ||
1364 | } | 1340 | } | ||
1365 | void SessionController::highlightMatches(bool highlight) | 1341 | void SessionController::highlightMatches(bool highlight) | ||
1366 | { | 1342 | { | ||
1367 | if (highlight) { | 1343 | if (highlight) { | ||
1368 | _view->filterChain()->addFilter(_searchFilter); | 1344 | _view->terminalDisplay()->filterChain()->addFilter(_searchFilter); | ||
1369 | _view->processFilters(); | 1345 | _view->terminalDisplay()->processFilters(); | ||
1370 | } else { | 1346 | } else { | ||
1371 | _view->filterChain()->removeFilter(_searchFilter); | 1347 | _view->terminalDisplay()->filterChain()->removeFilter(_searchFilter); | ||
1372 | } | 1348 | } | ||
1373 | 1349 | | |||
1374 | _view->update(); | 1350 | _view->terminalDisplay()->update(); | ||
1375 | } | 1351 | } | ||
1376 | 1352 | | |||
1377 | void SessionController::searchFrom() | 1353 | void SessionController::searchFrom() | ||
1378 | { | 1354 | { | ||
1379 | Q_ASSERT(_searchBar); | | |||
1380 | Q_ASSERT(_searchFilter); | 1355 | Q_ASSERT(_searchFilter); | ||
1381 | 1356 | | |||
1382 | if (reverseSearchChecked()) { | 1357 | if (reverseSearchChecked()) { | ||
1383 | setSearchStartTo(_view->screenWindow()->lineCount()); | 1358 | setSearchStartTo(_view->terminalDisplay()->screenWindow()->lineCount()); | ||
1384 | } else { | 1359 | } else { | ||
1385 | setSearchStartTo(0); | 1360 | setSearchStartTo(0); | ||
1386 | } | 1361 | } | ||
1387 | 1362 | | |||
1388 | 1363 | | |||
1389 | beginSearch(_searchBar->searchText(), reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); | 1364 | beginSearch(_view->searchBar()->searchText(), reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); | ||
1390 | } | 1365 | } | ||
1391 | void SessionController::findNextInHistory() | 1366 | void SessionController::findNextInHistory() | ||
1392 | { | 1367 | { | ||
1393 | Q_ASSERT(_searchBar); | | |||
1394 | Q_ASSERT(_searchFilter); | 1368 | Q_ASSERT(_searchFilter); | ||
1395 | 1369 | | |||
1396 | setSearchStartTo(_prevSearchResultLine); | 1370 | setSearchStartTo(_prevSearchResultLine); | ||
1397 | 1371 | | |||
1398 | beginSearch(_searchBar->searchText(), reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); | 1372 | beginSearch(_view->searchBar()->searchText(), reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); | ||
1399 | } | 1373 | } | ||
1400 | void SessionController::findPreviousInHistory() | 1374 | void SessionController::findPreviousInHistory() | ||
1401 | { | 1375 | { | ||
1402 | Q_ASSERT(_searchBar); | | |||
1403 | Q_ASSERT(_searchFilter); | 1376 | Q_ASSERT(_searchFilter); | ||
1404 | 1377 | | |||
1405 | setSearchStartTo(_prevSearchResultLine); | 1378 | setSearchStartTo(_prevSearchResultLine); | ||
1406 | 1379 | | |||
1407 | beginSearch(_searchBar->searchText(), reverseSearchChecked() ? Enum::ForwardsSearch : Enum::BackwardsSearch); | 1380 | beginSearch(_view->searchBar()->searchText(), reverseSearchChecked() ? Enum::ForwardsSearch : Enum::BackwardsSearch); | ||
1408 | } | 1381 | } | ||
1409 | void SessionController::changeSearchMatch() | 1382 | void SessionController::changeSearchMatch() | ||
1410 | { | 1383 | { | ||
1411 | Q_ASSERT(_searchBar); | | |||
1412 | Q_ASSERT(_searchFilter); | 1384 | Q_ASSERT(_searchFilter); | ||
1413 | 1385 | | |||
1414 | // reset Selection for new case match | 1386 | // reset Selection for new case match | ||
1415 | _view->screenWindow()->clearSelection(); | 1387 | _view->terminalDisplay()->screenWindow()->clearSelection(); | ||
1416 | beginSearch(_searchBar->searchText(), reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); | 1388 | beginSearch(_view->searchBar()->searchText(), reverseSearchChecked() ? Enum::BackwardsSearch : Enum::ForwardsSearch); | ||
1417 | } | 1389 | } | ||
1418 | void SessionController::showHistoryOptions() | 1390 | void SessionController::showHistoryOptions() | ||
1419 | { | 1391 | { | ||
1420 | QScopedPointer<HistorySizeDialog> dialog(new HistorySizeDialog(QApplication::activeWindow())); | 1392 | QScopedPointer<HistorySizeDialog> dialog(new HistorySizeDialog(QApplication::activeWindow())); | ||
1421 | const HistoryType& currentHistory = _session->historyType(); | 1393 | const HistoryType& currentHistory = _session->historyType(); | ||
1422 | 1394 | | |||
1423 | if (currentHistory.isEnabled()) { | 1395 | if (currentHistory.isEnabled()) { | ||
1424 | if (currentHistory.isUnlimited()) { | 1396 | if (currentHistory.isUnlimited()) { | ||
Show All 14 Lines | |||||
1439 | 1411 | | |||
1440 | if (result != 0) { | 1412 | if (result != 0) { | ||
1441 | scrollBackOptionsChanged(dialog->mode(), dialog->lineCount()); | 1413 | scrollBackOptionsChanged(dialog->mode(), dialog->lineCount()); | ||
1442 | } | 1414 | } | ||
1443 | } | 1415 | } | ||
1444 | void SessionController::sessionResizeRequest(const QSize& size) | 1416 | void SessionController::sessionResizeRequest(const QSize& size) | ||
1445 | { | 1417 | { | ||
1446 | ////qDebug() << "View resize requested to " << size; | 1418 | ////qDebug() << "View resize requested to " << size; | ||
1447 | _view->setSize(size.width(), size.height()); | 1419 | _view->terminalDisplay()->setSize(size.width(), size.height()); | ||
1448 | } | 1420 | } | ||
1449 | void SessionController::scrollBackOptionsChanged(int mode, int lines) | 1421 | void SessionController::scrollBackOptionsChanged(int mode, int lines) | ||
1450 | { | 1422 | { | ||
1451 | switch (mode) { | 1423 | switch (mode) { | ||
1452 | case Enum::NoHistory: | 1424 | case Enum::NoHistory: | ||
1453 | _session->setHistoryType(HistoryTypeNone()); | 1425 | _session->setHistoryType(HistoryTypeNone()); | ||
1454 | break; | 1426 | break; | ||
1455 | case Enum::FixedSizeHistory: | 1427 | case Enum::FixedSizeHistory: | ||
Show All 25 Lines | 1437 | { | |||
1481 | KConfigGroup configGroup(KSharedConfig::openConfig(), "PrintOptions"); | 1453 | KConfigGroup configGroup(KSharedConfig::openConfig(), "PrintOptions"); | ||
1482 | 1454 | | |||
1483 | if (configGroup.readEntry("ScaleOutput", true)) { | 1455 | if (configGroup.readEntry("ScaleOutput", true)) { | ||
1484 | double scale = qMin(printer.pageRect().width() / static_cast<double>(_view->width()), | 1456 | double scale = qMin(printer.pageRect().width() / static_cast<double>(_view->width()), | ||
1485 | printer.pageRect().height() / static_cast<double>(_view->height())); | 1457 | printer.pageRect().height() / static_cast<double>(_view->height())); | ||
1486 | painter.scale(scale, scale); | 1458 | painter.scale(scale, scale); | ||
1487 | } | 1459 | } | ||
1488 | 1460 | | |||
1489 | _view->printContent(painter, configGroup.readEntry("PrinterFriendly", true)); | 1461 | _view->terminalDisplay()->printContent(painter, configGroup.readEntry("PrinterFriendly", true)); | ||
1490 | } | 1462 | } | ||
1491 | 1463 | | |||
1492 | void SessionController::saveHistory() | 1464 | void SessionController::saveHistory() | ||
1493 | { | 1465 | { | ||
1494 | SessionTask* task = new SaveHistoryTask(this); | 1466 | SessionTask* task = new SaveHistoryTask(this); | ||
1495 | task->setAutoDelete(true); | 1467 | task->setAutoDelete(true); | ||
1496 | task->addSession(_session); | 1468 | task->addSession(_session); | ||
1497 | task->execute(); | 1469 | task->execute(); | ||
1498 | } | 1470 | } | ||
1499 | 1471 | | |||
1500 | void SessionController::clearHistory() | 1472 | void SessionController::clearHistory() | ||
1501 | { | 1473 | { | ||
1502 | _session->clearHistory(); | 1474 | _session->clearHistory(); | ||
1503 | _view->updateImage(); // To reset view scrollbar | 1475 | _view->terminalDisplay()->updateImage(); // To reset view scrollbar | ||
1504 | } | 1476 | } | ||
1505 | 1477 | | |||
1506 | void SessionController::clearHistoryAndReset() | 1478 | void SessionController::clearHistoryAndReset() | ||
1507 | { | 1479 | { | ||
1508 | Profile::Ptr profile = SessionManager::instance()->sessionProfile(_session); | 1480 | Profile::Ptr profile = SessionManager::instance()->sessionProfile(_session); | ||
1509 | QByteArray name = profile->defaultEncoding().toUtf8(); | 1481 | QByteArray name = profile->defaultEncoding().toUtf8(); | ||
1510 | 1482 | | |||
1511 | Emulation* emulation = _session->emulation(); | 1483 | Emulation* emulation = _session->emulation(); | ||
1512 | emulation->reset(); | 1484 | emulation->reset(); | ||
1513 | _session->refresh(); | 1485 | _session->refresh(); | ||
1514 | _session->setCodec(QTextCodec::codecForName(name)); | 1486 | _session->setCodec(QTextCodec::codecForName(name)); | ||
1515 | clearHistory(); | 1487 | clearHistory(); | ||
1516 | } | 1488 | } | ||
1517 | 1489 | | |||
1518 | void SessionController::increaseFontSize() | 1490 | void SessionController::increaseFontSize() | ||
1519 | { | 1491 | { | ||
1520 | _view->increaseFontSize(); | 1492 | _view->terminalDisplay()->increaseFontSize(); | ||
1521 | } | 1493 | } | ||
1522 | 1494 | | |||
1523 | void SessionController::decreaseFontSize() | 1495 | void SessionController::decreaseFontSize() | ||
1524 | { | 1496 | { | ||
1525 | _view->decreaseFontSize(); | 1497 | _view->terminalDisplay()->decreaseFontSize(); | ||
1526 | } | 1498 | } | ||
1527 | 1499 | | |||
1528 | void SessionController::monitorActivity(bool monitor) | 1500 | void SessionController::monitorActivity(bool monitor) | ||
1529 | { | 1501 | { | ||
1530 | _session->setMonitorActivity(monitor); | 1502 | _session->setMonitorActivity(monitor); | ||
1531 | } | 1503 | } | ||
1532 | void SessionController::monitorSilence(bool monitor) | 1504 | void SessionController::monitorSilence(bool monitor) | ||
1533 | { | 1505 | { | ||
Show All 37 Lines | 1523 | { | |||
1571 | updateActionState(QStringLiteral("send-signal")); | 1543 | updateActionState(QStringLiteral("send-signal")); | ||
1572 | updateActionState(QStringLiteral("zmodem-upload")); | 1544 | updateActionState(QStringLiteral("zmodem-upload")); | ||
1573 | 1545 | | |||
1574 | _codecAction->setEnabled(!readonly); | 1546 | _codecAction->setEnabled(!readonly); | ||
1575 | 1547 | | |||
1576 | // Without the timer, when detaching a tab while the message widget is visible, | 1548 | // Without the timer, when detaching a tab while the message widget is visible, | ||
1577 | // the size of the terminal becomes really small... | 1549 | // the size of the terminal becomes really small... | ||
1578 | QTimer::singleShot(0, this, [this, readonly]() { | 1550 | QTimer::singleShot(0, this, [this, readonly]() { | ||
1579 | _view->updateReadOnlyState(readonly); | 1551 | _view->terminalDisplay()->updateReadOnlyState(readonly); | ||
1580 | }); | 1552 | }); | ||
1581 | } | 1553 | } | ||
1582 | 1554 | | |||
1583 | bool SessionController::isReadOnly() const | 1555 | bool SessionController::isReadOnly() const | ||
1584 | { | 1556 | { | ||
1585 | if (!_session.isNull()) { | 1557 | if (!_session.isNull()) { | ||
1586 | return _session->isReadOnly(); | 1558 | return _session->isReadOnly(); | ||
1587 | } else { | 1559 | } else { | ||
Show All 29 Lines | |||||
1617 | void SessionController::sessionReadOnlyChanged() { | 1589 | void SessionController::sessionReadOnlyChanged() { | ||
1618 | // Trigger icon update | 1590 | // Trigger icon update | ||
1619 | sessionTitleChanged(); | 1591 | sessionTitleChanged(); | ||
1620 | 1592 | | |||
1621 | updateReadOnlyActionStates(); | 1593 | updateReadOnlyActionStates(); | ||
1622 | 1594 | | |||
1623 | // Update all views | 1595 | // Update all views | ||
1624 | for (TerminalDisplay* view : session()->views()) { | 1596 | for (TerminalDisplay* view : session()->views()) { | ||
1625 | if (view != _view.data()) { | 1597 | if (view != _view->terminalDisplay()) { | ||
1626 | view->updateReadOnlyState(isReadOnly()); | 1598 | view->updateReadOnlyState(isReadOnly()); | ||
1627 | } | 1599 | } | ||
1628 | } | 1600 | } | ||
1629 | } | 1601 | } | ||
1630 | 1602 | | |||
1631 | void SessionController::showDisplayContextMenu(const QPoint& position) | 1603 | void SessionController::showDisplayContextMenu(const QPoint& position) | ||
1632 | { | 1604 | { | ||
1633 | // needed to make sure the popup menu is available, even if a hosting | 1605 | // needed to make sure the popup menu is available, even if a hosting | ||
1634 | // application did not merge our GUI. | 1606 | // application did not merge our GUI. | ||
1635 | if (factory() == nullptr) { | 1607 | if (factory() == nullptr) { | ||
1636 | if (clientBuilder() == nullptr) { | 1608 | if (clientBuilder() == nullptr) { | ||
1637 | setClientBuilder(new KXMLGUIBuilder(_view)); | 1609 | setClientBuilder(new KXMLGUIBuilder(_view->terminalDisplay())); | ||
1638 | } | 1610 | } | ||
1639 | 1611 | | |||
1640 | auto factory = new KXMLGUIFactory(clientBuilder(), this); | 1612 | auto factory = new KXMLGUIFactory(clientBuilder(), this); | ||
1641 | factory->addClient(this); | 1613 | factory->addClient(this); | ||
1642 | ////qDebug() << "Created xmlgui factory" << factory; | 1614 | ////qDebug() << "Created xmlgui factory" << factory; | ||
1643 | } | 1615 | } | ||
1644 | 1616 | | |||
1645 | QPointer<QMenu> popup = qobject_cast<QMenu*>(factory()->container(QStringLiteral("session-popup-menu"), this)); | 1617 | QPointer<QMenu> popup = qobject_cast<QMenu*>(factory()->container(QStringLiteral("session-popup-menu"), this)); | ||
1646 | if (!popup.isNull()) { | 1618 | if (!popup.isNull()) { | ||
1647 | updateReadOnlyActionStates(); | 1619 | updateReadOnlyActionStates(); | ||
1648 | 1620 | | |||
1649 | // prepend content-specific actions such as "Open Link", "Copy Email Address" etc. | 1621 | // prepend content-specific actions such as "Open Link", "Copy Email Address" etc. | ||
1650 | QList<QAction*> contentActions = _view->filterActions(position); | 1622 | QList<QAction*> contentActions = _view->terminalDisplay()->filterActions(position); | ||
1651 | auto contentSeparator = new QAction(popup); | 1623 | auto contentSeparator = new QAction(popup); | ||
1652 | contentSeparator->setSeparator(true); | 1624 | contentSeparator->setSeparator(true); | ||
1653 | contentActions << contentSeparator; | 1625 | contentActions << contentSeparator; | ||
1654 | popup->insertActions(popup->actions().value(0, nullptr), contentActions); | 1626 | popup->insertActions(popup->actions().value(0, nullptr), contentActions); | ||
1655 | 1627 | | |||
1656 | // always update this submenu before showing the context menu, | 1628 | // always update this submenu before showing the context menu, | ||
1657 | // because the available search services might have changed | 1629 | // because the available search services might have changed | ||
1658 | // since the context menu is shown last time | 1630 | // since the context menu is shown last time | ||
▲ Show 20 Lines • Show All 477 Lines • Show Last 20 Lines |
New Empty line