diff --git a/agents/mailfilteragent/CMakeLists.txt b/agents/mailfilteragent/CMakeLists.txt index ffe3761c9..04a4468b4 100644 --- a/agents/mailfilteragent/CMakeLists.txt +++ b/agents/mailfilteragent/CMakeLists.txt @@ -10,6 +10,7 @@ set(akonadi_mailfilter_agent_SRCS mailfilteragent.cpp configuredialog.cpp configurewidget.cpp + mailfilterpurposemenuwidget.cpp ) qt5_add_dbus_adaptor(akonadi_mailfilter_agent_SRCS org.freedesktop.Akonadi.MailFilterAgent.xml mailfilteragent.h MailFilterAgent) diff --git a/agents/mailfilteragent/filterlogdialog.cpp b/agents/mailfilteragent/filterlogdialog.cpp index 7acdab186..50c9f5806 100644 --- a/agents/mailfilteragent/filterlogdialog.cpp +++ b/agents/mailfilteragent/filterlogdialog.cpp @@ -31,6 +31,7 @@ #include #include "kpimtextedit/plaintexteditorwidget.h" #include "kpimtextedit/plaintexteditor.h" +#include "mailfilterpurposemenuwidget.h" #include "mailfilteragent_debug.h" #include @@ -73,6 +74,8 @@ FilterLogDialog::FilterLogDialog(QWidget *parent) connect(buttonBox, &QDialogButtonBox::rejected, this, &FilterLogDialog::reject); setWindowIcon(QIcon::fromTheme(QStringLiteral("view-filter"))); setModal(false); + + buttonBox->button(QDialogButtonBox::Close)->setDefault(true); KGuiItem::assign(mUser1Button, KStandardGuiItem::clear()); KGuiItem::assign(mUser2Button, KStandardGuiItem::saveAs()); @@ -95,6 +98,17 @@ FilterLogDialog::FilterLogDialog(QWidget *parent) mTextEdit->editor()->appendHtml(*it); } + MailfilterPurposeMenuWidget *purposeMenu = new MailfilterPurposeMenuWidget(this, this); + if (purposeMenu->menu()) { + QPushButton *mShareButton = new QPushButton(i18n("Share..."), this); + mShareButton->setMenu(purposeMenu->menu()); + mShareButton->setIcon(QIcon::fromTheme(QStringLiteral("document-share"))); + purposeMenu->setEditorWidget(mTextEdit->editor()); + buttonBox->addButton(mShareButton, QDialogButtonBox::ActionRole); + } else { + delete purposeMenu; + } + mLogActiveBox = new QCheckBox(i18n("&Log filter activities"), page); pageVBoxLayout->addWidget(mLogActiveBox); mLogActiveBox->setChecked(FilterLog::instance()->isLogging()); diff --git a/agents/mailfilteragent/mailfilterpurposemenuwidget.cpp b/agents/mailfilteragent/mailfilterpurposemenuwidget.cpp new file mode 100644 index 000000000..2d7529a2e --- /dev/null +++ b/agents/mailfilteragent/mailfilterpurposemenuwidget.cpp @@ -0,0 +1,43 @@ +/* + Copyright (C) 2018 Laurent Montel + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ +#include "mailfilterpurposemenuwidget.h" +#include + +MailfilterPurposeMenuWidget::MailfilterPurposeMenuWidget(QWidget *parentWidget, QObject *parent) + : PimCommon::PurposeMenuWidget(parentWidget, parent) +{ + +} + +MailfilterPurposeMenuWidget::~MailfilterPurposeMenuWidget() +{ +} + +QByteArray MailfilterPurposeMenuWidget::text() +{ + if (mEditor) { + return mEditor->toPlainText().toUtf8(); + } + return {}; +} + +void MailfilterPurposeMenuWidget::setEditorWidget(KPIMTextEdit::PlainTextEditor *editor) +{ + mEditor = editor; +} diff --git a/agents/mailfilteragent/mailfilterpurposemenuwidget.h b/agents/mailfilteragent/mailfilterpurposemenuwidget.h new file mode 100644 index 000000000..0d6c60f74 --- /dev/null +++ b/agents/mailfilteragent/mailfilterpurposemenuwidget.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2018 Laurent Montel + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Library General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Library General Public License for more details. + + You should have received a copy of the GNU Library General Public License + along with this library; see the file COPYING.LIB. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef MAILFILTERPURPOSEMENUWIDGET_H +#define MAILFILTERPURPOSEMENUWIDGET_H + +#include +namespace KPIMTextEdit { +class PlainTextEditor; +} +class MailfilterPurposeMenuWidget : public PimCommon::PurposeMenuWidget +{ + Q_OBJECT +public: + explicit MailfilterPurposeMenuWidget(QWidget *parentWidget, QObject *parent = nullptr); + ~MailfilterPurposeMenuWidget() override; + + QByteArray text() override; + void setEditorWidget(KPIMTextEdit::PlainTextEditor *editor); +private: + KPIMTextEdit::PlainTextEditor *mEditor = nullptr; +}; + +#endif // MAILFILTERPURPOSEMENUWIDGET_H