From 167ef57a636052f8e18a206e84c3447552e84d2b Mon Sep 17 00:00:00 2001 From: Marcus Eggenberger Date: Sat, 1 Nov 2008 18:12:12 +0100 Subject: [PATCH 1/1] better handling of log messages (internal stuff only) --- src/client/client.cpp | 5 +++-- src/client/client.h | 2 +- src/qtui/debuglogwidget.cpp | 10 ++++++---- src/qtui/debuglogwidget.h | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/client/client.cpp b/src/client/client.cpp index f981040e..ca008e90 100644 --- a/src/client/client.cpp +++ b/src/client/client.cpp @@ -421,7 +421,8 @@ void Client::logMessage(QtMsgType type, const char *msg) { Quassel::logFatalMessage(msg); return; } - instance()->_debugLog << prefix << ": " << msg << "\n"; - emit instance()->logUpdated(); + QString msgString = QString("%1: %3\n").arg(prefix, msg); + instance()->_debugLog << msgString; + emit instance()->logUpdated(msgString); } diff --git a/src/client/client.h b/src/client/client.h index 52133b68..9f881d11 100644 --- a/src/client/client.h +++ b/src/client/client.h @@ -152,7 +152,7 @@ signals: void newClientSyncer(ClientSyncer *); - void logUpdated(); + void logUpdated(const QString &msg); public slots: //void selectBuffer(Buffer *); diff --git a/src/qtui/debuglogwidget.cpp b/src/qtui/debuglogwidget.cpp index 15b1c5c3..a4c6db06 100644 --- a/src/qtui/debuglogwidget.cpp +++ b/src/qtui/debuglogwidget.cpp @@ -27,12 +27,14 @@ DebugLogWidget::DebugLogWidget(QWidget *parent) { ui.setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); - logUpdated(); - connect(Client::instance(), SIGNAL(logUpdated()), this, SLOT(logUpdated())); + ui.textEdit->setPlainText(Client::debugLog()); + connect(Client::instance(), SIGNAL(logUpdated(const QString &)), this, SLOT(logUpdated(const QString &))); ui.textEdit->setReadOnly(true); } -void DebugLogWidget::logUpdated() { - ui.textEdit->setPlainText(Client::debugLog()); +void DebugLogWidget::logUpdated(const QString &msg) { + ui.textEdit->moveCursor(QTextCursor::End); + ui.textEdit->insertPlainText(msg); + ui.textEdit->moveCursor(QTextCursor::End); } diff --git a/src/qtui/debuglogwidget.h b/src/qtui/debuglogwidget.h index 476a80af..fb1c4829 100644 --- a/src/qtui/debuglogwidget.h +++ b/src/qtui/debuglogwidget.h @@ -30,7 +30,7 @@ public: DebugLogWidget(QWidget *parent = 0); private slots: - void logUpdated(); + void logUpdated(const QString &msg); private: Ui::DebugLogWidget ui; -- 2.20.1