diff options
Diffstat (limited to 'src-qt5/core')
-rw-r--r-- | src-qt5/core/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.cpp | 16 | ||||
-rw-r--r-- | src-qt5/core/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.h | 4 |
2 files changed, 18 insertions, 2 deletions
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(); +} diff --git a/src-qt5/core/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.h b/src-qt5/core/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.h index 5084dadf..2994cb97 100644 --- a/src-qt5/core/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.h +++ b/src-qt5/core/lumina-desktop/desktop-plugins/notepad/NotepadPlugin.h @@ -29,7 +29,7 @@ public: } private: QPlainTextEdit *edit; - QToolButton *config; //*open, *add, *rem; + QToolButton *config; // *open, *add, *rem; QComboBox *cnote; QFrame *frame; QFileSystemWatcher *watcher; @@ -53,6 +53,8 @@ private slots: void noteChanged(); void loadIcons(); + void showContextMenuForEdit(const QPoint &pos); + void resetContextMenu(); public slots: void LocaleChange(){ |