forked from qt-creator/qt-creator
Re-use output window implementation for general messages.
Moving the implementation to core plugin.
This commit is contained in:
@@ -101,6 +101,7 @@ const char * const C_DESIGN_MODE = "Core.DesignMode";
|
|||||||
const char * const C_EDITORMANAGER = "Core.EditorManager";
|
const char * const C_EDITORMANAGER = "Core.EditorManager";
|
||||||
const char * const C_NAVIGATION_PANE = "Core.NavigationPane";
|
const char * const C_NAVIGATION_PANE = "Core.NavigationPane";
|
||||||
const char * const C_PROBLEM_PANE = "Core.ProblemPane";
|
const char * const C_PROBLEM_PANE = "Core.ProblemPane";
|
||||||
|
const char * const C_GENERAL_OUTPUT_PANE = "Core.GeneralOutputPane";
|
||||||
|
|
||||||
//default editor kind
|
//default editor kind
|
||||||
const char * const K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME = QT_TRANSLATE_NOOP("OpenWith::Editors", "Plain Text Editor");
|
const char * const K_DEFAULT_TEXT_EDITOR_DISPLAY_NAME = QT_TRANSLATE_NOOP("OpenWith::Editors", "Plain Text Editor");
|
||||||
|
@@ -27,6 +27,7 @@ SOURCES += mainwindow.cpp \
|
|||||||
messagemanager.cpp \
|
messagemanager.cpp \
|
||||||
messageoutputwindow.cpp \
|
messageoutputwindow.cpp \
|
||||||
outputpane.cpp \
|
outputpane.cpp \
|
||||||
|
outputwindow.cpp \
|
||||||
vcsmanager.cpp \
|
vcsmanager.cpp \
|
||||||
statusbarmanager.cpp \
|
statusbarmanager.cpp \
|
||||||
versiondialog.cpp \
|
versiondialog.cpp \
|
||||||
@@ -104,6 +105,7 @@ HEADERS += mainwindow.h \
|
|||||||
messagemanager.h \
|
messagemanager.h \
|
||||||
messageoutputwindow.h \
|
messageoutputwindow.h \
|
||||||
outputpane.h \
|
outputpane.h \
|
||||||
|
outputwindow.h \
|
||||||
vcsmanager.h \
|
vcsmanager.h \
|
||||||
statusbarmanager.h \
|
statusbarmanager.h \
|
||||||
editormanager/editormanager.h \
|
editormanager/editormanager.h \
|
||||||
|
@@ -31,6 +31,8 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "messageoutputwindow.h"
|
#include "messageoutputwindow.h"
|
||||||
|
#include "icontext.h"
|
||||||
|
#include "coreconstants.h"
|
||||||
|
|
||||||
#include <QtGui/QScrollBar>
|
#include <QtGui/QScrollBar>
|
||||||
|
|
||||||
@@ -38,9 +40,8 @@ using namespace Core::Internal;
|
|||||||
|
|
||||||
MessageOutputWindow::MessageOutputWindow()
|
MessageOutputWindow::MessageOutputWindow()
|
||||||
{
|
{
|
||||||
m_widget = new TextView;
|
m_widget = new Core::OutputWindow(Core::Context(Core::Constants::C_GENERAL_OUTPUT_PANE));
|
||||||
m_widget->setReadOnly(true);
|
m_widget->setReadOnly(true);
|
||||||
m_widget->setFrameStyle(QFrame::NoFrame);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MessageOutputWindow::~MessageOutputWindow()
|
MessageOutputWindow::~MessageOutputWindow()
|
||||||
@@ -85,10 +86,7 @@ void MessageOutputWindow::visibilityChanged(bool /*b*/)
|
|||||||
|
|
||||||
void MessageOutputWindow::append(const QString &text)
|
void MessageOutputWindow::append(const QString &text)
|
||||||
{
|
{
|
||||||
bool scroll = m_widget->isScrollbarAtBottom() || !m_widget->isVisible();
|
m_widget->appendText(text);
|
||||||
m_widget->append(text);
|
|
||||||
if (scroll)
|
|
||||||
m_widget->scrollToBottom();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int MessageOutputWindow::priorityInStatusBar() const
|
int MessageOutputWindow::priorityInStatusBar() const
|
||||||
@@ -120,34 +118,3 @@ bool MessageOutputWindow::canNavigate()
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------- Copied from OutputWindow which should be shared instead
|
|
||||||
|
|
||||||
bool TextView::isScrollbarAtBottom() const
|
|
||||||
{
|
|
||||||
return verticalScrollBar()->value() == verticalScrollBar()->maximum();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextView::scrollToBottom()
|
|
||||||
{
|
|
||||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextView::showEvent(QShowEvent *e)
|
|
||||||
{
|
|
||||||
bool atBottom = isScrollbarAtBottom();
|
|
||||||
QTextEdit::showEvent(e);
|
|
||||||
if (atBottom)
|
|
||||||
scrollToBottom();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextView::resizeEvent(QResizeEvent *e)
|
|
||||||
{
|
|
||||||
//Keep scrollbar at bottom of window while resizing, to ensure we keep scrolling
|
|
||||||
//This can happen if window is resized while building, or if the horizontal scrollbar appears
|
|
||||||
bool atBottom = isScrollbarAtBottom();
|
|
||||||
QTextEdit::resizeEvent(e);
|
|
||||||
if (atBottom)
|
|
||||||
scrollToBottom();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -33,7 +33,8 @@
|
|||||||
#ifndef MESSAGEOUTPUTWINDOW_H
|
#ifndef MESSAGEOUTPUTWINDOW_H
|
||||||
#define MESSAGEOUTPUTWINDOW_H
|
#define MESSAGEOUTPUTWINDOW_H
|
||||||
|
|
||||||
#include <coreplugin/ioutputpane.h>
|
#include "ioutputpane.h"
|
||||||
|
#include "outputwindow.h"
|
||||||
|
|
||||||
#include <QtGui/QShowEvent>
|
#include <QtGui/QShowEvent>
|
||||||
#include <QtGui/QResizeEvent>
|
#include <QtGui/QResizeEvent>
|
||||||
@@ -42,21 +43,6 @@
|
|||||||
namespace Core {
|
namespace Core {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class TextView : public QTextEdit
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
TextView(QWidget *parent = 0) : QTextEdit(parent) {}
|
|
||||||
|
|
||||||
void showEvent(QShowEvent *);
|
|
||||||
void scrollToBottom();
|
|
||||||
bool isScrollbarAtBottom() const;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void resizeEvent(QResizeEvent *e);
|
|
||||||
};
|
|
||||||
|
|
||||||
class MessageOutputWindow : public Core::IOutputPane
|
class MessageOutputWindow : public Core::IOutputPane
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -85,7 +71,7 @@ public:
|
|||||||
bool canNavigate();
|
bool canNavigate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TextView *m_widget;
|
OutputWindow *m_widget;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
@@ -32,10 +32,10 @@
|
|||||||
|
|
||||||
#include "outputwindow.h"
|
#include "outputwindow.h"
|
||||||
|
|
||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include "actionmanager/actionmanager.h"
|
||||||
#include <coreplugin/actionmanager/command.h>
|
#include "actionmanager/command.h"
|
||||||
#include <coreplugin/coreconstants.h>
|
#include "coreconstants.h"
|
||||||
#include <coreplugin/icore.h>
|
#include "icore.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/outputformatter.h>
|
#include <utils/outputformatter.h>
|
||||||
@@ -47,8 +47,7 @@ static const int MaxBlockCount = 100000;
|
|||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace Core {
|
||||||
namespace Internal {
|
|
||||||
|
|
||||||
/*******************/
|
/*******************/
|
||||||
|
|
||||||
@@ -259,7 +258,7 @@ void OutputWindow::appendText(const QString &textIn, const QTextCharFormat &form
|
|||||||
{
|
{
|
||||||
QString text = textIn;
|
QString text = textIn;
|
||||||
text.remove(QLatin1Char('\r'));
|
text.remove(QLatin1Char('\r'));
|
||||||
if (document()->blockCount() > maxLineCount)
|
if (maxLineCount > 0 && document()->blockCount() > maxLineCount)
|
||||||
return;
|
return;
|
||||||
const bool atBottom = isScrollbarAtBottom();
|
const bool atBottom = isScrollbarAtBottom();
|
||||||
QTextCursor cursor = QTextCursor(document());
|
QTextCursor cursor = QTextCursor(document());
|
||||||
@@ -267,7 +266,7 @@ void OutputWindow::appendText(const QString &textIn, const QTextCharFormat &form
|
|||||||
cursor.beginEditBlock();
|
cursor.beginEditBlock();
|
||||||
cursor.insertText(doNewlineEnfocement(text), format);
|
cursor.insertText(doNewlineEnfocement(text), format);
|
||||||
|
|
||||||
if (document()->blockCount() > maxLineCount) {
|
if (maxLineCount > 0 && document()->blockCount() > maxLineCount) {
|
||||||
QTextCharFormat tmp;
|
QTextCharFormat tmp;
|
||||||
tmp.setFontWeight(QFont::Bold);
|
tmp.setFontWeight(QFont::Bold);
|
||||||
cursor.insertText(tr("Additional output omitted\n"), tmp);
|
cursor.insertText(tr("Additional output omitted\n"), tmp);
|
||||||
@@ -292,6 +291,10 @@ void OutputWindow::clear()
|
|||||||
void OutputWindow::scrollToBottom()
|
void OutputWindow::scrollToBottom()
|
||||||
{
|
{
|
||||||
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||||
|
// QPlainTextEdit destroys the first calls value in case of multiline
|
||||||
|
// text, so make sure that the scroll bar actually gets the value set.
|
||||||
|
// Is a noop if the first call succeeded.
|
||||||
|
verticalScrollBar()->setValue(verticalScrollBar()->maximum());
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutputWindow::grayOutOldContent()
|
void OutputWindow::grayOutOldContent()
|
||||||
@@ -331,5 +334,4 @@ void OutputWindow::setWordWrapEnabled(bool wrap)
|
|||||||
setWordWrapMode(QTextOption::NoWrap);
|
setWordWrapMode(QTextOption::NoWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Core
|
||||||
} // namespace ProjectExplorer
|
|
||||||
|
@@ -33,20 +33,18 @@
|
|||||||
#ifndef OUTPUTWINDOW_H
|
#ifndef OUTPUTWINDOW_H
|
||||||
#define OUTPUTWINDOW_H
|
#define OUTPUTWINDOW_H
|
||||||
|
|
||||||
|
#include "core_global.h"
|
||||||
|
#include "icontext.h"
|
||||||
|
|
||||||
#include <utils/outputformatter.h>
|
#include <utils/outputformatter.h>
|
||||||
#include <coreplugin/icontext.h>
|
|
||||||
|
|
||||||
#include <QtGui/QPlainTextEdit>
|
#include <QtGui/QPlainTextEdit>
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class IContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
class IContext;
|
||||||
|
|
||||||
namespace Internal {
|
class CORE_EXPORT OutputWindow : public QPlainTextEdit
|
||||||
|
|
||||||
class OutputWindow : public QPlainTextEdit
|
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -59,7 +57,7 @@ public:
|
|||||||
|
|
||||||
void appendMessage(const QString &out, Utils::OutputFormat format);
|
void appendMessage(const QString &out, Utils::OutputFormat format);
|
||||||
/// appends a \p text using \p format without using formater
|
/// appends a \p text using \p format without using formater
|
||||||
void appendText(const QString &text, const QTextCharFormat &format, int maxLineCount);
|
void appendText(const QString &text, const QTextCharFormat &format = QTextCharFormat(), int maxLineCount = -1);
|
||||||
|
|
||||||
void grayOutOldContent();
|
void grayOutOldContent();
|
||||||
void clear();
|
void clear();
|
||||||
@@ -93,7 +91,6 @@ private:
|
|||||||
bool m_mousePressed;
|
bool m_mousePressed;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Core
|
||||||
} // namespace ProjectExplorer
|
|
||||||
|
|
||||||
#endif // OUTPUTWINDOW_H
|
#endif // OUTPUTWINDOW_H
|
||||||
|
@@ -32,7 +32,6 @@
|
|||||||
**************************************************************************/
|
**************************************************************************/
|
||||||
|
|
||||||
#include "appoutputpane.h"
|
#include "appoutputpane.h"
|
||||||
#include "outputwindow.h"
|
|
||||||
#include "projectexplorerconstants.h"
|
#include "projectexplorerconstants.h"
|
||||||
#include "projectexplorer.h"
|
#include "projectexplorer.h"
|
||||||
#include "projectexplorersettings.h"
|
#include "projectexplorersettings.h"
|
||||||
@@ -65,7 +64,7 @@ enum { debug = 0 };
|
|||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace ProjectExplorer::Internal;
|
using namespace ProjectExplorer::Internal;
|
||||||
|
|
||||||
AppOutputPane::RunControlTab::RunControlTab(RunControl *rc, OutputWindow *w) :
|
AppOutputPane::RunControlTab::RunControlTab(RunControl *rc, Core::OutputWindow *w) :
|
||||||
runControl(rc), window(w), asyncClosing(false)
|
runControl(rc), window(w), asyncClosing(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -203,7 +202,7 @@ int AppOutputPane::priorityInStatusBar() const
|
|||||||
|
|
||||||
void AppOutputPane::clearContents()
|
void AppOutputPane::clearContents()
|
||||||
{
|
{
|
||||||
OutputWindow *currentWindow = qobject_cast<OutputWindow *>(m_tabWidget->currentWidget());
|
Core::OutputWindow *currentWindow = qobject_cast<Core::OutputWindow *>(m_tabWidget->currentWidget());
|
||||||
if (currentWindow)
|
if (currentWindow)
|
||||||
currentWindow->clear();
|
currentWindow->clear();
|
||||||
}
|
}
|
||||||
@@ -259,7 +258,7 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
|||||||
// Create new
|
// Create new
|
||||||
static uint counter = 0;
|
static uint counter = 0;
|
||||||
Core::Context context(Constants::C_APP_OUTPUT, counter++);
|
Core::Context context(Constants::C_APP_OUTPUT, counter++);
|
||||||
OutputWindow *ow = new OutputWindow(context, m_tabWidget);
|
Core::OutputWindow *ow = new Core::OutputWindow(context, m_tabWidget);
|
||||||
ow->setWindowTitle(tr("Application Output Window"));
|
ow->setWindowTitle(tr("Application Output Window"));
|
||||||
// TODO the following is a hidden impossible dependency of projectexplorer on qt4projectmanager
|
// TODO the following is a hidden impossible dependency of projectexplorer on qt4projectmanager
|
||||||
ow->setWindowIcon(QIcon(QLatin1String(Qt4ProjectManager::Constants::ICON_WINDOW)));
|
ow->setWindowIcon(QIcon(QLatin1String(Qt4ProjectManager::Constants::ICON_WINDOW)));
|
||||||
@@ -274,7 +273,7 @@ void AppOutputPane::createNewOutputWindow(RunControl *rc)
|
|||||||
qDebug() << "OutputPane::createNewOutputWindow: Adding tab for " << rc;
|
qDebug() << "OutputPane::createNewOutputWindow: Adding tab for " << rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AppOutputPane::handleOldOutput(OutputWindow *window) const
|
void AppOutputPane::handleOldOutput(Core::OutputWindow *window) const
|
||||||
{
|
{
|
||||||
if (ProjectExplorerPlugin::instance()->projectExplorerSettings().cleanOldAppOutput)
|
if (ProjectExplorerPlugin::instance()->projectExplorerSettings().cleanOldAppOutput)
|
||||||
window->clear();
|
window->clear();
|
||||||
|
@@ -34,8 +34,7 @@
|
|||||||
#ifndef APPOUTPUTPANE_H
|
#ifndef APPOUTPUTPANE_H
|
||||||
#define APPOUTPUTPANE_H
|
#define APPOUTPUTPANE_H
|
||||||
|
|
||||||
#include "outputwindow.h"
|
#include <coreplugin/outputwindow.h>
|
||||||
|
|
||||||
#include <coreplugin/ioutputpane.h>
|
#include <coreplugin/ioutputpane.h>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@@ -110,9 +109,9 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
struct RunControlTab {
|
struct RunControlTab {
|
||||||
explicit RunControlTab(RunControl *runControl = 0,
|
explicit RunControlTab(RunControl *runControl = 0,
|
||||||
OutputWindow *window = 0);
|
Core::OutputWindow *window = 0);
|
||||||
RunControl* runControl;
|
RunControl* runControl;
|
||||||
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;
|
||||||
};
|
};
|
||||||
@@ -126,7 +125,7 @@ private:
|
|||||||
int currentIndex() const;
|
int currentIndex() const;
|
||||||
RunControl *currentRunControl() const;
|
RunControl *currentRunControl() const;
|
||||||
int tabWidgetIndexOf(int runControlIndex) const;
|
int tabWidgetIndexOf(int runControlIndex) const;
|
||||||
void handleOldOutput(OutputWindow *window) const;
|
void handleOldOutput(Core::OutputWindow *window) const;
|
||||||
|
|
||||||
QWidget *m_mainWidget;
|
QWidget *m_mainWidget;
|
||||||
QTabWidget *m_tabWidget;
|
QTabWidget *m_tabWidget;
|
||||||
|
@@ -63,7 +63,7 @@ const int MAX_LINECOUNT = 50000;
|
|||||||
CompileOutputWindow::CompileOutputWindow(BuildManager * /*bm*/)
|
CompileOutputWindow::CompileOutputWindow(BuildManager * /*bm*/)
|
||||||
{
|
{
|
||||||
Core::Context context(Constants::C_COMPILE_OUTPUT);
|
Core::Context context(Constants::C_COMPILE_OUTPUT);
|
||||||
m_outputWindow = new OutputWindow(context);
|
m_outputWindow = new Core::OutputWindow(context);
|
||||||
m_outputWindow->setWindowTitle(tr("Compile Output"));
|
m_outputWindow->setWindowTitle(tr("Compile Output"));
|
||||||
m_outputWindow->setWindowIcon(QIcon(QLatin1String(Qt4ProjectManager::Constants::ICON_WINDOW)));
|
m_outputWindow->setWindowIcon(QIcon(QLatin1String(Qt4ProjectManager::Constants::ICON_WINDOW)));
|
||||||
m_outputWindow->setReadOnly(true);
|
m_outputWindow->setReadOnly(true);
|
||||||
|
@@ -33,8 +33,8 @@
|
|||||||
#ifndef COMPILEOUTPUTWINDOW_H
|
#ifndef COMPILEOUTPUTWINDOW_H
|
||||||
#define COMPILEOUTPUTWINDOW_H
|
#define COMPILEOUTPUTWINDOW_H
|
||||||
|
|
||||||
#include "outputwindow.h"
|
|
||||||
#include "buildstep.h"
|
#include "buildstep.h"
|
||||||
|
#include <coreplugin/outputwindow.h>
|
||||||
#include <coreplugin/ioutputpane.h>
|
#include <coreplugin/ioutputpane.h>
|
||||||
|
|
||||||
#include <QtCore/QHash>
|
#include <QtCore/QHash>
|
||||||
@@ -86,7 +86,7 @@ private slots:
|
|||||||
void updateWordWrapMode();
|
void updateWordWrapMode();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OutputWindow *m_outputWindow;
|
Core::OutputWindow *m_outputWindow;
|
||||||
QHash<unsigned int, int> m_taskPositions;
|
QHash<unsigned int, int> m_taskPositions;
|
||||||
ShowOutputTaskHandler * m_handler;
|
ShowOutputTaskHandler * m_handler;
|
||||||
};
|
};
|
||||||
|
@@ -58,7 +58,6 @@
|
|||||||
#include "iprojectmanager.h"
|
#include "iprojectmanager.h"
|
||||||
#include "metatypedeclarations.h"
|
#include "metatypedeclarations.h"
|
||||||
#include "nodesvisitor.h"
|
#include "nodesvisitor.h"
|
||||||
#include "outputwindow.h"
|
|
||||||
#include "appoutputpane.h"
|
#include "appoutputpane.h"
|
||||||
#include "persistentsettings.h"
|
#include "persistentsettings.h"
|
||||||
#include "pluginfilefactory.h"
|
#include "pluginfilefactory.h"
|
||||||
|
@@ -28,7 +28,6 @@ HEADERS += projectexplorer.h \
|
|||||||
showoutputtaskhandler.h \
|
showoutputtaskhandler.h \
|
||||||
vcsannotatetaskhandler.h \
|
vcsannotatetaskhandler.h \
|
||||||
taskwindow.h \
|
taskwindow.h \
|
||||||
outputwindow.h \
|
|
||||||
persistentsettings.h \
|
persistentsettings.h \
|
||||||
projectfilewizardextension.h \
|
projectfilewizardextension.h \
|
||||||
session.h \
|
session.h \
|
||||||
@@ -125,7 +124,6 @@ SOURCES += projectexplorer.cpp \
|
|||||||
showoutputtaskhandler.cpp \
|
showoutputtaskhandler.cpp \
|
||||||
vcsannotatetaskhandler.cpp \
|
vcsannotatetaskhandler.cpp \
|
||||||
taskwindow.cpp \
|
taskwindow.cpp \
|
||||||
outputwindow.cpp \
|
|
||||||
persistentsettings.cpp \
|
persistentsettings.cpp \
|
||||||
projectfilewizardextension.cpp \
|
projectfilewizardextension.cpp \
|
||||||
session.cpp \
|
session.cpp \
|
||||||
|
Reference in New Issue
Block a user