Commit 7bcaea0c authored by Christoph Cullmann's avatar Christoph Cullmann 🐮
Browse files

allow items in the allow/block list to be removed

parent eec20f0b
......@@ -19,6 +19,7 @@
#include <QJsonDocument>
#include <QJsonParseError>
#include <QMenu>
#include <QPalette>
LSPClientConfigPage::LSPClientConfigPage(QWidget *parent, LSPClientPlugin *plugin)
......@@ -77,6 +78,10 @@ LSPClientConfigPage::LSPClientConfigPage(QWidget *parent, LSPClientPlugin *plugi
connect(ui->allowedAndBlockedServers, &QListWidget::itemChanged, this, &LSPClientConfigPage::changed);
// own context menu to delete entries
ui->allowedAndBlockedServers->setContextMenuPolicy(Qt::CustomContextMenu);
connect(ui->allowedAndBlockedServers, &QWidget::customContextMenuRequested, this, &LSPClientConfigPage::showContextMenuAllowedBlocked);
auto cfgh = [this](int position, int added, int removed) {
Q_UNUSED(position);
// discard format change
......@@ -284,3 +289,21 @@ void LSPClientConfigPage::updateHighlighters()
highlighter->rehighlight();
}
}
void LSPClientConfigPage::showContextMenuAllowedBlocked(const QPoint &pos)
{
// allow deletion of stuff
QMenu myMenu;
auto currentDelete = myMenu.addAction(i18n("Delete current entry"), this, [this]() {
qDeleteAll(ui->allowedAndBlockedServers->selectedItems());
});
currentDelete->setEnabled(!ui->allowedAndBlockedServers->selectedItems().isEmpty());
auto allDelete = myMenu.addAction(i18n("Delete all entries"), this, [this]() {
ui->allowedAndBlockedServers->clear();
});
allDelete->setEnabled(ui->allowedAndBlockedServers->count() > 0);
myMenu.exec(ui->allowedAndBlockedServers->mapToGlobal(pos));
}
......@@ -35,6 +35,7 @@ public Q_SLOTS:
void configTextChanged();
void configUrlChanged();
void updateHighlighters();
void showContextMenuAllowedBlocked(const QPoint &pos);
private:
void readUserConfig(const QString &fileName);
......
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