2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2011-04-14 10:39:09 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2011-04-14 10:39:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2011-04-14 10:39:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2011-04-14 10:39:09 +02:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2011-04-14 10:39:09 +02:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2011-04-14 10:39:09 +02:00
|
|
|
|
|
|
|
|
#include "appoutputpane.h"
|
2019-03-13 08:06:08 +01:00
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
#include "projectexplorer.h"
|
2019-03-01 15:18:40 +01:00
|
|
|
#include "projectexplorerconstants.h"
|
2015-11-23 16:41:54 +01:00
|
|
|
#include "projectexplorericons.h"
|
2019-03-13 08:06:08 +01:00
|
|
|
#include "runcontrol.h"
|
2011-04-14 10:39:09 +02:00
|
|
|
#include "session.h"
|
2021-11-25 13:57:38 +01:00
|
|
|
#include "showoutputtaskhandler.h"
|
2015-01-19 10:44:30 +02:00
|
|
|
#include "windebuginterface.h"
|
2011-04-14 10:39:09 +02:00
|
|
|
|
|
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
2015-02-26 13:38:54 +01:00
|
|
|
#include <coreplugin/actionmanager/command.h>
|
2015-08-17 16:29:09 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
2019-03-16 17:00:23 +01:00
|
|
|
#include <coreplugin/outputwindow.h>
|
|
|
|
|
#include <texteditor/behaviorsettings.h>
|
2011-04-14 10:39:09 +02:00
|
|
|
#include <texteditor/fontsettings.h>
|
|
|
|
|
#include <texteditor/texteditorsettings.h>
|
|
|
|
|
|
2019-03-16 17:00:23 +01:00
|
|
|
#include <extensionsystem/invoker.h>
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2014-06-06 13:12:47 +02:00
|
|
|
#include <utils/algorithm.h>
|
2015-02-24 22:39:14 +02:00
|
|
|
#include <utils/outputformatter.h>
|
|
|
|
|
#include <utils/qtcassert.h>
|
2016-08-03 17:55:54 +02:00
|
|
|
#include <utils/utilsicons.h>
|
2011-04-14 10:39:09 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QAction>
|
2019-03-01 15:18:40 +01:00
|
|
|
#include <QCheckBox>
|
2019-08-14 18:03:49 +02:00
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QFormLayout>
|
2019-03-01 15:18:40 +01:00
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QLabel>
|
2019-03-16 17:07:20 +01:00
|
|
|
#include <QLoggingCategory>
|
2019-03-01 15:18:40 +01:00
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QSpinBox>
|
|
|
|
|
#include <QTabBar>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTabWidget>
|
2020-04-29 13:57:05 +02:00
|
|
|
#include <QTimer>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QToolButton>
|
2019-03-01 15:18:40 +01:00
|
|
|
#include <QVBoxLayout>
|
2011-04-14 10:39:09 +02:00
|
|
|
|
2019-03-16 17:07:20 +01:00
|
|
|
static Q_LOGGING_CATEGORY(appOutputLog, "qtc.projectexplorer.appoutput", QtWarningMsg);
|
2011-04-14 10:39:09 +02:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
|
2019-03-12 10:18:14 +01:00
|
|
|
const char OPTIONS_PAGE_ID[] = "B.ProjectExplorer.AppOutputOptions";
|
|
|
|
|
|
|
|
|
|
|
2014-10-28 08:26:25 +01:00
|
|
|
static QObject *debuggerPlugin()
|
2011-05-31 09:48:00 +02:00
|
|
|
{
|
2019-03-16 17:00:23 +01:00
|
|
|
return ExtensionSystem::PluginManager::getObjectByName("DebuggerPlugin");
|
2011-05-31 09:48:00 +02:00
|
|
|
}
|
|
|
|
|
|
2011-07-06 10:25:18 +02:00
|
|
|
static QString msgAttachDebuggerTooltip(const QString &handleDescription = QString())
|
|
|
|
|
{
|
|
|
|
|
return handleDescription.isEmpty() ?
|
|
|
|
|
AppOutputPane::tr("Attach debugger to this process") :
|
|
|
|
|
AppOutputPane::tr("Attach debugger to %1").arg(handleDescription);
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-17 16:29:09 +02:00
|
|
|
namespace {
|
|
|
|
|
const char SETTINGS_KEY[] = "ProjectExplorer/AppOutput/Zoom";
|
2017-03-17 15:33:07 +02:00
|
|
|
const char C_APP_OUTPUT[] = "ProjectExplorer.ApplicationOutput";
|
2019-03-01 15:18:40 +01:00
|
|
|
const char POP_UP_FOR_RUN_OUTPUT_KEY[] = "ProjectExplorer/Settings/ShowRunOutput";
|
|
|
|
|
const char POP_UP_FOR_DEBUG_OUTPUT_KEY[] = "ProjectExplorer/Settings/ShowDebugOutput";
|
|
|
|
|
const char CLEAN_OLD_OUTPUT_KEY[] = "ProjectExplorer/Settings/CleanOldAppOutput";
|
|
|
|
|
const char MERGE_CHANNELS_KEY[] = "ProjectExplorer/Settings/MergeStdErrAndStdOut";
|
|
|
|
|
const char WRAP_OUTPUT_KEY[] = "ProjectExplorer/Settings/WrapAppOutput";
|
|
|
|
|
const char MAX_LINES_KEY[] = "ProjectExplorer/Settings/MaxAppOutputLines";
|
2015-08-17 16:29:09 +02:00
|
|
|
}
|
|
|
|
|
|
2011-08-05 12:27:26 +02:00
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
|
|
|
|
class TabWidget : public QTabWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2016-04-13 15:52:14 +02:00
|
|
|
TabWidget(QWidget *parent = nullptr);
|
2011-08-05 12:27:26 +02:00
|
|
|
signals:
|
2016-08-01 09:27:42 +03:00
|
|
|
void contextMenuRequested(const QPoint &pos, int index);
|
2014-08-11 12:35:45 +02:00
|
|
|
protected:
|
2016-08-01 09:27:42 +03:00
|
|
|
bool eventFilter(QObject *object, QEvent *event) override;
|
2014-08-11 12:35:45 +02:00
|
|
|
private:
|
2016-01-29 16:38:37 +02:00
|
|
|
void slotContextMenuRequested(const QPoint &pos);
|
2016-08-01 09:27:42 +03:00
|
|
|
int m_tabIndexForMiddleClick = -1;
|
2011-08-05 12:27:26 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
TabWidget::TabWidget(QWidget *parent)
|
2016-08-01 09:27:42 +03:00
|
|
|
: QTabWidget(parent)
|
2011-08-05 12:27:26 +02:00
|
|
|
{
|
2014-08-11 12:35:45 +02:00
|
|
|
tabBar()->installEventFilter(this);
|
2011-08-05 12:27:26 +02:00
|
|
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(this, &QWidget::customContextMenuRequested,
|
|
|
|
|
this, &TabWidget::slotContextMenuRequested);
|
2011-08-05 12:27:26 +02:00
|
|
|
}
|
|
|
|
|
|
2014-08-11 12:35:45 +02:00
|
|
|
bool TabWidget::eventFilter(QObject *object, QEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (object == tabBar()) {
|
|
|
|
|
if (event->type() == QEvent::MouseButtonPress) {
|
2018-07-12 22:17:17 +02:00
|
|
|
auto *me = static_cast<QMouseEvent *>(event);
|
2014-08-11 12:35:45 +02:00
|
|
|
if (me->button() == Qt::MiddleButton) {
|
|
|
|
|
m_tabIndexForMiddleClick = tabBar()->tabAt(me->pos());
|
|
|
|
|
event->accept();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
} else if (event->type() == QEvent::MouseButtonRelease) {
|
2018-07-12 22:17:17 +02:00
|
|
|
auto *me = static_cast<QMouseEvent *>(event);
|
2014-08-11 12:35:45 +02:00
|
|
|
if (me->button() == Qt::MiddleButton) {
|
|
|
|
|
int tab = tabBar()->tabAt(me->pos());
|
|
|
|
|
if (tab != -1 && tab == m_tabIndexForMiddleClick)
|
|
|
|
|
emit tabCloseRequested(tab);
|
|
|
|
|
m_tabIndexForMiddleClick = -1;
|
|
|
|
|
event->accept();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return QTabWidget::eventFilter(object, event);
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-05 12:27:26 +02:00
|
|
|
void TabWidget::slotContextMenuRequested(const QPoint &pos)
|
|
|
|
|
{
|
|
|
|
|
emit contextMenuRequested(pos, tabBar()->tabAt(pos));
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-13 08:06:08 +01:00
|
|
|
AppOutputPane::RunControlTab::RunControlTab(RunControl *runControl, Core::OutputWindow *w) :
|
|
|
|
|
runControl(runControl), window(w)
|
2017-06-23 15:19:00 +02:00
|
|
|
{
|
2020-09-03 14:23:31 +02:00
|
|
|
if (runControl && w) {
|
|
|
|
|
w->reset();
|
|
|
|
|
runControl->setupFormatter(w->outputFormatter());
|
|
|
|
|
}
|
2017-06-23 15:19:00 +02:00
|
|
|
}
|
2011-04-14 10:39:09 +02:00
|
|
|
|
|
|
|
|
AppOutputPane::AppOutputPane() :
|
|
|
|
|
m_mainWidget(new QWidget),
|
2011-08-05 12:27:26 +02:00
|
|
|
m_tabWidget(new TabWidget),
|
2011-05-30 17:02:03 +02:00
|
|
|
m_stopAction(new QAction(tr("Stop"), this)),
|
2011-08-05 12:27:26 +02:00
|
|
|
m_closeCurrentTabAction(new QAction(tr("Close Tab"), this)),
|
|
|
|
|
m_closeAllTabsAction(new QAction(tr("Close All Tabs"), this)),
|
|
|
|
|
m_closeOtherTabsAction(new QAction(tr("Close Other Tabs"), this)),
|
2011-04-14 10:39:09 +02:00
|
|
|
m_reRunButton(new QToolButton),
|
2011-05-31 09:48:00 +02:00
|
|
|
m_stopButton(new QToolButton),
|
2015-08-17 16:29:09 +02:00
|
|
|
m_attachButton(new QToolButton),
|
2019-03-12 10:18:14 +01:00
|
|
|
m_settingsButton(new QToolButton),
|
2021-11-25 13:57:38 +01:00
|
|
|
m_formatterWidget(new QWidget),
|
|
|
|
|
m_handler(new ShowOutputTaskHandler(this))
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
2021-11-25 13:57:38 +01:00
|
|
|
ExtensionSystem::PluginManager::addObject(m_handler);
|
|
|
|
|
|
2019-03-16 17:00:23 +01:00
|
|
|
setObjectName("AppOutputPane"); // Used in valgrind engine
|
2019-03-01 15:18:40 +01:00
|
|
|
loadSettings();
|
2013-01-10 11:36:15 +01:00
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
// Rerun
|
2016-08-03 17:55:54 +02:00
|
|
|
m_reRunButton->setIcon(Utils::Icons::RUN_SMALL_TOOLBAR.icon());
|
2020-03-11 11:04:28 +01:00
|
|
|
m_reRunButton->setToolTip(tr("Re-run this run-configuration."));
|
2011-04-14 10:39:09 +02:00
|
|
|
m_reRunButton->setEnabled(false);
|
2016-08-01 09:27:42 +03:00
|
|
|
connect(m_reRunButton, &QToolButton::clicked,
|
2016-01-29 16:38:37 +02:00
|
|
|
this, &AppOutputPane::reRunRunControl);
|
2011-04-14 10:39:09 +02:00
|
|
|
|
|
|
|
|
// Stop
|
2016-08-03 17:55:54 +02:00
|
|
|
m_stopAction->setIcon(Utils::Icons::STOP_SMALL_TOOLBAR.icon());
|
2020-03-11 11:04:28 +01:00
|
|
|
m_stopAction->setToolTip(tr("Stop running program."));
|
2011-04-14 10:39:09 +02:00
|
|
|
m_stopAction->setEnabled(false);
|
|
|
|
|
|
2015-02-19 11:35:47 +01:00
|
|
|
Core::Command *cmd = Core::ActionManager::registerAction(m_stopAction, Constants::STOP);
|
2017-03-02 10:23:09 +01:00
|
|
|
cmd->setDescription(m_stopAction->toolTip());
|
2011-04-14 10:39:09 +02:00
|
|
|
|
|
|
|
|
m_stopButton->setDefaultAction(cmd->action());
|
|
|
|
|
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(m_stopAction, &QAction::triggered,
|
|
|
|
|
this, &AppOutputPane::stopRunControl);
|
2011-04-14 10:39:09 +02:00
|
|
|
|
2011-05-31 09:48:00 +02:00
|
|
|
// Attach
|
2011-07-06 10:25:18 +02:00
|
|
|
m_attachButton->setToolTip(msgAttachDebuggerTooltip());
|
2011-05-31 09:48:00 +02:00
|
|
|
m_attachButton->setEnabled(false);
|
2016-04-23 00:46:40 +02:00
|
|
|
m_attachButton->setIcon(Icons::DEBUG_START_SMALL_TOOLBAR.icon());
|
2011-05-31 09:48:00 +02:00
|
|
|
|
2016-08-01 09:27:42 +03:00
|
|
|
connect(m_attachButton, &QToolButton::clicked,
|
2016-01-29 16:38:37 +02:00
|
|
|
this, &AppOutputPane::attachToRunControl);
|
2011-05-31 09:48:00 +02:00
|
|
|
|
2020-11-17 15:50:11 +01:00
|
|
|
connect(this, &IOutputPane::zoomInRequested, this, &AppOutputPane::zoomIn);
|
|
|
|
|
connect(this, &IOutputPane::zoomOutRequested, this, &AppOutputPane::zoomOut);
|
|
|
|
|
connect(this, &IOutputPane::resetZoomRequested, this, &AppOutputPane::resetZoom);
|
2015-08-17 16:29:09 +02:00
|
|
|
|
2019-03-12 10:18:14 +01:00
|
|
|
m_settingsButton->setToolTip(tr("Open Settings Page"));
|
|
|
|
|
m_settingsButton->setIcon(Utils::Icons::SETTINGS_TOOLBAR.icon());
|
|
|
|
|
connect(m_settingsButton, &QToolButton::clicked, this, [] {
|
|
|
|
|
Core::ICore::showOptionsDialog(OPTIONS_PAGE_ID);
|
|
|
|
|
});
|
|
|
|
|
|
2016-10-10 15:43:22 +03:00
|
|
|
auto formatterWidgetsLayout = new QHBoxLayout;
|
|
|
|
|
formatterWidgetsLayout->setContentsMargins(QMargins());
|
|
|
|
|
m_formatterWidget->setLayout(formatterWidgetsLayout);
|
|
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
// Spacer (?)
|
|
|
|
|
|
2018-07-12 22:17:17 +02:00
|
|
|
auto *layout = new QVBoxLayout;
|
2019-08-29 10:36:01 +02:00
|
|
|
layout->setContentsMargins(0, 0, 0, 0);
|
2011-04-14 10:39:09 +02:00
|
|
|
m_tabWidget->setDocumentMode(true);
|
|
|
|
|
m_tabWidget->setTabsClosable(true);
|
|
|
|
|
m_tabWidget->setMovable(true);
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(m_tabWidget, &QTabWidget::tabCloseRequested,
|
|
|
|
|
this, [this](int index) { closeTab(index); });
|
2011-04-14 10:39:09 +02:00
|
|
|
layout->addWidget(m_tabWidget);
|
|
|
|
|
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(m_tabWidget, &QTabWidget::currentChanged, this, &AppOutputPane::tabChanged);
|
|
|
|
|
connect(m_tabWidget, &TabWidget::contextMenuRequested,
|
|
|
|
|
this, &AppOutputPane::contextMenuRequested);
|
2011-04-14 10:39:09 +02:00
|
|
|
|
|
|
|
|
m_mainWidget->setLayout(layout);
|
|
|
|
|
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(SessionManager::instance(), &SessionManager::aboutToUnloadSession,
|
|
|
|
|
this, &AppOutputPane::aboutToUnloadSession);
|
2019-04-23 18:03:12 +02:00
|
|
|
|
2019-05-14 13:55:14 +02:00
|
|
|
setupFilterUi("AppOutputPane.Filter");
|
|
|
|
|
setFilteringEnabled(false);
|
2019-04-23 18:03:12 +02:00
|
|
|
setZoomButtonsEnabled(false);
|
2019-06-20 17:27:10 +02:00
|
|
|
setupContext("Core.AppOutputPane", m_mainWidget);
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppOutputPane::~AppOutputPane()
|
|
|
|
|
{
|
2019-03-16 17:07:20 +01:00
|
|
|
qCDebug(appOutputLog) << "AppOutputPane::~AppOutputPane: Entries left" << m_runControlTabs.size();
|
2011-04-14 10:39:09 +02:00
|
|
|
|
2019-03-16 17:00:23 +01:00
|
|
|
for (const RunControlTab &rt : qAsConst(m_runControlTabs)) {
|
2017-06-23 15:19:00 +02:00
|
|
|
delete rt.window;
|
2011-04-14 10:39:09 +02:00
|
|
|
delete rt.runControl;
|
2017-03-01 16:26:34 +01:00
|
|
|
}
|
2011-04-14 10:39:09 +02:00
|
|
|
delete m_mainWidget;
|
2021-11-25 13:57:38 +01:00
|
|
|
ExtensionSystem::PluginManager::removeObject(m_handler);
|
|
|
|
|
delete m_handler;
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AppOutputPane::currentIndex() const
|
|
|
|
|
{
|
|
|
|
|
if (const QWidget *w = m_tabWidget->currentWidget())
|
|
|
|
|
return indexOf(w);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunControl *AppOutputPane::currentRunControl() const
|
|
|
|
|
{
|
|
|
|
|
const int index = currentIndex();
|
|
|
|
|
if (index != -1)
|
|
|
|
|
return m_runControlTabs.at(index).runControl;
|
2017-03-01 16:26:34 +01:00
|
|
|
return nullptr;
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AppOutputPane::indexOf(const RunControl *rc) const
|
|
|
|
|
{
|
|
|
|
|
for (int i = m_runControlTabs.size() - 1; i >= 0; i--)
|
|
|
|
|
if (m_runControlTabs.at(i).runControl == rc)
|
|
|
|
|
return i;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AppOutputPane::indexOf(const QWidget *outputWindow) const
|
|
|
|
|
{
|
|
|
|
|
for (int i = m_runControlTabs.size() - 1; i >= 0; i--)
|
|
|
|
|
if (m_runControlTabs.at(i).window == outputWindow)
|
|
|
|
|
return i;
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AppOutputPane::tabWidgetIndexOf(int runControlIndex) const
|
|
|
|
|
{
|
|
|
|
|
if (runControlIndex >= 0 && runControlIndex < m_runControlTabs.size())
|
|
|
|
|
return m_tabWidget->indexOf(m_runControlTabs.at(runControlIndex).window);
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-05 12:27:26 +02:00
|
|
|
void AppOutputPane::updateCloseActions()
|
|
|
|
|
{
|
|
|
|
|
const int tabCount = m_tabWidget->count();
|
|
|
|
|
m_closeCurrentTabAction->setEnabled(tabCount > 0);
|
|
|
|
|
m_closeAllTabsAction->setEnabled(tabCount > 0);
|
|
|
|
|
m_closeOtherTabsAction->setEnabled(tabCount > 1);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
bool AppOutputPane::aboutToClose() const
|
|
|
|
|
{
|
2014-06-06 13:12:47 +02:00
|
|
|
return Utils::allOf(m_runControlTabs, [](const RunControlTab &rt) {
|
2017-11-14 13:11:06 +01:00
|
|
|
return !rt.runControl || !rt.runControl->isRunning() || rt.runControl->promptToStop();
|
2014-06-06 13:12:47 +02:00
|
|
|
});
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::aboutToUnloadSession()
|
|
|
|
|
{
|
|
|
|
|
closeTabs(CloseTabWithPrompt);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *AppOutputPane::outputWidget(QWidget *)
|
|
|
|
|
{
|
|
|
|
|
return m_mainWidget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<QWidget*> AppOutputPane::toolBarWidgets() const
|
|
|
|
|
{
|
2019-03-31 08:04:43 +02:00
|
|
|
return QList<QWidget *>{m_reRunButton, m_stopButton, m_attachButton, m_settingsButton,
|
2019-05-14 13:55:14 +02:00
|
|
|
m_formatterWidget} + IOutputPane::toolBarWidgets();
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString AppOutputPane::displayName() const
|
|
|
|
|
{
|
|
|
|
|
return tr("Application Output");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int AppOutputPane::priorityInStatusBar() const
|
|
|
|
|
{
|
|
|
|
|
return 60;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::clearContents()
|
|
|
|
|
{
|
2018-07-12 22:17:17 +02:00
|
|
|
auto *currentWindow = qobject_cast<Core::OutputWindow *>(m_tabWidget->currentWidget());
|
2011-04-14 10:39:09 +02:00
|
|
|
if (currentWindow)
|
|
|
|
|
currentWindow->clear();
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool AppOutputPane::hasFocus() const
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
2014-11-07 15:48:36 +01:00
|
|
|
QWidget *widget = m_tabWidget->currentWidget();
|
|
|
|
|
if (!widget)
|
|
|
|
|
return false;
|
|
|
|
|
return widget->window()->focusWidget() == widget;
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool AppOutputPane::canFocus() const
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
|
|
|
|
return m_tabWidget->currentWidget();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::setFocus()
|
|
|
|
|
{
|
|
|
|
|
if (m_tabWidget->currentWidget())
|
|
|
|
|
m_tabWidget->currentWidget()->setFocus();
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-20 14:16:46 +02:00
|
|
|
void AppOutputPane::updateFilter()
|
|
|
|
|
{
|
|
|
|
|
const int index = currentIndex();
|
2019-05-15 13:56:03 +02:00
|
|
|
if (index != -1) {
|
|
|
|
|
m_runControlTabs.at(index).window->updateFilterProperties(
|
2019-11-18 13:56:59 +01:00
|
|
|
filterText(), filterCaseSensitivity(), filterUsesRegexp(), filterIsInverted());
|
2019-05-15 13:56:03 +02:00
|
|
|
}
|
2018-08-20 14:16:46 +02:00
|
|
|
}
|
|
|
|
|
|
2021-11-25 13:57:38 +01:00
|
|
|
const QList<Core::OutputWindow *> AppOutputPane::outputWindows() const
|
|
|
|
|
{
|
|
|
|
|
QList<Core::OutputWindow *> windows;
|
|
|
|
|
for (const RunControlTab &tab : qAsConst(m_runControlTabs)) {
|
|
|
|
|
if (tab.window)
|
|
|
|
|
windows << tab.window;
|
|
|
|
|
}
|
|
|
|
|
return windows;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::ensureWindowVisible(Core::OutputWindow *ow)
|
|
|
|
|
{
|
|
|
|
|
m_tabWidget->setCurrentWidget(ow);
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
|
|
|
|
{
|
2017-08-21 12:04:06 +03:00
|
|
|
QTC_ASSERT(rc, return);
|
|
|
|
|
|
2017-03-29 14:08:44 +02:00
|
|
|
connect(rc, &RunControl::aboutToStart,
|
2017-07-05 14:25:42 +02:00
|
|
|
this, &AppOutputPane::slotRunControlChanged);
|
|
|
|
|
connect(rc, &RunControl::started,
|
|
|
|
|
this, &AppOutputPane::slotRunControlChanged);
|
2017-07-11 17:25:33 +02:00
|
|
|
connect(rc, &RunControl::stopped,
|
2016-01-29 16:38:37 +02:00
|
|
|
this, &AppOutputPane::slotRunControlFinished);
|
|
|
|
|
connect(rc, &RunControl::applicationProcessHandleChanged,
|
|
|
|
|
this, &AppOutputPane::enableDefaultButtons);
|
2019-03-11 16:22:33 +01:00
|
|
|
connect(rc, &RunControl::appendMessage,
|
|
|
|
|
this, [this, rc](const QString &out, Utils::OutputFormat format) {
|
|
|
|
|
appendMessage(rc, out, format);
|
|
|
|
|
});
|
2011-04-14 10:39:09 +02:00
|
|
|
|
|
|
|
|
// First look if we can reuse a tab
|
2018-05-29 14:23:07 +02:00
|
|
|
const Runnable thisRunnable = rc->runnable();
|
|
|
|
|
const int tabIndex = Utils::indexOf(m_runControlTabs, [&](const RunControlTab &tab) {
|
|
|
|
|
if (!tab.runControl || tab.runControl->isRunning())
|
|
|
|
|
return false;
|
|
|
|
|
const Runnable otherRunnable = tab.runControl->runnable();
|
2021-08-10 09:19:30 +02:00
|
|
|
return thisRunnable.command == otherRunnable.command
|
2018-05-29 14:23:07 +02:00
|
|
|
&& thisRunnable.workingDirectory == otherRunnable.workingDirectory
|
|
|
|
|
&& thisRunnable.environment == otherRunnable.environment;
|
2016-08-01 09:27:42 +03:00
|
|
|
});
|
|
|
|
|
if (tabIndex != -1) {
|
|
|
|
|
RunControlTab &tab = m_runControlTabs[tabIndex];
|
|
|
|
|
// Reuse this tab
|
2017-07-13 15:24:04 +02:00
|
|
|
if (tab.runControl)
|
|
|
|
|
tab.runControl->initiateFinish();
|
2017-03-01 16:26:34 +01:00
|
|
|
tab.runControl = rc;
|
2020-09-03 14:23:31 +02:00
|
|
|
tab.window->reset();
|
|
|
|
|
rc->setupFormatter(tab.window->outputFormatter());
|
2017-06-23 15:19:00 +02:00
|
|
|
|
|
|
|
|
handleOldOutput(tab.window);
|
2017-05-09 10:54:38 +02:00
|
|
|
|
|
|
|
|
// Update the title.
|
|
|
|
|
m_tabWidget->setTabText(tabIndex, rc->displayName());
|
|
|
|
|
|
2016-08-01 09:27:42 +03:00
|
|
|
tab.window->scrollToBottom();
|
2019-03-16 17:07:20 +01:00
|
|
|
qCDebug(appOutputLog) << "AppOutputPane::createNewOutputWindow: Reusing tab"
|
|
|
|
|
<< tabIndex << "for" << rc;
|
2016-08-01 09:27:42 +03:00
|
|
|
return;
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
// Create new
|
2017-03-01 16:26:34 +01:00
|
|
|
static int counter = 0;
|
2020-06-26 13:59:38 +02:00
|
|
|
Utils::Id contextId = Utils::Id(C_APP_OUTPUT).withSuffix(counter++);
|
2013-01-28 10:37:19 +01:00
|
|
|
Core::Context context(contextId);
|
2019-03-31 08:04:43 +02:00
|
|
|
Core::OutputWindow *ow = new Core::OutputWindow(context, SETTINGS_KEY, m_tabWidget);
|
2011-04-14 10:39:09 +02:00
|
|
|
ow->setWindowTitle(tr("Application Output Window"));
|
2015-11-23 16:41:54 +01:00
|
|
|
ow->setWindowIcon(Icons::WINDOW.icon());
|
2019-03-01 15:18:40 +01:00
|
|
|
ow->setWordWrapEnabled(m_settings.wrapOutput);
|
|
|
|
|
ow->setMaxCharCount(m_settings.maxCharCount);
|
2019-03-31 08:04:43 +02:00
|
|
|
|
|
|
|
|
auto updateFontSettings = [ow] {
|
|
|
|
|
ow->setBaseFont(TextEditor::TextEditorSettings::fontSettings().font());
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
auto updateBehaviorSettings = [ow] {
|
|
|
|
|
ow->setWheelZoomEnabled(
|
|
|
|
|
TextEditor::TextEditorSettings::behaviorSettings().m_scrollWheelZooming);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
updateFontSettings();
|
|
|
|
|
updateBehaviorSettings();
|
2015-08-17 16:29:09 +02:00
|
|
|
|
2016-08-01 09:27:42 +03:00
|
|
|
connect(ow, &Core::OutputWindow::wheelZoom, this, [this, ow]() {
|
2019-03-31 08:04:43 +02:00
|
|
|
float fontZoom = ow->fontZoom();
|
2019-03-16 17:00:23 +01:00
|
|
|
for (const RunControlTab &tab : qAsConst(m_runControlTabs))
|
2019-03-31 08:04:43 +02:00
|
|
|
tab.window->setFontZoom(fontZoom);
|
2015-08-17 16:29:09 +02:00
|
|
|
});
|
2019-03-31 08:04:43 +02:00
|
|
|
connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::fontSettingsChanged,
|
2019-09-18 13:06:55 +02:00
|
|
|
ow, updateFontSettings);
|
2019-03-31 08:04:43 +02:00
|
|
|
connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::behaviorSettingsChanged,
|
2019-09-18 13:06:55 +02:00
|
|
|
ow, updateBehaviorSettings);
|
2015-08-17 16:29:09 +02:00
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
m_runControlTabs.push_back(RunControlTab(rc, ow));
|
|
|
|
|
m_tabWidget->addTab(ow, rc->displayName());
|
2019-03-16 17:07:20 +01:00
|
|
|
qCDebug(appOutputLog) << "AppOutputPane::createNewOutputWindow: Adding tab for" << rc;
|
2011-08-05 12:27:26 +02:00
|
|
|
updateCloseActions();
|
2019-05-14 13:55:14 +02:00
|
|
|
setFilteringEnabled(m_tabWidget->count() > 0);
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-21 13:42:17 +02:00
|
|
|
void AppOutputPane::handleOldOutput(Core::OutputWindow *window) const
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
2019-03-01 15:18:40 +01:00
|
|
|
if (m_settings.cleanOldOutput)
|
2011-04-14 10:39:09 +02:00
|
|
|
window->clear();
|
|
|
|
|
else
|
|
|
|
|
window->grayOutOldContent();
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-29 09:36:04 +02:00
|
|
|
void AppOutputPane::updateFromSettings()
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
2019-03-16 17:00:23 +01:00
|
|
|
for (const RunControlTab &tab : qAsConst(m_runControlTabs)) {
|
2019-03-01 15:18:40 +01:00
|
|
|
tab.window->setWordWrapEnabled(m_settings.wrapOutput);
|
|
|
|
|
tab.window->setMaxCharCount(m_settings.maxCharCount);
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::appendMessage(RunControl *rc, const QString &out, Utils::OutputFormat format)
|
|
|
|
|
{
|
|
|
|
|
const int index = indexOf(rc);
|
2013-04-16 16:21:28 +02:00
|
|
|
if (index != -1) {
|
|
|
|
|
Core::OutputWindow *window = m_runControlTabs.at(index).window;
|
2018-06-13 10:45:57 +03:00
|
|
|
QString stringToWrite;
|
|
|
|
|
if (format == Utils::NormalMessageFormat || format == Utils::ErrorMessageFormat) {
|
|
|
|
|
stringToWrite = QTime::currentTime().toString();
|
2019-03-16 17:00:23 +01:00
|
|
|
stringToWrite += ": ";
|
2018-06-13 10:45:57 +03:00
|
|
|
}
|
|
|
|
|
stringToWrite += out;
|
|
|
|
|
window->appendMessage(stringToWrite, format);
|
2013-04-16 16:21:28 +02:00
|
|
|
if (format != Utils::NormalMessageFormat) {
|
2019-08-14 18:03:49 +02:00
|
|
|
RunControlTab &tab = m_runControlTabs[index];
|
|
|
|
|
switch (tab.behaviorOnOutput) {
|
|
|
|
|
case AppOutputPaneMode::FlashOnOutput:
|
2013-04-16 16:21:28 +02:00
|
|
|
flash();
|
2019-08-14 18:03:49 +02:00
|
|
|
break;
|
|
|
|
|
case AppOutputPaneMode::PopupOnFirstOutput:
|
|
|
|
|
tab.behaviorOnOutput = AppOutputPaneMode::FlashOnOutput;
|
|
|
|
|
Q_FALLTHROUGH();
|
|
|
|
|
case AppOutputPaneMode::PopupOnOutput:
|
2013-04-16 16:21:28 +02:00
|
|
|
popup(NoModeSwitch);
|
2019-08-14 18:03:49 +02:00
|
|
|
break;
|
|
|
|
|
}
|
2013-04-16 16:21:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-01 15:18:40 +01:00
|
|
|
void AppOutputPane::setSettings(const AppOutputSettings &settings)
|
|
|
|
|
{
|
|
|
|
|
m_settings = settings;
|
|
|
|
|
storeSettings();
|
|
|
|
|
updateFromSettings();
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-14 17:00:53 +01:00
|
|
|
const AppOutputPaneMode kRunOutputModeDefault = AppOutputPaneMode::PopupOnFirstOutput;
|
|
|
|
|
const AppOutputPaneMode kDebugOutputModeDefault = AppOutputPaneMode::FlashOnOutput;
|
|
|
|
|
const bool kCleanOldOutputDefault = false;
|
|
|
|
|
const bool kMergeChannelsDefault = false;
|
|
|
|
|
const bool kWrapOutputDefault = true;
|
|
|
|
|
|
2019-03-01 15:18:40 +01:00
|
|
|
void AppOutputPane::storeSettings() const
|
|
|
|
|
{
|
2020-12-14 17:00:53 +01:00
|
|
|
Utils::QtcSettings *const s = Core::ICore::settings();
|
|
|
|
|
s->setValueWithDefault(POP_UP_FOR_RUN_OUTPUT_KEY,
|
|
|
|
|
int(m_settings.runOutputMode),
|
|
|
|
|
int(kRunOutputModeDefault));
|
|
|
|
|
s->setValueWithDefault(POP_UP_FOR_DEBUG_OUTPUT_KEY,
|
|
|
|
|
int(m_settings.debugOutputMode),
|
|
|
|
|
int(kDebugOutputModeDefault));
|
|
|
|
|
s->setValueWithDefault(CLEAN_OLD_OUTPUT_KEY, m_settings.cleanOldOutput, kCleanOldOutputDefault);
|
|
|
|
|
s->setValueWithDefault(MERGE_CHANNELS_KEY, m_settings.mergeChannels, kMergeChannelsDefault);
|
|
|
|
|
s->setValueWithDefault(WRAP_OUTPUT_KEY, m_settings.wrapOutput, kWrapOutputDefault);
|
|
|
|
|
s->setValueWithDefault(MAX_LINES_KEY,
|
|
|
|
|
m_settings.maxCharCount / 100,
|
|
|
|
|
Core::Constants::DEFAULT_MAX_CHAR_COUNT);
|
2019-03-01 15:18:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::loadSettings()
|
|
|
|
|
{
|
|
|
|
|
QSettings * const s = Core::ICore::settings();
|
2019-08-14 18:03:49 +02:00
|
|
|
const auto modeFromSettings = [s](const QString key, AppOutputPaneMode defaultValue) {
|
|
|
|
|
return static_cast<AppOutputPaneMode>(s->value(key, int(defaultValue)).toInt());
|
|
|
|
|
};
|
2020-12-14 17:00:53 +01:00
|
|
|
m_settings.runOutputMode = modeFromSettings(POP_UP_FOR_RUN_OUTPUT_KEY, kRunOutputModeDefault);
|
2019-08-14 18:03:49 +02:00
|
|
|
m_settings.debugOutputMode = modeFromSettings(POP_UP_FOR_DEBUG_OUTPUT_KEY,
|
2020-12-14 17:00:53 +01:00
|
|
|
kDebugOutputModeDefault);
|
|
|
|
|
m_settings.cleanOldOutput = s->value(CLEAN_OLD_OUTPUT_KEY, kCleanOldOutputDefault).toBool();
|
|
|
|
|
m_settings.mergeChannels = s->value(MERGE_CHANNELS_KEY, kMergeChannelsDefault).toBool();
|
|
|
|
|
m_settings.wrapOutput = s->value(WRAP_OUTPUT_KEY, kWrapOutputDefault).toBool();
|
2019-03-01 15:18:40 +01:00
|
|
|
m_settings.maxCharCount = s->value(MAX_LINES_KEY,
|
|
|
|
|
Core::Constants::DEFAULT_MAX_CHAR_COUNT).toInt() * 100;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
void AppOutputPane::showTabFor(RunControl *rc)
|
|
|
|
|
{
|
|
|
|
|
m_tabWidget->setCurrentIndex(tabWidgetIndexOf(indexOf(rc)));
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-14 18:03:49 +02:00
|
|
|
void AppOutputPane::setBehaviorOnOutput(RunControl *rc, AppOutputPaneMode mode)
|
2013-04-16 16:21:28 +02:00
|
|
|
{
|
|
|
|
|
const int index = indexOf(rc);
|
|
|
|
|
if (index != -1)
|
2013-12-13 22:03:26 +01:00
|
|
|
m_runControlTabs[index].behaviorOnOutput = mode;
|
2013-04-16 16:21:28 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
void AppOutputPane::reRunRunControl()
|
|
|
|
|
{
|
|
|
|
|
const int index = currentIndex();
|
2017-11-14 13:11:06 +01:00
|
|
|
const RunControlTab &tab = m_runControlTabs.at(index);
|
|
|
|
|
QTC_ASSERT(tab.runControl, return);
|
|
|
|
|
QTC_ASSERT(index != -1 && !tab.runControl->isRunning(), return);
|
2011-04-14 10:39:09 +02:00
|
|
|
|
|
|
|
|
handleOldOutput(tab.window);
|
|
|
|
|
tab.window->scrollToBottom();
|
2017-07-05 15:17:38 +02:00
|
|
|
tab.runControl->initiateReStart();
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
2011-05-31 09:48:00 +02:00
|
|
|
void AppOutputPane::attachToRunControl()
|
|
|
|
|
{
|
|
|
|
|
const int index = currentIndex();
|
|
|
|
|
QTC_ASSERT(index != -1, return);
|
2014-10-13 22:37:28 +03:00
|
|
|
RunControl *rc = m_runControlTabs.at(index).runControl;
|
2017-11-14 13:11:06 +01:00
|
|
|
QTC_ASSERT(rc && rc->isRunning(), return);
|
2014-10-28 08:26:25 +01:00
|
|
|
ExtensionSystem::Invoker<void>(debuggerPlugin(), "attachExternalApplication", rc);
|
2011-05-31 09:48:00 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
void AppOutputPane::stopRunControl()
|
|
|
|
|
{
|
|
|
|
|
const int index = currentIndex();
|
2017-05-09 10:25:11 +02:00
|
|
|
QTC_ASSERT(index != -1, return);
|
2011-04-14 10:39:09 +02:00
|
|
|
RunControl *rc = m_runControlTabs.at(index).runControl;
|
2017-05-09 10:25:11 +02:00
|
|
|
QTC_ASSERT(rc, return);
|
|
|
|
|
|
2022-01-03 17:09:15 +01:00
|
|
|
if (rc->isRunning()) {
|
|
|
|
|
if (optionallyPromptToStop(rc))
|
|
|
|
|
rc->initiateStop();
|
|
|
|
|
} else {
|
2017-05-09 10:25:11 +02:00
|
|
|
QTC_CHECK(false);
|
2017-09-12 08:47:17 +02:00
|
|
|
rc->forceStop();
|
2017-05-09 10:25:11 +02:00
|
|
|
}
|
2011-04-14 10:39:09 +02:00
|
|
|
|
2019-03-16 17:07:20 +01:00
|
|
|
qCDebug(appOutputLog) << "AppOutputPane::stopRunControl" << rc;
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
2017-07-20 14:43:24 +02:00
|
|
|
void AppOutputPane::closeTabs(CloseTabMode mode)
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
|
|
|
|
for (int t = m_tabWidget->count() - 1; t >= 0; t--)
|
2017-07-20 14:43:24 +02:00
|
|
|
closeTab(t, mode);
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
2015-09-17 15:24:32 +02:00
|
|
|
QList<RunControl *> AppOutputPane::allRunControls() const
|
|
|
|
|
{
|
2017-11-14 13:11:06 +01:00
|
|
|
const QList<RunControl *> list = Utils::transform<QList>(m_runControlTabs,[](const RunControlTab &tab) {
|
2017-07-13 15:24:04 +02:00
|
|
|
return tab.runControl.data();
|
2015-09-17 15:24:32 +02:00
|
|
|
});
|
2017-11-14 13:11:06 +01:00
|
|
|
return Utils::filtered(list, [](RunControl *rc) { return rc; });
|
2015-09-17 15:24:32 +02:00
|
|
|
}
|
|
|
|
|
|
2017-07-20 14:43:24 +02:00
|
|
|
void AppOutputPane::closeTab(int tabIndex, CloseTabMode closeTabMode)
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
2011-11-24 15:46:03 +01:00
|
|
|
int index = indexOf(m_tabWidget->widget(tabIndex));
|
2017-07-20 14:43:24 +02:00
|
|
|
QTC_ASSERT(index != -1, return);
|
2011-04-14 10:39:09 +02:00
|
|
|
|
2017-07-20 14:43:24 +02:00
|
|
|
RunControl *runControl = m_runControlTabs[index].runControl;
|
|
|
|
|
Core::OutputWindow *window = m_runControlTabs[index].window;
|
2019-03-16 17:07:20 +01:00
|
|
|
qCDebug(appOutputLog) << "AppOutputPane::closeTab tab" << tabIndex << runControl << window;
|
2011-04-14 10:39:09 +02:00
|
|
|
// Prompt user to stop
|
2017-07-20 14:43:24 +02:00
|
|
|
if (closeTabMode == CloseTabWithPrompt) {
|
|
|
|
|
QWidget *tabWidget = m_tabWidget->widget(tabIndex);
|
2017-11-14 13:11:06 +01:00
|
|
|
if (runControl && runControl->isRunning() && !runControl->promptToStop())
|
2017-07-20 14:43:24 +02:00
|
|
|
return;
|
|
|
|
|
// The event loop has run, thus the ordering might have changed, a tab might
|
|
|
|
|
// have been closed, so do some strange things...
|
|
|
|
|
tabIndex = m_tabWidget->indexOf(tabWidget);
|
|
|
|
|
index = indexOf(tabWidget);
|
|
|
|
|
if (tabIndex == -1 || index == -1)
|
|
|
|
|
return;
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_tabWidget->removeTab(tabIndex);
|
2017-07-20 14:43:24 +02:00
|
|
|
delete window;
|
|
|
|
|
|
2017-12-04 19:12:01 +01:00
|
|
|
if (runControl)
|
|
|
|
|
runControl->initiateFinish(); // Will self-destruct.
|
2011-04-14 10:39:09 +02:00
|
|
|
m_runControlTabs.removeAt(index);
|
2011-08-05 12:27:26 +02:00
|
|
|
updateCloseActions();
|
2019-05-14 13:55:14 +02:00
|
|
|
setFilteringEnabled(m_tabWidget->count() > 0);
|
2015-05-15 17:07:45 +02:00
|
|
|
|
|
|
|
|
if (m_runControlTabs.isEmpty())
|
|
|
|
|
hide();
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool AppOutputPane::optionallyPromptToStop(RunControl *runControl)
|
|
|
|
|
{
|
2013-09-05 18:30:50 +02:00
|
|
|
ProjectExplorerSettings settings = ProjectExplorerPlugin::projectExplorerSettings();
|
2011-04-14 10:39:09 +02:00
|
|
|
if (!runControl->promptToStop(&settings.prompToStopRunControl))
|
|
|
|
|
return false;
|
2013-09-05 18:30:50 +02:00
|
|
|
ProjectExplorerPlugin::setProjectExplorerSettings(settings);
|
2011-04-14 10:39:09 +02:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::projectRemoved()
|
|
|
|
|
{
|
|
|
|
|
tabChanged(m_tabWidget->currentIndex());
|
|
|
|
|
}
|
|
|
|
|
|
2016-01-29 16:38:37 +02:00
|
|
|
void AppOutputPane::enableDefaultButtons()
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
2017-07-05 14:25:42 +02:00
|
|
|
enableButtons(currentRunControl());
|
2011-07-06 10:25:18 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-31 08:04:43 +02:00
|
|
|
void AppOutputPane::zoomIn(int range)
|
2015-08-17 16:29:09 +02:00
|
|
|
{
|
2019-03-16 17:00:23 +01:00
|
|
|
for (const RunControlTab &tab : qAsConst(m_runControlTabs))
|
2019-03-31 08:04:43 +02:00
|
|
|
tab.window->zoomIn(range);
|
2015-08-17 16:29:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-31 08:04:43 +02:00
|
|
|
void AppOutputPane::zoomOut(int range)
|
2015-08-17 16:29:09 +02:00
|
|
|
{
|
2019-03-16 17:00:23 +01:00
|
|
|
for (const RunControlTab &tab : qAsConst(m_runControlTabs))
|
2019-03-31 08:04:43 +02:00
|
|
|
tab.window->zoomOut(range);
|
2015-08-17 16:29:09 +02:00
|
|
|
}
|
|
|
|
|
|
2019-06-20 17:27:10 +02:00
|
|
|
void AppOutputPane::resetZoom()
|
|
|
|
|
{
|
|
|
|
|
for (const RunControlTab &tab : qAsConst(m_runControlTabs))
|
|
|
|
|
tab.window->resetZoom();
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-05 14:25:42 +02:00
|
|
|
void AppOutputPane::enableButtons(const RunControl *rc)
|
2011-07-06 10:25:18 +02:00
|
|
|
{
|
|
|
|
|
if (rc) {
|
2017-07-05 14:25:42 +02:00
|
|
|
const bool isRunning = rc->isRunning();
|
|
|
|
|
m_reRunButton->setEnabled(rc->isStopped() && rc->supportsReRunning());
|
2015-11-23 16:41:54 +01:00
|
|
|
m_reRunButton->setIcon(rc->icon().icon());
|
2011-07-06 10:25:18 +02:00
|
|
|
m_stopAction->setEnabled(isRunning);
|
2014-10-28 08:26:25 +01:00
|
|
|
if (isRunning && debuggerPlugin() && rc->applicationProcessHandle().isValid()) {
|
2011-07-06 10:25:18 +02:00
|
|
|
m_attachButton->setEnabled(true);
|
2017-01-16 15:53:53 +01:00
|
|
|
Utils::ProcessHandle h = rc->applicationProcessHandle();
|
|
|
|
|
QString tip = h.isValid() ? RunControl::tr("PID %1").arg(h.pid())
|
|
|
|
|
: RunControl::tr("Invalid");
|
|
|
|
|
m_attachButton->setToolTip(msgAttachDebuggerTooltip(tip));
|
2011-07-06 10:25:18 +02:00
|
|
|
} else {
|
|
|
|
|
m_attachButton->setEnabled(false);
|
|
|
|
|
m_attachButton->setToolTip(msgAttachDebuggerTooltip());
|
|
|
|
|
}
|
2019-03-31 08:04:43 +02:00
|
|
|
setZoomButtonsEnabled(true);
|
2011-07-06 10:25:18 +02:00
|
|
|
} else {
|
2011-04-14 10:39:09 +02:00
|
|
|
m_reRunButton->setEnabled(false);
|
2016-08-03 17:55:54 +02:00
|
|
|
m_reRunButton->setIcon(Utils::Icons::RUN_SMALL_TOOLBAR.icon());
|
2011-05-31 09:48:00 +02:00
|
|
|
m_attachButton->setEnabled(false);
|
2011-07-06 10:25:18 +02:00
|
|
|
m_attachButton->setToolTip(msgAttachDebuggerTooltip());
|
|
|
|
|
m_stopAction->setEnabled(false);
|
2019-03-31 08:04:43 +02:00
|
|
|
setZoomButtonsEnabled(false);
|
2011-07-06 10:25:18 +02:00
|
|
|
}
|
2016-10-10 15:43:22 +03:00
|
|
|
m_formatterWidget->setVisible(m_formatterWidget->layout()->count());
|
2011-07-06 10:25:18 +02:00
|
|
|
}
|
2011-04-14 10:39:09 +02:00
|
|
|
|
2011-07-06 10:25:18 +02:00
|
|
|
void AppOutputPane::tabChanged(int i)
|
|
|
|
|
{
|
|
|
|
|
const int index = indexOf(m_tabWidget->widget(i));
|
2016-08-01 00:09:47 +03:00
|
|
|
if (i != -1 && index != -1) {
|
2018-08-20 14:16:46 +02:00
|
|
|
const RunControlTab &controlTab = m_runControlTabs[index];
|
2019-05-15 13:56:03 +02:00
|
|
|
controlTab.window->updateFilterProperties(filterText(), filterCaseSensitivity(),
|
2019-11-18 13:56:59 +01:00
|
|
|
filterUsesRegexp(), filterIsInverted());
|
2018-08-20 14:16:46 +02:00
|
|
|
enableButtons(controlTab.runControl);
|
2011-07-06 10:25:18 +02:00
|
|
|
} else {
|
2016-01-29 16:38:37 +02:00
|
|
|
enableDefaultButtons();
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-05 12:27:26 +02:00
|
|
|
void AppOutputPane::contextMenuRequested(const QPoint &pos, int index)
|
|
|
|
|
{
|
2019-01-18 20:25:30 +01:00
|
|
|
const QList<QAction *> actions = {m_closeCurrentTabAction, m_closeAllTabsAction, m_closeOtherTabsAction};
|
2018-07-12 22:17:17 +02:00
|
|
|
QAction *action = QMenu::exec(actions, m_tabWidget->mapToGlobal(pos), nullptr, m_tabWidget);
|
2011-08-05 12:27:26 +02:00
|
|
|
const int currentIdx = index != -1 ? index : currentIndex();
|
|
|
|
|
if (action == m_closeCurrentTabAction) {
|
|
|
|
|
if (currentIdx >= 0)
|
|
|
|
|
closeTab(currentIdx);
|
|
|
|
|
} else if (action == m_closeAllTabsAction) {
|
|
|
|
|
closeTabs(AppOutputPane::CloseTabWithPrompt);
|
|
|
|
|
} else if (action == m_closeOtherTabsAction) {
|
|
|
|
|
for (int t = m_tabWidget->count() - 1; t >= 0; t--)
|
|
|
|
|
if (t != currentIdx)
|
|
|
|
|
closeTab(t);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-07-05 14:25:42 +02:00
|
|
|
void AppOutputPane::slotRunControlChanged()
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
|
|
|
|
RunControl *current = currentRunControl();
|
2011-07-06 10:25:18 +02:00
|
|
|
if (current && current == sender())
|
2017-07-05 14:25:42 +02:00
|
|
|
enableButtons(current); // RunControl::isRunning() cannot be trusted in signal handler.
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
2011-10-20 12:59:13 +00:00
|
|
|
void AppOutputPane::slotRunControlFinished()
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
2018-07-12 22:17:17 +02:00
|
|
|
auto *rc = qobject_cast<RunControl *>(sender());
|
2016-01-29 16:38:37 +02:00
|
|
|
QTimer::singleShot(0, this, [this, rc]() { slotRunControlFinished2(rc); });
|
2021-02-16 22:43:21 +01:00
|
|
|
for (const RunControlTab &t : qAsConst(m_runControlTabs)) {
|
2020-03-19 16:00:37 +01:00
|
|
|
if (t.runControl == rc) {
|
|
|
|
|
t.window->flush();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-11-03 15:08:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::slotRunControlFinished2(RunControl *sender)
|
|
|
|
|
{
|
|
|
|
|
const int senderIndex = indexOf(sender);
|
2011-04-14 10:39:09 +02:00
|
|
|
|
2014-09-01 16:24:24 +02:00
|
|
|
// This slot is queued, so the stop() call in closeTab might lead to this slot, after closeTab already cleaned up
|
|
|
|
|
if (senderIndex == -1)
|
|
|
|
|
return;
|
2011-04-14 10:39:09 +02:00
|
|
|
|
|
|
|
|
// Enable buttons for current
|
|
|
|
|
RunControl *current = currentRunControl();
|
|
|
|
|
|
2019-03-16 17:07:20 +01:00
|
|
|
qCDebug(appOutputLog) << "AppOutputPane::runControlFinished" << sender << senderIndex
|
|
|
|
|
<< "current" << current << m_runControlTabs.size();
|
2011-04-14 10:39:09 +02:00
|
|
|
|
2011-11-03 15:08:59 +01:00
|
|
|
if (current && current == sender)
|
2017-07-05 14:25:42 +02:00
|
|
|
enableButtons(current);
|
2011-07-06 10:25:18 +02:00
|
|
|
|
2020-02-24 15:55:15 +01:00
|
|
|
ProjectExplorerPlugin::updateRunActions();
|
2011-10-20 12:59:13 +00:00
|
|
|
|
2017-07-20 14:43:24 +02:00
|
|
|
#ifdef Q_OS_WIN
|
|
|
|
|
const bool isRunning = Utils::anyOf(m_runControlTabs, [](const RunControlTab &rt) {
|
2018-02-28 14:20:09 +02:00
|
|
|
return rt.runControl && rt.runControl->isRunning();
|
2014-06-06 13:12:47 +02:00
|
|
|
});
|
2017-07-20 14:43:24 +02:00
|
|
|
if (!isRunning)
|
|
|
|
|
WinDebugInterface::instance()->stop();
|
|
|
|
|
#endif
|
|
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool AppOutputPane::canNext() const
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool AppOutputPane::canPrevious() const
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::goToNext()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::goToPrev()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-27 13:47:06 +02:00
|
|
|
bool AppOutputPane::canNavigate() const
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2011-07-04 14:09:27 +02:00
|
|
|
|
2020-01-07 14:08:17 +01:00
|
|
|
class AppOutputSettingsWidget : public Core::IOptionsPageWidget
|
2019-03-01 15:18:40 +01:00
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(ProjectExplorer::Internal::AppOutputSettingsPage)
|
|
|
|
|
public:
|
2020-01-07 14:08:17 +01:00
|
|
|
AppOutputSettingsWidget()
|
2019-03-01 15:18:40 +01:00
|
|
|
{
|
|
|
|
|
const AppOutputSettings &settings = ProjectExplorerPlugin::appOutputSettings();
|
|
|
|
|
m_wrapOutputCheckBox.setText(tr("Word-wrap output"));
|
|
|
|
|
m_wrapOutputCheckBox.setChecked(settings.wrapOutput);
|
|
|
|
|
m_cleanOldOutputCheckBox.setText(tr("Clear old output on a new run"));
|
|
|
|
|
m_cleanOldOutputCheckBox.setChecked(settings.cleanOldOutput);
|
|
|
|
|
m_mergeChannelsCheckBox.setText(tr("Merge stderr and stdout"));
|
|
|
|
|
m_mergeChannelsCheckBox.setChecked(settings.mergeChannels);
|
2019-08-14 18:03:49 +02:00
|
|
|
for (QComboBox * const modeComboBox
|
|
|
|
|
: {&m_runOutputModeComboBox, &m_debugOutputModeComboBox}) {
|
|
|
|
|
modeComboBox->addItem(tr("Always"), int(AppOutputPaneMode::PopupOnOutput));
|
|
|
|
|
modeComboBox->addItem(tr("Never"), int(AppOutputPaneMode::FlashOnOutput));
|
2020-03-11 11:04:28 +01:00
|
|
|
modeComboBox->addItem(tr("On First Output Only"),
|
2019-08-14 18:03:49 +02:00
|
|
|
int(AppOutputPaneMode::PopupOnFirstOutput));
|
|
|
|
|
}
|
|
|
|
|
m_runOutputModeComboBox.setCurrentIndex(m_runOutputModeComboBox
|
|
|
|
|
.findData(int(settings.runOutputMode)));
|
|
|
|
|
m_debugOutputModeComboBox.setCurrentIndex(m_debugOutputModeComboBox
|
|
|
|
|
.findData(int(settings.debugOutputMode)));
|
2019-03-01 15:18:40 +01:00
|
|
|
m_maxCharsBox.setMaximum(100000000);
|
|
|
|
|
m_maxCharsBox.setValue(settings.maxCharCount);
|
|
|
|
|
const auto layout = new QVBoxLayout(this);
|
|
|
|
|
layout->addWidget(&m_wrapOutputCheckBox);
|
|
|
|
|
layout->addWidget(&m_cleanOldOutputCheckBox);
|
|
|
|
|
layout->addWidget(&m_mergeChannelsCheckBox);
|
|
|
|
|
const auto maxCharsLayout = new QHBoxLayout;
|
2019-05-08 14:32:36 +02:00
|
|
|
const QString msg = tr("Limit output to %1 characters");
|
|
|
|
|
const QStringList parts = msg.split("%1") << QString() << QString();
|
|
|
|
|
maxCharsLayout->addWidget(new QLabel(parts.at(0).trimmed()));
|
2019-03-01 15:18:40 +01:00
|
|
|
maxCharsLayout->addWidget(&m_maxCharsBox);
|
2019-05-08 14:32:36 +02:00
|
|
|
maxCharsLayout->addWidget(new QLabel(parts.at(1).trimmed()));
|
2019-03-01 15:18:40 +01:00
|
|
|
maxCharsLayout->addStretch(1);
|
2019-08-14 18:03:49 +02:00
|
|
|
const auto outputModeLayout = new QFormLayout;
|
|
|
|
|
outputModeLayout->addRow(tr("Open pane on output when running:"), &m_runOutputModeComboBox);
|
|
|
|
|
outputModeLayout->addRow(tr("Open pane on output when debugging:"),
|
|
|
|
|
&m_debugOutputModeComboBox);
|
|
|
|
|
layout->addLayout(outputModeLayout);
|
2019-03-01 15:18:40 +01:00
|
|
|
layout->addLayout(maxCharsLayout);
|
|
|
|
|
layout->addStretch(1);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 14:08:17 +01:00
|
|
|
void apply() final
|
2019-03-01 15:18:40 +01:00
|
|
|
{
|
|
|
|
|
AppOutputSettings s;
|
|
|
|
|
s.wrapOutput = m_wrapOutputCheckBox.isChecked();
|
|
|
|
|
s.cleanOldOutput = m_cleanOldOutputCheckBox.isChecked();
|
|
|
|
|
s.mergeChannels = m_mergeChannelsCheckBox.isChecked();
|
2019-08-14 18:03:49 +02:00
|
|
|
s.runOutputMode = static_cast<AppOutputPaneMode>(
|
|
|
|
|
m_runOutputModeComboBox.currentData().toInt());
|
|
|
|
|
s.debugOutputMode = static_cast<AppOutputPaneMode>(
|
|
|
|
|
m_debugOutputModeComboBox.currentData().toInt());
|
2019-03-01 15:18:40 +01:00
|
|
|
s.maxCharCount = m_maxCharsBox.value();
|
2020-01-07 14:08:17 +01:00
|
|
|
|
|
|
|
|
ProjectExplorerPlugin::setAppOutputSettings(s);
|
2019-03-01 15:18:40 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QCheckBox m_wrapOutputCheckBox;
|
|
|
|
|
QCheckBox m_cleanOldOutputCheckBox;
|
|
|
|
|
QCheckBox m_mergeChannelsCheckBox;
|
2019-08-14 18:03:49 +02:00
|
|
|
QComboBox m_runOutputModeComboBox;
|
|
|
|
|
QComboBox m_debugOutputModeComboBox;
|
2019-03-01 15:18:40 +01:00
|
|
|
QSpinBox m_maxCharsBox;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AppOutputSettingsPage::AppOutputSettingsPage()
|
|
|
|
|
{
|
2019-03-12 10:18:14 +01:00
|
|
|
setId(OPTIONS_PAGE_ID);
|
2020-01-27 08:58:38 +01:00
|
|
|
setDisplayName(AppOutputSettingsWidget::tr("Application Output"));
|
2019-03-01 15:18:40 +01:00
|
|
|
setCategory(Constants::BUILD_AND_RUN_SETTINGS_CATEGORY);
|
2020-01-07 14:08:17 +01:00
|
|
|
setWidgetCreator([] { return new AppOutputSettingsWidget; });
|
2019-03-01 15:18:40 +01:00
|
|
|
}
|
|
|
|
|
|
2020-03-12 13:46:25 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ProjectExplorer
|
2019-03-01 15:18:40 +01:00
|
|
|
|
2011-08-05 12:27:26 +02:00
|
|
|
#include "appoutputpane.moc"
|
|
|
|
|
|