Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit d689ba54 authored by Thomas Surrel's avatar Thomas Surrel Committed by Kurt Hindenburg

Profile shortcuts switch profile instead of opening new tab

Summary:
This is a proposal to modify the profile shortcuts behaviour:
instead of opening a new tab with the corresponding profile
they now switch the profile of the current terminal display.

FEATURE: 319926

Reviewers: #konsole, hindenburg, tcanabrava

Reviewed By: #konsole, hindenburg

Subscribers: loh.tar, konsole-devel

Tags: #konsole

Differential Revision: https://phabricator.kde.org/D17374
parent 137ee330
......@@ -134,7 +134,7 @@ MainWindow::MainWindow() :
// 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();
......
......@@ -76,6 +76,7 @@ ProfileManager::ProfileManager()
, _loadedAllProfiles(false)
, _loadedFavorites(false)
, _shortcuts(QMap<QKeySequence, ShortcutData>())
, _profileList(nullptr)
{
//load fallback profile
_fallbackProfile = Profile::Ptr(new Profile());
......@@ -697,3 +698,10 @@ QKeySequence ProfileManager::shortcut(Profile::Ptr profile) const
return QKeySequence();
}
ProfileList *ProfileManager::getProfileList()
{
if (_profileList == nullptr) {
_profileList = new ProfileList(true, this);
}
return _profileList;
}
......@@ -33,6 +33,7 @@
// Konsole
#include "Profile.h"
#include "ProfileList.h"
namespace Konsole {
/**
......@@ -211,6 +212,7 @@ public:
*/
Profile::Ptr findByShortcut(const QKeySequence &shortcut);
ProfileList *getProfileList();
Q_SIGNALS:
/** Emitted when a profile is added to the manager. */
......@@ -288,6 +290,8 @@ private:
// 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;
};
/**
......
......@@ -97,7 +97,6 @@ SessionController::SessionController(Session* session , TerminalDisplay* view, Q
, _session(session)
, _view(view)
, _copyToGroup(nullptr)
, _profileList(nullptr)
, _sessionIcon(QIcon())
, _sessionIconName(QString())
, _previousState(-1)
......@@ -223,6 +222,10 @@ SessionController::SessionController(Session* session , TerminalDisplay* view, Q
_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 @@ bool SessionController::eventFilter(QObject* watched , QEvent* event)
// 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 @@ void SessionController::setupCommonActions()
_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::setupExtraActions()
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());
}
......
......@@ -156,6 +156,10 @@ void SessionManager::setSessionProfile(Session *session, Profile::Ptr profile)
Q_ASSERT(profile);
if (_sessionProfiles[session] == profile) {
return;
}
_sessionProfiles[session] = profile;
applyProfile(session, profile, false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment