mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-21 11:20:49 +08:00
add: added maximum log line count
This commit is contained in:
parent
e0b8207552
commit
e99d71f2e9
@ -1 +1 @@
|
||||
2944
|
||||
2957
|
||||
|
@ -179,8 +179,9 @@ namespace Qv2ray
|
||||
QString language;
|
||||
bool useDarkTheme;
|
||||
bool useDarkTrayIcon;
|
||||
Qv2rayUIConfig() : theme("Fusion"), language("en-US"), useDarkTheme(false), useDarkTrayIcon(true) { }
|
||||
XTOSTRUCT(O(theme, language, useDarkTheme, useDarkTrayIcon))
|
||||
int maximumLogLines;
|
||||
Qv2rayUIConfig() : theme("Fusion"), language("en-US"), useDarkTheme(false), useDarkTrayIcon(true), maximumLogLines(2000) { }
|
||||
XTOSTRUCT(O(theme, language, useDarkTheme, useDarkTrayIcon, maximumLogLines))
|
||||
};
|
||||
|
||||
struct Qv2rayConnectionConfig {
|
||||
|
@ -56,6 +56,23 @@
|
||||
|
||||
#define IsConnectableItem(item) (item != nullptr && item->childCount() == 0 && (CheckConfigType(item, REGULAR) || CheckConfigType(item, SUBSCRIPTION)))
|
||||
#define IsSelectionConnectable (!connectionListWidget->selectedItems().empty() && IsConnectableItem(connectionListWidget->selectedItems().first()))
|
||||
// From https://gist.github.com/jemyzhang/7130092
|
||||
#define CleanUpLogs(browser) \
|
||||
{\
|
||||
auto maxLines = currentConfig.uiConfig.maximumLogLines; \
|
||||
QTextBlock block = browser->document()->begin();\
|
||||
while (block.isValid()) {\
|
||||
if (browser->document()->blockCount() > maxLines) {\
|
||||
QTextCursor cursor(block);\
|
||||
block = block.next();\
|
||||
cursor.select(QTextCursor::BlockUnderCursor);\
|
||||
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor);\
|
||||
cursor.removeSelectedText();\
|
||||
} else {\
|
||||
break;\
|
||||
}\
|
||||
}\
|
||||
}
|
||||
|
||||
MainWindow *MainWindow::mwInstance = nullptr;
|
||||
|
||||
@ -95,7 +112,7 @@ MainWindow::MainWindow(QWidget *parent):
|
||||
masterLogBrowser->document()->adjustSize();
|
||||
masterLogBrowser->setLineWrapMode(QTextBrowser::LineWrapMode::NoWrap);
|
||||
//
|
||||
logTimerId = startTimer(500);
|
||||
qvLogTimerId = startTimer(500);
|
||||
//
|
||||
pacServer = new PACServer();
|
||||
tcpingModel = new QvTCPingModel(3, this);
|
||||
@ -414,7 +431,7 @@ void MainWindow::OnConfigListChanged(bool need_restart)
|
||||
}
|
||||
MainWindow::~MainWindow()
|
||||
{
|
||||
killTimer(logTimerId);
|
||||
killTimer(qvLogTimerId);
|
||||
hTray->hide();
|
||||
delete this->hTray;
|
||||
delete this->vinstance;
|
||||
@ -422,6 +439,7 @@ MainWindow::~MainWindow()
|
||||
void MainWindow::UpdateVCoreLog(const QString &log)
|
||||
{
|
||||
vCoreLogBrowser->append(log);
|
||||
CleanUpLogs(vCoreLogBrowser)
|
||||
setMasterLogHBar();
|
||||
}
|
||||
void MainWindow::setMasterLogHBar()
|
||||
@ -1038,12 +1056,14 @@ void MainWindow::timerEvent(QTimerEvent *event)
|
||||
dataamountLabel->setText(totalDataUp + NEWLINE + totalDataDown);
|
||||
//
|
||||
hTray->setToolTip(TRAY_TOOLTIP_PREFIX NEWLINE + tr("Connected: ") + CurrentConnectionIdentifier.IdentifierString() + NEWLINE "Up: " + totalSpeedUp + " Down: " + totalSpeedDown);
|
||||
} else if (event->timerId() == logTimerId) {
|
||||
} else if (event->timerId() == qvLogTimerId) {
|
||||
QString lastLog = readLastLog();
|
||||
|
||||
if (!lastLog.isEmpty()) {
|
||||
qvAppLogBrowser->append(lastLog);
|
||||
}
|
||||
|
||||
CleanUpLogs(vCoreLogBrowser)
|
||||
} else if (event->timerId() == pingTimerId) {
|
||||
MWTryPingConnection(CurrentConnectionIdentifier);
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ class MainWindow : public QMainWindow, Ui::MainWindow
|
||||
//
|
||||
// ID for QTimers
|
||||
//
|
||||
int logTimerId;
|
||||
int qvLogTimerId;
|
||||
int speedTimerId;
|
||||
int pingTimerId;
|
||||
//
|
||||
|
@ -170,6 +170,8 @@ PreferencesWindow::PreferencesWindow(QWidget *parent) : QDialog(parent),
|
||||
fpUsernameTx->setEnabled(fpUseAuthCB->isChecked());
|
||||
fpPasswordTx->setEnabled(fpUseAuthCB->isChecked());
|
||||
//
|
||||
maxLogLinesSB->setValue(CurrentConfig.uiConfig.maximumLogLines);
|
||||
//
|
||||
pacListenAddrLabel->setText("http://" + (pacProxyTxt->text().isEmpty() ? "127.0.0.1" : pacProxyTxt->text()) + ":" + QSTRN(pacPortSB->value()) + "/pac");
|
||||
//
|
||||
finishedLoading = true;
|
||||
@ -1012,3 +1014,10 @@ void PreferencesWindow::on_fpGroupBox_clicked(bool checked)
|
||||
NEEDRESTART
|
||||
CurrentConfig.connectionConfig.forwardProxyConfig.enableForwardProxy = checked;
|
||||
}
|
||||
|
||||
void PreferencesWindow::on_maxLogLinesSB_valueChanged(int arg1)
|
||||
{
|
||||
LOADINGCHECK
|
||||
NEEDRESTART
|
||||
CurrentConfig.uiConfig.maximumLogLines = arg1;
|
||||
}
|
||||
|
@ -158,6 +158,8 @@ class PreferencesWindow : public QDialog, private Ui::PreferencesWindow
|
||||
|
||||
void on_fpGroupBox_clicked(bool checked);
|
||||
|
||||
void on_maxLogLinesSB_valueChanged(int arg1);
|
||||
|
||||
private:
|
||||
void SetAutoStartButtonsState(bool isAutoStart);
|
||||
// Set ui parameters for a line;
|
||||
|
@ -44,26 +44,141 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>647</width>
|
||||
<height>440</height>
|
||||
<height>476</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout_5">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_35">
|
||||
<property name="text">
|
||||
<string>UI Theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_55">
|
||||
<property name="text">
|
||||
<string>UI Settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="themeCombo">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
<layout class="QGridLayout" name="gridLayout_6" columnstretch="0,0,1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="label_35">
|
||||
<property name="text">
|
||||
<string>UI Theme</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="darkThemeCB">
|
||||
<property name="text">
|
||||
<string>Enabled</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="darkTrayCB">
|
||||
<property name="text">
|
||||
<string>Enabled</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="4">
|
||||
<widget class="Line" name="line">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_36">
|
||||
<property name="text">
|
||||
<string>Darkmode Tray Icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="2">
|
||||
<widget class="QComboBox" name="themeCombo">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="darkThemeLabel">
|
||||
<property name="text">
|
||||
<string>Darkmode UI Icons</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QComboBox" name="languageComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>zh-CN</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>en-US</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
@ -104,141 +219,13 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_6">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_7">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_55">
|
||||
<property name="text">
|
||||
<string>Theme Settings</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_6" columnstretch="0,0,0,1">
|
||||
<item row="1" column="2">
|
||||
<widget class="QCheckBox" name="darkTrayCB">
|
||||
<property name="text">
|
||||
<string>Enabled</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="3" rowspan="2">
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="2">
|
||||
<widget class="QCheckBox" name="darkThemeCB">
|
||||
<property name="text">
|
||||
<string>Enabled</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLabel" name="darkThemeLabel">
|
||||
<property name="text">
|
||||
<string>Darkmode UI Icons</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_36">
|
||||
<property name="text">
|
||||
<string>Darkmode Tray Icon</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<property name="lineWidth">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Language</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QComboBox" name="languageComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>100</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>zh-CN</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>en-US</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Log Level</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="logLevelComboBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
|
||||
@ -279,7 +266,7 @@
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="4" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_9">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_6">
|
||||
@ -316,7 +303,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="4" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_8" columnstretch="0,0,1">
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_61">
|
||||
@ -365,21 +352,21 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Transparent Proxy</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="tProxyCheckBox">
|
||||
<property name="text">
|
||||
<string>Enabled</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="6" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<spacer name="verticalSpacer_12">
|
||||
@ -416,7 +403,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="6" column="1">
|
||||
<layout class="QGridLayout" name="gridLayout_9">
|
||||
<item row="0" column="0" rowspan="3">
|
||||
<widget class="Line" name="line_3">
|
||||
@ -478,7 +465,7 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="7" column="1">
|
||||
<spacer name="verticalSpacer_11">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@ -491,6 +478,29 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_48">
|
||||
<property name="text">
|
||||
<string>Maximum log lines</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="maxLogLinesSB">
|
||||
<property name="accelerated">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="suffix">
|
||||
<string> lines</string>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>50</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2000</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
|
@ -22,7 +22,11 @@ const QString readLastLog()
|
||||
QString result;
|
||||
|
||||
while (!__loggerBuffer.isEmpty()) {
|
||||
result += __loggerBuffer.dequeue();
|
||||
auto str = __loggerBuffer.dequeue();
|
||||
|
||||
if (!str.trimmed().isEmpty()) {
|
||||
result += str;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
|
Loading…
Reference in New Issue
Block a user