Commit 687bda9e authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add context menu

parent 45a1f064
......@@ -33,6 +33,7 @@
#include <KSharedConfig>
#include <QDialogButtonBox>
#include <KConfigGroup>
#include <QMenu>
KNoteFindDialog::KNoteFindDialog(QWidget *parent)
: QDialog(parent)
......@@ -99,9 +100,11 @@ KNoteFindWidget::KNoteFindWidget(QWidget *parent)
//Result
mNoteList = new NoteShared::NoteListWidget(this);
mNoteList->setContextMenuPolicy(Qt::CustomContextMenu);
mNoteList->setSelectionMode(QAbstractItemView::SingleSelection);
connect(mNoteList, &NoteShared::NoteListWidget::itemDoubleClicked,
this, &KNoteFindWidget::slotItemDoubleClicked);
connect(mNoteList, &NoteShared::NoteListWidget::customContextMenuRequested, this, &KNoteFindWidget::customContextMenuRequested);
vbox->addWidget(mNoteList);
mResultSearch = new QLabel(this);
......@@ -156,3 +159,15 @@ void KNoteFindWidget::slotTextChanged(const QString &text)
{
mSearchButton->setEnabled(!text.trimmed().isEmpty());
}
void KNoteFindWidget::customContextMenuRequested(const QPoint &)
{
QListWidgetItem *item = mNoteList->currentItem();
QMenu menu(this);
if (item) {
menu.addAction(i18n("Show Note"), this, [this, item]() {
Q_EMIT noteSelected(mNoteList->itemId(item));
});
menu.exec(QCursor::pos());
}
}
......@@ -48,6 +48,7 @@ private Q_SLOTS:
void slotItemDoubleClicked(QListWidgetItem *);
private:
void customContextMenuRequested(const QPoint &);
QHash<Akonadi::Item::Id, Akonadi::Item> mNotes;
QLabel *mResultSearch = nullptr;
QLineEdit *mSearchLineEdit = 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