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:
@@ -31,6 +31,8 @@
|
||||
**************************************************************************/
|
||||
|
||||
#include "messageoutputwindow.h"
|
||||
#include "icontext.h"
|
||||
#include "coreconstants.h"
|
||||
|
||||
#include <QtGui/QScrollBar>
|
||||
|
||||
@@ -38,9 +40,8 @@ using namespace Core::Internal;
|
||||
|
||||
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->setFrameStyle(QFrame::NoFrame);
|
||||
}
|
||||
|
||||
MessageOutputWindow::~MessageOutputWindow()
|
||||
@@ -85,10 +86,7 @@ void MessageOutputWindow::visibilityChanged(bool /*b*/)
|
||||
|
||||
void MessageOutputWindow::append(const QString &text)
|
||||
{
|
||||
bool scroll = m_widget->isScrollbarAtBottom() || !m_widget->isVisible();
|
||||
m_widget->append(text);
|
||||
if (scroll)
|
||||
m_widget->scrollToBottom();
|
||||
m_widget->appendText(text);
|
||||
}
|
||||
|
||||
int MessageOutputWindow::priorityInStatusBar() const
|
||||
@@ -120,34 +118,3 @@ bool MessageOutputWindow::canNavigate()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user