summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI')
-rw-r--r--Swift/QtUI/QtXMLConsoleWidget.cpp21
-rw-r--r--Swift/QtUI/QtXMLConsoleWidget.h3
2 files changed, 16 insertions, 8 deletions
diff --git a/Swift/QtUI/QtXMLConsoleWidget.cpp b/Swift/QtUI/QtXMLConsoleWidget.cpp
index 00f9d3b..1e7eff3 100644
--- a/Swift/QtUI/QtXMLConsoleWidget.cpp
+++ b/Swift/QtUI/QtXMLConsoleWidget.cpp
@@ -71,22 +71,29 @@ void QtXMLConsoleWidget::closeEvent(QCloseEvent* event) {
}
void QtXMLConsoleWidget::handleDataRead(const String& data) {
- textEdit->setTextColor(QColor(33,98,33));
- appendTextIfEnabled(data);
+ appendTextIfEnabled(data, QColor(33,98,33));
}
void QtXMLConsoleWidget::handleDataWritten(const String& data) {
- textEdit->setTextColor(QColor(155,1,0));
- appendTextIfEnabled(data);
+ appendTextIfEnabled(data, QColor(155,1,0));
}
-void QtXMLConsoleWidget::appendTextIfEnabled(const String& data) {
+void QtXMLConsoleWidget::appendTextIfEnabled(const String& data, const QColor& color) {
if (enabled->isChecked()) {
QScrollBar* scrollBar = textEdit->verticalScrollBar();
bool scrollToBottom = (!scrollBar || scrollBar->value() == scrollBar->maximum());
- textEdit->append(P2QSTRING(data));
+
+ QTextCursor cursor(textEdit->document());
+ cursor.beginEditBlock();
+ cursor.movePosition(QTextCursor::End);
+ QTextCharFormat format;
+ format.setForeground(QBrush(color));
+ cursor.mergeCharFormat(format);
+ cursor.insertText(P2QSTRING(data));
+ cursor.endEditBlock();
+
if (scrollToBottom) {
- textEdit->ensureCursorVisible();
+ scrollBar->setValue(scrollBar->maximum());
}
}
}
diff --git a/Swift/QtUI/QtXMLConsoleWidget.h b/Swift/QtUI/QtXMLConsoleWidget.h
index 28b15e8..1cfe54f 100644
--- a/Swift/QtUI/QtXMLConsoleWidget.h
+++ b/Swift/QtUI/QtXMLConsoleWidget.h
@@ -11,6 +11,7 @@
class QTextEdit;
class QCheckBox;
+class QColor;
namespace Swift {
class QtXMLConsoleWidget : public QtTabbable, public XMLConsoleWidget {
@@ -29,7 +30,7 @@ namespace Swift {
virtual void closeEvent(QCloseEvent* event);
virtual void showEvent(QShowEvent* event);
- void appendTextIfEnabled(const String& data);
+ void appendTextIfEnabled(const String& data, const QColor& color);
private:
QTextEdit* textEdit;