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