CMake: Duplicate CMake output in Projects mode

There is some space on the right side there, and in Projects mode it is
nice to have the output directly visible without opening the General
Messages pane (without intermangling with other output there).
This is a first step that duplicates the output in a very simple manner.

Fixes: QTCREATORBUG-25522
Change-Id: Id53b21d629b1f1bbc46ebf3d38bcec1fd83a6360
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2021-06-01 16:21:03 +02:00
parent dcbf26490d
commit 3c9da87f33
7 changed files with 64 additions and 20 deletions

View File

@@ -27,9 +27,9 @@
#include "cmakeparser.h"
#include <coreplugin/messagemanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/reaper.h>
#include <projectexplorer/buildsystem.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/taskhub.h>
@@ -117,7 +117,7 @@ void CMakeProcess::run(const BuildDirParameters &parameters, const QStringList &
TaskHub::clearTasks(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
Core::MessageManager::writeFlashing(
BuildSystem::startNewBuildSystemOutput(
tr("Running %1 in %2.").arg(commandLine.toUserOutput()).arg(workDirectory.toUserOutput()));
auto future = std::make_unique<QFutureInterface<void>>();
@@ -168,7 +168,7 @@ void CMakeProcess::processStandardOutput()
static QString rest;
rest = lineSplit(rest, m_process->readAllStandardOutput(), [](const QString &s) {
Core::MessageManager::writeSilently(s);
BuildSystem::appendBuildSystemOutput(s);
});
}
@@ -179,7 +179,7 @@ void CMakeProcess::processStandardError()
static QString rest;
rest = lineSplit(rest, m_process->readAllStandardError(), [this](const QString &s) {
m_parser.appendMessage(s + '\n', Utils::StdErrFormat);
Core::MessageManager::writeSilently(s);
BuildSystem::appendBuildSystemOutput(s);
});
}
@@ -205,7 +205,7 @@ void CMakeProcess::handleProcessFinished(int code, QProcess::ExitStatus status)
m_lastExitCode = code;
if (!msg.isEmpty()) {
Core::MessageManager::writeSilently(msg);
BuildSystem::appendBuildSystemOutput(msg);
TaskHub::addTask(BuildSystemTask(Task::Error, msg));
m_future->reportCanceled();
} else {
@@ -217,7 +217,7 @@ void CMakeProcess::handleProcessFinished(int code, QProcess::ExitStatus status)
emit finished(code, status);
const QString elapsedTime = Utils::formatElapsedTime(m_elapsed.elapsed());
Core::MessageManager::writeSilently(elapsedTime);
BuildSystem::appendBuildSystemOutput(elapsedTime);
}
void CMakeProcess::checkForCancelled()

View File

@@ -26,10 +26,13 @@
#include "buildsystem.h"
#include "buildconfiguration.h"
#include "projectexplorer.h"
#include "runconfiguration.h"
#include "runcontrol.h"
#include "target.h"
#include <coreplugin/messagemanager.h>
#include <coreplugin/outputwindow.h>
#include <projectexplorer/buildaspects.h>
#include <utils/qtcassert.h>
@@ -351,6 +354,21 @@ QVariant BuildSystem::extraData(const QString &buildKey, Utils::Id dataKey) cons
return node->data(dataKey);
}
void BuildSystem::startNewBuildSystemOutput(const QString &message)
{
Core::OutputWindow *outputArea = ProjectExplorerPlugin::buildSystemOutput();
outputArea->grayOutOldContent();
outputArea->appendMessage(message + '\n', Utils::GeneralMessageFormat);
Core::MessageManager::writeFlashing(message);
}
void BuildSystem::appendBuildSystemOutput(const QString &message)
{
Core::OutputWindow *outputArea = ProjectExplorerPlugin::buildSystemOutput();
outputArea->appendMessage(message + '\n', Utils::GeneralMessageFormat);
Core::MessageManager::writeSilently(message);
}
QString BuildSystem::disabledReason(const QString &buildKey) const
{
if (!hasParsingData()) {

View File

@@ -141,6 +141,9 @@ public:
void setExtraData(const QString &buildKey, Utils::Id dataKey, const QVariant &data);
QVariant extraData(const QString &buildKey, Utils::Id dataKey) const;
static void startNewBuildSystemOutput(const QString &message);
static void appendBuildSystemOutput(const QString &message);
public:
// FIXME: Make this private and the BuildSystem a friend
ParseGuard guardParsingRun() { return ParseGuard(this); }

View File

@@ -4086,6 +4086,11 @@ void ProjectExplorerPlugin::updateRunActions()
dd->doUpdateRunActions();
}
OutputWindow *ProjectExplorerPlugin::buildSystemOutput()
{
return dd->m_proWindow->buildSystemOutput();
}
QList<QPair<QString, QString> > ProjectExplorerPlugin::recentProjects()
{
return dd->recentProjects();

View File

@@ -40,6 +40,7 @@ QT_END_NAMESPACE
namespace Core {
class IMode;
class OutputWindow;
} // namespace Core
namespace Utils {
@@ -186,6 +187,8 @@ public:
static void updateRunActions();
static Core::OutputWindow *buildSystemOutput();
signals:
void finishedInitialization();

View File

@@ -40,11 +40,12 @@
#include "targetsettingspanel.h"
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/icontext.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/coreicons.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/idocument.h>
#include <coreplugin/outputwindow.h>
#include <utils/algorithm.h>
#include <utils/basetreeview.h>
@@ -472,6 +473,21 @@ public:
auto selectorDock = q->addDockForWidget(selectorView, true);
q->addDockWidget(Qt::LeftDockWidgetArea, selectorDock);
m_buildSystemOutput = new OutputWindow(Context("ProjectsMode.BuildSystemOutput"),
"ProjectsMode.BuildSystemOutput.Zoom");
m_buildSystemOutput->setReadOnly(true);
auto output = new QWidget;
output->setObjectName("BuildSystemOutput");
output->setWindowTitle(ProjectWindow::tr("Build System Output"));
auto outputLayout = new QVBoxLayout;
output->setLayout(outputLayout);
outputLayout->setContentsMargins(0, 0, 0, 0);
outputLayout->setSpacing(0);
outputLayout->addWidget(new StyledBar(output));
outputLayout->addWidget(m_buildSystemOutput);
auto outputDock = q->addDockForWidget(output, true);
q->addDockWidget(Qt::RightDockWidgetArea, outputDock);
}
void updatePanel()
@@ -642,6 +658,7 @@ public:
SelectorTree *m_selectorTree;
QPushButton *m_importBuild;
QPushButton *m_manageKits;
OutputWindow *m_buildSystemOutput;
};
//
@@ -653,19 +670,6 @@ ProjectWindow::ProjectWindow()
{
setBackgroundRole(QPalette::Base);
// The empty space on the right side of the project mode window.
auto rightSpace = new QWidget;
rightSpace->setAutoFillBackground(true);
rightSpace->setObjectName("ProjectModeRightSpace"); // Needed for dock widget state saving
rightSpace->setWindowTitle("dummy");
auto rightSpaceLayout = new QVBoxLayout(rightSpace);
rightSpaceLayout->setContentsMargins(0, 0, 0, 0);
rightSpaceLayout->addWidget(new StyledBar(rightSpace)); // The black blob on top
rightSpaceLayout->addStretch();
addDockWidget(Qt::RightDockWidgetArea, addDockForWidget(rightSpace, true));
// Request custom context menu but do not provide any to avoid
// the creation of the dock window selection menu.
setContextMenuPolicy(Qt::CustomContextMenu);
@@ -676,6 +680,11 @@ void ProjectWindow::activateProjectPanel(Utils::Id panelId)
d->activateProjectPanel(panelId);
}
OutputWindow *ProjectWindow::buildSystemOutput() const
{
return d->m_buildSystemOutput;
}
void ProjectWindow::hideEvent(QHideEvent *event)
{
savePersistentSettings();

View File

@@ -32,6 +32,10 @@
#include <memory>
namespace Core {
class OutputWindow;
}
namespace ProjectExplorer {
namespace Internal {
@@ -64,6 +68,8 @@ public:
void activateProjectPanel(Utils::Id panelId);
Core::OutputWindow *buildSystemOutput() const;
private:
void hideEvent(QHideEvent *event) override;
void showEvent(QShowEvent *event) override;