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