From e98acff889fe55fd23200e8880bfb46560154787 Mon Sep 17 00:00:00 2001 From: Nova Date: Sun, 6 Jul 2025 23:44:18 +0330 Subject: [PATCH] improve log performance and remove useless functions --- src/global/NekoGui.cpp | 1 - src/ui/mainwindow.cpp | 54 +++--------------------------------------- 2 files changed, 3 insertions(+), 52 deletions(-) diff --git a/src/global/NekoGui.cpp b/src/global/NekoGui.cpp index 65e8777..81ef61e 100644 --- a/src/global/NekoGui.cpp +++ b/src/global/NekoGui.cpp @@ -277,7 +277,6 @@ namespace NekoGui { _add(new configItem("sub_clear", &sub_clear, itemType::boolean)); _add(new configItem("sub_insecure", &sub_insecure, itemType::boolean)); _add(new configItem("sub_auto_update", &sub_auto_update, itemType::integer)); - _add(new configItem("log_ignore", &log_ignore, itemType::stringList)); _add(new configItem("start_minimal", &start_minimal, itemType::boolean)); _add(new configItem("max_log_line", &max_log_line, itemType::integer)); _add(new configItem("splitter_state", &splitter_state, itemType::string)); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 3f46819..681dd64 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -1955,24 +1955,10 @@ void MainWindow::show_log_impl(const QString &log) { show_log_impl("Ignored massive log of size:" + Int2String(log.size())); return; } - auto lines = SplitLines(log.trimmed()); - if (lines.isEmpty()) return; + auto trimmed = log.trimmed(); + if (trimmed.isEmpty()) return; - QStringList newLines; - auto log_ignore = NekoGui::dataStore->log_ignore; - for (const auto &line: lines) { - bool showThisLine = true; - for (const auto &str: log_ignore) { - if (line.contains(str)) { - showThisLine = false; - break; - } - } - if (showThisLine) newLines << line; - } - if (newLines.isEmpty()) return; - - FastAppendTextDocument(newLines.join("\n"), qvLogDocument); + FastAppendTextDocument(trimmed, qvLogDocument); // qvLogDocument->setPlainText(qvLogDocument->toPlainText() + log); // From https://gist.github.com/jemyzhang/7130092 auto block = qvLogDocument->begin(); @@ -1997,40 +1983,6 @@ void MainWindow::on_masterLogBrowser_customContextMenuRequested(const QPoint &po sep->setSeparator(true); menu->addAction(sep); - auto action_add_ignore = new QAction(this); - action_add_ignore->setText(tr("Set ignore keyword")); - connect(action_add_ignore, &QAction::triggered, this, [=] { - auto list = NekoGui::dataStore->log_ignore; - auto newStr = ui->masterLogBrowser->textCursor().selectedText().trimmed(); - if (!newStr.isEmpty()) list << newStr; - bool ok; - newStr = QInputDialog::getMultiLineText(GetMessageBoxParent(), tr("Set ignore keyword"), tr("Set the following keywords to ignore?\nSplit by line."), list.join("\n"), &ok); - if (ok) { - NekoGui::dataStore->log_ignore = SplitLines(newStr); - NekoGui::dataStore->Save(); - } - }); - menu->addAction(action_add_ignore); - - auto action_add_route = new QAction(this); - action_add_route->setText(tr("Save as route")); - connect(action_add_route, &QAction::triggered, this, [=] { - auto newStr = ui->masterLogBrowser->textCursor().selectedText().trimmed(); - if (newStr.isEmpty()) return; - // - bool ok; - newStr = QInputDialog::getText(GetMessageBoxParent(), tr("Save as route"), tr("Edit"), {}, newStr, &ok).trimmed(); - if (!ok) return; - if (newStr.isEmpty()) return; - // - auto select = IsIpAddress(newStr) ? 0 : 3; - QStringList items = {"proxyIP", "bypassIP", "blockIP", "proxyDomain", "bypassDomain", "blockDomain"}; - auto item = QInputDialog::getItem(GetMessageBoxParent(), tr("Save as route"), - tr("Save \"%1\" as a routing rule?").arg(newStr), - items, select, false, &ok); - }); - menu->addAction(action_add_route); - auto action_clear = new QAction(this); action_clear->setText(tr("Clear")); connect(action_clear, &QAction::triggered, this, [=] {