]> sigrok.org Git - pulseview.git/commitdiff
Flag: Added context menu
authorJoel Holdsworth <redacted>
Sat, 20 Dec 2014 18:44:58 +0000 (18:44 +0000)
committerJoel Holdsworth <redacted>
Mon, 29 Dec 2014 11:56:00 +0000 (11:56 +0000)
pv/view/flag.cpp
pv/view/flag.hpp

index 2ee8ced4972413439d67ba938014c2dee5617e46..81cfae873eb82365f355b109c15cc54b0d390e4a 100644 (file)
@@ -24,6 +24,7 @@
 #include <QColor>
 #include <QFormLayout>
 #include <QLineEdit>
+#include <QMenu>
 
 #include <libsigrok/libsigrok.hpp>
 
@@ -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<Flag>(shared_from_this()));
 }
index fdebe1c0a6b4139b9675aa57c1771ed151fc7041..c4e4cbb2c211b8b11e7ba96cebcfe274d6651f23 100644 (file)
@@ -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: