diff options
author | Yordan Karadzhov <ykaradzhov@vmware.com> | 2019-02-12 19:03:58 +0200 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2019-02-13 09:40:26 -0500 |
commit | 595d43c5b9c0db36e647c2d3b2b77887140bffb2 (patch) | |
tree | 413ef6823912af12b4294ae15d597339d3003919 | |
parent | e50d3bbfc9a44e3e79147b41f6cd4d6258db1ee5 (diff) | |
download | trace-cmd-595d43c5b9c0db36e647c2d3b2b77887140bffb2.tar.gz |
kernel-shark: Customize the marker switching button
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.
Link: http://lore.kernel.org/linux-trace-devel/20190212170402.10104-2-ykaradzhov@vmware.com
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202327
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r-- | kernel-shark/src/KsDualMarker.cpp | 21 | ||||
-rw-r--r-- | 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 dbeb9230..43bc1774 100644 --- a/kernel-shark/src/KsDualMarker.cpp +++ b/kernel-shark/src/KsDualMarker.cpp @@ -13,6 +13,21 @@ #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. * * @param s: The Identifier of the marker (state A or state B). @@ -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 73d4f8a4..597bddb2 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; |