mirror of
https://github.com/MatsuriDayo/nekoray.git
synced 2025-12-17 20:44:38 +03:00
feat: max log lines
This commit is contained in:
@@ -69,6 +69,7 @@ namespace NekoRay {
|
|||||||
_add(new configItem("enable_js_hook", &enable_js_hook, itemType::integer));
|
_add(new configItem("enable_js_hook", &enable_js_hook, itemType::integer));
|
||||||
_add(new configItem("log_ignore", &log_ignore, itemType::stringList));
|
_add(new configItem("log_ignore", &log_ignore, itemType::stringList));
|
||||||
_add(new configItem("start_minimal", &start_minimal, itemType::boolean));
|
_add(new configItem("start_minimal", &start_minimal, itemType::boolean));
|
||||||
|
_add(new configItem("max_log_line", &max_log_line, itemType::integer));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataStore::UpdateStartedId(int id) {
|
void DataStore::UpdateStartedId(int id) {
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ namespace NekoRay {
|
|||||||
QString system_proxy_format = "";
|
QString system_proxy_format = "";
|
||||||
QStringList log_ignore = {};
|
QStringList log_ignore = {};
|
||||||
bool start_minimal = false;
|
bool start_minimal = false;
|
||||||
|
int max_log_line = 200;
|
||||||
|
|
||||||
// Subscription
|
// Subscription
|
||||||
QString user_agent = "Nekoray/1.0 (Prefer Clash Format)";
|
QString user_agent = "Nekoray/1.0 (Prefer Clash Format)";
|
||||||
|
|||||||
@@ -213,6 +213,10 @@
|
|||||||
<source>Please select a valid square image.</source>
|
<source>Please select a valid square image.</source>
|
||||||
<translation>لطفاً یک تصویر مربع معتبر انتخاب کنید.</translation>
|
<translation>لطفاً یک تصویر مربع معتبر انتخاب کنید.</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Max log lines</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>DialogEditGroup</name>
|
<name>DialogEditGroup</name>
|
||||||
|
|||||||
@@ -211,6 +211,10 @@
|
|||||||
<source>Hide dashboard at startup</source>
|
<source>Hide dashboard at startup</source>
|
||||||
<translation>启动时不显示仪表盘</translation>
|
<translation>启动时不显示仪表盘</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Max log lines</source>
|
||||||
|
<translation>日志最大行数限制</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>DialogEditGroup</name>
|
<name>DialogEditGroup</name>
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ DialogBasicSettings::DialogBasicSettings(QWidget *parent)
|
|||||||
D_LOAD_BOOL(check_include_pre)
|
D_LOAD_BOOL(check_include_pre)
|
||||||
D_LOAD_BOOL(connection_statistics)
|
D_LOAD_BOOL(connection_statistics)
|
||||||
D_LOAD_BOOL(start_minimal)
|
D_LOAD_BOOL(start_minimal)
|
||||||
|
D_LOAD_INT(max_log_line)
|
||||||
//
|
//
|
||||||
if (NekoRay::dataStore->traffic_loop_interval == 500) {
|
if (NekoRay::dataStore->traffic_loop_interval == 500) {
|
||||||
ui->rfsh_r->setCurrentIndex(0);
|
ui->rfsh_r->setCurrentIndex(0);
|
||||||
@@ -256,6 +257,11 @@ void DialogBasicSettings::accept() {
|
|||||||
D_SAVE_BOOL(connection_statistics)
|
D_SAVE_BOOL(connection_statistics)
|
||||||
D_SAVE_BOOL(check_include_pre)
|
D_SAVE_BOOL(check_include_pre)
|
||||||
D_SAVE_BOOL(start_minimal)
|
D_SAVE_BOOL(start_minimal)
|
||||||
|
D_SAVE_INT(max_log_line)
|
||||||
|
|
||||||
|
if (NekoRay::dataStore->max_log_line <= 0) {
|
||||||
|
NekoRay::dataStore->max_log_line = 200;
|
||||||
|
}
|
||||||
|
|
||||||
if (ui->rfsh_r->currentIndex() == 0) {
|
if (ui->rfsh_r->currentIndex() == 0) {
|
||||||
NekoRay::dataStore->traffic_loop_interval = 500;
|
NekoRay::dataStore->traffic_loop_interval = 500;
|
||||||
|
|||||||
@@ -20,16 +20,6 @@
|
|||||||
<string>Basic Settings</string>
|
<string>Basic Settings</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="7" column="3">
|
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="3">
|
<item row="2" column="3">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
@@ -250,93 +240,139 @@
|
|||||||
<string>Style</string>
|
<string>Style</string>
|
||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QGridLayout" name="gridLayout_5">
|
<layout class="QGridLayout" name="gridLayout_5">
|
||||||
|
<item row="4" column="0">
|
||||||
|
<layout class="QHBoxLayout" name="_4">
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="horizontalGroupBox2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_20">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="set_custom_icon">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Set custom icon</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="horizontalGroupBox_5">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="start_minimal">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Hide dashboard at startup</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<layout class="QHBoxLayout" name="_3">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
<item>
|
||||||
<item>
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<widget class="QLabel" name="label_8">
|
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Theme</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="theme">
|
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<widget class="QLabel" name="label_8">
|
||||||
<string>System</string>
|
<property name="sizePolicy">
|
||||||
</property>
|
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Theme</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<widget class="QComboBox" name="theme">
|
||||||
<string notr="true">flatgray</string>
|
<item>
|
||||||
</property>
|
<property name="text">
|
||||||
|
<string>System</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">flatgray</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">lightblue</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">blacksoft</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QGroupBox" name="groupBox2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_15">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Language</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<widget class="QComboBox" name="language">
|
||||||
<string notr="true">lightblue</string>
|
<item>
|
||||||
</property>
|
<property name="text">
|
||||||
|
<string>System</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">English</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">简体中文</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<property name="text">
|
||||||
|
<string notr="true">فارسی</string>
|
||||||
|
</property>
|
||||||
|
</item>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
</layout>
|
||||||
<property name="text">
|
</widget>
|
||||||
<string notr="true">blacksoft</string>
|
</item>
|
||||||
</property>
|
</layout>
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QGroupBox" name="groupBox2">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
|
||||||
<item>
|
|
||||||
<widget class="QLabel" name="label_15">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Language</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QComboBox" name="language">
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string>System</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">English</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">简体中文</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true">فارسی</string>
|
|
||||||
</property>
|
|
||||||
</item>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
<layout class="QHBoxLayout" name="horizontalLayout_12">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="traffic_statistics_box">
|
<widget class="QGroupBox" name="traffic_statistics_box">
|
||||||
@@ -392,47 +428,21 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="5" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_22">
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
<item>
|
<layout class="QHBoxLayout" name="horizontalLayout_23">
|
||||||
<widget class="QGroupBox" name="horizontalGroupBox2">
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_20">
|
<widget class="QLabel" name="label_17">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QPushButton" name="set_custom_icon">
|
<string>Max log lines</string>
|
||||||
<property name="sizePolicy">
|
</property>
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
</widget>
|
||||||
<horstretch>0</horstretch>
|
</item>
|
||||||
<verstretch>0</verstretch>
|
<item>
|
||||||
</sizepolicy>
|
<widget class="QLineEdit" name="max_log_line"/>
|
||||||
</property>
|
</item>
|
||||||
<property name="text">
|
</layout>
|
||||||
<string>Set custom icon</string>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="horizontalGroupBox_5">
|
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
|
||||||
<item>
|
|
||||||
<widget class="QCheckBox" name="start_minimal">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Hide dashboard at startup</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
@@ -492,7 +502,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
<layout class="QHBoxLayout" name="horizontalLayout_22">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_12">
|
<widget class="QLabel" name="label_12">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -654,6 +664,16 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="7" column="3">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
|
|||||||
@@ -1295,11 +1295,10 @@ void MainWindow::show_log_impl(const QString &log) {
|
|||||||
FastAppendTextDocument(newLines.join("\n"), qvLogDocument);
|
FastAppendTextDocument(newLines.join("\n"), qvLogDocument);
|
||||||
// qvLogDocument->setPlainText(qvLogDocument->toPlainText() + log);
|
// qvLogDocument->setPlainText(qvLogDocument->toPlainText() + log);
|
||||||
// From https://gist.github.com/jemyzhang/7130092
|
// From https://gist.github.com/jemyzhang/7130092
|
||||||
auto maxLines = 200;
|
|
||||||
auto block = qvLogDocument->begin();
|
auto block = qvLogDocument->begin();
|
||||||
|
|
||||||
while (block.isValid()) {
|
while (block.isValid()) {
|
||||||
if (qvLogDocument->blockCount() > maxLines) {
|
if (qvLogDocument->blockCount() > NekoRay::dataStore->max_log_line) {
|
||||||
QTextCursor cursor(block);
|
QTextCursor cursor(block);
|
||||||
block = block.next();
|
block = block.next();
|
||||||
cursor.select(QTextCursor::BlockUnderCursor);
|
cursor.select(QTextCursor::BlockUnderCursor);
|
||||||
|
|||||||
Reference in New Issue
Block a user