forked from qt-creator/qt-creator
OutputPanes code style fixes
Change-Id: I58c4fd1369dc2d6400416b0366b1d357a3308523 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -38,26 +38,26 @@ class MessageOutputWindow : public IOutputPane
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MessageOutputWindow();
|
MessageOutputWindow();
|
||||||
~MessageOutputWindow();
|
~MessageOutputWindow() override;
|
||||||
|
|
||||||
QWidget *outputWidget(QWidget *parent);
|
QWidget *outputWidget(QWidget *parent) override;
|
||||||
QList<QWidget*> toolBarWidgets() const { return QList<QWidget *>(); }
|
QList<QWidget*> toolBarWidgets() const override { return {}; }
|
||||||
|
|
||||||
QString displayName() const;
|
QString displayName() const override;
|
||||||
int priorityInStatusBar() const;
|
int priorityInStatusBar() const override;
|
||||||
void clearContents();
|
void clearContents() override;
|
||||||
void visibilityChanged(bool visible);
|
void visibilityChanged(bool visible) override;
|
||||||
|
|
||||||
void append(const QString &text);
|
void append(const QString &text);
|
||||||
bool canFocus() const;
|
bool canFocus() const override;
|
||||||
bool hasFocus() const;
|
bool hasFocus() const override;
|
||||||
void setFocus();
|
void setFocus() override;
|
||||||
|
|
||||||
virtual bool canNext() const;
|
bool canNext() const override;
|
||||||
virtual bool canPrevious() const;
|
bool canPrevious() const override;
|
||||||
virtual void goToNext();
|
void goToNext() override;
|
||||||
virtual void goToPrev();
|
void goToPrev() override;
|
||||||
bool canNavigate() const;
|
bool canNavigate() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OutputWindow *m_widget;
|
OutputWindow *m_widget;
|
||||||
|
|||||||
@@ -45,16 +45,7 @@ class OutputWindowPrivate
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
OutputWindowPrivate(QTextDocument *document)
|
OutputWindowPrivate(QTextDocument *document)
|
||||||
: outputWindowContext(0)
|
: cursor(document)
|
||||||
, formatter(0)
|
|
||||||
, enforceNewline(false)
|
|
||||||
, scrollToBottom(false)
|
|
||||||
, linksActive(true)
|
|
||||||
, mousePressed(false)
|
|
||||||
, m_zoomEnabled(false)
|
|
||||||
, m_originalFontSize(0)
|
|
||||||
, maxLineCount(100000)
|
|
||||||
, cursor(document)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,16 +55,16 @@ public:
|
|||||||
delete outputWindowContext;
|
delete outputWindowContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
IContext *outputWindowContext;
|
IContext *outputWindowContext = nullptr;
|
||||||
Utils::OutputFormatter *formatter;
|
Utils::OutputFormatter *formatter = nullptr;
|
||||||
|
|
||||||
bool enforceNewline;
|
bool enforceNewline = false;
|
||||||
bool scrollToBottom;
|
bool scrollToBottom = true;
|
||||||
bool linksActive;
|
bool linksActive = true;
|
||||||
bool mousePressed;
|
bool mousePressed = false;
|
||||||
bool m_zoomEnabled;
|
bool m_zoomEnabled = false;
|
||||||
float m_originalFontSize;
|
float m_originalFontSize = 0.;
|
||||||
int maxLineCount;
|
int maxLineCount = 100000;
|
||||||
QTextCursor cursor;
|
QTextCursor cursor;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
void grayOutOldContent();
|
void grayOutOldContent();
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
void showEvent(QShowEvent *);
|
void showEvent(QShowEvent *) override;
|
||||||
|
|
||||||
void scrollToBottom();
|
void scrollToBottom();
|
||||||
|
|
||||||
@@ -79,12 +79,12 @@ public slots:
|
|||||||
protected:
|
protected:
|
||||||
bool isScrollbarAtBottom() const;
|
bool isScrollbarAtBottom() const;
|
||||||
|
|
||||||
virtual void mousePressEvent(QMouseEvent *e);
|
void mousePressEvent(QMouseEvent *e) override;
|
||||||
virtual void mouseReleaseEvent(QMouseEvent *e);
|
void mouseReleaseEvent(QMouseEvent *e) override;
|
||||||
virtual void mouseMoveEvent(QMouseEvent *e);
|
void mouseMoveEvent(QMouseEvent *e) override;
|
||||||
virtual void resizeEvent(QResizeEvent *e);
|
void resizeEvent(QResizeEvent *e) override;
|
||||||
virtual void keyPressEvent(QKeyEvent *ev);
|
void keyPressEvent(QKeyEvent *ev) override;
|
||||||
virtual void wheelEvent(QWheelEvent *e);
|
void wheelEvent(QWheelEvent *e) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
using QPlainTextEdit::setFont; // call setBaseFont instead, which respects the zoom factor
|
using QPlainTextEdit::setFont; // call setBaseFont instead, which respects the zoom factor
|
||||||
|
|||||||
@@ -87,19 +87,19 @@ class TabWidget : public QTabWidget
|
|||||||
public:
|
public:
|
||||||
TabWidget(QWidget *parent = nullptr);
|
TabWidget(QWidget *parent = nullptr);
|
||||||
signals:
|
signals:
|
||||||
void contextMenuRequested(const QPoint &pos, const int index);
|
void contextMenuRequested(const QPoint &pos, int index);
|
||||||
protected:
|
protected:
|
||||||
bool eventFilter(QObject *object, QEvent *event);
|
bool eventFilter(QObject *object, QEvent *event) override;
|
||||||
private:
|
private:
|
||||||
void slotContextMenuRequested(const QPoint &pos);
|
void slotContextMenuRequested(const QPoint &pos);
|
||||||
int m_tabIndexForMiddleClick;
|
int m_tabIndexForMiddleClick = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TabWidget::TabWidget(QWidget *parent)
|
TabWidget::TabWidget(QWidget *parent)
|
||||||
: QTabWidget(parent), m_tabIndexForMiddleClick(-1)
|
: QTabWidget(parent)
|
||||||
{
|
{
|
||||||
tabBar()->installEventFilter(this);
|
tabBar()->installEventFilter(this);
|
||||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
@@ -138,7 +138,7 @@ void TabWidget::slotContextMenuRequested(const QPoint &pos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
AppOutputPane::RunControlTab::RunControlTab(RunControl *rc, Core::OutputWindow *w) :
|
AppOutputPane::RunControlTab::RunControlTab(RunControl *rc, Core::OutputWindow *w) :
|
||||||
runControl(rc), window(w), asyncClosing(false), behaviorOnOutput(Flash)
|
runControl(rc), window(w)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
AppOutputPane::AppOutputPane() :
|
AppOutputPane::AppOutputPane() :
|
||||||
@@ -161,7 +161,7 @@ AppOutputPane::AppOutputPane() :
|
|||||||
m_reRunButton->setToolTip(tr("Re-run this run-configuration"));
|
m_reRunButton->setToolTip(tr("Re-run this run-configuration"));
|
||||||
m_reRunButton->setAutoRaise(true);
|
m_reRunButton->setAutoRaise(true);
|
||||||
m_reRunButton->setEnabled(false);
|
m_reRunButton->setEnabled(false);
|
||||||
connect(m_reRunButton, &QAbstractButton::clicked,
|
connect(m_reRunButton, &QToolButton::clicked,
|
||||||
this, &AppOutputPane::reRunRunControl);
|
this, &AppOutputPane::reRunRunControl);
|
||||||
|
|
||||||
// Stop
|
// Stop
|
||||||
@@ -183,7 +183,7 @@ AppOutputPane::AppOutputPane() :
|
|||||||
m_attachButton->setIcon(Icons::DEBUG_START_SMALL_TOOLBAR.icon());
|
m_attachButton->setIcon(Icons::DEBUG_START_SMALL_TOOLBAR.icon());
|
||||||
m_attachButton->setAutoRaise(true);
|
m_attachButton->setAutoRaise(true);
|
||||||
|
|
||||||
connect(m_attachButton, &QAbstractButton::clicked,
|
connect(m_attachButton, &QToolButton::clicked,
|
||||||
this, &AppOutputPane::attachToRunControl);
|
this, &AppOutputPane::attachToRunControl);
|
||||||
|
|
||||||
m_zoomInButton->setToolTip(tr("Increase Font Size"));
|
m_zoomInButton->setToolTip(tr("Increase Font Size"));
|
||||||
@@ -392,10 +392,11 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
|||||||
Utils::OutputFormatter *formatter = rc->outputFormatter();
|
Utils::OutputFormatter *formatter = rc->outputFormatter();
|
||||||
|
|
||||||
// First look if we can reuse a tab
|
// First look if we can reuse a tab
|
||||||
const int size = m_runControlTabs.size();
|
const int tabIndex = Utils::indexOf(m_runControlTabs, [rc](const RunControlTab &tab) {
|
||||||
for (int i = 0; i < size; i++) {
|
return rc->canReUseOutputPane(tab.runControl);
|
||||||
RunControlTab &tab =m_runControlTabs[i];
|
});
|
||||||
if (rc->canReUseOutputPane(tab.runControl)) {
|
if (tabIndex != -1) {
|
||||||
|
RunControlTab &tab = m_runControlTabs[tabIndex];
|
||||||
// Reuse this tab
|
// Reuse this tab
|
||||||
delete tab.runControl;
|
delete tab.runControl;
|
||||||
tab.runControl = rc;
|
tab.runControl = rc;
|
||||||
@@ -403,10 +404,9 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
|||||||
tab.window->scrollToBottom();
|
tab.window->scrollToBottom();
|
||||||
tab.window->setFormatter(formatter);
|
tab.window->setFormatter(formatter);
|
||||||
if (debug)
|
if (debug)
|
||||||
qDebug() << "OutputPane::createNewOutputWindow: Reusing tab" << i << " for " << rc;
|
qDebug() << "OutputPane::createNewOutputWindow: Reusing tab" << tabIndex << " for " << rc;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// Create new
|
// Create new
|
||||||
static uint counter = 0;
|
static uint counter = 0;
|
||||||
Core::Id contextId = Core::Id(Constants::C_APP_OUTPUT).withSuffix(counter++);
|
Core::Id contextId = Core::Id(Constants::C_APP_OUTPUT).withSuffix(counter++);
|
||||||
@@ -421,8 +421,7 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
|||||||
ow->setBaseFont(TextEditor::TextEditorSettings::fontSettings().font());
|
ow->setBaseFont(TextEditor::TextEditorSettings::fontSettings().font());
|
||||||
ow->setFontZoom(m_zoom);
|
ow->setFontZoom(m_zoom);
|
||||||
|
|
||||||
connect(ow, &Core::OutputWindow::wheelZoom,
|
connect(ow, &Core::OutputWindow::wheelZoom, this, [this, ow]() {
|
||||||
this, [this, ow]() {
|
|
||||||
m_zoom = ow->fontZoom();
|
m_zoom = ow->fontZoom();
|
||||||
foreach (const RunControlTab &tab, m_runControlTabs)
|
foreach (const RunControlTab &tab, m_runControlTabs)
|
||||||
tab.window->setFontZoom(m_zoom);
|
tab.window->setFontZoom(m_zoom);
|
||||||
@@ -448,9 +447,7 @@ void AppOutputPane::handleOldOutput(Core::OutputWindow *window) const
|
|||||||
|
|
||||||
void AppOutputPane::updateFromSettings()
|
void AppOutputPane::updateFromSettings()
|
||||||
{
|
{
|
||||||
const int size = m_runControlTabs.size();
|
foreach (const RunControlTab &tab, m_runControlTabs) {
|
||||||
for (int i = 0; i < size; i++) {
|
|
||||||
RunControlTab &tab =m_runControlTabs[i];
|
|
||||||
tab.window->setWordWrapEnabled(ProjectExplorerPlugin::projectExplorerSettings().wrapAppOutput);
|
tab.window->setWordWrapEnabled(ProjectExplorerPlugin::projectExplorerSettings().wrapAppOutput);
|
||||||
tab.window->setMaxLineCount(ProjectExplorerPlugin::projectExplorerSettings().maxAppOutputLines);
|
tab.window->setMaxLineCount(ProjectExplorerPlugin::projectExplorerSettings().maxAppOutputLines);
|
||||||
}
|
}
|
||||||
@@ -530,7 +527,7 @@ bool AppOutputPane::closeTabs(CloseTabMode mode)
|
|||||||
|
|
||||||
QList<RunControl *> AppOutputPane::allRunControls() const
|
QList<RunControl *> AppOutputPane::allRunControls() const
|
||||||
{
|
{
|
||||||
return Utils::transform(m_runControlTabs,[](const RunControlTab &tab) {
|
return Utils::transform<QList>(m_runControlTabs,[](const RunControlTab &tab) {
|
||||||
return tab.runControl;
|
return tab.runControl;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
#include <coreplugin/ioutputpane.h>
|
#include <coreplugin/ioutputpane.h>
|
||||||
|
|
||||||
#include <utils/outputformat.h>
|
#include <utils/outputformat.h>
|
||||||
@@ -45,6 +47,7 @@ class Project;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class TabWidget;
|
||||||
class AppOutputPane : public Core::IOutputPane
|
class AppOutputPane : public Core::IOutputPane
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -119,14 +122,15 @@ private:
|
|||||||
|
|
||||||
void enableButtons(const RunControl *rc, bool isRunning);
|
void enableButtons(const RunControl *rc, bool isRunning);
|
||||||
|
|
||||||
struct RunControlTab {
|
class RunControlTab {
|
||||||
|
public:
|
||||||
explicit RunControlTab(RunControl *runControl = nullptr,
|
explicit RunControlTab(RunControl *runControl = nullptr,
|
||||||
Core::OutputWindow *window = nullptr);
|
Core::OutputWindow *window = nullptr);
|
||||||
RunControl *runControl;
|
RunControl *runControl;
|
||||||
Core::OutputWindow *window;
|
Core::OutputWindow *window;
|
||||||
// Is the run control stopping asynchronously, close the tab once it finishes
|
// Is the run control stopping asynchronously, close the tab once it finishes
|
||||||
bool asyncClosing;
|
bool asyncClosing = false;
|
||||||
BehaviorOnOutput behaviorOnOutput;
|
BehaviorOnOutput behaviorOnOutput = Flash;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool isRunning() const;
|
bool isRunning() const;
|
||||||
@@ -145,8 +149,8 @@ private:
|
|||||||
void updateBehaviorSettings();
|
void updateBehaviorSettings();
|
||||||
|
|
||||||
QWidget *m_mainWidget;
|
QWidget *m_mainWidget;
|
||||||
class TabWidget *m_tabWidget;
|
TabWidget *m_tabWidget;
|
||||||
QList<RunControlTab> m_runControlTabs;
|
QVector<RunControlTab> m_runControlTabs;
|
||||||
QAction *m_stopAction;
|
QAction *m_stopAction;
|
||||||
QAction *m_closeCurrentTabAction;
|
QAction *m_closeCurrentTabAction;
|
||||||
QAction *m_closeAllTabsAction;
|
QAction *m_closeAllTabsAction;
|
||||||
|
|||||||
@@ -279,23 +279,11 @@ void OutputWindowPlainTextEdit::setFormat(enum VcsOutputWindow::MessageStyle sty
|
|||||||
class VcsOutputWindowPrivate
|
class VcsOutputWindowPrivate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Internal::OutputWindowPlainTextEdit *widget();
|
Internal::OutputWindowPlainTextEdit widget;
|
||||||
|
|
||||||
QPointer<Internal::OutputWindowPlainTextEdit> m_widget;
|
|
||||||
QString repository;
|
QString repository;
|
||||||
QRegExp passwordRegExp;
|
QRegExp passwordRegExp;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create log editor on demand. Some errors might be logged
|
|
||||||
// before CorePlugin::extensionsInitialized() pulls up the windows.
|
|
||||||
|
|
||||||
Internal::OutputWindowPlainTextEdit *VcsOutputWindowPrivate::widget()
|
|
||||||
{
|
|
||||||
if (!m_widget)
|
|
||||||
m_widget = new Internal::OutputWindowPlainTextEdit();
|
|
||||||
return m_widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
static VcsOutputWindow *m_instance = 0;
|
static VcsOutputWindow *m_instance = 0;
|
||||||
static VcsOutputWindowPrivate *d = 0;
|
static VcsOutputWindowPrivate *d = 0;
|
||||||
|
|
||||||
@@ -329,18 +317,14 @@ VcsOutputWindow::~VcsOutputWindow()
|
|||||||
|
|
||||||
QWidget *VcsOutputWindow::outputWidget(QWidget *parent)
|
QWidget *VcsOutputWindow::outputWidget(QWidget *parent)
|
||||||
{
|
{
|
||||||
if (d->m_widget) {
|
if (parent != d->widget.parent())
|
||||||
if (parent != d->m_widget->parent())
|
d->widget.setParent(parent);
|
||||||
d->m_widget->setParent(parent);
|
return &d->widget;
|
||||||
} else {
|
|
||||||
d->m_widget = new Internal::OutputWindowPlainTextEdit(parent);
|
|
||||||
}
|
|
||||||
return d->m_widget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidgetList VcsOutputWindow::toolBarWidgets() const
|
QList<QWidget *> VcsOutputWindow::toolBarWidgets() const
|
||||||
{
|
{
|
||||||
return QWidgetList();
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString VcsOutputWindow::displayName() const
|
QString VcsOutputWindow::displayName() const
|
||||||
@@ -355,14 +339,13 @@ int VcsOutputWindow::priorityInStatusBar() const
|
|||||||
|
|
||||||
void VcsOutputWindow::clearContents()
|
void VcsOutputWindow::clearContents()
|
||||||
{
|
{
|
||||||
if (d->m_widget)
|
d->widget.clear();
|
||||||
d->m_widget->clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsOutputWindow::visibilityChanged(bool visible)
|
void VcsOutputWindow::visibilityChanged(bool visible)
|
||||||
{
|
{
|
||||||
if (visible && d->m_widget)
|
if (visible)
|
||||||
d->m_widget->setFocus();
|
d->widget.setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsOutputWindow::setFocus()
|
void VcsOutputWindow::setFocus()
|
||||||
@@ -404,7 +387,7 @@ void VcsOutputWindow::goToPrev()
|
|||||||
|
|
||||||
void VcsOutputWindow::setText(const QString &text)
|
void VcsOutputWindow::setText(const QString &text)
|
||||||
{
|
{
|
||||||
d->widget()->setPlainText(text);
|
d->widget.setPlainText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
void VcsOutputWindow::setData(const QByteArray &data)
|
void VcsOutputWindow::setData(const QByteArray &data)
|
||||||
@@ -419,9 +402,9 @@ void VcsOutputWindow::appendSilently(const QString &text)
|
|||||||
|
|
||||||
void VcsOutputWindow::append(const QString &text, enum MessageStyle style, bool silently)
|
void VcsOutputWindow::append(const QString &text, enum MessageStyle style, bool silently)
|
||||||
{
|
{
|
||||||
d->widget()->appendLinesWithStyle(text, style, d->repository);
|
d->widget.appendLinesWithStyle(text, style, d->repository);
|
||||||
|
|
||||||
if (!silently && !d->widget()->isVisible())
|
if (!silently && !d->widget.isVisible())
|
||||||
m_instance->popup(Core::IOutputPane::NoModeSwitch);
|
m_instance->popup(Core::IOutputPane::NoModeSwitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user