Commit b8130ea5 authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Allow changing the name of a group of keys

GnuPG-bug-id: 5175, 5239
parent 71980f21
...@@ -82,6 +82,7 @@ void EditGroupCommand::Private::start() ...@@ -82,6 +82,7 @@ void EditGroupCommand::Private::start()
void EditGroupCommand::Private::slotDialogAccepted() void EditGroupCommand::Private::slotDialogAccepted()
{ {
group.setName(dialog->groupName());
group.setKeys(dialog->groupKeys()); group.setKeys(dialog->groupKeys());
KeyCache::mutableInstance()->update(group); KeyCache::mutableInstance()->update(group);
......
...@@ -68,7 +68,7 @@ class EditGroupDialog::Private ...@@ -68,7 +68,7 @@ class EditGroupDialog::Private
EditGroupDialog *const q; EditGroupDialog *const q;
struct { struct {
QLabel *groupNameLabel = nullptr; QLineEdit *groupNameEdit = nullptr;
QLineEdit *availableKeysFilter = nullptr; QLineEdit *availableKeysFilter = nullptr;
QListView *availableKeysList = nullptr; QListView *availableKeysList = nullptr;
QLineEdit *groupKeysFilter = nullptr; QLineEdit *groupKeysFilter = nullptr;
...@@ -86,9 +86,11 @@ public: ...@@ -86,9 +86,11 @@ public:
{ {
auto mainLayout = new QVBoxLayout(q); auto mainLayout = new QVBoxLayout(q);
ui.groupNameLabel = new QLabel(); auto groupNameLayout = new QHBoxLayout();
ui.groupNameLabel->setWordWrap(true); groupNameLayout->addWidget(new QLabel(i18nc("Name of a group of keys", "Name:")));
mainLayout->addWidget(ui.groupNameLabel); ui.groupNameEdit = new QLineEdit();
groupNameLayout->addWidget(ui.groupNameEdit);
mainLayout->addLayout(groupNameLayout);
mainLayout->addWidget(new KSeparator(Qt::Horizontal)); mainLayout->addWidget(new KSeparator(Qt::Horizontal));
...@@ -167,10 +169,16 @@ public: ...@@ -167,10 +169,16 @@ public:
mainLayout->addWidget(new KSeparator(Qt::Horizontal)); mainLayout->addWidget(new KSeparator(Qt::Horizontal));
ui.buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); ui.buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
KGuiItem::assign(ui.buttonBox->button(QDialogButtonBox::Ok), KStandardGuiItem::ok()); QPushButton *okButton = ui.buttonBox->button(QDialogButtonBox::Ok);
KGuiItem::assign(okButton, KStandardGuiItem::ok());
KGuiItem::assign(ui.buttonBox->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel()); KGuiItem::assign(ui.buttonBox->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
okButton->setEnabled(false);
mainLayout->addWidget(ui.buttonBox); mainLayout->addWidget(ui.buttonBox);
connect(ui.groupNameEdit, &QLineEdit::textChanged,
q, [okButton] (const QString &text) {
okButton->setEnabled(!text.trimmed().isEmpty());
});
connect(ui.availableKeysFilter, &QLineEdit::textChanged, availableKeysFilterModel, &QSortFilterProxyModel::setFilterFixedString); connect(ui.availableKeysFilter, &QLineEdit::textChanged, availableKeysFilterModel, &QSortFilterProxyModel::setFilterFixedString);
connect(ui.availableKeysList->selectionModel(), &QItemSelectionModel::selectionChanged, connect(ui.availableKeysList->selectionModel(), &QItemSelectionModel::selectionChanged,
q, [addButton] (const QItemSelection &selected, const QItemSelection &) { q, [addButton] (const QItemSelection &selected, const QItemSelection &) {
...@@ -276,7 +284,12 @@ EditGroupDialog::~EditGroupDialog() ...@@ -276,7 +284,12 @@ EditGroupDialog::~EditGroupDialog()
void EditGroupDialog::setGroupName(const QString &name) void EditGroupDialog::setGroupName(const QString &name)
{ {
d->ui.groupNameLabel->setText(name); d->ui.groupNameEdit->setText(name);
}
QString EditGroupDialog::groupName() const
{
return d->ui.groupNameEdit->text().trimmed();
} }
void EditGroupDialog::setGroupKeys(const std::vector<Key> &keys) void EditGroupDialog::setGroupKeys(const std::vector<Key> &keys)
......
...@@ -33,6 +33,7 @@ public: ...@@ -33,6 +33,7 @@ public:
~EditGroupDialog() override; ~EditGroupDialog() override;
void setGroupName(const QString &name); void setGroupName(const QString &name);
QString groupName() const;
void setGroupKeys(const std::vector<GpgME::Key> &keys); void setGroupKeys(const std::vector<GpgME::Key> &keys);
std::vector<GpgME::Key> groupKeys() const; std::vector<GpgME::Key> groupKeys() const;
......
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