linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] kernel-shark-qt: Improve the KsQuickContextMenu
@ 2018-12-17 17:55 Yordan Karadzhov
  2018-12-17 17:56 ` [PATCH 2/3] kernel-shark-qt: Better positioning of the Quick Context menu Yordan Karadzhov
  2018-12-17 17:56 ` [PATCH 3/3] kernel-shark-qt: Make the Quick Contex menu less touchy Yordan Karadzhov
  0 siblings, 2 replies; 3+ messages in thread
From: Yordan Karadzhov @ 2018-12-17 17:55 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

In this patch the KsQuickContextMenu gets upgraded according
to the user feedback, received from Steven. First of all a
"Show CPU X only" action is added to the version of the menu
that gets opened from the Table widget. In addition to this
"Apply filter to XX" check-boxes are added in order to control
the visibility of the filtered data.

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark-qt/src/KsQuickContextMenu.cpp | 45 ++++++++++++++++++++++
 kernel-shark-qt/src/KsQuickContextMenu.hpp |  6 ++-
 2 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/kernel-shark-qt/src/KsQuickContextMenu.cpp b/kernel-shark-qt/src/KsQuickContextMenu.cpp
index 815e4b9..6c9c9ef 100644
--- a/kernel-shark-qt/src/KsQuickContextMenu.cpp
+++ b/kernel-shark-qt/src/KsQuickContextMenu.cpp
@@ -50,11 +50,14 @@ KsQuickContextMenu::KsQuickContextMenu(KsDataStore *data, size_t row,
 : KsQuickMarkerMenu(dm, parent),
   _data(data),
   _row(row),
+  _graphSyncCBox(nullptr),
+  _listSyncCBox(nullptr),
   _hideTaskAction(this),
   _showTaskAction(this),
   _hideEventAction(this),
   _showEventAction(this),
   _hideCPUAction(this),
+  _showCPUAction(this),
   _addCPUPlotAction(this),
   _addTaskPlotAction(this),
   _removeCPUPlotAction(this),
@@ -85,6 +88,37 @@ KsQuickContextMenu::KsQuickContextMenu(KsDataStore *data, size_t row,
 	parentName = parent->metaObject()->className();
 
 	addSection("Pointer menu");
+
+	if (parentName == "KsTraceViewer") {
+		_graphSyncCBox =
+			KsUtils::addCheckBoxToMenu(this, "Apply filters to Graph");
+
+		connect(_graphSyncCBox,	&QCheckBox::stateChanged,
+					&KsUtils::graphFilterSync);
+
+		/*
+		 * By defauls the filters will be append to the List (Table)
+		 * only.
+		 */
+		KsUtils::listFilterSync(true);
+		KsUtils::graphFilterSync(false);
+		_graphSyncCBox->setChecked(false);
+	}
+
+	if (parentName == "KsTraceGraph" &&
+	    (graphs = dynamic_cast<KsTraceGraph *>(parent))) {
+		_listSyncCBox =
+			KsUtils::addCheckBoxToMenu(this, "Apply filters to List");
+
+		connect(_listSyncCBox,	&QCheckBox::stateChanged,
+					&KsUtils::listFilterSync);
+
+		/* By defauls the filters will be append to the Graph only. */
+		KsUtils::graphFilterSync(true);
+		KsUtils::listFilterSync(false);
+		_listSyncCBox->setChecked(false);
+	}
+
 	descr = "Hide task [";
 	descr += taskName;
 	descr += "-";
@@ -113,6 +147,9 @@ KsQuickContextMenu::KsQuickContextMenu(KsDataStore *data, size_t row,
 	lamAddAction(&_hideCPUAction, &KsQuickContextMenu::_hideCPU);
 
 	if (parentName == "KsTraceViewer") {
+		descr = QString("Show CPU [%1] only").arg(cpu);
+		lamAddAction(&_showCPUAction, &KsQuickContextMenu::_showCPU);
+
 		descr = "Add [";
 		descr += taskName;
 		descr += "-";
@@ -198,6 +235,13 @@ void KsQuickContextMenu::_showEvent()
 	_data->applyPosEventFilter(QVector<int>(1, eventId));
 }
 
+void KsQuickContextMenu::_showCPU()
+{
+	int cpu = _data->rows()[_row]->cpu;
+
+	_data->applyPosCPUFilter(QVector<int>(1, cpu));
+}
+
 void KsQuickContextMenu::_hideCPU()
 {
 	kshark_context *kshark_ctx(nullptr);
@@ -208,6 +252,7 @@ void KsQuickContextMenu::_hideCPU()
 
 	vec =_getFilterVector(kshark_ctx->hide_cpu_filter,
 			      _data->rows()[_row]->cpu);
+
 	_data->applyNegCPUFilter(vec);
 }
 
diff --git a/kernel-shark-qt/src/KsQuickContextMenu.hpp b/kernel-shark-qt/src/KsQuickContextMenu.hpp
index 6ca1b08..f5a2a78 100644
--- a/kernel-shark-qt/src/KsQuickContextMenu.hpp
+++ b/kernel-shark-qt/src/KsQuickContextMenu.hpp
@@ -71,6 +71,8 @@ private:
 
 	void _showEvent();
 
+	void _showCPU();
+
 	void _hideCPU();
 
 	void _addCPUPlot();
@@ -87,11 +89,13 @@ private:
 
 	size_t		_row;
 
+	QCheckBox	*_graphSyncCBox, *_listSyncCBox;
+
 	QAction _hideTaskAction, _showTaskAction;
 
 	QAction _hideEventAction, _showEventAction;
 
-	QAction _hideCPUAction;
+	QAction _hideCPUAction, _showCPUAction;
 
 	QAction _addCPUPlotAction;
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/3] kernel-shark-qt: Better positioning of the Quick Context menu.
  2018-12-17 17:55 [PATCH 1/3] kernel-shark-qt: Improve the KsQuickContextMenu Yordan Karadzhov
@ 2018-12-17 17:56 ` Yordan Karadzhov
  2018-12-17 17:56 ` [PATCH 3/3] kernel-shark-qt: Make the Quick Contex menu less touchy Yordan Karadzhov
  1 sibling, 0 replies; 3+ messages in thread
From: Yordan Karadzhov @ 2018-12-17 17:56 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

So far I wrongly assumed that the coordinates of the point provided by
the customContextMenuRequested signal are given in the reference frame
of the parent widget (KsTraceGraph or KsTraceViewer). In fact the signal
is emitted by the child widget (KsGLWidget or KsTableView) and the
coordinates are given in the reference frame of the child. This patch
provides a proper positioning of the menu.

Reported-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark-qt/src/KsTraceGraph.cpp  | 13 ++++++++-----
 kernel-shark-qt/src/KsTraceViewer.cpp | 13 +++++++++++--
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/kernel-shark-qt/src/KsTraceGraph.cpp b/kernel-shark-qt/src/KsTraceGraph.cpp
index 858930c..5144f61 100644
--- a/kernel-shark-qt/src/KsTraceGraph.cpp
+++ b/kernel-shark-qt/src/KsTraceGraph.cpp
@@ -136,7 +136,7 @@ KsTraceGraph::KsTraceGraph(QWidget *parent)
 		this,			&KsTraceGraph::_updateTimeLegends);
 
 	_glWindow.setContextMenuPolicy(Qt::CustomContextMenu);
-	connect(&_glWindow,	&QTableView::customContextMenuRequested,
+	connect(&_glWindow,	&QWidget::customContextMenuRequested,
 		this,		&KsTraceGraph::_onCustomContextMenu);
 
 	_scrollArea.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
@@ -782,12 +782,15 @@ void KsTraceGraph::_onCustomContextMenu(const QPoint &point)
 		connect(menu,	&KsQuickMarkerMenu::deselect,
 			this,	&KsTraceGraph::deselect);
 
-		QPoint global = mapToGlobal(point);
 		/*
-		 * The global coordinates have to be corrected for the offset
-		 * of the vertical scrollbar.
+		 * Note that this slot was connected to the
+		 * customContextMenuRequested signal of the OpenGL widget.
+		 * Because of this the coordinates of the point are given with
+		 * respect to the frame of this widget.
 		 */
-		global.ry() -= _scrollArea.verticalScrollBar()->value();
+		QPoint global = _glWindow.mapToGlobal(point);
+		global.ry() -= menu->sizeHint().height() / 2;
+
 		menu->exec(global);
 	}
 }
