PerfProfiler: Inline perfloaddialog.ui

Change-Id: I4d347cc75248f76e9bf505c2b31a37b4b85ffe6a
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
hjk
2022-07-21 08:07:22 +02:00
parent 9328aaa835
commit 0e0a5a5db8
5 changed files with 71 additions and 140 deletions

View File

@@ -14,7 +14,7 @@ set(PERFPROFILER_CPP_SOURCES
perfdatareader.cpp perfdatareader.h
perfevent.h
perfeventtype.h
perfloaddialog.cpp perfloaddialog.h perfloaddialog.ui
perfloaddialog.cpp perfloaddialog.h
perfoptionspage.cpp perfoptionspage.h
perfprofiler.qrc
perfprofilerconstants.h

View File

@@ -24,53 +24,94 @@
****************************************************************************/
#include "perfloaddialog.h"
#include "perfprofilerconstants.h"
#include "ui_perfloaddialog.h"
#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/kit.h>
#include <projectexplorer/kitchooser.h>
#include <projectexplorer/project.h>
#include <projectexplorer/session.h>
#include <projectexplorer/target.h>
#include <utils/layoutbuilder.h>
#include <QDialogButtonBox>
#include <QFrame>
#include <QGridLayout>
#include <QLabel>
#include <QLineEdit>
#include <QPushButton>
using namespace Utils;
namespace PerfProfiler {
namespace Internal {
PerfLoadDialog::PerfLoadDialog(QWidget *parent)
: QDialog(parent),
ui(new Ui::PerfLoadDialog)
: QDialog(parent)
{
ui->setupUi(this);
ui->kitChooser->populate();
connect(ui->buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(ui->browseExecutableDirButton, &QPushButton::pressed,
setWindowTitle(tr("Load Perf Trace"));
resize(710, 164);
auto label1 = new QLabel(tr("&Trace file:"));
m_traceFileLineEdit = new QLineEdit(this);
label1->setBuddy(m_traceFileLineEdit);
auto browseTraceFileButton = new QPushButton(tr("&Browse..."));
auto label2 = new QLabel(tr("Directory of &executable:"));
m_executableDirLineEdit = new QLineEdit(this);
label2->setBuddy(m_executableDirLineEdit);
auto browseExecutableDirButton = new QPushButton(tr("B&rowse..."));
auto label3 = new QLabel(tr("Kit:"));
m_kitChooser = new ProjectExplorer::KitChooser(this);
m_kitChooser->populate();
auto line = new QFrame(this);
line->setFrameShape(QFrame::HLine);
line->setFrameShadow(QFrame::Sunken);
auto buttonBox = new QDialogButtonBox(this);
buttonBox->setStandardButtons(QDialogButtonBox::Cancel|QDialogButtonBox::Ok);
using namespace Layouting;
Column {
Grid {
label1, m_traceFileLineEdit, browseTraceFileButton, Break(),
label2, m_executableDirLineEdit, browseExecutableDirButton, Break(),
label3, Span(2, m_kitChooser)
},
Stretch(),
line,
buttonBox
}.attachTo(this);
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
connect(browseExecutableDirButton, &QPushButton::pressed,
this, &PerfLoadDialog::on_browseExecutableDirButton_pressed);
connect(ui->browseTraceFileButton, &QPushButton::pressed,
connect(browseTraceFileButton, &QPushButton::pressed,
this, &PerfLoadDialog::on_browseTraceFileButton_pressed);
chooseDefaults();
}
PerfLoadDialog::~PerfLoadDialog()
{
delete ui;
}
PerfLoadDialog::~PerfLoadDialog() = default;
QString PerfLoadDialog::traceFilePath() const
{
return ui->traceFileLineEdit->text();
return m_traceFileLineEdit->text();
}
QString PerfLoadDialog::executableDirPath() const
{
return ui->executableDirLineEdit->text();
return m_executableDirLineEdit->text();
}
ProjectExplorer::Kit *PerfLoadDialog::kit() const
{
return ui->kitChooser->currentKit();
return m_kitChooser->currentKit();
}
void PerfLoadDialog::on_browseTraceFileButton_pressed()
@@ -81,7 +122,7 @@ void PerfLoadDialog::on_browseTraceFileButton_pressed()
if (filePath.isEmpty())
return;
ui->traceFileLineEdit->setText(filePath.toUserOutput());
m_traceFileLineEdit->setText(filePath.toUserOutput());
}
void PerfLoadDialog::on_browseExecutableDirButton_pressed()
@@ -91,7 +132,7 @@ void PerfLoadDialog::on_browseExecutableDirButton_pressed()
if (filePath.isEmpty())
return;
ui->executableDirLineEdit->setText(filePath.toUserOutput());
m_executableDirLineEdit->setText(filePath.toUserOutput());
}
void PerfLoadDialog::chooseDefaults()
@@ -100,10 +141,10 @@ void PerfLoadDialog::chooseDefaults()
if (!target)
return;
ui->kitChooser->setCurrentKitId(target->kit()->id());
m_kitChooser->setCurrentKitId(target->kit()->id());
if (auto *bc = target->activeBuildConfiguration())
ui->executableDirLineEdit->setText(bc->buildDirectory().toString());
m_executableDirLineEdit->setText(bc->buildDirectory().toString());
}
} // namespace Internal

View File

@@ -27,17 +27,18 @@
#include <QDialog>
QT_BEGIN_NAMESPACE
class QLineEdit;
QT_END_NAMESPACE
namespace ProjectExplorer {
class Kit;
} // namespace ProjectExplorer
class KitChooser;
} // ProjectExplorer
namespace PerfProfiler {
namespace Internal {
namespace Ui {
class PerfLoadDialog;
} // namespace Ui
class PerfLoadDialog : public QDialog
{
Q_OBJECT
@@ -56,7 +57,9 @@ private:
void chooseDefaults();
Ui::PerfLoadDialog *ui;
QLineEdit *m_traceFileLineEdit;
QLineEdit *m_executableDirLineEdit;
ProjectExplorer::KitChooser *m_kitChooser;
};
} // namespace Internal

View File

@@ -1,112 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PerfProfiler::Internal::PerfLoadDialog</class>
<widget class="QWidget" name="PerfProfiler::Internal::PerfLoadDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>710</width>
<height>164</height>
</rect>
</property>
<property name="windowTitle">
<string>Load Perf Trace</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label1">
<property name="text">
<string>&amp;Trace file:</string>
</property>
<property name="buddy">
<cstring>traceFileLineEdit</cstring>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="traceFileLineEdit"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="browseTraceFileButton">
<property name="text">
<string>&amp;Browse...</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label2">
<property name="text">
<string>Directory of &amp;executable:</string>
</property>
<property name="buddy">
<cstring>executableDirLineEdit</cstring>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="executableDirLineEdit"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="browseExecutableDirButton">
<property name="text">
<string>B&amp;rowse...</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label3">
<property name="text">
<string>Kit:</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="ProjectExplorer::KitChooser" name="kitChooser" native="true"/>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</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>
<customwidgets>
<customwidget>
<class>ProjectExplorer::KitChooser</class>
<extends>QWidget</extends>
<header location="global">projectexplorer/kitchooser.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
</ui>

View File

@@ -27,7 +27,6 @@ QtcPlugin {
"perfeventtype.h",
"perfloaddialog.cpp",
"perfloaddialog.h",
"perfloaddialog.ui",
"perfoptionspage.cpp",
"perfoptionspage.h",
"perfprofiler_global.h", "perfprofilertr.h",