From 2462587f45be033249cf8e036fd6a4dff91c744f Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Fri, 10 Mar 2017 14:07:35 -0500 Subject: Fix up the context menu policies for the notepad desktop plugin. --- .../desktop-plugins/notepad/NotepadPlugin.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src-qt5/core/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp') diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp b/src-qt5/core/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp index 6d321305..479cc23e 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp +++ b/src-qt5/core/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp @@ -60,7 +60,9 @@ NotePadPlugin::NotePadPlugin(QWidget* parent, QString ID) : LDPlugin(parent, ID) edit->setReadOnly(false); edit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); vlay->addWidget(edit); - edit->setContextMenuPolicy(Qt::NoContextMenu); + edit->setContextMenuPolicy(Qt::CustomContextMenu); //Need to forward the context menu request to the plugin itself + connect(edit, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT( showContextMenuForEdit(const QPoint&)) ); + //Now load the new file-based system for saving notes //qDebug() << "Saving a new setting"; @@ -328,3 +330,15 @@ void NotePadPlugin::loadIcons(){ rem->setIcon( LXDG::findIcon("document-close","") );*/ config->setIcon( LXDG::findIcon("configure","") ); } + +void NotePadPlugin::showContextMenuForEdit(const QPoint &pos){ + this->setContextMenu( edit->createStandardContextMenu(pos) ); + connect(this->contextMenu(), SIGNAL(aboutToHide()), this, SLOT(resetContextMenu()) ); + this->showPluginMenu(); +} + +void NotePadPlugin::resetContextMenu(){ + QMenu *menu = this->contextMenu(); + this->setContextMenu(0); + menu->deleteLater(); +} -- cgit