diff --git a/kernel-shark-qt/src/KsTraceViewer.cpp b/kernel-shark-qt/src/KsTraceViewer.cpp
index 971793f..09f6a1e 100644
--- a/kernel-shark-qt/src/KsTraceViewer.cpp
+++ b/kernel-shark-qt/src/KsTraceViewer.cpp
@@ -150,7 +150,7 @@ KsTraceViewer::KsTraceViewer(QWidget *parent)
 		this, &KsTraceViewer::_searchReset);
 
 	_view.setContextMenuPolicy(Qt::CustomContextMenu);
-	connect(&_view,	&QTableView::customContextMenuRequested,
+	connect(&_view,	&QWidget::customContextMenuRequested,
 		this,	&KsTraceViewer::_onCustomContextMenu);
 
 	connect(&_view,	&QTableView::clicked,
@@ -263,13 +263,22 @@ void KsTraceViewer::_onCustomContextMenu(const QPoint &point)
 		size_t row = _proxyModel.mapRowFromSource(i.row());
 		KsQuickContextMenu menu(_data, row, _mState, this);
 
+		/*
+		 * Note that this slot was connected to the
+		 * customContextMenuRequested signal of the Table widget.
+		 * Because of this the coordinates of the point are given with
+		 * respect to the frame of this widget.
+		 */
+		QPoint global = _view.mapToGlobal(point);
+		global.ry() -= menu.sizeHint().height() / 2;
+
 		connect(&menu,	&KsQuickContextMenu::addTaskPlot,
 			this,	&KsTraceViewer::addTaskPlot);
 
 		connect(&menu,	&KsQuickMarkerMenu::deselect,
 			this,	&KsTraceViewer::deselect);
 
-		menu.exec(mapToGlobal(point));
+		menu.exec(global);
 	}
 }
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 3/3] kernel-shark-qt: Make the Quick Contex menu less touchy
  2018-12-17 17:55 [PATCH 1/3] kernel-shark-qt: Improve the KsQuickContextMenu Yordan Karadzhov
  2018-12-17 17:56 ` [PATCH 2/3] kernel-shark-qt: Better positioning of the Quick Context menu Yordan Karadzhov
@ 2018-12-17 17:56 ` Yordan Karadzhov
  1 sibling, 0 replies; 3+ messages in thread
