Commit 22b47f62 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Clear all menu

parent db978ce4
......@@ -5,12 +5,28 @@
*/
#include "emoticonrecentlistview.h"
#include <KLocalizedString>
#include <QContextMenuEvent>
#include <QMenu>
using namespace KPIMTextEdit;
EmoticonRecentListView::EmoticonRecentListView(QWidget *parent)
: EmoticonListView(parent)
{
setContextMenuPolicy(Qt::DefaultContextMenu);
}
EmoticonRecentListView::~EmoticonRecentListView()
{
}
void EmoticonRecentListView::contextMenuEvent(QContextMenuEvent *event)
{
if (model()->rowCount() > 0) {
QMenu menu(this);
auto clearRecent = new QAction(i18n("Clear Recents"), &menu);
connect(clearRecent, &QAction::triggered, this, &EmoticonRecentListView::clearAll);
menu.addAction(clearRecent);
menu.exec(event->globalPos());
}
}
......@@ -15,5 +15,11 @@ class KPIMTEXTEDIT_TESTS_EXPORT EmoticonRecentListView : public EmoticonListView
public:
explicit EmoticonRecentListView(QWidget *parent = nullptr);
~EmoticonRecentListView() override;
protected:
void contextMenuEvent(QContextMenuEvent *event) override;
Q_SIGNALS:
void clearAll();
};
}
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