Commit bc1f84bc authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

"Add Rule" button

parent 60c15751
......@@ -49,9 +49,14 @@ DKIMManageRulesDialog::DKIMManageRulesDialog(QWidget *parent)
buttonBox->setObjectName(QStringLiteral("buttonBox"));
mainLayout->addWidget(buttonBox);
QPushButton *addButton = new QPushButton(i18n("Add Rule..."), this);
buttonBox->addButton(addButton, QDialogButtonBox::ActionRole);
connect(addButton, &QPushButton::clicked, mRulesWidget, &DKIMManageRulesWidget::addRule);
QPushButton *importButton = new QPushButton(i18n("Import..."), this);
buttonBox->addButton(importButton, QDialogButtonBox::ActionRole);
connect(importButton, &QPushButton::clicked, this, &DKIMManageRulesDialog::slotImport);
QPushButton *exportButton = new QPushButton(i18n("Export..."), this);
buttonBox->addButton(exportButton, QDialogButtonBox::ActionRole);
connect(exportButton, &QPushButton::clicked, this, &DKIMManageRulesDialog::slotExport);
......
......@@ -120,18 +120,23 @@ void DKIMManageRulesWidget::restoreHeaders(const QByteArray &header)
mTreeWidget->header()->restoreState(header);
}
void DKIMManageRulesWidget::addRule()
{
QPointer<DKIMRuleDialog> dlg = new DKIMRuleDialog(this);
if (dlg->exec()) {
DKIMManageRulesWidgetItem *item = new DKIMManageRulesWidgetItem(mTreeWidget);
item->setRule(dlg->rule());
}
delete dlg;
}
void DKIMManageRulesWidget::customContextMenuRequested(const QPoint &pos)
{
Q_UNUSED(pos);
QTreeWidgetItem *item = mTreeWidget->currentItem();
QMenu menu(this);
menu.addAction(QIcon::fromTheme(QStringLiteral("list-add")), i18n("Add..."), this, [this]() {
QPointer<DKIMRuleDialog> dlg = new DKIMRuleDialog(this);
if (dlg->exec()) {
DKIMManageRulesWidgetItem *item = new DKIMManageRulesWidgetItem(mTreeWidget);
item->setRule(dlg->rule());
}
delete dlg;
addRule();
});
DKIMManageRulesWidgetItem *rulesItem = dynamic_cast<DKIMManageRulesWidgetItem *>(item);
if (rulesItem) {
......
......@@ -69,6 +69,8 @@ public:
void saveSettings();
Q_REQUIRED_RESULT QByteArray saveHeaders() const;
void restoreHeaders(const QByteArray &header);
void addRule();
private:
void customContextMenuRequested(const QPoint &);
QTreeWidget *mTreeWidget = nullptr;
......
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