diff options
author | Remko Tronçon <git@el-tramo.be> | 2009-11-28 20:29:13 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2009-11-28 20:29:13 (GMT) |
commit | ed9a0f344ba78525254cacfb0f446a666b385a40 (patch) | |
tree | 9263463d2c76835ff68b136ff4080490f78f7e66 /Swift | |
parent | 5c2567847c73f6095206dfbd451fe2f26f4056aa (diff) | |
download | swift-ed9a0f344ba78525254cacfb0f446a666b385a40.zip swift-ed9a0f344ba78525254cacfb0f446a666b385a40.tar.bz2 |
Add checkbox for tracing input/output in debug console.
Diffstat (limited to 'Swift')
-rw-r--r-- | Swift/QtUI/QtXMLConsoleWidget.cpp | 27 | ||||
-rw-r--r-- | Swift/QtUI/QtXMLConsoleWidget.h | 4 |
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; }; } |