[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [kmail] agents/mailfilteragent: Add purpose menu
From:       Laurent Montel <null () kde ! org>
Date:       2018-09-28 5:57:00
Message-ID: E1g5lls-0004xe-MX () code ! kde ! org
[Download RAW message or body]

Git commit 2aab7759eaed67bfe9a49d52ae9be3bb9ecb0bba by Laurent Montel.
Committed on 28/09/2018 at 05:56.
Pushed by mlaurent into branch 'master'.

Add purpose menu

M  +1    -0    agents/mailfilteragent/CMakeLists.txt
M  +14   -0    agents/mailfilteragent/filterlogdialog.cpp
A  +43   -0    agents/mailfilteragent/mailfilterpurposemenuwidget.cpp     [License: \
LGPL (v2+)] A  +40   -0    agents/mailfilteragent/mailfilterpurposemenuwidget.h     \
[License: LGPL (v2+)]

https://commits.kde.org/kmail/2aab7759eaed67bfe9a49d52ae9be3bb9ecb0bba

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 <MailCommon/FilterLog>
 #include "kpimtextedit/plaintexteditorwidget.h"
 #include "kpimtextedit/plaintexteditor.h"
+#include "mailfilterpurposemenuwidget.h"
 
 #include "mailfilteragent_debug.h"
 #include <QFileDialog>
@@ -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 <montel@kde.org>
+
+   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 <KPIMTextEdit/PlainTextEditor>
+
+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 <montel@kde.org>
+
+   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 <PimCommon/PurposeMenuWidget>
+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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic