linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yordan Karadzhov <ykaradzhov@vmware.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org,
	Yordan Karadzhov <ykaradzhov@vmware.com>
Subject: [PATCH 1/5] kernel-shark: Customize the marker switching button
Date: Tue, 12 Feb 2019 19:03:58 +0200	[thread overview]
Message-ID: <20190212170402.10104-2-ykaradzhov@vmware.com> (raw)
In-Reply-To: <20190212170402.10104-1-ykaradzhov@vmware.com>

The handler for "mouse press events" in the customized button is
reimplemented in order to provide the emission of a "deselect"
signal in the case of right mouse click. Two additional signals are
defined in KsDualMarkerSM. Those signals are used to re-emit the
"deselect" signals of the two marker buttons. Later (in another patch)
the signals will be connected to methods where the actual deselection
of the markers will take place.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202327
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/src/KsDualMarker.cpp | 21 ++++++++++++++
 kernel-shark/src/KsDualMarker.hpp | 46 +++++++++++++++++++++++++++++--
 2 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/kernel-shark/src/KsDualMarker.cpp b/kernel-shark/src/KsDualMarker.cpp
index dbeb923..43bc177 100644
--- a/kernel-shark/src/KsDualMarker.cpp
+++ b/kernel-shark/src/KsDualMarker.cpp
@@ -12,6 +12,21 @@
 #include "KsDualMarker.hpp"
 #include "KsGLWidget.hpp"
 
+/**
+ * Reimplemented handler for mouse press events. Right mouse click events will
+ * deselect the corresponding marker.
+ */
+void KsMarkerButton::mousePressEvent(QMouseEvent *e)
+{
+	if(e->button() == Qt::RightButton) {
+		emit deselect();
+
+		return;
+	}
+
+	QPushButton::mousePressEvent(e);
+}
+
 /**
  * @brief Create KsGraphMark object.
  *
@@ -178,6 +193,9 @@ KsDualMarkerSM::KsDualMarkerSM(QWidget *parent)
 	connect(&_buttonB,	&QPushButton::clicked,
 		this,		&KsDualMarkerSM::_doStateB);
 
+	connect(&_buttonB,	&KsMarkerButton::deselect,
+		this,		&KsDualMarkerSM::deselectB);
+
 	/* Define transitions from State B to State A. */
 	_stateB->addTransition(this,	&KsDualMarkerSM::machineToA, _stateA);
 
@@ -192,6 +210,9 @@ KsDualMarkerSM::KsDualMarkerSM(QWidget *parent)
 	connect(&_buttonA,	&QPushButton::clicked,
 		this,		&KsDualMarkerSM::_doStateA);
 
+	connect(&_buttonA,	&KsMarkerButton::deselect,
+		this,		&KsDualMarkerSM::deselectA);
+
 	_machine.addState(_stateA);
 	_machine.addState(_stateB);
 	_machine.setInitialState(_stateA);
diff --git a/kernel-shark/src/KsDualMarker.hpp b/kernel-shark/src/KsDualMarker.hpp
index 73d4f8a..597bddb 100644
--- a/kernel-shark/src/KsDualMarker.hpp
+++ b/kernel-shark/src/KsDualMarker.hpp
@@ -19,6 +19,36 @@
 #include "KsUtils.hpp"
 #include "KsPlotTools.hpp"
 
+/**
+ * The Marker Button class provides a button that deselect the corresponding
+ * marker in the case of a Right  mouse click.
+ */
+class KsMarkerButton : public QPushButton
+{
+	Q_OBJECT
+public:
+	/**
+	 * @brief Create a default button.
+	 */
+	explicit KsMarkerButton(QWidget *parent = nullptr)
+	: QPushButton(parent) {}
+
+	/**
+	 * @brief Create a button with text.
+	 */
+	explicit KsMarkerButton(const QString &text, QWidget *parent = nullptr)
+	: QPushButton(text, parent) {}
+
+	void mousePressEvent(QMouseEvent *e);
+
+signals:
+	/**
+	 * This signal is emitted when the button is click by the Right mouse
+	 * button.
+	 */
+	void deselect();
+};
+
 class KsGLWidget;
 
 /** The KsGraphMark represents a marker for KernelShark GUI. */
@@ -161,10 +191,22 @@ signals:
 	 */
 	void machineToB();
 
+	/**
+	 * This signal is used to re-emitted the deselect signal of the
+	 * Marker A button.
+	 */
+	void deselectA();
+
+	/**
+	 * This signal is used to re-emitted the deselect signal of the
+	 * Marker B button.
+	 */
+	void deselectB();
+
 private:
-	QPushButton	 _buttonA;
+	KsMarkerButton	 _buttonA;
 
-	QPushButton	 _buttonB;
+	KsMarkerButton	 _buttonB;
 
 	QLabel		 _labelMA, _labelMB, _labelDelta;
 
-- 
2.17.1


  reply	other threads:[~2019-02-12 17:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-12 17:03 [PATCH 0/5] The right click of the button deselects the marker Yordan Karadzhov
2019-02-12 17:03 ` Yordan Karadzhov [this message]
2019-02-12 17:03 ` [PATCH 2/5] kernel-shark: Define a method in View for selecting the Passive marker Yordan Karadzhov
2019-02-12 17:04 ` [PATCH 3/5] kernel-shark: Define KS_NO_ROW_SELECTED as a negative row index (-1) Yordan Karadzhov
2019-02-12 17:04 ` [PATCH 4/5] kernel-shark-qt: Do marker-deselect by right mouse click of the button Yordan Karadzhov
2019-02-12 17:04 ` [PATCH 5/5] kernel-shark: Rename the method for deselecting the Active marker Yordan Karadzhov
2019-02-13 14:41 ` [PATCH 0/5] The right click of the button deselects the marker Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190212170402.10104-2-ykaradzhov@vmware.com \
    --to=ykaradzhov@vmware.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).