1
0
Fork 0

GUI: better flush log behavior

This commit is contained in:
mrexodia 2017-03-19 10:37:35 +01:00
parent 52b75cdd8b
commit 37de75450c
No known key found for this signature in database
GPG Key ID: FC89E0AAA0C1AAD8
2 changed files with 14 additions and 1 deletions

View File

@ -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();
}

View File

@ -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