mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 20:44:38 +03:00
limit log rate in UI
This commit is contained in:
@@ -36,7 +36,6 @@
|
||||
#include <QLabel>
|
||||
#include <QTextBlock>
|
||||
#include <QScrollBar>
|
||||
#include <QMutex>
|
||||
#include <QScreen>
|
||||
#include <QDesktopServices>
|
||||
#include <QInputDialog>
|
||||
@@ -48,6 +47,7 @@
|
||||
#include <QElapsedTimer>
|
||||
|
||||
QElapsedTimer coreRestartTimer;
|
||||
QAtomicInt logCounter;
|
||||
|
||||
void UI_InitMainWindow() {
|
||||
mainwindow = new MainWindow;
|
||||
@@ -150,6 +150,11 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
MW_show_log_ext_vt100 = [=](const QString &log) {
|
||||
runOnUiThread([=] { show_log_impl(cleanVT100String(log)); });
|
||||
};
|
||||
//
|
||||
auto logCounterTimer = new QTimer(this);
|
||||
connect(logCounterTimer, &QTimer::timeout, this, [&] { logCounter.fetchAndStoreRelaxed(0); });
|
||||
logCounterTimer->setInterval(1000);
|
||||
logCounterTimer->start();
|
||||
|
||||
// table UI
|
||||
ui->proxyListTable->callback_save_order = [=] {
|
||||
@@ -672,10 +677,7 @@ void MainWindow::on_menu_exit_triggered() {
|
||||
QDir::setCurrent(QApplication::applicationDirPath());
|
||||
|
||||
auto arguments = NekoRay::dataStore->argv;
|
||||
if (arguments.length() > 0) {
|
||||
arguments.removeFirst();
|
||||
arguments.removeAll("-tray");
|
||||
}
|
||||
if (arguments.length() > 0) arguments.removeFirst();
|
||||
auto isLauncher = qEnvironmentVariable("NKR_FROM_LAUNCHER") == "1";
|
||||
if (isLauncher) arguments.prepend("--");
|
||||
auto program = isLauncher ? "./launcher" : QApplication::applicationFilePath();
|
||||
@@ -1491,6 +1493,7 @@ void MainWindow::show_log_impl(const QString &log) {
|
||||
if (showThisLine) newLines << line;
|
||||
}
|
||||
if (newLines.isEmpty()) return;
|
||||
if (logCounter.fetchAndAddRelaxed(newLines.count()) > NekoRay::dataStore->max_log_line) return;
|
||||
|
||||
FastAppendTextDocument(newLines.join("\n"), qvLogDocument);
|
||||
// qvLogDocument->setPlainText(qvLogDocument->toPlainText() + log);
|
||||
|
||||
Reference in New Issue
Block a user