GUI: better flush log behavior
This commit is contained in:
parent
52b75cdd8b
commit
37de75450c
|
@ -31,7 +31,7 @@ LogView::LogView(QWidget* parent) : QTextBrowser(parent), logRedirection(NULL)
|
|||
connect(Bridge::getBridge(), SIGNAL(addMsgToLog(QByteArray)), this, SLOT(addMsgToLogSlot(QByteArray)));
|
||||
connect(Bridge::getBridge(), SIGNAL(clearLog()), this, SLOT(clearLogSlot()));
|
||||
connect(Bridge::getBridge(), SIGNAL(setLogEnabled(bool)), this, SLOT(setLoggingEnabled(bool)));
|
||||
connect(Bridge::getBridge(), SIGNAL(flushLog()), this, SLOT(flushTimerSlot()));
|
||||
connect(Bridge::getBridge(), SIGNAL(flushLog()), this, SLOT(flushLogSlot()));
|
||||
connect(this, SIGNAL(anchorClicked(QUrl)), this, SLOT(onAnchorClicked(QUrl)));
|
||||
|
||||
duint setting;
|
||||
|
@ -267,6 +267,11 @@ void LogView::addMsgToLogSlot(QByteArray msg)
|
|||
if(logBuffer.length() >= 10000 * 10) //limit the log buffer to ~10mb
|
||||
logBuffer.clear();
|
||||
logBuffer.append(msgUtf16);
|
||||
if(flushLog)
|
||||
{
|
||||
flushTimerSlot();
|
||||
flushLog = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -440,3 +445,9 @@ void LogView::flushTimerSlot()
|
|||
setUpdatesEnabled(true);
|
||||
logBuffer.clear();
|
||||
}
|
||||
|
||||
void LogView::flushLogSlot()
|
||||
{
|
||||
flushLog = true;
|
||||
flushTimerSlot();
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ public slots:
|
|||
void saveSlot();
|
||||
void toggleLoggingSlot();
|
||||
void flushTimerSlot();
|
||||
void flushLogSlot();
|
||||
|
||||
private:
|
||||
bool loggingEnabled;
|
||||
|
@ -53,6 +54,7 @@ private:
|
|||
FILE* logRedirection;
|
||||
QString logBuffer;
|
||||
QTimer* flushTimer;
|
||||
bool flushLog;
|
||||
};
|
||||
|
||||
#endif // LOGVIEW_H
|
||||
|
|
Loading…
Reference in New Issue