mirror of
https://github.com/Mahdi-zarei/nekoray.git
synced 2025-12-29 13:51:24 +08:00
Fix: fix current index being reset & fix network not being persisted
This commit is contained in:
parent
3da55198e4
commit
b4b7e6b41f
@ -381,9 +381,6 @@ namespace NekoGui {
|
||||
// SingBox
|
||||
|
||||
void BuildConfigSingBox(const std::shared_ptr<BuildConfigStatus> &status) {
|
||||
// Log
|
||||
status->result->coreConfig["log"] = QJsonObject{{"level", dataStore->log_level}};
|
||||
|
||||
// Inbounds
|
||||
|
||||
// mixed-in
|
||||
@ -464,9 +461,6 @@ namespace NekoGui {
|
||||
// custom inbound
|
||||
if (!status->forTest) QJSONARRAY_ADD(status->inbounds, QString2QJsonObject(dataStore->custom_inbound)["inbounds"].toArray())
|
||||
|
||||
status->result->coreConfig.insert("inbounds", status->inbounds);
|
||||
status->result->coreConfig.insert("outbounds", status->outbounds);
|
||||
|
||||
// Routing
|
||||
// geopath
|
||||
auto geoip = FindCoreAsset("geoip.db");
|
||||
@ -547,8 +541,6 @@ namespace NekoGui {
|
||||
}
|
||||
routeObj["rule_set"] = ruleSetArray;
|
||||
|
||||
status->result->coreConfig["route"] = routeObj;
|
||||
|
||||
// DNS settings
|
||||
// final add DNS
|
||||
QJsonObject dns;
|
||||
@ -635,7 +627,6 @@ namespace NekoGui {
|
||||
if (dataStore->routing->use_dns_object) {
|
||||
dns = QString2QJsonObject(dataStore->routing->dns_object);
|
||||
}
|
||||
status->result->coreConfig.insert("dns", dns);
|
||||
|
||||
// experimental
|
||||
QJsonObject experimentalObj;
|
||||
@ -649,6 +640,11 @@ namespace NekoGui {
|
||||
experimentalObj["clash_api"] = clash_api;
|
||||
}
|
||||
|
||||
status->result->coreConfig.insert("log", QJsonObject{{"level", dataStore->log_level}});
|
||||
status->result->coreConfig.insert("dns", dns);
|
||||
status->result->coreConfig.insert("inbounds", status->inbounds);
|
||||
status->result->coreConfig.insert("outbounds", status->outbounds);
|
||||
status->result->coreConfig.insert("route", routeObj);
|
||||
if (!experimentalObj.isEmpty()) status->result->coreConfig.insert("experimental", experimentalObj);
|
||||
}
|
||||
} // namespace NekoGui
|
||||
@ -405,6 +405,7 @@ namespace NekoGui {
|
||||
RouteRule::RouteRule() {
|
||||
_add(new configItem("name", &name, itemType::string));
|
||||
_add(new configItem("ip_version", &ip_version, itemType::string));
|
||||
_add(new configItem("network", &network, itemType::string));
|
||||
_add(new configItem("protocol", &protocol, itemType::string));
|
||||
_add(new configItem("domain", &domain, itemType::stringList));
|
||||
_add(new configItem("domain_suffix", &domain_suffix, itemType::stringList));
|
||||
|
||||
@ -24,9 +24,9 @@ namespace NekoGui {
|
||||
QJsonObject RouteRule::get_rule_json(bool forView, const QString& outboundTag) const {
|
||||
QJsonObject obj;
|
||||
|
||||
if (ip_version != "") obj["ip_version"] = ip_version.toInt();
|
||||
if (network != "") obj["network"] = network;
|
||||
if (protocol != "") obj["protocol"] = protocol;
|
||||
if (!ip_version.isEmpty()) obj["ip_version"] = ip_version.toInt();
|
||||
if (!network.isEmpty()) obj["network"] = network;
|
||||
if (!protocol.isEmpty()) obj["protocol"] = protocol;
|
||||
if (isValidStrArray(domain)) obj["domain"] = get_as_array(domain);
|
||||
if (isValidStrArray(domain_suffix)) obj["domain_suffix"] = get_as_array(domain_suffix);
|
||||
if (isValidStrArray(domain_keyword)) obj["domain_keyword"] = get_as_array(domain_keyword);
|
||||
|
||||
@ -11,9 +11,13 @@
|
||||
#include <QMessageBox>
|
||||
|
||||
void DialogManageRoutes::reloadProfileItems() {
|
||||
if (chainList.empty()) {
|
||||
MessageBoxWarning("Invalid state", "The list of routing profiles is empty, this should be an unreachable state, crashes may occur now");
|
||||
return;
|
||||
}
|
||||
|
||||
QSignalBlocker blocker = QSignalBlocker(ui->route_prof); // apparently the currentIndexChanged will make us crash if we clear the QComboBox
|
||||
ui->route_prof->clear();
|
||||
blocker.unblock();
|
||||
|
||||
ui->route_profiles->clear();
|
||||
bool selectedChainGone = true;
|
||||
@ -28,9 +32,10 @@ void DialogManageRoutes::reloadProfileItems() {
|
||||
i++;
|
||||
}
|
||||
if (selectedChainGone) {
|
||||
currentRouteProfileID=0;
|
||||
currentRouteProfileID=chainList[0]->id;
|
||||
ui->route_prof->setCurrentIndex(0);
|
||||
}
|
||||
blocker.unblock();
|
||||
}
|
||||
|
||||
DialogManageRoutes::DialogManageRoutes(QWidget *parent) : QDialog(parent), ui(new Ui::DialogManageRoutes) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user