Changeset View
Changeset View
Standalone View
Standalone View
src/SessionController.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | |||||
92 | int SessionController::_lastControllerId; | 92 | int SessionController::_lastControllerId; | ||
93 | 93 | | |||
94 | SessionController::SessionController(Session* session , TerminalDisplay* view, QObject* parent) | 94 | SessionController::SessionController(Session* session , TerminalDisplay* view, QObject* parent) | ||
95 | : ViewProperties(parent) | 95 | : ViewProperties(parent) | ||
96 | , KXMLGUIClient() | 96 | , KXMLGUIClient() | ||
97 | , _session(session) | 97 | , _session(session) | ||
98 | , _view(view) | 98 | , _view(view) | ||
99 | , _copyToGroup(nullptr) | 99 | , _copyToGroup(nullptr) | ||
100 | , _profileList(nullptr) | | |||
101 | , _sessionIcon(QIcon()) | 100 | , _sessionIcon(QIcon()) | ||
102 | , _sessionIconName(QString()) | 101 | , _sessionIconName(QString()) | ||
103 | , _previousState(-1) | 102 | , _previousState(-1) | ||
104 | , _searchFilter(nullptr) | 103 | , _searchFilter(nullptr) | ||
105 | , _urlFilter(nullptr) | 104 | , _urlFilter(nullptr) | ||
106 | , _fileFilter(nullptr) | 105 | , _fileFilter(nullptr) | ||
107 | , _copyInputToAllTabsAction(nullptr) | 106 | , _copyInputToAllTabsAction(nullptr) | ||
108 | , _findAction(nullptr) | 107 | , _findAction(nullptr) | ||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | 125 | { | |||
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"); | ||
224 | setupSearchBar(); | 223 | setupSearchBar(); | ||
225 | _searchBar->setVisible(_isSearchBarEnabled); | 224 | _searchBar->setVisible(_isSearchBarEnabled); | ||
225 | | ||||
226 | _profileList = ProfileManager::instance()->getProfileList(); | ||||
hindenburg: This isn't good; instead of putting getProfileList() in ViewManager, put it in ProfileManager… | |||||
227 | connect(_profileList, &ProfileList::actionsChanged, this, &Konsole::SessionController::prepareSwitchProfileMenu); | ||||
228 | prepareSwitchProfileMenu(); | ||||
226 | } | 229 | } | ||
227 | 230 | | |||
228 | SessionController::~SessionController() | 231 | SessionController::~SessionController() | ||
229 | { | 232 | { | ||
230 | if (!_view.isNull()) { | 233 | if (!_view.isNull()) { | ||
231 | _view->setScreenWindow(nullptr); | 234 | _view->setScreenWindow(nullptr); | ||
232 | } | 235 | } | ||
233 | 236 | | |||
▲ Show 20 Lines • Show All 251 Lines • ▼ Show 20 Line(s) | 483 | if (event->type() == QEvent::FocusIn && watched == _view) { | |||
485 | // when the view is focused, set bell events from the associated session to be delivered | 488 | // when the view is focused, set bell events from the associated session to be delivered | ||
486 | // by the focused view | 489 | // by the focused view | ||
487 | 490 | | |||
488 | // first, disconnect any other views which are listening for bell signals from the session | 491 | // first, disconnect any other views which are listening for bell signals from the session | ||
489 | disconnect(_session.data(), &Konsole::Session::bellRequest, nullptr, nullptr); | 492 | disconnect(_session.data(), &Konsole::Session::bellRequest, nullptr, nullptr); | ||
490 | // second, connect the newly focused view to listen for the session's bell signal | 493 | // 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); | 494 | connect(_session.data(), &Konsole::Session::bellRequest, _view.data(), &Konsole::TerminalDisplay::bell); | ||
492 | 495 | | |||
496 | disconnect(_profileList, &Konsole::ProfileList::profileSelected, nullptr, nullptr); | ||||
497 | connect(_profileList, &Konsole::ProfileList::profileSelected, this, &Konsole::SessionController::switchProfile); | ||||
498 | | ||||
493 | if ((_copyInputToAllTabsAction != nullptr) && _copyInputToAllTabsAction->isChecked()) { | 499 | if ((_copyInputToAllTabsAction != nullptr) && _copyInputToAllTabsAction->isChecked()) { | ||
494 | // A session with "Copy To All Tabs" has come into focus: | 500 | // A session with "Copy To All Tabs" has come into focus: | ||
495 | // Ensure that newly created sessions are included in _copyToGroup! | 501 | // Ensure that newly created sessions are included in _copyToGroup! | ||
496 | copyInputToAllTabs(); | 502 | copyInputToAllTabs(); | ||
497 | } | 503 | } | ||
498 | } | 504 | } | ||
499 | return Konsole::ViewProperties::eventFilter(watched, event); | 505 | return Konsole::ViewProperties::eventFilter(watched, event); | ||
500 | } | 506 | } | ||
▲ Show 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | 604 | #endif | |||
616 | 622 | | |||
617 | // Profile Options | 623 | // Profile Options | ||
618 | action = collection->addAction(QStringLiteral("edit-current-profile"), this, SLOT(editCurrentProfile())); | 624 | action = collection->addAction(QStringLiteral("edit-current-profile"), this, SLOT(editCurrentProfile())); | ||
619 | action->setText(i18n("Edit Current Profile...")); | 625 | action->setText(i18n("Edit Current Profile...")); | ||
620 | action->setIcon(QIcon::fromTheme(QStringLiteral("document-properties"))); | 626 | action->setIcon(QIcon::fromTheme(QStringLiteral("document-properties"))); | ||
621 | 627 | | |||
622 | _switchProfileMenu = new KActionMenu(i18n("Switch Profile"), this); | 628 | _switchProfileMenu = new KActionMenu(i18n("Switch Profile"), this); | ||
623 | collection->addAction(QStringLiteral("switch-profile"), _switchProfileMenu); | 629 | collection->addAction(QStringLiteral("switch-profile"), _switchProfileMenu); | ||
624 | connect(_switchProfileMenu->menu(), &QMenu::aboutToShow, this, &Konsole::SessionController::prepareSwitchProfileMenu); | | |||
625 | 630 | | |||
626 | // History | 631 | // History | ||
627 | _findAction = KStandardAction::find(this, SLOT(searchBarEvent()), collection); | 632 | _findAction = KStandardAction::find(this, SLOT(searchBarEvent()), collection); | ||
628 | collection->setDefaultShortcut(_findAction, QKeySequence()); | 633 | collection->setDefaultShortcut(_findAction, QKeySequence()); | ||
629 | 634 | | |||
630 | _findNextAction = KStandardAction::findNext(this, SLOT(findNextInHistory()), collection); | 635 | _findNextAction = KStandardAction::findNext(this, SLOT(findNextInHistory()), collection); | ||
631 | collection->setDefaultShortcut(_findNextAction, QKeySequence()); | 636 | collection->setDefaultShortcut(_findNextAction, QKeySequence()); | ||
632 | _findNextAction->setEnabled(false); | 637 | _findNextAction->setEnabled(false); | ||
▲ Show 20 Lines • Show All 142 Lines • ▼ Show 20 Line(s) | 779 | #else | |||
775 | collection->setDefaultShortcut(_findAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_F); | 780 | collection->setDefaultShortcut(_findAction, Konsole::ACCEL + Qt::SHIFT + Qt::Key_F); | ||
776 | collection->setDefaultShortcut(_findNextAction, Qt::Key_F3); | 781 | collection->setDefaultShortcut(_findNextAction, Qt::Key_F3); | ||
777 | collection->setDefaultShortcut(_findPreviousAction, Qt::SHIFT + Qt::Key_F3); | 782 | collection->setDefaultShortcut(_findPreviousAction, Qt::SHIFT + Qt::Key_F3); | ||
778 | #endif | 783 | #endif | ||
779 | } | 784 | } | ||
780 | 785 | | |||
781 | void SessionController::switchProfile(Profile::Ptr profile) | 786 | void SessionController::switchProfile(Profile::Ptr profile) | ||
782 | { | 787 | { | ||
788 | if (isReadOnly()) { | ||||
789 | return; | ||||
790 | } | ||||
791 | | ||||
783 | SessionManager::instance()->setSessionProfile(_session, profile); | 792 | SessionManager::instance()->setSessionProfile(_session, profile); | ||
784 | updateFilterList(profile); | 793 | updateFilterList(profile); | ||
785 | } | 794 | } | ||
786 | 795 | | |||
787 | void SessionController::prepareSwitchProfileMenu() | 796 | void SessionController::prepareSwitchProfileMenu() | ||
788 | { | 797 | { | ||
789 | if (_switchProfileMenu->menu()->isEmpty()) { | | |||
790 | _profileList = new ProfileList(false, this); | | |||
791 | connect(_profileList, &Konsole::ProfileList::profileSelected, this, &Konsole::SessionController::switchProfile); | | |||
792 | } | | |||
793 | | ||||
794 | _switchProfileMenu->menu()->clear(); | 798 | _switchProfileMenu->menu()->clear(); | ||
795 | _switchProfileMenu->menu()->addActions(_profileList->actions()); | 799 | _switchProfileMenu->menu()->addActions(_profileList->actions()); | ||
796 | } | 800 | } | ||
797 | void SessionController::updateCodecAction() | 801 | void SessionController::updateCodecAction() | ||
798 | { | 802 | { | ||
799 | _codecAction->setCurrentCodec(QString::fromUtf8(_session->codec())); | 803 | _codecAction->setCurrentCodec(QString::fromUtf8(_session->codec())); | ||
800 | } | 804 | } | ||
801 | 805 | | |||
▲ Show 20 Lines • Show All 990 Lines • Show Last 20 Lines |
This isn't good; instead of putting getProfileList() in ViewManager, put it in ProfileManager (without QObject) and then do '_profileList = ProfileManager::instance()->getProfileList();
'