diff mbox series

[2/4] kernel-shark: Add dialog for user-defined plugin to the Tools menu

Message ID 20190308171405.15266-3-ykaradzhov@vmware.com (mailing list archive)
State Superseded
Headers show
Series Add dialog for loading user-defined plugins | expand

Commit Message

Yordan Karadzhov March 8, 2019, 5:14 p.m. UTC
The dialog allows the user to find and load the plugin's
lobrary (.so file).

Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
---
 kernel-shark/src/KsMainWindow.cpp | 20 ++++++++++++++++++++
 kernel-shark/src/KsMainWindow.hpp |  4 ++++
 2 files changed, 24 insertions(+)
diff mbox series

Patch

diff --git a/kernel-shark/src/KsMainWindow.cpp b/kernel-shark/src/KsMainWindow.cpp
index 362b955..004c9ac 100644
--- a/kernel-shark/src/KsMainWindow.cpp
+++ b/kernel-shark/src/KsMainWindow.cpp
@@ -59,6 +59,7 @@  KsMainWindow::KsMainWindow(QWidget *parent)
   _cpuSelectAction("CPUs", this),
   _taskSelectAction("Tasks", this),
   _pluginsAction("Plugins", this),
+  _addPluginAction("Add plugin", this),
   _captureAction("Record", this),
   _colorAction(this),
   _colSlider(this),
@@ -233,6 +234,11 @@  void KsMainWindow::_createActions()
 	connect(&_pluginsAction,	&QAction::triggered,
 		this,			&KsMainWindow::_pluginSelect);
 
+	_addPluginAction.setStatusTip("Add plugin");
+
+	connect(&_addPluginAction,	&QAction::triggered,
+		this,			&KsMainWindow::_pluginAdd);
+
 	_captureAction.setIcon(QIcon::fromTheme("media-record"));
 	_captureAction.setShortcut(tr("Ctrl+R"));
 	_captureAction.setStatusTip("Capture trace data");
@@ -336,6 +342,7 @@  void KsMainWindow::_createMenus()
 	/* Tools menu */
 	tools = menuBar()->addMenu("Tools");
 	tools->addAction(&_pluginsAction);
+	tools->addAction(&_addPluginAction);
 	tools->addAction(&_captureAction);
 	tools->addSeparator();
 	tools->addAction(&_colorAction);
@@ -796,6 +803,19 @@  void KsMainWindow::_pluginSelect()
 	dialog->show();
 }
 
+void KsMainWindow::_pluginAdd()
+{
+	QString fileName;
+
+	fileName = QFileDialog::getOpenFileName(this, "Add KernelShark plugin", KS_DIR,
+						"KernelShark Plugins (*.so);;");
+
+	if (fileName.isEmpty())
+		return;
+
+	_plugins.addPlugin(fileName);
+}
+
 void KsMainWindow::_record()
 {
 #ifndef DO_AS_ROOT
diff --git a/kernel-shark/src/KsMainWindow.hpp b/kernel-shark/src/KsMainWindow.hpp
index 969b603..a4eed19 100644
--- a/kernel-shark/src/KsMainWindow.hpp
+++ b/kernel-shark/src/KsMainWindow.hpp
@@ -132,6 +132,8 @@  private:
 	// Tools menu.
 	QAction		_pluginsAction;
 
+	QAction		_addPluginAction;
+
 	QAction		_captureAction;
 
 	QWidgetAction	_colorAction;
@@ -185,6 +187,8 @@  private:
 
 	void _pluginSelect();
 
+	void _pluginAdd();
+
 	void _record();
 
 	void _setColorPhase(int);