diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -134,7 +134,7 @@ // emulator (as they are reserved for use by terminal applications) correctStandardShortcuts(); - setProfileList(new ProfileList(true, this)); + setProfileList(new ProfileList(false, this)); // this must come at the end applyKonsoleSettings(); diff --git a/src/ProfileManager.h b/src/ProfileManager.h --- a/src/ProfileManager.h +++ b/src/ProfileManager.h @@ -33,6 +33,7 @@ // Konsole #include "Profile.h" +#include "ProfileList.h" namespace Konsole { /** @@ -211,6 +212,7 @@ */ Profile::Ptr findByShortcut(const QKeySequence &shortcut); + ProfileList *getProfileList(); Q_SIGNALS: /** Emitted when a profile is added to the manager. */ @@ -288,6 +290,8 @@ // finds out if it's a internal profile or an external one, // fixing the path to point to the correct location for the profile. QString normalizePath(const QString& path) const; + + ProfileList *_profileList; }; /** diff --git a/src/ProfileManager.cpp b/src/ProfileManager.cpp --- a/src/ProfileManager.cpp +++ b/src/ProfileManager.cpp @@ -76,6 +76,7 @@ , _loadedAllProfiles(false) , _loadedFavorites(false) , _shortcuts(QMap()) + , _profileList(nullptr) { //load fallback profile _fallbackProfile = Profile::Ptr(new Profile()); @@ -697,3 +698,10 @@ return QKeySequence(); } +ProfileList *ProfileManager::getProfileList() +{ + if (_profileList == nullptr) { + _profileList = new ProfileList(true, this); + } + return _profileList; +} diff --git a/src/SessionController.cpp b/src/SessionController.cpp --- a/src/SessionController.cpp +++ b/src/SessionController.cpp @@ -97,7 +97,6 @@ , _session(session) , _view(view) , _copyToGroup(nullptr) - , _profileList(nullptr) , _sessionIcon(QIcon()) , _sessionIconName(QString()) , _previousState(-1) @@ -223,6 +222,10 @@ _bookmarkValidProgramsToClear << QStringLiteral("tcsh") << QStringLiteral("zsh"); setupSearchBar(); _searchBar->setVisible(_isSearchBarEnabled); + + _profileList = ProfileManager::instance()->getProfileList(); + connect(_profileList, &ProfileList::actionsChanged, this, &Konsole::SessionController::prepareSwitchProfileMenu); + prepareSwitchProfileMenu(); } SessionController::~SessionController() @@ -490,6 +493,9 @@ // second, connect the newly focused view to listen for the session's bell signal connect(_session.data(), &Konsole::Session::bellRequest, _view.data(), &Konsole::TerminalDisplay::bell); + disconnect(_profileList, &Konsole::ProfileList::profileSelected, nullptr, nullptr); + connect(_profileList, &Konsole::ProfileList::profileSelected, this, &Konsole::SessionController::switchProfile); + if ((_copyInputToAllTabsAction != nullptr) && _copyInputToAllTabsAction->isChecked()) { // A session with "Copy To All Tabs" has come into focus: // Ensure that newly created sessions are included in _copyToGroup! @@ -621,7 +627,6 @@ _switchProfileMenu = new KActionMenu(i18n("Switch Profile"), this); collection->addAction(QStringLiteral("switch-profile"), _switchProfileMenu); - connect(_switchProfileMenu->menu(), &QMenu::aboutToShow, this, &Konsole::SessionController::prepareSwitchProfileMenu); // History _findAction = KStandardAction::find(this, SLOT(searchBarEvent()), collection); @@ -780,17 +785,16 @@ void SessionController::switchProfile(Profile::Ptr profile) { + if (isReadOnly()) { + return; + } + SessionManager::instance()->setSessionProfile(_session, profile); updateFilterList(profile); } void SessionController::prepareSwitchProfileMenu() { - if (_switchProfileMenu->menu()->isEmpty()) { - _profileList = new ProfileList(false, this); - connect(_profileList, &Konsole::ProfileList::profileSelected, this, &Konsole::SessionController::switchProfile); - } - _switchProfileMenu->menu()->clear(); _switchProfileMenu->menu()->addActions(_profileList->actions()); } diff --git a/src/SessionManager.cpp b/src/SessionManager.cpp --- a/src/SessionManager.cpp +++ b/src/SessionManager.cpp @@ -156,6 +156,10 @@ Q_ASSERT(profile); + if (_sessionProfiles[session] == profile) { + return; + } + _sessionProfiles[session] = profile; applyProfile(session, profile, false);