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"
|
|
|
|
|
#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"
|
2011-04-14 10:39:09 +02:00
|
|
|
#include "runconfiguration.h"
|
|
|
|
|
#include "session.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>
|
2013-03-25 17:13:18 +01:00
|
|
|
#include <coreplugin/outputwindow.h>
|
2014-01-13 16:17:34 +01:00
|
|
|
#include <coreplugin/find/basetextfind.h>
|
2015-08-17 16:29:09 +02:00
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
2011-04-14 10:39:09 +02:00
|
|
|
#include <texteditor/fontsettings.h>
|
|
|
|
|
#include <texteditor/texteditorsettings.h>
|
2015-08-17 16:29:09 +02:00
|
|
|
#include <texteditor/behaviorsettings.h>
|
2011-05-31 09:48:00 +02:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
|
|
|
|
#include <extensionsystem/invoker.h>
|
2011-04-14 10:39:09 +02:00
|
|
|
|
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>
|
|
|
|
|
#include <QHBoxLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QSpinBox>
|
|
|
|
|
#include <QTabBar>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QTabWidget>
|
|
|
|
|
#include <QToolButton>
|
2019-03-01 15:18:40 +01:00
|
|
|
#include <QVBoxLayout>
|
2011-04-14 10:39:09 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDebug>
|
2011-04-14 10:39:09 +02:00
|
|
|
|
|
|
|
|
enum { debug = 0 };
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
|
2014-10-28 08:26:25 +01:00
|
|
|
static QObject *debuggerPlugin()
|
2011-05-31 09:48:00 +02:00
|
|
|
{
|
2014-10-28 08:26:25 +01:00
|
|
|
return ExtensionSystem::PluginManager::getObjectByName(QLatin1String("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);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-10 15:43:22 +03:00
|
|
|
static void replaceAllChildWidgets(QLayout *layout, const QList<QWidget *> &newChildren)
|
|
|
|
|
{
|
|
|
|
|
while (QLayoutItem *child = layout->takeAt(0))
|
|
|
|
|
delete child;
|
|
|
|
|
|
|
|
|
|
foreach (QWidget *widget, newChildren)
|
|
|
|
|
layout->addWidget(widget);
|
|
|
|
|
}
|
|
|
|
|
|
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));
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-21 13:42:17 +02:00
|
|
|
AppOutputPane::RunControlTab::RunControlTab(RunControl *rc, Core::OutputWindow *w) :
|
2016-08-01 09:27:42 +03:00
|
|
|
runControl(rc), window(w)
|
2017-06-23 15:19:00 +02:00
|
|
|
{
|
|
|
|
|
if (rc && w)
|
|
|
|
|
w->setFormatter(rc->outputFormatter());
|
|
|
|
|
}
|
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),
|
|
|
|
|
m_zoomInButton(new QToolButton),
|
2016-10-10 15:43:22 +03:00
|
|
|
m_zoomOutButton(new QToolButton),
|
|
|
|
|
m_formatterWidget(new QWidget)
|
2011-04-14 10:39:09 +02:00
|
|
|
{
|
2013-01-10 11:36:15 +01:00
|
|
|
setObjectName(QLatin1String("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());
|
2011-04-14 10:39:09 +02:00
|
|
|
m_reRunButton->setToolTip(tr("Re-run this run-configuration"));
|
|
|
|
|
m_reRunButton->setAutoRaise(true);
|
|
|
|
|
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());
|
2017-03-02 10:23:09 +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());
|
|
|
|
|
m_stopButton->setAutoRaise(true);
|
|
|
|
|
|
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
|
|
|
m_attachButton->setAutoRaise(true);
|
|
|
|
|
|
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
|
|
|
|
2015-08-17 16:29:09 +02:00
|
|
|
m_zoomInButton->setToolTip(tr("Increase Font Size"));
|
2016-09-20 15:59:48 +02:00
|
|
|
m_zoomInButton->setIcon(Utils::Icons::PLUS_TOOLBAR.icon());
|
2015-08-17 16:29:09 +02:00
|
|
|
m_zoomInButton->setAutoRaise(true);
|
|
|
|
|
|
|
|
|
|
connect(m_zoomInButton, &QToolButton::clicked,
|
|
|
|
|
this, &AppOutputPane::zoomIn);
|
|
|
|
|
|
|
|
|
|
m_zoomOutButton->setToolTip(tr("Decrease Font Size"));
|
2016-08-03 17:55:54 +02:00
|
|
|
m_zoomOutButton->setIcon(Utils::Icons::MINUS.icon());
|
2015-08-17 16:29:09 +02:00
|
|
|
m_zoomOutButton->setAutoRaise(true);
|
|
|
|
|
|
|
|
|
|
connect(m_zoomOutButton, &QToolButton::clicked,
|
|
|
|
|
this, &AppOutputPane::zoomOut);
|
|
|
|
|
|
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;
|
2011-04-14 10:39:09 +02:00
|
|
|
layout->setMargin(0);
|
|
|
|
|
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);
|
|
|
|
|
|
2015-08-17 16:29:09 +02:00
|
|
|
connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::fontSettingsChanged,
|
|
|
|
|
this, &AppOutputPane::updateFontSettings);
|
|
|
|
|
|
|
|
|
|
connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::behaviorSettingsChanged,
|
|
|
|
|
this, &AppOutputPane::updateBehaviorSettings);
|
|
|
|
|
|
2016-01-29 16:38:37 +02:00
|
|
|
connect(SessionManager::instance(), &SessionManager::aboutToUnloadSession,
|
|
|
|
|
this, &AppOutputPane::aboutToUnloadSession);
|
2015-08-17 16:29:09 +02:00
|
|
|
|
|
|
|
|
connect(Core::ICore::instance(), &Core::ICore::saveSettingsRequested,
|
2019-03-01 15:18:40 +01:00
|
|
|
this, &AppOutputPane::storeZoomFactor);
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppOutputPane::~AppOutputPane()
|
|
|
|
|
{
|
|
|
|
|
if (debug)
|
|
|
|
|
qDebug() << "OutputPane::~OutputPane: Entries left" << m_runControlTabs.size();
|
|
|
|
|
|
2017-03-01 16:26:34 +01:00
|
|
|
foreach (const RunControlTab &rt, 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;
|
|
|
|
|
}
|
|
|
|
|
|
2019-03-01 15:18:40 +01:00
|
|
|
void AppOutputPane::storeZoomFactor()
|
2015-08-17 16:29:09 +02:00
|
|
|
{
|
|
|
|
|
QSettings *settings = Core::ICore::settings();
|
|
|
|
|
settings->setValue(QLatin1String(SETTINGS_KEY), m_zoom);
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
|
|
{
|
2016-10-10 15:43:22 +03:00
|
|
|
return { m_reRunButton, m_stopButton, m_attachButton, m_zoomInButton,
|
|
|
|
|
m_zoomOutButton, m_formatterWidget };
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::visibilityChanged(bool /* b */)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2015-08-17 16:29:09 +02:00
|
|
|
void AppOutputPane::updateFontSettings()
|
|
|
|
|
{
|
|
|
|
|
QFont f = TextEditor::TextEditorSettings::fontSettings().font();
|
|
|
|
|
foreach (const RunControlTab &rcTab, m_runControlTabs)
|
|
|
|
|
rcTab.window->setBaseFont(f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::updateBehaviorSettings()
|
|
|
|
|
{
|
|
|
|
|
bool zoomEnabled = TextEditor::TextEditorSettings::behaviorSettings().m_scrollWheelZooming;
|
|
|
|
|
foreach (const RunControlTab &rcTab, m_runControlTabs)
|
|
|
|
|
rcTab.window->setWheelZoomEnabled(zoomEnabled);
|
|
|
|
|
}
|
|
|
|
|
|
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();
|
|
|
|
|
return thisRunnable.executable == otherRunnable.executable
|
|
|
|
|
&& thisRunnable.commandLineArguments == otherRunnable.commandLineArguments
|
|
|
|
|
&& 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;
|
2017-08-21 12:04:06 +03:00
|
|
|
tab.window->setFormatter(rc->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();
|
|
|
|
|
if (debug)
|
|
|
|
|
qDebug() << "OutputPane::createNewOutputWindow: Reusing tab" << tabIndex << " for " << rc;
|
|
|
|
|
return;
|
2011-04-14 10:39:09 +02:00
|
|
|
}
|
|
|
|
|
// Create new
|
2017-03-01 16:26:34 +01:00
|
|
|
static int counter = 0;
|
2017-03-17 15:33:07 +02:00
|
|
|
Core::Id contextId = Core::Id(C_APP_OUTPUT).withSuffix(counter++);
|
2013-01-28 10:37:19 +01:00
|
|
|
Core::Context context(contextId);
|
2011-04-21 13:42:17 +02:00
|
|
|
Core::OutputWindow *ow = new Core::OutputWindow(context, 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);
|
2015-08-17 16:29:09 +02:00
|
|
|
ow->setWheelZoomEnabled(TextEditor::TextEditorSettings::behaviorSettings().m_scrollWheelZooming);
|
|
|
|
|
ow->setBaseFont(TextEditor::TextEditorSettings::fontSettings().font());
|
|
|
|
|
ow->setFontZoom(m_zoom);
|
|
|
|
|
|
2016-08-01 09:27:42 +03:00
|
|
|
connect(ow, &Core::OutputWindow::wheelZoom, this, [this, ow]() {
|
2015-08-17 16:29:09 +02:00
|
|
|
m_zoom = ow->fontZoom();
|
|
|
|
|
foreach (const RunControlTab &tab, m_runControlTabs)
|
|
|
|
|
tab.window->setFontZoom(m_zoom);
|
|
|
|
|
});
|
|
|
|
|
|
2018-07-12 22:17:17 +02:00
|
|
|
auto *agg = new Aggregation::Aggregate;
|
2011-04-14 10:39:09 +02:00
|
|
|
agg->add(ow);
|
2014-01-13 16:17:34 +01:00
|
|
|
agg->add(new Core::BaseTextFind(ow));
|
2011-04-14 10:39:09 +02:00
|
|
|
m_runControlTabs.push_back(RunControlTab(rc, ow));
|
|
|
|
|
m_tabWidget->addTab(ow, rc->displayName());
|
|
|
|
|
if (debug)
|
|
|
|
|
qDebug() << "OutputPane::createNewOutputWindow: Adding tab for " << rc;
|
2011-08-05 12:27:26 +02:00
|
|
|
updateCloseActions();
|
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
|
|
|
{
|
2016-08-01 09:27:42 +03:00
|
|
|
foreach (const RunControlTab &tab, 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();
|
|
|
|
|
stringToWrite += QLatin1String(": ");
|
|
|
|
|
}
|
|
|
|
|
stringToWrite += out;
|
|
|
|
|
window->appendMessage(stringToWrite, format);
|
2013-04-16 16:21:28 +02:00
|
|
|
if (format != Utils::NormalMessageFormat) {
|
2013-12-13 22:03:26 +01:00
|
|
|
if (m_runControlTabs.at(index).behaviorOnOutput == Flash)
|
2013-04-16 16:21:28 +02:00
|
|
|
flash();
|
|
|
|
|
else
|
|
|
|
|
popup(NoModeSwitch);
|
|
|
|
|
}
|
|
|
|
|
}
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::storeSettings() const
|
|
|
|
|
{
|
|
|
|
|
QSettings * const s = Core::ICore::settings();
|
|
|
|
|
s->setValue(POP_UP_FOR_RUN_OUTPUT_KEY, m_settings.popUpForRunOutput);
|
|
|
|
|
s->setValue(POP_UP_FOR_DEBUG_OUTPUT_KEY, m_settings.popUpForDebugOutput);
|
|
|
|
|
s->setValue(CLEAN_OLD_OUTPUT_KEY, m_settings.cleanOldOutput);
|
|
|
|
|
s->setValue(MERGE_CHANNELS_KEY, m_settings.mergeChannels);
|
|
|
|
|
s->setValue(WRAP_OUTPUT_KEY, m_settings.wrapOutput);
|
|
|
|
|
s->setValue(MAX_LINES_KEY, m_settings.maxCharCount / 100);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::loadSettings()
|
|
|
|
|
{
|
|
|
|
|
QSettings * const s = Core::ICore::settings();
|
|
|
|
|
m_settings.popUpForRunOutput = s->value(POP_UP_FOR_RUN_OUTPUT_KEY, true).toBool();
|
|
|
|
|
m_settings.popUpForDebugOutput = s->value(POP_UP_FOR_DEBUG_OUTPUT_KEY, false).toBool();
|
|
|
|
|
m_settings.cleanOldOutput = s->value(CLEAN_OLD_OUTPUT_KEY, false).toBool();
|
|
|
|
|
m_settings.mergeChannels = s->value(MERGE_CHANNELS_KEY, false).toBool();
|
|
|
|
|
m_settings.wrapOutput = s->value(WRAP_OUTPUT_KEY, true).toBool();
|
|
|
|
|
m_settings.maxCharCount = s->value(MAX_LINES_KEY,
|
|
|
|
|
Core::Constants::DEFAULT_MAX_CHAR_COUNT).toInt() * 100;
|
|
|
|
|
m_zoom = s->value(SETTINGS_KEY, 0).toFloat();
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
void AppOutputPane::showTabFor(RunControl *rc)
|
|
|
|
|
{
|
|
|
|
|
m_tabWidget->setCurrentIndex(tabWidgetIndexOf(indexOf(rc)));
|
|
|
|
|
}
|
|
|
|
|
|
2013-12-13 22:03:26 +01:00
|
|
|
void AppOutputPane::setBehaviorOnOutput(RunControl *rc, AppOutputPane::BehaviorOnOutput 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);
|
|
|
|
|
|
2011-04-14 10:39:09 +02:00
|
|
|
if (rc->isRunning() && optionallyPromptToStop(rc))
|
2017-03-13 13:48:55 +01:00
|
|
|
rc->initiateStop();
|
2017-09-12 08:47:17 +02:00
|
|
|
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
|
|
|
|
|
|
|
|
if (debug)
|
|
|
|
|
qDebug() << "OutputPane::stopRunControl " << rc;
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
2011-04-14 10:39:09 +02:00
|
|
|
if (debug)
|
2017-07-20 14:43:24 +02:00
|
|
|
qDebug() << "OutputPane::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();
|
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
|
|
|
}
|
|
|
|
|
|
2015-08-17 16:29:09 +02:00
|
|
|
void AppOutputPane::zoomIn()
|
|
|
|
|
{
|
|
|
|
|
foreach (const RunControlTab &tab, m_runControlTabs)
|
|
|
|
|
tab.window->zoomIn(1);
|
|
|
|
|
if (m_runControlTabs.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
m_zoom = m_runControlTabs.first().window->fontZoom();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputPane::zoomOut()
|
|
|
|
|
{
|
|
|
|
|
foreach (const RunControlTab &tab, m_runControlTabs)
|
|
|
|
|
tab.window->zoomOut(1);
|
|
|
|
|
if (m_runControlTabs.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
m_zoom = m_runControlTabs.first().window->fontZoom();
|
|
|
|
|
}
|
|
|
|
|
|
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());
|
|
|
|
|
}
|
2015-08-17 16:29:09 +02:00
|
|
|
m_zoomInButton->setEnabled(true);
|
|
|
|
|
m_zoomOutButton->setEnabled(true);
|
2016-10-10 15:43:22 +03:00
|
|
|
|
|
|
|
|
replaceAllChildWidgets(m_formatterWidget->layout(), rc->outputFormatter() ?
|
|
|
|
|
rc->outputFormatter()->toolbarWidgets() :
|
|
|
|
|
QList<QWidget *>());
|
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);
|
2015-08-17 16:29:09 +02:00
|
|
|
m_zoomInButton->setEnabled(false);
|
|
|
|
|
m_zoomOutButton->setEnabled(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) {
|
2017-07-05 14:25:42 +02:00
|
|
|
enableButtons(m_runControlTabs.at(index).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); });
|
2017-03-01 16:26:34 +01:00
|
|
|
if (rc->outputFormatter())
|
|
|
|
|
rc->outputFormatter()->flush();
|
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();
|
|
|
|
|
|
|
|
|
|
if (debug)
|
2011-11-03 15:08:59 +01:00
|
|
|
qDebug() << "OutputPane::runControlFinished" << sender << senderIndex
|
2011-04-14 10:39:09 +02:00
|
|
|
<< " current " << current << m_runControlTabs.size();
|
|
|
|
|
|
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
|
|
|
|
2019-01-16 18:06:21 +01:00
|
|
|
emit ProjectExplorerPlugin::instance()->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
|
|
|
|
2019-03-01 15:18:40 +01:00
|
|
|
class AppOutputSettingsPage::SettingsWidget : public QWidget
|
|
|
|
|
{
|
|
|
|
|
Q_DECLARE_TR_FUNCTIONS(ProjectExplorer::Internal::AppOutputSettingsPage)
|
|
|
|
|
public:
|
|
|
|
|
SettingsWidget()
|
|
|
|
|
{
|
|
|
|
|
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);
|
|
|
|
|
m_popUpForRunOutputCheckBox.setText(tr("Open pane on output when running"));
|
|
|
|
|
m_popUpForRunOutputCheckBox.setChecked(settings.popUpForRunOutput);
|
|
|
|
|
m_popUpForDebugOutputCheckBox.setText(tr("Open pane on output when debugging"));
|
|
|
|
|
m_popUpForDebugOutputCheckBox.setChecked(settings.popUpForDebugOutput);
|
|
|
|
|
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);
|
|
|
|
|
layout->addWidget(&m_popUpForRunOutputCheckBox);
|
|
|
|
|
layout->addWidget(&m_popUpForDebugOutputCheckBox);
|
|
|
|
|
const auto maxCharsLayout = new QHBoxLayout;
|
|
|
|
|
maxCharsLayout->addWidget(new QLabel(tr("Limit output to"))); // TODO: This looks problematic i18n-wise
|
|
|
|
|
maxCharsLayout->addWidget(&m_maxCharsBox);
|
|
|
|
|
maxCharsLayout->addWidget(new QLabel(tr("characters")));
|
|
|
|
|
maxCharsLayout->addStretch(1);
|
|
|
|
|
layout->addLayout(maxCharsLayout);
|
|
|
|
|
layout->addStretch(1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AppOutputSettings settings() const
|
|
|
|
|
{
|
|
|
|
|
AppOutputSettings s;
|
|
|
|
|
s.wrapOutput = m_wrapOutputCheckBox.isChecked();
|
|
|
|
|
s.cleanOldOutput = m_cleanOldOutputCheckBox.isChecked();
|
|
|
|
|
s.mergeChannels = m_mergeChannelsCheckBox.isChecked();
|
|
|
|
|
s.popUpForRunOutput = m_popUpForRunOutputCheckBox.isChecked();
|
|
|
|
|
s.popUpForDebugOutput = m_popUpForDebugOutputCheckBox.isChecked();
|
|
|
|
|
s.maxCharCount = m_maxCharsBox.value();
|
|
|
|
|
return s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
QCheckBox m_wrapOutputCheckBox;
|
|
|
|
|
QCheckBox m_cleanOldOutputCheckBox;
|
|
|
|
|
QCheckBox m_mergeChannelsCheckBox;
|
|
|
|
|
QCheckBox m_popUpForRunOutputCheckBox;
|
|
|
|
|
QCheckBox m_popUpForDebugOutputCheckBox;
|
|
|
|
|
QSpinBox m_maxCharsBox;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AppOutputSettingsPage::AppOutputSettingsPage()
|
|
|
|
|
{
|
|
|
|
|
setId("B.ProjectExplorer.AppOutputOptions");
|
|
|
|
|
setDisplayName(tr("Application Output"));
|
|
|
|
|
setCategory(Constants::BUILD_AND_RUN_SETTINGS_CATEGORY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QWidget *AppOutputSettingsPage::widget()
|
|
|
|
|
{
|
|
|
|
|
if (!m_widget)
|
|
|
|
|
m_widget = new SettingsWidget;
|
|
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputSettingsPage::apply()
|
|
|
|
|
{
|
|
|
|
|
if (m_widget)
|
|
|
|
|
ProjectExplorerPlugin::setAppOutputSettings(m_widget->settings());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void AppOutputSettingsPage::finish()
|
|
|
|
|
{
|
|
|
|
|
delete m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-05 12:27:26 +02:00
|
|
|
#include "appoutputpane.moc"
|
|
|
|
|
|