@@ -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);
@@ -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;
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(-)