2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 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
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "compileoutputwindow.h"
|
2020-04-16 13:53:05 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "buildmanager.h"
|
2023-01-13 14:02:32 +01:00
|
|
|
#include "projectexplorerconstants.h"
|
2015-11-23 16:41:54 +01:00
|
|
|
#include "projectexplorericons.h"
|
2011-04-14 10:39:09 +02:00
|
|
|
#include "projectexplorersettings.h"
|
2023-01-13 12:38:22 +01:00
|
|
|
#include "projectexplorertr.h"
|
2020-04-16 13:53:05 +02:00
|
|
|
#include "showoutputtaskhandler.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-03-25 17:13:18 +01:00
|
|
|
#include <coreplugin/outputwindow.h>
|
2023-07-17 17:04:05 +02:00
|
|
|
#include <coreplugin/dialogs/ioptionspage.h>
|
2015-08-17 16:29:09 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2016-09-26 23:40:25 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2023-07-17 17:04:05 +02:00
|
|
|
|
2010-06-30 16:39:32 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2023-07-17 17:04:05 +02:00
|
|
|
|
2012-05-07 16:32:06 +02:00
|
|
|
#include <texteditor/texteditorsettings.h>
|
|
|
|
|
#include <texteditor/fontsettings.h>
|
2015-08-17 16:29:09 +02:00
|
|
|
#include <texteditor/behaviorsettings.h>
|
2023-05-31 12:38:49 +02:00
|
|
|
|
2020-04-16 13:53:05 +02:00
|
|
|
#include <utils/algorithm.h>
|
2023-05-31 12:38:49 +02:00
|
|
|
#include <utils/layoutbuilder.h>
|
2020-04-16 13:53:05 +02:00
|
|
|
#include <utils/outputformatter.h>
|
2016-05-04 13:39:12 +02:00
|
|
|
#include <utils/proxyaction.h>
|
2015-03-19 20:00:15 +01:00
|
|
|
#include <utils/theme/theme.h>
|
2016-08-03 17:55:54 +02:00
|
|
|
#include <utils/utilsicons.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2019-03-01 15:18:40 +01:00
|
|
|
#include <QCheckBox>
|
|
|
|
|
#include <QHBoxLayout>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QIcon>
|
2019-03-01 15:18:40 +01:00
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QPlainTextEdit>
|
|
|
|
|
#include <QSpinBox>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTextBlock>
|
2019-03-01 15:18:40 +01:00
|
|
|
#include <QTextCharFormat>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTextCursor>
|
2012-03-28 22:23:03 +02:00
|
|
|
#include <QToolButton>
|
2019-03-01 15:18:40 +01:00
|
|
|
#include <QVBoxLayout>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2023-07-17 17:04:05 +02:00
|
|
|
namespace ProjectExplorer::Internal {
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2015-08-17 16:29:09 +02:00
|
|
|
const char SETTINGS_KEY[] = "ProjectExplorer/CompileOutput/Zoom";
|
2017-03-17 15:33:07 +02:00
|
|
|
const char C_COMPILE_OUTPUT[] = "ProjectExplorer.CompileOutput";
|
2019-03-12 10:18:14 +01:00
|
|
|
const char OPTIONS_PAGE_ID[] = "C.ProjectExplorer.CompileOutputOptions";
|
2010-06-25 10:41:49 +02:00
|
|
|
|
2014-01-27 14:04:03 +01:00
|
|
|
CompileOutputWindow::CompileOutputWindow(QAction *cancelBuildAction) :
|
2013-09-03 06:47:17 +03:00
|
|
|
m_cancelBuildButton(new QToolButton),
|
2020-03-20 15:04:33 +01:00
|
|
|
m_settingsButton(new QToolButton)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2023-09-13 15:36:07 +02:00
|
|
|
setId("CompileOutput");
|
2023-09-13 11:46:00 +02:00
|
|
|
setDisplayName(QCoreApplication::translate("QtC::ProjectExplorer", "Compile Output"));
|
2023-09-14 09:40:56 +02:00
|
|
|
setPriorityInStatusBar(40);
|
|
|
|
|
|
2017-03-17 15:33:07 +02:00
|
|
|
Core::Context context(C_COMPILE_OUTPUT);
|
2020-04-16 13:53:05 +02:00
|
|
|
m_outputWindow = new Core::OutputWindow(context, SETTINGS_KEY);
|
2016-08-11 18:03:19 +02:00
|
|
|
m_outputWindow->setWindowTitle(displayName());
|
2015-11-23 16:41:54 +01:00
|
|
|
m_outputWindow->setWindowIcon(Icons::WINDOW.icon());
|
2010-07-12 14:01:42 +02:00
|
|
|
m_outputWindow->setReadOnly(true);
|
2011-02-04 14:51:55 +01:00
|
|
|
m_outputWindow->setUndoRedoEnabled(false);
|
2018-09-25 13:58:24 +02:00
|
|
|
m_outputWindow->setMaxCharCount(Core::Constants::DEFAULT_MAX_CHAR_COUNT);
|
2010-07-12 14:01:42 +02:00
|
|
|
|
2016-05-04 13:39:12 +02:00
|
|
|
Utils::ProxyAction *cancelBuildProxyButton =
|
2016-08-03 17:55:54 +02:00
|
|
|
Utils::ProxyAction::proxyActionWithIcon(cancelBuildAction,
|
|
|
|
|
Utils::Icons::STOP_SMALL_TOOLBAR.icon());
|
2016-05-04 13:39:12 +02:00
|
|
|
m_cancelBuildButton->setDefaultAction(cancelBuildProxyButton);
|
2023-02-14 10:10:20 +01:00
|
|
|
m_settingsButton->setToolTip(Core::ICore::msgShowOptionsDialog());
|
2019-03-12 10:18:14 +01:00
|
|
|
m_settingsButton->setIcon(Utils::Icons::SETTINGS_TOOLBAR.icon());
|
2015-08-17 16:29:09 +02:00
|
|
|
|
2019-03-31 08:04:43 +02:00
|
|
|
auto updateFontSettings = [this] {
|
|
|
|
|
m_outputWindow->setBaseFont(TextEditor::TextEditorSettings::fontSettings().font());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
auto updateZoomEnabled = [this] {
|
|
|
|
|
m_outputWindow->setWheelZoomEnabled(
|
2024-01-26 18:27:53 +01:00
|
|
|
TextEditor::globalBehaviorSettings().m_scrollWheelZooming);
|
2019-03-31 08:04:43 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updateFontSettings();
|
2015-08-17 16:29:09 +02:00
|
|
|
updateZoomEnabled();
|
2019-05-14 14:05:47 +02:00
|
|
|
setupFilterUi("CompileOutputPane.Filter");
|
|
|
|
|
setFilteringEnabled(true);
|
2015-08-17 16:29:09 +02:00
|
|
|
|
2020-11-17 15:50:11 +01:00
|
|
|
connect(this, &IOutputPane::zoomInRequested, m_outputWindow, &Core::OutputWindow::zoomIn);
|
|
|
|
|
connect(this, &IOutputPane::zoomOutRequested, m_outputWindow, &Core::OutputWindow::zoomOut);
|
|
|
|
|
connect(this, &IOutputPane::resetZoomRequested, m_outputWindow, &Core::OutputWindow::resetZoom);
|
2019-03-31 08:04:43 +02:00
|
|
|
connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::fontSettingsChanged,
|
|
|
|
|
this, updateFontSettings);
|
|
|
|
|
connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::behaviorSettingsChanged,
|
|
|
|
|
this, updateZoomEnabled);
|
2015-08-17 16:29:09 +02:00
|
|
|
|
2019-03-12 10:18:14 +01:00
|
|
|
connect(m_settingsButton, &QToolButton::clicked, this, [] {
|
|
|
|
|
Core::ICore::showOptionsDialog(OPTIONS_PAGE_ID);
|
|
|
|
|
});
|
2012-03-28 22:23:03 +02:00
|
|
|
|
2010-06-08 15:04:42 +02:00
|
|
|
qRegisterMetaType<QTextCharFormat>("QTextCharFormat");
|
2010-06-30 16:39:32 +02:00
|
|
|
|
2022-02-09 18:00:59 +01:00
|
|
|
m_handler = new ShowOutputTaskHandler(this,
|
2023-01-13 12:38:22 +01:00
|
|
|
Tr::tr("Show Compile &Output"),
|
|
|
|
|
Tr::tr("Show the output that generated this issue in Compile Output."),
|
|
|
|
|
Tr::tr("O"));
|
2012-06-18 11:34:15 +02:00
|
|
|
ExtensionSystem::PluginManager::addObject(m_handler);
|
2019-06-20 17:27:10 +02:00
|
|
|
setupContext(C_COMPILE_OUTPUT, m_outputWindow);
|
2016-09-26 23:40:25 +02:00
|
|
|
updateFromSettings();
|
2023-05-31 12:38:49 +02:00
|
|
|
|
2023-07-17 17:04:05 +02:00
|
|
|
CompileOutputSettings &s = compileOutputSettings();
|
|
|
|
|
m_outputWindow->setWordWrapEnabled(s.wrapOutput());
|
|
|
|
|
m_outputWindow->setMaxCharCount(s.maxCharCount());
|
2023-05-31 12:38:49 +02:00
|
|
|
|
2023-07-17 17:04:05 +02:00
|
|
|
connect(&s.wrapOutput, &Utils::BaseAspect::changed, m_outputWindow, [this] {
|
|
|
|
|
m_outputWindow->setWordWrapEnabled(compileOutputSettings().wrapOutput());
|
2023-05-31 12:38:49 +02:00
|
|
|
});
|
2023-07-17 17:04:05 +02:00
|
|
|
connect(&s.maxCharCount, &Utils::BaseAspect::changed, m_outputWindow, [this] {
|
|
|
|
|
m_outputWindow->setMaxCharCount(compileOutputSettings().maxCharCount());
|
2023-05-31 12:38:49 +02:00
|
|
|
});
|
2010-06-30 16:39:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CompileOutputWindow::~CompileOutputWindow()
|
|
|
|
|
{
|
2012-06-18 11:34:15 +02:00
|
|
|
ExtensionSystem::PluginManager::removeObject(m_handler);
|
2010-06-30 16:39:32 +02:00
|
|
|
delete m_handler;
|
2012-03-28 22:23:03 +02:00
|
|
|
delete m_cancelBuildButton;
|
2019-03-12 10:18:14 +01:00
|
|
|
delete m_settingsButton;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2016-09-26 23:40:25 +02:00
|
|
|
void CompileOutputWindow::updateFromSettings()
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
|
|
|
|
}
|
2011-09-27 13:47:06 +02:00
|
|
|
bool CompileOutputWindow::hasFocus() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2014-11-07 15:48:36 +01:00
|
|
|
return m_outputWindow->window()->focusWidget() == m_outputWindow;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool CompileOutputWindow::canFocus() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompileOutputWindow::setFocus()
|
|
|
|
|
{
|
2010-07-12 14:01:42 +02:00
|
|
|
m_outputWindow->setFocus();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *CompileOutputWindow::outputWidget(QWidget *)
|
|
|
|
|
{
|
2010-07-12 14:01:42 +02:00
|
|
|
return m_outputWindow;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2012-03-28 22:23:03 +02:00
|
|
|
QList<QWidget *> CompileOutputWindow::toolBarWidgets() const
|
|
|
|
|
{
|
2019-03-31 08:04:43 +02:00
|
|
|
return QList<QWidget *>{m_cancelBuildButton, m_settingsButton} + IOutputPane::toolBarWidgets();
|
2012-03-28 22:23:03 +02:00
|
|
|
}
|
|
|
|
|
|
2014-10-13 22:37:28 +03:00
|
|
|
void CompileOutputWindow::appendText(const QString &text, BuildStep::OutputFormat format)
|
2010-07-15 10:29:38 +02:00
|
|
|
{
|
2018-11-16 08:59:57 +02:00
|
|
|
Utils::OutputFormat fmt = Utils::NormalMessageFormat;
|
2010-07-15 10:29:38 +02:00
|
|
|
switch (format) {
|
2017-01-12 10:59:12 +01:00
|
|
|
case BuildStep::OutputFormat::Stdout:
|
2018-11-16 08:59:57 +02:00
|
|
|
fmt = Utils::StdOutFormat;
|
2010-07-15 10:29:38 +02:00
|
|
|
break;
|
2017-01-12 10:59:12 +01:00
|
|
|
case BuildStep::OutputFormat::Stderr:
|
2018-11-16 08:59:57 +02:00
|
|
|
fmt = Utils::StdErrFormat;
|
2010-07-15 10:29:38 +02:00
|
|
|
break;
|
2017-01-12 10:59:12 +01:00
|
|
|
case BuildStep::OutputFormat::NormalMessage:
|
2018-11-16 08:59:57 +02:00
|
|
|
fmt = Utils::NormalMessageFormat;
|
2010-07-15 10:29:38 +02:00
|
|
|
break;
|
2017-01-12 10:59:12 +01:00
|
|
|
case BuildStep::OutputFormat::ErrorMessage:
|
2018-11-16 08:59:57 +02:00
|
|
|
fmt = Utils::ErrorMessageFormat;
|
2010-07-15 10:29:38 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-16 08:59:57 +02:00
|
|
|
m_outputWindow->appendMessage(text, fmt);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompileOutputWindow::clearContents()
|
|
|
|
|
{
|
2010-07-12 14:01:42 +02:00
|
|
|
m_outputWindow->clear();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool CompileOutputWindow::canNext() const
|
2009-04-30 12:50:52 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool CompileOutputWindow::canPrevious() const
|
2009-04-30 12:50:52 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CompileOutputWindow::goToNext()
|
2016-04-13 15:52:14 +02:00
|
|
|
{ }
|
2009-04-30 12:50:52 +02:00
|
|
|
|
|
|
|
|
void CompileOutputWindow::goToPrev()
|
2016-04-13 15:52:14 +02:00
|
|
|
{ }
|
2009-04-30 12:50:52 +02:00
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool CompileOutputWindow::canNavigate() const
|
2009-04-30 12:50:52 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-06-30 16:39:32 +02:00
|
|
|
|
2020-04-16 13:53:05 +02:00
|
|
|
void CompileOutputWindow::registerPositionOf(const Task &task, int linkedOutputLines, int skipLines,
|
|
|
|
|
int offset)
|
2010-06-30 16:39:32 +02:00
|
|
|
{
|
2021-11-25 12:31:14 +01:00
|
|
|
m_outputWindow->registerPositionOf(task.taskId, linkedOutputLines, skipLines, offset);
|
2010-06-30 16:39:32 +02:00
|
|
|
}
|
2012-05-07 16:32:06 +02:00
|
|
|
|
2013-09-03 06:47:17 +03:00
|
|
|
void CompileOutputWindow::flush()
|
|
|
|
|
{
|
2020-03-20 15:04:33 +01:00
|
|
|
m_outputWindow->flush();
|
2013-09-03 06:47:17 +03:00
|
|
|
}
|
|
|
|
|
|
2020-04-29 13:37:36 +02:00
|
|
|
void CompileOutputWindow::reset()
|
|
|
|
|
{
|
|
|
|
|
m_outputWindow->reset();
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-16 13:53:05 +02:00
|
|
|
Utils::OutputFormatter *CompileOutputWindow::outputFormatter() const
|
|
|
|
|
{
|
|
|
|
|
return m_outputWindow->outputFormatter();
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-14 14:05:47 +02:00
|
|
|
void CompileOutputWindow::updateFilter()
|
|
|
|
|
{
|
2019-05-15 13:56:03 +02:00
|
|
|
m_outputWindow->updateFilterProperties(filterText(), filterCaseSensitivity(),
|
2019-11-18 13:56:59 +01:00
|
|
|
filterUsesRegexp(), filterIsInverted());
|
2019-05-14 14:05:47 +02:00
|
|
|
}
|
|
|
|
|
|
2023-05-31 12:38:49 +02:00
|
|
|
// CompileOutputSettings
|
2020-12-14 17:00:53 +01:00
|
|
|
|
2023-07-17 17:04:05 +02:00
|
|
|
CompileOutputSettings &compileOutputSettings()
|
2019-03-01 15:18:40 +01:00
|
|
|
{
|
2023-07-17 17:04:05 +02:00
|
|
|
static CompileOutputSettings theSettings;
|
|
|
|
|
return theSettings;
|
2019-03-01 15:18:40 +01:00
|
|
|
}
|
|
|
|
|
|
2023-05-31 12:38:49 +02:00
|
|
|
CompileOutputSettings::CompileOutputSettings()
|
2019-03-01 15:18:40 +01:00
|
|
|
{
|
2023-07-17 17:04:05 +02:00
|
|
|
setAutoApply(false);
|
2023-05-31 12:38:49 +02:00
|
|
|
|
|
|
|
|
wrapOutput.setSettingsKey("ProjectExplorer/Settings/WrapBuildOutput");
|
|
|
|
|
wrapOutput.setDefaultValue(true);
|
|
|
|
|
wrapOutput.setLabelText(Tr::tr("Word-wrap output"));
|
|
|
|
|
|
|
|
|
|
popUp.setSettingsKey("ProjectExplorer/Settings/ShowCompilerOutput");
|
|
|
|
|
popUp.setLabelText(Tr::tr("Open Compile Output when building"));
|
|
|
|
|
|
|
|
|
|
maxCharCount.setSettingsKey("ProjectExplorer/Settings/MaxBuildOutputLines");
|
|
|
|
|
maxCharCount.setRange(1, Core::Constants::DEFAULT_MAX_CHAR_COUNT);
|
|
|
|
|
maxCharCount.setDefaultValue(Core::Constants::DEFAULT_MAX_CHAR_COUNT);
|
|
|
|
|
maxCharCount.setToSettingsTransformation([](const QVariant &v) { return v.toInt() / 100; });
|
|
|
|
|
maxCharCount.setFromSettingsTransformation([](const QVariant &v) { return v.toInt() * 100; });
|
|
|
|
|
|
|
|
|
|
setLayouter([this] {
|
|
|
|
|
using namespace Layouting;
|
|
|
|
|
const QString msg = Tr::tr("Limit output to %1 characters");
|
|
|
|
|
const QStringList parts = msg.split("%1") << QString() << QString();
|
|
|
|
|
return Column {
|
|
|
|
|
wrapOutput,
|
|
|
|
|
popUp,
|
|
|
|
|
Row { parts.at(0), maxCharCount, parts.at(1), st },
|
|
|
|
|
st
|
|
|
|
|
};
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
readSettings();
|
2019-03-01 15:18:40 +01:00
|
|
|
}
|
|
|
|
|
|
2023-07-17 17:04:05 +02:00
|
|
|
// CompileOutputSettingsPage
|
|
|
|
|
|
|
|
|
|
class CompileOutputSettingsPage final : public Core::IOptionsPage
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CompileOutputSettingsPage()
|
|
|
|
|
{
|
|
|
|
|
setId(OPTIONS_PAGE_ID);
|
|
|
|
|
setDisplayName(Tr::tr("Compile Output"));
|
|
|
|
|
setCategory(Constants::BUILD_AND_RUN_SETTINGS_CATEGORY);
|
|
|
|
|
setSettingsProvider([] { return &compileOutputSettings(); });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const CompileOutputSettingsPage settingsPage;
|
|
|
|
|
|
|
|
|
|
} // ProjectExplorer::Internal
|