2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2019 The Qt Company Ltd.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2019-05-16 17:51:55 +02:00
|
|
|
|
|
|
|
|
#include "parseissuesdialog.h"
|
|
|
|
|
|
|
|
|
|
#include "ioutputparser.h"
|
2023-08-11 09:18:56 +02:00
|
|
|
#include "kitaspects.h"
|
2019-05-16 17:51:55 +02:00
|
|
|
#include "kitchooser.h"
|
|
|
|
|
#include "kitmanager.h"
|
|
|
|
|
#include "projectexplorerconstants.h"
|
2023-01-13 12:38:22 +01:00
|
|
|
#include "projectexplorertr.h"
|
2019-05-16 17:51:55 +02:00
|
|
|
#include "taskhub.h"
|
|
|
|
|
|
|
|
|
|
#include <QButtonGroup>
|
|
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QDialogButtonBox>
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QFileDialog>
|
|
|
|
|
#include <QGroupBox>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
2021-08-17 16:36:42 +02:00
|
|
|
using namespace Utils;
|
|
|
|
|
|
2019-05-16 17:51:55 +02:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class ParseIssuesDialog::Private
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
QPlainTextEdit compileOutputEdit;
|
|
|
|
|
QCheckBox stderrCheckBox;
|
|
|
|
|
QCheckBox clearTasksCheckBox;
|
|
|
|
|
KitChooser kitChooser;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ParseIssuesDialog::ParseIssuesDialog(QWidget *parent) : QDialog(parent), d(new Private)
|
|
|
|
|
{
|
2023-01-13 12:38:22 +01:00
|
|
|
setWindowTitle(Tr::tr("Parse Build Output"));
|
2019-05-16 17:51:55 +02:00
|
|
|
|
2023-01-13 12:38:22 +01:00
|
|
|
d->stderrCheckBox.setText(Tr::tr("Output went to stderr"));
|
2019-05-16 17:51:55 +02:00
|
|
|
d->stderrCheckBox.setChecked(true);
|
|
|
|
|
|
2023-01-13 12:38:22 +01:00
|
|
|
d->clearTasksCheckBox.setText(Tr::tr("Clear existing tasks"));
|
2019-05-16 17:51:55 +02:00
|
|
|
d->clearTasksCheckBox.setChecked(true);
|
|
|
|
|
|
2023-01-13 12:38:22 +01:00
|
|
|
const auto loadFileButton = new QPushButton(Tr::tr("Load from File..."));
|
2019-05-16 17:51:55 +02:00
|
|
|
connect(loadFileButton, &QPushButton::clicked, this, [this] {
|
2023-01-13 12:38:22 +01:00
|
|
|
const FilePath filePath = FileUtils::getOpenFilePath(this, Tr::tr("Choose File"));
|
2019-05-16 17:51:55 +02:00
|
|
|
if (filePath.isEmpty())
|
|
|
|
|
return;
|
2021-08-17 16:36:42 +02:00
|
|
|
QFile file(filePath.toString());
|
2019-05-16 17:51:55 +02:00
|
|
|
if (!file.open(QIODevice::ReadOnly)) {
|
2023-01-13 12:38:22 +01:00
|
|
|
QMessageBox::critical(this, Tr::tr("Could Not Open File"),
|
|
|
|
|
Tr::tr("Could not open file: \"%1\": %2")
|
2021-08-17 16:36:42 +02:00
|
|
|
.arg(filePath.toUserOutput(), file.errorString()));
|
2019-05-16 17:51:55 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
d->compileOutputEdit.setPlainText(QString::fromLocal8Bit(file.readAll()));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
d->kitChooser.populate();
|
|
|
|
|
if (!d->kitChooser.hasStartupKit()) {
|
|
|
|
|
for (const Kit * const k : KitManager::kits()) {
|
|
|
|
|
if (DeviceTypeKitAspect::deviceTypeId(k) == Constants::DESKTOP_DEVICE_TYPE) {
|
|
|
|
|
d->kitChooser.setCurrentKitId(k->id());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
|
|
|
|
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &QDialog::accept);
|
|
|
|
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &QDialog::reject);
|
|
|
|
|
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(d->kitChooser.currentKit());
|
|
|
|
|
|
|
|
|
|
const auto layout = new QVBoxLayout(this);
|
2023-01-13 12:38:22 +01:00
|
|
|
const auto outputGroupBox = new QGroupBox(Tr::tr("Build Output"));
|
2019-05-16 17:51:55 +02:00
|
|
|
layout->addWidget(outputGroupBox);
|
|
|
|
|
const auto outputLayout = new QHBoxLayout(outputGroupBox);
|
|
|
|
|
outputLayout->addWidget(&d->compileOutputEdit);
|
|
|
|
|
const auto buttonsWidget = new QWidget;
|
|
|
|
|
const auto outputButtonsLayout = new QVBoxLayout(buttonsWidget);
|
|
|
|
|
outputLayout->addWidget(buttonsWidget);
|
|
|
|
|
outputButtonsLayout->addWidget(loadFileButton);
|
|
|
|
|
outputButtonsLayout->addWidget(&d->stderrCheckBox);
|
|
|
|
|
outputButtonsLayout->addStretch(1);
|
|
|
|
|
|
|
|
|
|
// TODO: Only very few parsers are available from a Kit (basically just the Toolchain one).
|
|
|
|
|
// If we introduced factories for IOutputParsers, we could offer the user
|
|
|
|
|
// to combine arbitrary parsers here.
|
2023-01-13 12:38:22 +01:00
|
|
|
const auto parserGroupBox = new QGroupBox(Tr::tr("Parsing Options"));
|
2019-05-16 17:51:55 +02:00
|
|
|
layout->addWidget(parserGroupBox);
|
|
|
|
|
const auto parserLayout = new QVBoxLayout(parserGroupBox);
|
|
|
|
|
const auto kitChooserWidget = new QWidget;
|
|
|
|
|
const auto kitChooserLayout = new QHBoxLayout(kitChooserWidget);
|
|
|
|
|
kitChooserLayout->setContentsMargins(0, 0, 0, 0);
|
2023-01-13 12:38:22 +01:00
|
|
|
kitChooserLayout->addWidget(new QLabel(Tr::tr("Use parsers from kit:")));
|
2019-05-16 17:51:55 +02:00
|
|
|
kitChooserLayout->addWidget(&d->kitChooser);
|
|
|
|
|
parserLayout->addWidget(kitChooserWidget);
|
|
|
|
|
parserLayout->addWidget(&d->clearTasksCheckBox);
|
|
|
|
|
|
|
|
|
|
layout->addWidget(buttonBox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ParseIssuesDialog::~ParseIssuesDialog()
|
|
|
|
|
{
|
|
|
|
|
delete d;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ParseIssuesDialog::accept()
|
|
|
|
|
{
|
2020-04-16 13:53:05 +02:00
|
|
|
const QList<Utils::OutputLineParser *> lineParsers =
|
|
|
|
|
d->kitChooser.currentKit()->createOutputParsers();
|
2020-04-08 17:45:39 +02:00
|
|
|
if (lineParsers.isEmpty()) {
|
2023-01-13 12:38:22 +01:00
|
|
|
QMessageBox::critical(this, Tr::tr("Cannot Parse"), Tr::tr("Cannot parse: The chosen kit does "
|
2019-05-16 17:51:55 +02:00
|
|
|
"not provide an output parser."));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2021-10-14 15:05:31 +02:00
|
|
|
Utils::OutputFormatter parser;
|
|
|
|
|
parser.setLineParsers(lineParsers);
|
2019-05-16 17:51:55 +02:00
|
|
|
if (d->clearTasksCheckBox.isChecked())
|
|
|
|
|
TaskHub::clearTasks();
|
2021-10-14 15:05:31 +02:00
|
|
|
const QStringList lines = d->compileOutputEdit.toPlainText().split('\n');
|
|
|
|
|
const Utils::OutputFormat format = d->stderrCheckBox.isChecked()
|
|
|
|
|
? Utils::StdErrFormat : Utils::StdOutFormat;
|
|
|
|
|
for (const QString &line : lines)
|
|
|
|
|
parser.appendMessage(line + '\n', format);
|
|
|
|
|
parser.flush();
|
2019-05-16 17:51:55 +02:00
|
|
|
QDialog::accept();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ProjectExplorer
|