2018-10-18 11:57:19 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** Copyright (C) 2018 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator.
|
|
|
|
|
**
|
|
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
|
|
|
|
**
|
|
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
|
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "perfloaddialog.h"
|
2022-07-21 08:07:22 +02:00
|
|
|
|
2018-10-18 11:57:19 +02:00
|
|
|
#include "perfprofilerconstants.h"
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
|
|
|
|
#include <projectexplorer/kit.h>
|
2022-07-21 08:07:22 +02:00
|
|
|
#include <projectexplorer/kitchooser.h>
|
2018-10-18 11:57:19 +02:00
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/session.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
|
2022-07-21 08:07:22 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QFrame>
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QLineEdit>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
|
2021-08-17 16:36:42 +02:00
|
|
|
using namespace Utils;
|
2018-10-18 11:57:19 +02:00
|
|
|
|
|
|
|
|
namespace PerfProfiler {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
PerfLoadDialog::PerfLoadDialog(QWidget *parent)
|
2022-07-21 08:07:22 +02:00
|
|
|
: QDialog(parent)
|
2018-10-18 11:57:19 +02:00
|
|
|
{
|
2022-07-21 08:07:22 +02:00
|
|
|
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,
|
2018-10-18 11:57:19 +02:00
|
|
|
this, &PerfLoadDialog::on_browseExecutableDirButton_pressed);
|
2022-07-21 08:07:22 +02:00
|
|
|
connect(browseTraceFileButton, &QPushButton::pressed,
|
2018-10-18 11:57:19 +02:00
|
|
|
this, &PerfLoadDialog::on_browseTraceFileButton_pressed);
|
|
|
|
|
chooseDefaults();
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-21 08:07:22 +02:00
|
|
|
PerfLoadDialog::~PerfLoadDialog() = default;
|
2018-10-18 11:57:19 +02:00
|
|
|
|
|
|
|
|
QString PerfLoadDialog::traceFilePath() const
|
|
|
|
|
{
|
2022-07-21 08:07:22 +02:00
|
|
|
return m_traceFileLineEdit->text();
|
2018-10-18 11:57:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString PerfLoadDialog::executableDirPath() const
|
|
|
|
|
{
|
2022-07-21 08:07:22 +02:00
|
|
|
return m_executableDirLineEdit->text();
|
2018-10-18 11:57:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectExplorer::Kit *PerfLoadDialog::kit() const
|
|
|
|
|
{
|
2022-07-21 08:07:22 +02:00
|
|
|
return m_kitChooser->currentKit();
|
2018-10-18 11:57:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PerfLoadDialog::on_browseTraceFileButton_pressed()
|
|
|
|
|
{
|
2021-08-17 16:36:42 +02:00
|
|
|
FilePath filePath = FileUtils::getOpenFilePath(
|
|
|
|
|
this, tr("Choose Perf Trace"), {},
|
|
|
|
|
tr("Perf traces (*%1)").arg(Constants::TraceFileExtension));
|
|
|
|
|
if (filePath.isEmpty())
|
2018-10-18 11:57:19 +02:00
|
|
|
return;
|
|
|
|
|
|
2022-07-21 08:07:22 +02:00
|
|
|
m_traceFileLineEdit->setText(filePath.toUserOutput());
|
2018-10-18 11:57:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PerfLoadDialog::on_browseExecutableDirButton_pressed()
|
|
|
|
|
{
|
2021-08-17 16:36:42 +02:00
|
|
|
FilePath filePath = FileUtils::getExistingDirectory(
|
2018-10-18 11:57:19 +02:00
|
|
|
this, tr("Choose Directory of Executable"));
|
2021-08-17 16:36:42 +02:00
|
|
|
if (filePath.isEmpty())
|
2018-10-18 11:57:19 +02:00
|
|
|
return;
|
|
|
|
|
|
2022-07-21 08:07:22 +02:00
|
|
|
m_executableDirLineEdit->setText(filePath.toUserOutput());
|
2018-10-18 11:57:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void PerfLoadDialog::chooseDefaults()
|
|
|
|
|
{
|
2019-11-21 16:32:50 +01:00
|
|
|
ProjectExplorer::Target *target = ProjectExplorer::SessionManager::startupTarget();
|
2018-10-18 11:57:19 +02:00
|
|
|
if (!target)
|
|
|
|
|
return;
|
|
|
|
|
|
2022-07-21 08:07:22 +02:00
|
|
|
m_kitChooser->setCurrentKitId(target->kit()->id());
|
2018-10-18 11:57:19 +02:00
|
|
|
|
2019-10-25 19:48:14 +02:00
|
|
|
if (auto *bc = target->activeBuildConfiguration())
|
2022-07-21 08:07:22 +02:00
|
|
|
m_executableDirLineEdit->setText(bc->buildDirectory().toString());
|
2018-10-18 11:57:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace PerfProfiler
|