From 0e0a5a5db84c4cdfaa5f167933d811b3bb358bd0 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 21 Jul 2022 08:07:22 +0200 Subject: [PATCH] PerfProfiler: Inline perfloaddialog.ui Change-Id: I4d347cc75248f76e9bf505c2b31a37b4b85ffe6a Reviewed-by: Alessandro Portale --- src/plugins/perfprofiler/CMakeLists.txt | 2 +- src/plugins/perfprofiler/perfloaddialog.cpp | 81 ++++++++++---- src/plugins/perfprofiler/perfloaddialog.h | 15 +-- src/plugins/perfprofiler/perfloaddialog.ui | 112 -------------------- src/plugins/perfprofiler/perfprofiler.qbs | 1 - 5 files changed, 71 insertions(+), 140 deletions(-) delete mode 100644 src/plugins/perfprofiler/perfloaddialog.ui diff --git a/src/plugins/perfprofiler/CMakeLists.txt b/src/plugins/perfprofiler/CMakeLists.txt index 3fd28374b48..f1667687e3b 100644 --- a/src/plugins/perfprofiler/CMakeLists.txt +++ b/src/plugins/perfprofiler/CMakeLists.txt @@ -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 diff --git a/src/plugins/perfprofiler/perfloaddialog.cpp b/src/plugins/perfprofiler/perfloaddialog.cpp index 90de6ea989b..14eb53d1d41 100644 --- a/src/plugins/perfprofiler/perfloaddialog.cpp +++ b/src/plugins/perfprofiler/perfloaddialog.cpp @@ -24,53 +24,94 @@ ****************************************************************************/ #include "perfloaddialog.h" + #include "perfprofilerconstants.h" -#include "ui_perfloaddialog.h" #include #include +#include #include #include #include +#include + +#include +#include +#include +#include +#include +#include + 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 diff --git a/src/plugins/perfprofiler/perfloaddialog.h b/src/plugins/perfprofiler/perfloaddialog.h index 3f38fe374cf..d2ca3bdb067 100644 --- a/src/plugins/perfprofiler/perfloaddialog.h +++ b/src/plugins/perfprofiler/perfloaddialog.h @@ -27,17 +27,18 @@ #include +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 diff --git a/src/plugins/perfprofiler/perfloaddialog.ui b/src/plugins/perfprofiler/perfloaddialog.ui deleted file mode 100644 index dc6ae1972ac..00000000000 --- a/src/plugins/perfprofiler/perfloaddialog.ui +++ /dev/null @@ -1,112 +0,0 @@ - - - PerfProfiler::Internal::PerfLoadDialog - - - - 0 - 0 - 710 - 164 - - - - Load Perf Trace - - - - - - - - &Trace file: - - - traceFileLineEdit - - - - - - - - - - &Browse... - - - - - - - Directory of &executable: - - - executableDirLineEdit - - - - - - - - - - B&rowse... - - - - - - - Kit: - - - - - - - - - - - - Qt::Vertical - - - - 20 - 0 - - - - - - - - Qt::Horizontal - - - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - - ProjectExplorer::KitChooser - QWidget -
projectexplorer/kitchooser.h
- 1 -
-
- -
diff --git a/src/plugins/perfprofiler/perfprofiler.qbs b/src/plugins/perfprofiler/perfprofiler.qbs index a136cdbadd8..e53f9db564c 100644 --- a/src/plugins/perfprofiler/perfprofiler.qbs +++ b/src/plugins/perfprofiler/perfprofiler.qbs @@ -27,7 +27,6 @@ QtcPlugin { "perfeventtype.h", "perfloaddialog.cpp", "perfloaddialog.h", - "perfloaddialog.ui", "perfoptionspage.cpp", "perfoptionspage.h", "perfprofiler_global.h", "perfprofilertr.h",