add url test button on main window

This commit is contained in:
armv9
2024-10-09 13:27:22 +09:00
parent 2a177256ce
commit 99c8d50943
7 changed files with 62 additions and 20 deletions

View File

@@ -1492,6 +1492,10 @@ End: %2</source>
<source>Stop Testing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>URL Test</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProxyItem</name>
@@ -1632,6 +1636,10 @@ Direct: %2</source>
<source>Default</source>
<translation type="unfinished">پیش فرض</translation>
</message>
<message>
<source>The last speed test did not exit completely, please wait. If it persists, please restart the program.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Qv2ray::ui::widgets::AutoCompleteTextEdit</name>

View File

@@ -1498,6 +1498,10 @@ End: %2</source>
<source>Stop Testing</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>URL Test</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ProxyItem</name>
@@ -1645,6 +1649,10 @@ Release note:
<source>Default</source>
<translation>По умолчанию</translation>
</message>
<message>
<source>The last speed test did not exit completely, please wait. If it persists, please restart the program.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>Qv2ray::ui::widgets::AutoCompleteTextEdit</name>

View File

@@ -1488,7 +1488,7 @@ Split by line.</source>
</message>
<message>
<source>In and Out IP</source>
<translation>IP</translation>
<translation> IP</translation>
</message>
<message>
<source>Test Options</source>
@@ -1498,6 +1498,10 @@ Split by line.</source>
<source>Stop Testing</source>
<translation></translation>
</message>
<message>
<source>URL Test</source>
<translation>URL </translation>
</message>
</context>
<context>
<name>ProxyItem</name>
@@ -1645,6 +1649,10 @@ Release note:
<source>Default</source>
<translation></translation>
</message>
<message>
<source>The last speed test did not exit completely, please wait. If it persists, please restart the program.</source>
<translation>退</translation>
</message>
</context>
<context>
<name>Qv2ray::ui::widgets::AutoCompleteTextEdit</name>

View File

@@ -103,6 +103,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
connect(ui->toolButton_document, &QToolButton::clicked, this, [=] { QDesktopServices::openUrl(QUrl("https://matsuridayo.github.io/")); });
connect(ui->toolButton_ads, &QToolButton::clicked, this, [=] { QDesktopServices::openUrl(QUrl("https://matsuricom.pages.dev/")); });
connect(ui->toolButton_update, &QToolButton::clicked, this, [=] { runOnNewThread([=] { CheckUpdate(); }); });
connect(ui->toolButton_url_test, &QToolButton::clicked, this, [=] { speedtest_current_group(1, true); });
// Setup log UI
ui->splitter->restoreState(DecodeB64IfValid(NekoGui::dataStore->splitter_state));
@@ -333,10 +334,10 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
neko_set_spmode_vpn(false);
});
connect(ui->menu_qr, &QAction::triggered, this, [=]() { display_qr_link(false); });
connect(ui->menu_tcp_ping, &QAction::triggered, this, [=]() { speedtest_current_group(0); });
connect(ui->menu_url_test, &QAction::triggered, this, [=]() { speedtest_current_group(1); });
connect(ui->menu_full_test, &QAction::triggered, this, [=]() { speedtest_current_group(2); });
connect(ui->menu_stop_testing, &QAction::triggered, this, [=]() { speedtest_current_group(114514); });
connect(ui->menu_tcp_ping, &QAction::triggered, this, [=]() { speedtest_current_group(0, false); });
connect(ui->menu_url_test, &QAction::triggered, this, [=]() { speedtest_current_group(1, false); });
connect(ui->menu_full_test, &QAction::triggered, this, [=]() { speedtest_current_group(2, false); });
connect(ui->menu_stop_testing, &QAction::triggered, this, [=]() { speedtest_current_group(114514, false); });
//
auto set_selected_or_group = [=](int mode) {
// 0=group 1=select 2=unknown(menu is hide)

View File

@@ -185,7 +185,7 @@ private:
static void setup_grpc();
void speedtest_current_group(int mode);
void speedtest_current_group(int mode, bool test_group);
void speedtest_current();

View File

@@ -205,6 +205,19 @@
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_url_test">
<property name="text">
<string>URL Test</string>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
@@ -665,7 +678,7 @@
<string notr="true">Tcp Ping</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Shift+T</string>
<string notr="true">Ctrl+Alt+T</string>
</property>
</action>
<action name="menu_url_test">
@@ -673,7 +686,7 @@
<string notr="true">Url Test</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Shift+U</string>
<string notr="true">Ctrl+Alt+U</string>
</property>
</action>
<action name="menu_clear_test_result">
@@ -681,7 +694,7 @@
<string>Clear Test Result</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Shift+C</string>
<string notr="true">Ctrl+Alt+C</string>
</property>
</action>
<action name="menu_export_config">
@@ -726,7 +739,7 @@
<string>Remove Duplicates</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Shift+D</string>
<string notr="true">Ctrl+Alt+D</string>
</property>
</action>
<action name="actionfake">
@@ -774,7 +787,7 @@
<string>Remove Unavailable</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Shift+R</string>
<string notr="true">Ctrl+Alt+R</string>
</property>
</action>
<action name="menu_full_test">
@@ -782,7 +795,7 @@
<string>Full Test</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Shift+F</string>
<string notr="true">Ctrl+Alt+F</string>
</property>
</action>
<action name="menu_hotkey_settings">
@@ -803,7 +816,7 @@
<string>Copy links of selected (Neko Links)</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Alt+C</string>
<string notr="true">Ctrl+N</string>
</property>
</action>
<action name="actionfake_2">
@@ -859,7 +872,7 @@
<string>Resolve domain</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Shift+I</string>
<string notr="true">Ctrl+Alt+I</string>
</property>
</action>
<action name="menu_vpn_settings">
@@ -902,6 +915,9 @@
<property name="text">
<string>Stop Testing</string>
</property>
<property name="shortcut">
<string notr="true">Ctrl+Alt+S</string>
</property>
</action>
</widget>
<customwidgets>

View File

@@ -58,8 +58,14 @@ void MainWindow::setup_grpc() {
inline bool speedtesting = false;
inline QList<QThread *> speedtesting_threads = {};
void MainWindow::speedtest_current_group(int mode) {
void MainWindow::speedtest_current_group(int mode, bool test_group) {
if (speedtesting) {
MessageBoxWarning(software_name, QObject::tr("The last speed test did not exit completely, please wait. If it persists, please restart the program."));
return;
}
auto profiles = get_selected_or_group();
if (test_group) profiles = NekoGui::profileManager->CurrentGroup()->ProfilesWithOrder();
if (profiles.isEmpty()) return;
auto group = NekoGui::profileManager->CurrentGroup();
if (group->archive) return;
@@ -75,11 +81,6 @@ void MainWindow::speedtest_current_group(int mode) {
}
#ifndef NKR_NO_GRPC
if (speedtesting) {
MessageBoxWarning(software_name, "The last speed test did not exit completely, please wait. If it persists, please restart the program.");
return;
}
QStringList full_test_flags;
if (mode == libcore::FullTest) {
auto w = new QDialog(this);