Skip to content

Commit

Permalink
fix: clear system proxy when zju-connect exits abnormally
Browse files Browse the repository at this point in the history
  • Loading branch information
Mythologyli committed Jan 13, 2025
1 parent 4c5510c commit d603562
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions zjuconnectmode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void MainWindow::setModeToZjuConnect()
addLog("工作模式设置为:RVPN");

// 连接服务器
connect(zjuConnectController, &ZjuConnectController::outputRead, this, [&](const QString &output)
connect(zjuConnectController, &ZjuConnectController::outputRead, this, [&](const QString& output)
{
ui->logPlainTextEdit->appendPlainText(output);
});
Expand All @@ -58,7 +58,7 @@ void MainWindow::setModeToZjuConnect()
!isZjuConnectAccessDenied &&
settings->value("ZJUConnect/AutoReconnect", false).toBool() &&
isZjuConnectLinked
)
)
{
QTimer::singleShot(settings->value("ZJUConnect/ReconnectTime", 1).toInt() * 1000, this, [&]()
{
Expand All @@ -80,6 +80,11 @@ void MainWindow::setModeToZjuConnect()
ui->pushButton1->setText("连接服务器");
ui->modeComboBox->setEnabled(true);

if (isSystemProxySet)
{
ui->pushButton2->click();
}

if (isZjuConnectLoginError)
{
isZjuConnectLoginError = false;
Expand Down Expand Up @@ -144,18 +149,7 @@ void MainWindow::setModeToZjuConnect()
}
else
{
isZjuConnectLinked = false;

zjuConnectController->stop();

if (isSystemProxySet)
{
ui->pushButton2->click();
}

ui->pushButton1->setText("连接服务器");
ui->pushButton2->hide();
ui->modeComboBox->setEnabled(true);
}
});

Expand All @@ -165,7 +159,12 @@ void MainWindow::setModeToZjuConnect()
{
if (!isSystemProxySet)
{
if (networkDetectResult.isProxyEnabled)
QSettings proxySettings(
R"(HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings)",
QSettings::NativeFormat
);

if (proxySettings.value("ProxyEnable", 0).toInt() == 1)
{
QMessageBox messageBox(this);
messageBox.setWindowTitle("警告");
Expand Down

0 comments on commit d603562

Please sign in to comment.