Commit e121a4c3 authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

allow to adjust the allow/block state

parent c290d489
......@@ -75,6 +75,8 @@ LSPClientConfigPage::LSPClientConfigPage(QWidget *parent, LSPClientPlugin *plugi
connect(ui->edtConfigPath, &KUrlRequester::textChanged, this, &LSPClientConfigPage::configUrlChanged);
connect(ui->edtConfigPath, &KUrlRequester::urlSelected, this, &LSPClientConfigPage::configUrlChanged);
connect(ui->allowedAndBlockedServers, &QListWidget::itemChanged, this, &LSPClientConfigPage::changed);
auto cfgh = [this](int position, int added, int removed) {
Q_UNUSED(position);
// discard format change
......@@ -147,6 +149,12 @@ void LSPClientConfigPage::apply()
m_plugin->m_configPath = ui->edtConfigPath->url();
m_plugin->m_serverCommandLineToAllowedState.clear();
for (int i = 0; i < ui->allowedAndBlockedServers->count(); ++i) {
const auto item = ui->allowedAndBlockedServers->item(i);
m_plugin->m_serverCommandLineToAllowedState.emplace(item->text(), item->checkState() == Qt::Checked);
}
// own scope to ensure file is flushed before we signal below in writeConfig!
{
QFile configFile(m_plugin->configPath().toLocalFile());
......@@ -189,6 +197,13 @@ void LSPClientConfigPage::reset()
ui->edtConfigPath->setUrl(m_plugin->m_configPath);
readUserConfig(m_plugin->configPath().toLocalFile());
// fill in the allowed and blocked servers
ui->allowedAndBlockedServers->clear();
for (const auto &it : m_plugin->m_serverCommandLineToAllowedState) {
auto item = new QListWidgetItem(it.first, ui->allowedAndBlockedServers);
item->setCheckState(it.second ? Qt::Checked : Qt::Unchecked);
}
}
void LSPClientConfigPage::defaults()
......
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>622</width>
<width>671</width>
<height>751</height>
</rect>
</property>
......@@ -259,6 +259,16 @@
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_4">
<attribute name="title">
<string>Allowed &amp;&amp; Blocked Servers</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="allowedAndBlockedServers"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="tab_2">
<attribute name="title">
<string>User Server Settings</string>
......@@ -274,8 +284,8 @@
</widget>
</item>
<item>
<widget class="KUrlRequester" name="edtConfigPath" native="true">
<property name="text" stdset="0">
<widget class="KUrlRequester" name="edtConfigPath">
<property name="text">
<string/>
</property>
</widget>
......
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