From: Yordan Karadzhov @ 2018-12-17 17:56 UTC (permalink / raw)
  To: rostedt; +Cc: linux-trace-devel

The menu is shifted just a bit so that it is not positioned under
the mouse. This will prevent from an accidental selection of the menu
item under the mouse.

Reported-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark-qt/src/KsTraceGraph.cpp  | 7 +++++++
 kernel-shark-qt/src/KsTraceViewer.cpp | 7 +++++++
 2 files changed, 14 insertions(+)

diff --git a/kernel-shark-qt/src/KsTraceGraph.cpp b/kernel-shark-qt/src/KsTraceGraph.cpp
index 5144f61..462918f 100644
--- a/kernel-shark-qt/src/KsTraceGraph.cpp
+++ b/kernel-shark-qt/src/KsTraceGraph.cpp
@@ -791,6 +791,13 @@ void KsTraceGraph::_onCustomContextMenu(const QPoint &point)
 		QPoint global = _glWindow.mapToGlobal(point);
 		global.ry() -= menu->sizeHint().height() / 2;
 
+		/*
+		 * Shift the menu so that it is not positioned under the mouse.
+		 * This will prevent from an accidental selection of the menu
+		 * item under the mouse.
+		 */
+		global.rx() += FONT_WIDTH;
+
 		menu->exec(global);
 	}
 }
diff --git a/kernel-shark-qt/src/KsTraceViewer.cpp b/kernel-shark-qt/src/KsTraceViewer.cpp
index 09f6a1e..d64c2af 100644
--- a/kernel-shark-qt/src/KsTraceViewer.cpp
+++ b/kernel-shark-qt/src/KsTraceViewer.cpp
@@ -272,6 +272,13 @@ void KsTraceViewer::_onCustomContextMenu(const QPoint &point)
 		QPoint global = _view.mapToGlobal(point);
 		global.ry() -= menu.sizeHint().height() / 2;
 
+		/*
+		 * Shift the menu so that it is not positioned under the mouse.
+		 * This will prevent from an accidental selection of the menu
+		 * item under the mouse.
+		 */
+		global.rx() += FONT_WIDTH;
+
 		connect(&menu,	&KsQuickContextMenu::addTaskPlot,
 			this,	&KsTraceViewer::addTaskPlot);
 
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-12-17 17:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-17 17:55 [PATCH 1/3] kernel-shark-qt: Improve the KsQuickContextMenu Yordan Karadzhov
2018-12-17 17:56 ` [PATCH 2/3] kernel-shark-qt: Better positioning of the Quick Context menu Yordan Karadzhov
2018-12-17 17:56 ` [PATCH 3/3] kernel-shark-qt: Make the Quick Contex menu less touchy Yordan Karadzhov

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).