summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Swift/QtUI/QtXMLConsoleWidget.cpp27
-rw-r--r--Swift/QtUI/QtXMLConsoleWidget.h4
2 files changed, 21 insertions, 10 deletions
diff --git a/Swift/QtUI/QtXMLConsoleWidget.cpp b/Swift/QtUI/QtXMLConsoleWidget.cpp
index 662f070..3968cfd 100644
--- a/Swift/QtUI/QtXMLConsoleWidget.cpp
+++ b/Swift/QtUI/QtXMLConsoleWidget.cpp
@@ -5,6 +5,7 @@
#include <QVBoxLayout>
#include <QPushButton>
#include <QScrollBar>
+#include <QCheckBox>
#include "QtSwiftUtil.h"
#include "Swiften/Base/String.h"
@@ -26,9 +27,15 @@ QtXMLConsoleWidget::QtXMLConsoleWidget() {
layout->addWidget(bottom);
QHBoxLayout* buttonLayout = new QHBoxLayout(bottom);
- buttonLayout->setContentsMargins(0,0,20,0);
+ buttonLayout->setContentsMargins(10,0,20,0);
buttonLayout->setSpacing(0);
+
+ enabled = new QCheckBox("Trace input/output", bottom);
+ enabled->setChecked(true);
+ buttonLayout->addWidget(enabled);
+
buttonLayout->addStretch();
+
QPushButton* clearButton = new QPushButton("Clear", bottom);
connect(clearButton, SIGNAL(clicked()), textEdit, SLOT(clear()));
buttonLayout->addWidget(clearButton);
@@ -55,20 +62,22 @@ void QtXMLConsoleWidget::closeEvent(QCloseEvent* event) {
void QtXMLConsoleWidget::handleDataRead(const String& data) {
textEdit->setTextColor(QColor(33,98,33));
- appendText(data);
+ appendTextIfEnabled(data);
}
void QtXMLConsoleWidget::handleDataWritten(const String& data) {
textEdit->setTextColor(QColor(155,1,0));
- appendText(data);
+ appendTextIfEnabled(data);
}
-void QtXMLConsoleWidget::appendText(const String& data) {
- QScrollBar* scrollBar = textEdit->verticalScrollBar();
- bool scrollToBottom = (!scrollBar || scrollBar->value() == scrollBar->maximum());
- textEdit->append(P2QSTRING(data));
- if (scrollToBottom) {
- textEdit->ensureCursorVisible();
+void QtXMLConsoleWidget::appendTextIfEnabled(const String& data) {
+ if (enabled->isChecked()) {
+ QScrollBar* scrollBar = textEdit->verticalScrollBar();
+ bool scrollToBottom = (!scrollBar || scrollBar->value() == scrollBar->maximum());
+ textEdit->append(P2QSTRING(data));
+ if (scrollToBottom) {
+ textEdit->ensureCursorVisible();
+ }
}
}
diff --git a/Swift/QtUI/QtXMLConsoleWidget.h b/Swift/QtUI/QtXMLConsoleWidget.h
index 0d5a10d..0a10762 100644
--- a/Swift/QtUI/QtXMLConsoleWidget.h
+++ b/Swift/QtUI/QtXMLConsoleWidget.h
@@ -4,6 +4,7 @@
#include "QtTabbable.h"
class QTextEdit;
+class QCheckBox;
namespace Swift {
class QtXMLConsoleWidget : public QtTabbable, public XMLConsoleWidget {
@@ -22,9 +23,10 @@ namespace Swift {
virtual void closeEvent(QCloseEvent* event);
virtual void showEvent(QShowEvent* event);
- void appendText(const String& data);
+ void appendTextIfEnabled(const String& data);
private:
QTextEdit* textEdit;
+ QCheckBox* enabled;
};
}