Skip to content

Commit

Permalink
add url test button on main window
Browse files Browse the repository at this point in the history
  • Loading branch information
arm64v8a committed Oct 9, 2024
1 parent 2a17725 commit 99c8d50
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 20 deletions.
8 changes: 8 additions & 0 deletions translations/fa_IR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
8 changes: 8 additions & 0 deletions translations/ru_RU.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
10 changes: 9 additions & 1 deletion translations/zh_CN.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
9 changes: 5 additions & 4 deletions ui/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ui/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ private slots:

static void setup_grpc();

void speedtest_current_group(int mode);
void speedtest_current_group(int mode, bool test_group);

void speedtest_current();

Expand Down
32 changes: 24 additions & 8 deletions ui/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -665,23 +678,23 @@
<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">
<property name="text">
<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">
<property name="text">
<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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -774,15 +787,15 @@
<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">
<property name="text">
<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">
Expand All @@ -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">
Expand Down Expand Up @@ -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">
Expand Down Expand Up @@ -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>
Expand Down
13 changes: 7 additions & 6 deletions ui/mainwindow_grpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 99c8d50

Please sign in to comment.