forked from qt-creator/qt-creator
Add the needed infrastucture to enable application output filters
Currently will be used only by Android, but in the future can be extended everywhere Change-Id: I37314248f2d6dba2401e853b2a6ea4a36859f502 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -59,6 +59,8 @@ public:
|
||||
virtual void appendMessage(const QString &text, OutputFormat format);
|
||||
virtual void appendMessage(const QString &text, const QTextCharFormat &format);
|
||||
virtual void handleLink(const QString &href);
|
||||
virtual QList<QWidget *> toolbarWidgets() const { return {}; }
|
||||
virtual void clear() {}
|
||||
|
||||
protected:
|
||||
void initFormats();
|
||||
|
@@ -368,6 +368,8 @@ void OutputWindow::clear()
|
||||
{
|
||||
d->enforceNewline = false;
|
||||
QPlainTextEdit::clear();
|
||||
if (d->formatter)
|
||||
d->formatter->clear();
|
||||
}
|
||||
|
||||
void OutputWindow::scrollToBottom()
|
||||
|
@@ -74,6 +74,15 @@ static QString msgAttachDebuggerTooltip(const QString &handleDescription = QStri
|
||||
AppOutputPane::tr("Attach debugger to %1").arg(handleDescription);
|
||||
}
|
||||
|
||||
static void replaceAllChildWidgets(QLayout *layout, const QList<QWidget *> &newChildren)
|
||||
{
|
||||
while (QLayoutItem *child = layout->takeAt(0))
|
||||
delete child;
|
||||
|
||||
foreach (QWidget *widget, newChildren)
|
||||
layout->addWidget(widget);
|
||||
}
|
||||
|
||||
namespace {
|
||||
const char SETTINGS_KEY[] = "ProjectExplorer/AppOutput/Zoom";
|
||||
}
|
||||
@@ -152,7 +161,8 @@ AppOutputPane::AppOutputPane() :
|
||||
m_stopButton(new QToolButton),
|
||||
m_attachButton(new QToolButton),
|
||||
m_zoomInButton(new QToolButton),
|
||||
m_zoomOutButton(new QToolButton)
|
||||
m_zoomOutButton(new QToolButton),
|
||||
m_formatterWidget(new QWidget)
|
||||
{
|
||||
setObjectName(QLatin1String("AppOutputPane")); // Used in valgrind engine
|
||||
|
||||
@@ -200,6 +210,10 @@ AppOutputPane::AppOutputPane() :
|
||||
connect(m_zoomOutButton, &QToolButton::clicked,
|
||||
this, &AppOutputPane::zoomOut);
|
||||
|
||||
auto formatterWidgetsLayout = new QHBoxLayout;
|
||||
formatterWidgetsLayout->setContentsMargins(QMargins());
|
||||
m_formatterWidget->setLayout(formatterWidgetsLayout);
|
||||
|
||||
// Spacer (?)
|
||||
|
||||
QVBoxLayout *layout = new QVBoxLayout;
|
||||
@@ -321,7 +335,8 @@ QWidget *AppOutputPane::outputWidget(QWidget *)
|
||||
|
||||
QList<QWidget*> AppOutputPane::toolBarWidgets() const
|
||||
{
|
||||
return {m_reRunButton, m_stopButton, m_attachButton, m_zoomInButton, m_zoomOutButton};
|
||||
return { m_reRunButton, m_stopButton, m_attachButton, m_zoomInButton,
|
||||
m_zoomOutButton, m_formatterWidget };
|
||||
}
|
||||
|
||||
QString AppOutputPane::displayName() const
|
||||
@@ -639,6 +654,10 @@ void AppOutputPane::enableButtons(const RunControl *rc, bool isRunning)
|
||||
}
|
||||
m_zoomInButton->setEnabled(true);
|
||||
m_zoomOutButton->setEnabled(true);
|
||||
|
||||
replaceAllChildWidgets(m_formatterWidget->layout(), rc->outputFormatter() ?
|
||||
rc->outputFormatter()->toolbarWidgets() :
|
||||
QList<QWidget *>());
|
||||
} else {
|
||||
m_reRunButton->setEnabled(false);
|
||||
m_reRunButton->setIcon(Utils::Icons::RUN_SMALL_TOOLBAR.icon());
|
||||
@@ -648,6 +667,7 @@ void AppOutputPane::enableButtons(const RunControl *rc, bool isRunning)
|
||||
m_zoomInButton->setEnabled(false);
|
||||
m_zoomOutButton->setEnabled(false);
|
||||
}
|
||||
m_formatterWidget->setVisible(m_formatterWidget->layout()->count());
|
||||
}
|
||||
|
||||
void AppOutputPane::tabChanged(int i)
|
||||
|
@@ -160,6 +160,7 @@ private:
|
||||
QToolButton *m_attachButton;
|
||||
QToolButton *m_zoomInButton;
|
||||
QToolButton *m_zoomOutButton;
|
||||
QWidget *m_formatterWidget;
|
||||
float m_zoom;
|
||||
};
|
||||
|
||||
|
@@ -573,7 +573,7 @@ RunControl::~RunControl()
|
||||
delete d;
|
||||
}
|
||||
|
||||
Utils::OutputFormatter *RunControl::outputFormatter()
|
||||
Utils::OutputFormatter *RunControl::outputFormatter() const
|
||||
{
|
||||
return d->outputFormatter;
|
||||
}
|
||||
|
@@ -379,7 +379,7 @@ public:
|
||||
Project *project() const;
|
||||
bool canReUseOutputPane(const RunControl *other) const;
|
||||
|
||||
Utils::OutputFormatter *outputFormatter();
|
||||
Utils::OutputFormatter *outputFormatter() const;
|
||||
Core::Id runMode() const;
|
||||
|
||||
const Runnable &runnable() const;
|
||||
|
Reference in New Issue
Block a user