forked from qt-creator/qt-creator
PerfProfiler: inline perftracepointdialog.ui
Change-Id: I138d3a4aeae2eef0e2127e8770961109d252ec98 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -36,7 +36,7 @@ set(PERFPROFILER_CPP_SOURCES
|
|||||||
perftimelinemodel.cpp perftimelinemodel.h
|
perftimelinemodel.cpp perftimelinemodel.h
|
||||||
perftimelinemodelmanager.cpp perftimelinemodelmanager.h
|
perftimelinemodelmanager.cpp perftimelinemodelmanager.h
|
||||||
perftimelineresourcesrenderpass.cpp perftimelineresourcesrenderpass.h
|
perftimelineresourcesrenderpass.cpp perftimelineresourcesrenderpass.h
|
||||||
perftracepointdialog.cpp perftracepointdialog.h perftracepointdialog.ui
|
perftracepointdialog.cpp perftracepointdialog.h
|
||||||
)
|
)
|
||||||
|
|
||||||
add_qtc_plugin(PerfProfiler
|
add_qtc_plugin(PerfProfiler
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ QtcPlugin {
|
|||||||
"perfsettings.h",
|
"perfsettings.h",
|
||||||
"perftracepointdialog.cpp",
|
"perftracepointdialog.cpp",
|
||||||
"perftracepointdialog.h",
|
"perftracepointdialog.h",
|
||||||
"perftracepointdialog.ui",
|
|
||||||
"perfprofiler.qrc",
|
"perfprofiler.qrc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
||||||
|
|
||||||
#include "perftracepointdialog.h"
|
#include "perftracepointdialog.h"
|
||||||
#include "ui_perftracepointdialog.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/devicesupport/devicemanager.h>
|
#include <projectexplorer/devicesupport/devicemanager.h>
|
||||||
#include <projectexplorer/kitinformation.h>
|
#include <projectexplorer/kitinformation.h>
|
||||||
@@ -14,20 +13,43 @@
|
|||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/qtcprocess.h>
|
#include <utils/qtcprocess.h>
|
||||||
|
#include <utils/layoutbuilder.h>
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QLabel>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
#include <QTextEdit>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
const char ELEVATE_METHOD_NA[] = "n.a";
|
||||||
|
const char ELEVATE_METHOD_PKEXEC[] = "pkexec";
|
||||||
|
const char ELEVATE_METHOD_SUDO[] = "sudo";
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace PerfProfiler {
|
namespace PerfProfiler {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
PerfTracePointDialog::PerfTracePointDialog() :
|
PerfTracePointDialog::PerfTracePointDialog()
|
||||||
m_ui(new Ui::PerfTracePointDialog)
|
|
||||||
{
|
{
|
||||||
m_ui->setupUi(this);
|
resize(400, 300);
|
||||||
|
m_label = new QLabel(tr("Run the following script as root to create trace points?"));
|
||||||
|
m_textEdit = new QTextEdit;
|
||||||
|
m_privilegesChooser = new QComboBox;
|
||||||
|
m_privilegesChooser->addItems({ELEVATE_METHOD_NA, ELEVATE_METHOD_PKEXEC, ELEVATE_METHOD_SUDO});
|
||||||
|
m_buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
||||||
|
|
||||||
|
using namespace Utils::Layouting;
|
||||||
|
Column {
|
||||||
|
m_label,
|
||||||
|
m_textEdit,
|
||||||
|
Form {
|
||||||
|
tr("Elevate privileges using:"), m_privilegesChooser, br,
|
||||||
|
},
|
||||||
|
m_buttonBox,
|
||||||
|
}.attachTo(this);
|
||||||
|
|
||||||
if (const Target *target = SessionManager::startupTarget()) {
|
if (const Target *target = SessionManager::startupTarget()) {
|
||||||
const Kit *kit = target->kit();
|
const Kit *kit = target->kit();
|
||||||
@@ -35,7 +57,7 @@ PerfTracePointDialog::PerfTracePointDialog() :
|
|||||||
|
|
||||||
m_device = DeviceKitAspect::device(kit);
|
m_device = DeviceKitAspect::device(kit);
|
||||||
if (!m_device) {
|
if (!m_device) {
|
||||||
m_ui->textEdit->setPlainText(tr("Error: No device available for active target."));
|
m_textEdit->setPlainText(tr("Error: No device available for active target."));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -48,31 +70,35 @@ PerfTracePointDialog::PerfTracePointDialog() :
|
|||||||
|
|
||||||
QFile file(":/perfprofiler/tracepoints.sh");
|
QFile file(":/perfprofiler/tracepoints.sh");
|
||||||
if (file.open(QIODevice::ReadOnly)) {
|
if (file.open(QIODevice::ReadOnly)) {
|
||||||
m_ui->textEdit->setPlainText(QString::fromUtf8(file.readAll()));
|
m_textEdit->setPlainText(QString::fromUtf8(file.readAll()));
|
||||||
} else {
|
} else {
|
||||||
m_ui->textEdit->setPlainText(tr("Error: Failed to load trace point script %1: %2.")
|
m_textEdit->setPlainText(tr("Error: Failed to load trace point script %1: %2.")
|
||||||
.arg(file.fileName()).arg(file.errorString()));
|
.arg(file.fileName()).arg(file.errorString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui->privilegesChooser->setCurrentText(m_device->type() == Constants::DESKTOP_DEVICE_TYPE
|
m_privilegesChooser->setCurrentText(
|
||||||
? QLatin1String("pkexec") : QLatin1String("n.a."));
|
QLatin1String(m_device->type() == Constants::DESKTOP_DEVICE_TYPE
|
||||||
|
? ELEVATE_METHOD_PKEXEC : ELEVATE_METHOD_NA));
|
||||||
|
|
||||||
|
connect(m_buttonBox, &QDialogButtonBox::accepted, this, &PerfTracePointDialog::accept);
|
||||||
|
connect(m_buttonBox, &QDialogButtonBox::rejected, this, &PerfTracePointDialog::reject);
|
||||||
}
|
}
|
||||||
|
|
||||||
PerfTracePointDialog::~PerfTracePointDialog() = default;
|
PerfTracePointDialog::~PerfTracePointDialog() = default;
|
||||||
|
|
||||||
void PerfTracePointDialog::runScript()
|
void PerfTracePointDialog::runScript()
|
||||||
{
|
{
|
||||||
m_ui->label->setText(tr("Executing script..."));
|
m_label->setText(tr("Executing script..."));
|
||||||
m_ui->textEdit->setReadOnly(true);
|
m_textEdit->setReadOnly(true);
|
||||||
m_ui->privilegesChooser->setEnabled(false);
|
m_privilegesChooser->setEnabled(false);
|
||||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||||
|
|
||||||
m_process.reset(new QtcProcess(this));
|
m_process.reset(new QtcProcess(this));
|
||||||
m_process->setWriteData(m_ui->textEdit->toPlainText().toUtf8());
|
m_process->setWriteData(m_textEdit->toPlainText().toUtf8());
|
||||||
m_ui->textEdit->clear();
|
m_textEdit->clear();
|
||||||
|
|
||||||
const QString elevate = m_ui->privilegesChooser->currentText();
|
const QString elevate = m_privilegesChooser->currentText();
|
||||||
if (elevate != QLatin1String("n.a."))
|
if (elevate != QLatin1String(ELEVATE_METHOD_NA))
|
||||||
m_process->setCommand({m_device->filePath(elevate), {"sh"}});
|
m_process->setCommand({m_device->filePath(elevate), {"sh"}});
|
||||||
else
|
else
|
||||||
m_process->setCommand({m_device->filePath("sh"), {}});
|
m_process->setCommand({m_device->filePath("sh"), {}});
|
||||||
@@ -93,10 +119,10 @@ void PerfTracePointDialog::handleProcessDone()
|
|||||||
message = tr("Created trace points for: %1").arg(QString::fromUtf8(
|
message = tr("Created trace points for: %1").arg(QString::fromUtf8(
|
||||||
m_process->readAllStandardOutput().trimmed().replace('\n', ", ")));
|
m_process->readAllStandardOutput().trimmed().replace('\n', ", ")));
|
||||||
}
|
}
|
||||||
m_ui->label->setText(message);
|
m_label->setText(message);
|
||||||
m_ui->textEdit->setHtml(QString::fromUtf8(m_process->readAllStandardError()));
|
m_textEdit->setHtml(QString::fromUtf8(m_process->readAllStandardError()));
|
||||||
m_ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
m_buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||||
m_ui->buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
|
m_buttonBox->button(QDialogButtonBox::Cancel)->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PerfTracePointDialog::accept()
|
void PerfTracePointDialog::accept()
|
||||||
|
|||||||
@@ -8,6 +8,13 @@
|
|||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE
|
||||||
|
class QComboBox;
|
||||||
|
class QDialogButtonBox;
|
||||||
|
class QLabel;
|
||||||
|
class QTextEdit;
|
||||||
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace Utils { class QtcProcess; }
|
namespace Utils { class QtcProcess; }
|
||||||
|
|
||||||
namespace PerfProfiler {
|
namespace PerfProfiler {
|
||||||
@@ -28,7 +35,10 @@ private:
|
|||||||
void handleProcessDone();
|
void handleProcessDone();
|
||||||
void finish();
|
void finish();
|
||||||
|
|
||||||
Ui::PerfTracePointDialog *m_ui;
|
QLabel *m_label;
|
||||||
|
QTextEdit *m_textEdit;
|
||||||
|
QComboBox *m_privilegesChooser;
|
||||||
|
QDialogButtonBox *m_buttonBox;
|
||||||
ProjectExplorer::IDeviceConstPtr m_device;
|
ProjectExplorer::IDeviceConstPtr m_device;
|
||||||
std::unique_ptr<Utils::QtcProcess> m_process;
|
std::unique_ptr<Utils::QtcProcess> m_process;
|
||||||
|
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<ui version="4.0">
|
|
||||||
<class>PerfProfiler::Internal::PerfTracePointDialog</class>
|
|
||||||
<widget class="QDialog" name="PerfProfiler::Internal::PerfTracePointDialog">
|
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>400</width>
|
|
||||||
<height>300</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Creating Memory Trace Points</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label">
|
|
||||||
<property name="text">
|
|
||||||
<string>Run the following script as root to create trace points?</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QTextEdit" name="textEdit"/>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<layout class="QHBoxLayout" name="privilegesLayout">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="privilegeslabel">
|
|
||||||
<property name="text">
|
|
||||||
<string>Elevate privileges using:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="privilegesChooser">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">n.a.</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">pkexec</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">sudo</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
<resources/>
|
|
||||||
<connections>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>accepted()</signal>
|
|
||||||
<receiver>PerfProfiler::Internal::PerfTracePointDialog</receiver>
|
|
||||||
<slot>accept()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>248</x>
|
|
||||||
<y>254</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>157</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
<connection>
|
|
||||||
<sender>buttonBox</sender>
|
|
||||||
<signal>rejected()</signal>
|
|
||||||
<receiver>PerfProfiler::Internal::PerfTracePointDialog</receiver>
|
|
||||||
<slot>reject()</slot>
|
|
||||||
<hints>
|
|
||||||
<hint type="sourcelabel">
|
|
||||||
<x>316</x>
|
|
||||||
<y>260</y>
|
|
||||||
</hint>
|
|
||||||
<hint type="destinationlabel">
|
|
||||||
<x>286</x>
|
|
||||||
<y>274</y>
|
|
||||||
</hint>
|
|
||||||
</hints>
|
|
||||||
</connection>
|
|
||||||
</connections>
|
|
||||||
</ui>
|
|
||||||
Reference in New Issue
Block a user