Commit e295f48e authored by Matan Ziv-Av's avatar Matan Ziv-Av Committed by Kurt Hindenburg
Browse files

Add an option to ssh plugin to avoid changing profile

The default is not to change profiles on ssh connect/disconnect.
The current state is saved in the ssh plugin config file, and can be modified in the ssh plugin widget.

BUG: 453545
BUG: 459705
FIXED-IN: 22.12
parent 983ba461
Pipeline #257457 passed with stage
in 8 minutes and 46 seconds
......@@ -184,6 +184,10 @@ void SSHManagerModel::setSessionController(Konsole::SessionController *controlle
void SSHManagerModel::triggerProfileChange(const QString &sshHost)
{
if (!manageProfile) {
return;
}
auto *sm = Konsole::SessionManager::instance();
QString profileToLoad;
......@@ -248,6 +252,10 @@ void SSHManagerModel::load()
auto config = KConfig(QStringLiteral("konsolesshconfig"), KConfig::OpenFlag::SimpleConfig);
for (const QString &groupName : config.groupList()) {
KConfigGroup group = config.group(groupName);
if (groupName == QStringLiteral("Global plugin config")) {
manageProfile = group.readEntry<bool>("manageProfile", false);
continue;
}
addTopLevelItem(groupName);
for (const QString &sessionName : group.groupList()) {
SSHConfigurationData data;
......@@ -272,6 +280,9 @@ void SSHManagerModel::save()
config.deleteGroup(groupName);
}
KConfigGroup globalGroup = config.group(QStringLiteral("Global plugin config"));
globalGroup.writeEntry("manageProfile", manageProfile);
for (int i = 0, end = invisibleRootItem()->rowCount(); i < end; i++) {
QStandardItem *groupItem = invisibleRootItem()->child(i);
const QString groupName = groupItem->text();
......@@ -410,3 +421,13 @@ void SSHManagerModel::importFromSshConfigFile(const QString &file)
}
}
}
void SSHManagerModel::setManageProfile(bool manage)
{
manageProfile = manage;
}
bool SSHManagerModel::getManageProfile()
{
return manageProfile;
}
......@@ -56,6 +56,8 @@ public:
bool hasHost(const QString &hostName) const;
std::optional<QString> profileForHost(const QString &host) const;
void setManageProfile(bool manage);
bool getManageProfile();
private:
QStandardItem *m_sshConfigTopLevelItem = nullptr;
......@@ -63,6 +65,8 @@ private:
Konsole::Session *m_session = nullptr;
QHash<Konsole::Session *, QString> m_sessionToProfileName;
bool manageProfile = false;
};
#endif
......@@ -372,6 +372,8 @@ void SSHManagerTreeWidget::setModel(SSHManagerModel *model)
d->model = model;
d->filterModel->setSourceModel(model);
ui->folder->addItems(d->model->folders());
ui->btnManageProfile->setChecked(d->model->getManageProfile());
connect(ui->btnManageProfile, &QPushButton::clicked, d->model, &SSHManagerModel::setManageProfile);
}
void SSHManagerTreeWidget::setCurrentController(Konsole::SessionController *controller)
......
......@@ -49,6 +49,20 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="btnManageProfile">
<property name="toolTip">
<string>Change profile on connect/disconnect</string>
</property>
<property name="text">
<string>Manage profile</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="SshTreeView" name="treeView">
<attribute name="headerVisible">
......
Supports Markdown
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