Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Modifying configuration errors can also set proxy issues #256

Merged
merged 2 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions dcc-network-plugin/window/sysproxymodule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ SysProxyModule::SysProxyModule(QObject *parent)
if (checked) {
uiMethodChanged(m_lastCombIndex == 0 ? ProxyMethod::Manual : ProxyMethod::Auto);
m_proxyTypeBox->comboBox()->setCurrentIndex(m_lastCombIndex);
checkConf();
} else {
// 关闭代理
NetworkController::instance()->proxyController()->setProxyMethod(ProxyMethod::None);
Expand Down Expand Up @@ -97,6 +98,7 @@ SysProxyModule::SysProxyModule(QObject *parent)
uiMethodChanged(ProxyMethod::Manual);
break;
}
checkConf();
m_buttonTuple->setEnabled(true);
});
}));
Expand All @@ -107,6 +109,7 @@ SysProxyModule::SysProxyModule(QObject *parent)
m_autoUrl->textEdit()->installEventFilter(this);
ProxyController *proxyController = NetworkController::instance()->proxyController();
connect(proxyController, &ProxyController::autoProxyChanged, m_autoUrl, &LineEditWidget::setText);
connect(m_autoUrl->textEdit(), &QLineEdit::textChanged, this, &SysProxyModule::checkConf);
autoGroup->appendItem(m_autoUrl);
resetData(ProxyMethod::Auto);
}));
Expand All @@ -119,6 +122,7 @@ SysProxyModule::SysProxyModule(QObject *parent)
m_buttonTuple->rightButton()->setText(tr("Save", "button"));
m_buttonTuple->setVisible(NetworkController::instance()->proxyController()->proxyMethod() != ProxyMethod::None);
m_buttonTuple->setEnabled(false);
checkConf();

connect(m_buttonTuple->rightButton(), &QPushButton::clicked, this, [this] {
m_lastCombIndex = m_proxyTypeBox->comboBox()->currentIndex();
Expand Down Expand Up @@ -160,7 +164,9 @@ void SysProxyModule::deactive()
m_socksPort = nullptr;
m_ignoreList = nullptr;
m_buttonTuple = nullptr;
uiMethodChanged(NetworkController::instance()->proxyController()->proxyMethod());
QTimer::singleShot(1, this, [this]() {
uiMethodChanged(NetworkController::instance()->proxyController()->proxyMethod());
});
}

void SysProxyModule::initManualView(QWidget *w)
Expand All @@ -177,13 +183,14 @@ void SysProxyModule::initManualView(QWidget *w)
portEdit->textEdit()->installEventFilter(this);
group->appendItem(proxyEdit);
group->appendItem(portEdit);
connect(portEdit->textEdit(), &QLineEdit::textChanged, this, [=](const QString &str) {
connect(portEdit->textEdit(), &QLineEdit::textChanged, this, [portEdit](const QString &str) {
if (str.toInt() < 0) {
portEdit->setText("0");
} else if (str.toInt() > 65535) {
portEdit->setText("65535");
}
});
connect(proxyEdit->textEdit(), &QLineEdit::textChanged, this, &SysProxyModule::checkConf);
};

// 手动代理编辑界面控件初始化
Expand Down Expand Up @@ -324,6 +331,17 @@ void SysProxyModule::resetData(ProxyMethod uiMethod)
}
}

void SysProxyModule::checkConf()
{
if (!m_proxyTypeBox || !m_buttonTuple)
return;
if (m_proxyTypeBox->comboBox()->currentIndex() == ProxyMethodIndex_Manual) {
m_buttonTuple->rightButton()->setEnabled(!m_httpAddr->text().isEmpty() || !m_httpsAddr->text().isEmpty() || !m_ftpAddr->text().isEmpty() || !m_socksAddr->text().isEmpty());
} else if (m_proxyTypeBox->comboBox()->currentIndex() == ProxyMethodIndex_Auto) {
m_buttonTuple->rightButton()->setEnabled(!m_autoUrl->text().isEmpty());
}
}

bool SysProxyModule::eventFilter(QObject *watched, QEvent *event)
{
// 实现鼠标点击编辑框,确定按钮激活,捕捉FocusIn消息,DTextEdit没有鼠标点击消息
Expand Down
1 change: 1 addition & 0 deletions dcc-network-plugin/window/sysproxymodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ private Q_SLOTS:
void applySettings();
void uiMethodChanged(dde::network::ProxyMethod uiMethod);
void resetData(dde::network::ProxyMethod uiMethod);
void checkConf();

private:
virtual bool eventFilter(QObject *watched, QEvent *event) override;
Expand Down
7 changes: 7 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
dde-network-core (2.0.31) unstable; urgency=medium

* fix: Modify the interface to display multiple system proxy issues(Issue: 9961)
* fix: Modifying configuration errors can also set proxy issues(Issue: 9983)

-- caixiangrong <[email protected]> Fri, 26 Jul 2024 16:25:40 +0800

dde-network-core (2.0.30) unstable; urgency=medium

* fix: Responding to proxy change signals (#252)(Issue: 9711)
Expand Down
Loading