Add purpose menu

wilder
Laurent Montel 8 years ago
parent e35fb942d1
commit 2aab7759ea
  1. 1
      agents/mailfilteragent/CMakeLists.txt
  2. 14
      agents/mailfilteragent/filterlogdialog.cpp
  3. 43
      agents/mailfilteragent/mailfilterpurposemenuwidget.cpp
  4. 40
      agents/mailfilteragent/mailfilterpurposemenuwidget.h

@ -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)

@ -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());

@ -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;
}

@ -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
Loading…
Cancel
Save