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