From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org, stephen@brennan.io,
"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH v2 2/3] kernel-shark: give more space to the command field of the Record dialog
Date: Wed, 18 Sep 2019 17:23:18 +0300 [thread overview]
Message-ID: <20190918142319.11821-3-y.karadz@gmail.com> (raw)
In-Reply-To: <20190918142319.11821-1-y.karadz@gmail.com>
Since the Record dialog not support parsing of complex multi-line
commands the corresponding field of the widget has to be able to
accommodate such multi-line user input.
Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
kernel-shark/src/KsCaptureDialog.cpp | 29 +++++++++++++++++++++++++---
kernel-shark/src/KsCaptureDialog.hpp | 18 ++++++++++++++++-
2 files changed, 43 insertions(+), 4 deletions(-)
diff --git a/kernel-shark/src/KsCaptureDialog.cpp b/kernel-shark/src/KsCaptureDialog.cpp
index 7c2ef46..fff42aa 100644
--- a/kernel-shark/src/KsCaptureDialog.cpp
+++ b/kernel-shark/src/KsCaptureDialog.cpp
@@ -29,6 +29,25 @@ static inline tep_handle *local_events()
return tracecmd_local_events(tracecmd_get_tracing_dir());
}
+/**
+ * @brief Create KsCommandLineEdit.
+ *
+ * @param text: Defaulst text to be shown.
+ * @param parent: The parent of this widget.
+ */
+KsCommandLineEdit::KsCommandLineEdit(QString text, QWidget *parent)
+: QPlainTextEdit(text, parent) {}
+
+QSize KsCommandLineEdit::minimumSizeHint() const
+{
+ return {FONT_WIDTH * 30, FONT_HEIGHT * 2};
+}
+
+QSize KsCommandLineEdit::sizeHint() const
+{
+ return {FONT_WIDTH * 30, FONT_HEIGHT * 3};
+}
+
/** @brief Create KsCaptureControl widget. */
KsCaptureControl::KsCaptureControl(QWidget *parent)
: QWidget(parent),
@@ -117,7 +136,11 @@ KsCaptureControl::KsCaptureControl(QWidget *parent)
_commandLabel.adjustSize();
_commandLabel.setFixedWidth(_outputLabel.width());
_execLayout.addWidget(&_commandLabel, row, 0);
+
_commandLineEdit.setFixedWidth(FONT_WIDTH * 30);
+ _commandLineEdit.setMinimumHeight(FONT_HEIGHT * 2);
+ _commandLineEdit.setMaximumHeight(FONT_HEIGHT * 9);
+
_execLayout.addWidget(&_commandLineEdit, row, 1);
_commandCheckBox.setCheckState(Qt::Unchecked);
_commandCheckBox.adjustSize();
@@ -171,7 +194,7 @@ QStringList KsCaptureControl::getArgs()
argv << "-o" << outputFileName();
- argv << KsUtils::splitArguments(_commandLineEdit.text());
+ argv << KsUtils::splitArguments(_commandLineEdit.toPlainText());
return argv;
}
@@ -282,7 +305,7 @@ void KsCaptureControl::_importSettings()
_outputLineEdit.setText(KS_C_STR_CAST(temp->conf_doc));
if (kshark_config_doc_get(conf, "Command", temp))
- _commandLineEdit.setText(KS_C_STR_CAST(temp->conf_doc));
+ _commandLineEdit.setPlainText(KS_C_STR_CAST(temp->conf_doc));
}
void KsCaptureControl::_exportSettings()
@@ -330,7 +353,7 @@ void KsCaptureControl::_exportSettings()
kshark_config_doc_add(conf, "Output", kshark_json_to_conf(jout));
/* Save the command. */
- comm = _commandLineEdit.text();
+ comm = _commandLineEdit.toPlainText();
json_object *jcomm = json_object_new_string(comm.toStdString().c_str());
kshark_config_doc_add(conf, "Command", kshark_json_to_conf(jcomm));
diff --git a/kernel-shark/src/KsCaptureDialog.hpp b/kernel-shark/src/KsCaptureDialog.hpp
index f8ddf4a..612080c 100644
--- a/kernel-shark/src/KsCaptureDialog.hpp
+++ b/kernel-shark/src/KsCaptureDialog.hpp
@@ -18,6 +18,20 @@
// KernelShark
#include "KsWidgetsLib.hpp"
+/**
+ * The KsCommandLineEdit class is used to override the default size hints of
+ * the QPlainTextEdit class.
+ */
+struct KsCommandLineEdit : public QPlainTextEdit
+{
+ KsCommandLineEdit(QString text, QWidget *parent = 0);
+
+private:
+ QSize sizeHint() const override;
+
+ QSize minimumSizeHint() const override;
+};
+
/**
* The KsCaptureControl class provides a control panel for the KernelShark
* Capture dialog.
@@ -57,7 +71,9 @@ private:
QLabel _pluginsLabel, _outputLabel, _commandLabel;
- QLineEdit _outputLineEdit, _commandLineEdit;
+ QLineEdit _outputLineEdit;
+
+ KsCommandLineEdit _commandLineEdit;
QToolBar _settingsToolBar, _controlToolBar;
--
2.20.1
next prev parent reply other threads:[~2019-09-18 14:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-18 14:23 [PATCH v2 0/3] Support "shell quoting" in the Record dialog Yordan Karadzhov (VMware)
2019-09-18 14:23 ` [PATCH v2 1/3] kernel-shark: Provide parsing for quotation marks in Record command line Yordan Karadzhov (VMware)
2019-09-19 23:20 ` Steven Rostedt
2019-09-20 9:48 ` Yordan Karadzhov (VMware)
2019-09-18 14:23 ` Yordan Karadzhov (VMware) [this message]
2019-09-18 14:23 ` [PATCH v2 3/3] kernel-shark: Add quotation marks parsing example/test Yordan Karadzhov (VMware)
2019-09-19 23:12 ` Steven Rostedt
2019-09-20 9:50 ` Yordan Karadzhov (VMware)
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=20190918142319.11821-3-y.karadz@gmail.com \
--to=y.karadz@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=stephen@brennan.io \
/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).