From: Joel Holdsworth Date: Sat, 20 Dec 2014 18:44:58 +0000 (+0000) Subject: Flag: Added context menu X-Git-Tag: pulseview-0.3.0~323 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=97430d7726c69e1710aef223c39c760c79721ff5;p=pulseview.git Flag: Added context menu --- diff --git a/pv/view/flag.cpp b/pv/view/flag.cpp index 2ee8ced4..81cfae87 100644 --- a/pv/view/flag.cpp +++ b/pv/view/flag.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include @@ -74,7 +75,24 @@ pv::widgets::Popup* Flag::create_popup(QWidget *parent) return popup; } +QMenu* Flag::create_context_menu(QWidget *parent) +{ + QMenu *const menu = new QMenu(parent); + + QAction *const del = new QAction(tr("Delete"), this); + del->setShortcuts(QKeySequence::Delete); + connect(del, SIGNAL(triggered()), this, SLOT(on_delete())); + menu->addAction(del); + + return menu; +} + void Flag::delete_pressed() +{ + on_delete(); +} + +void Flag::on_delete() { view_.remove_flag(shared_ptr(shared_from_this())); } diff --git a/pv/view/flag.hpp b/pv/view/flag.hpp index fdebe1c0..c4e4cbb2 100644 --- a/pv/view/flag.hpp +++ b/pv/view/flag.hpp @@ -25,6 +25,8 @@ #include "timemarker.hpp" +class QMenu; + namespace pv { namespace view { @@ -62,9 +64,13 @@ public: pv::widgets::Popup* create_popup(QWidget *parent); + QMenu* create_context_menu(QWidget *parent); + void delete_pressed(); private Q_SLOTS: + void on_delete(); + void on_text_changed(const QString &text); private: