From 3c9da87f33c9cb1b0a87d5aa31a385c46ae67b07 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Tue, 1 Jun 2021 16:21:03 +0200 Subject: [PATCH] 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 --- .../cmakeprojectmanager/cmakeprocess.cpp | 12 +++--- src/plugins/projectexplorer/buildsystem.cpp | 18 +++++++++ src/plugins/projectexplorer/buildsystem.h | 3 ++ .../projectexplorer/projectexplorer.cpp | 5 +++ src/plugins/projectexplorer/projectexplorer.h | 3 ++ src/plugins/projectexplorer/projectwindow.cpp | 37 ++++++++++++------- src/plugins/projectexplorer/projectwindow.h | 6 +++ 7 files changed, 64 insertions(+), 20 deletions(-) diff --git a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp index 5a78f4a7b90..4bf87c3a8fc 100644 --- a/src/plugins/cmakeprojectmanager/cmakeprocess.cpp +++ b/src/plugins/cmakeprojectmanager/cmakeprocess.cpp @@ -27,9 +27,9 @@ #include "cmakeparser.h" -#include #include #include +#include #include #include @@ -117,7 +117,7 @@ void CMakeProcess::run(const BuildDirParameters ¶meters, 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>(); @@ -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() diff --git a/src/plugins/projectexplorer/buildsystem.cpp b/src/plugins/projectexplorer/buildsystem.cpp index 3f4bb3b4bb8..a5a027b21f0 100644 --- a/src/plugins/projectexplorer/buildsystem.cpp +++ b/src/plugins/projectexplorer/buildsystem.cpp @@ -26,10 +26,13 @@ #include "buildsystem.h" #include "buildconfiguration.h" +#include "projectexplorer.h" #include "runconfiguration.h" #include "runcontrol.h" #include "target.h" +#include +#include #include #include @@ -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()) { diff --git a/src/plugins/projectexplorer/buildsystem.h b/src/plugins/projectexplorer/buildsystem.h index de610811cf8..a545d969b4b 100644 --- a/src/plugins/projectexplorer/buildsystem.h +++ b/src/plugins/projectexplorer/buildsystem.h @@ -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); } diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 02d98bc2792..7ffd85af5d3 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -4086,6 +4086,11 @@ void ProjectExplorerPlugin::updateRunActions() dd->doUpdateRunActions(); } +OutputWindow *ProjectExplorerPlugin::buildSystemOutput() +{ + return dd->m_proWindow->buildSystemOutput(); +} + QList > ProjectExplorerPlugin::recentProjects() { return dd->recentProjects(); diff --git a/src/plugins/projectexplorer/projectexplorer.h b/src/plugins/projectexplorer/projectexplorer.h index 2d6aaf9a518..74527bbd964 100644 --- a/src/plugins/projectexplorer/projectexplorer.h +++ b/src/plugins/projectexplorer/projectexplorer.h @@ -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(); diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp index 5d000c1108f..1ae7bb4761c 100644 --- a/src/plugins/projectexplorer/projectwindow.cpp +++ b/src/plugins/projectexplorer/projectwindow.cpp @@ -40,11 +40,12 @@ #include "targetsettingspanel.h" #include -#include #include #include +#include #include #include +#include #include #include @@ -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(); diff --git a/src/plugins/projectexplorer/projectwindow.h b/src/plugins/projectexplorer/projectwindow.h index 73fb486b7af..31efbe32108 100644 --- a/src/plugins/projectexplorer/projectwindow.h +++ b/src/plugins/projectexplorer/projectwindow.h @@ -32,6 +32,10 @@ #include +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;