remove extra core residuals

This commit is contained in:
Nova 2025-03-26 17:30:30 +03:30
parent b207dacd20
commit 306db5d7d4
5 changed files with 2 additions and 216 deletions

View File

@ -26,19 +26,6 @@ namespace NekoGui {
static QStringList List(); static QStringList List();
}; };
class ExtraCore : public JsonStore {
public:
QString core_map;
explicit ExtraCore();
[[nodiscard]] QString Get(const QString &id) const;
void Set(const QString &id, const QString &path);
void Delete(const QString &id);
};
class DataStore : public JsonStore { class DataStore : public JsonStore {
public: public:
// Running // Running
@ -169,9 +156,6 @@ namespace NekoGui {
QString core_box_clash_api_secret = ""; QString core_box_clash_api_secret = "";
QString core_box_underlying_dns = ""; QString core_box_underlying_dns = "";
// Other Core
ExtraCore *extraCore = new ExtraCore;
// Methods // Methods
DataStore(); DataStore();

View File

@ -29,32 +29,6 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QComboBox" name="core">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="editable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<widget class="QPushButton" name="as_json"> <widget class="QPushButton" name="as_json">
<property name="sizePolicy"> <property name="sizePolicy">
@ -85,49 +59,6 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item>
<widget class="QLabel" name="command_l">
<property name="text">
<string>Command</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="command">
<property name="placeholderText">
<string notr="true">%config%</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="config_suffix_l">
<property name="text">
<string>Config Suffix</string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="config_suffix">
<property name="editable">
<bool>true</bool>
</property>
<item>
<property name="text">
<string notr="true"/>
</property>
</item>
<item>
<property name="text">
<string notr="true">json</string>
</property>
</item>
<item>
<property name="text">
<string notr="true">yml</string>
</property>
</item>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -146,39 +77,6 @@
<property name="bottomMargin"> <property name="bottomMargin">
<number>0</number> <number>0</number>
</property> </property>
<item>
<widget class="QLabel" name="label">
<property name="toolTip">
<string>Random if it's empty or zero.</string>
</property>
<property name="text">
<string notr="true">Mapping Port</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="mapping_port"/>
</item>
<item>
<widget class="QLabel" name="label_2">
<property name="toolTip">
<string>Random if it's empty or zero.</string>
</property>
<property name="text">
<string notr="true">Socks Port</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="socks_port"/>
</item>
<item>
<widget class="QPushButton" name="preview">
<property name="text">
<string>Preview</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@ -195,13 +93,7 @@
</layout> </layout>
</widget> </widget>
<tabstops> <tabstops>
<tabstop>core</tabstop>
<tabstop>as_json</tabstop> <tabstop>as_json</tabstop>
<tabstop>command</tabstop>
<tabstop>config_suffix</tabstop>
<tabstop>mapping_port</tabstop>
<tabstop>socks_port</tabstop>
<tabstop>preview</tabstop>
<tabstop>config_simple</tabstop> <tabstop>config_simple</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>

View File

@ -239,8 +239,6 @@ namespace NekoGui {
// datastore // datastore
DataStore::DataStore() : JsonStore() { DataStore::DataStore() : JsonStore() {
_add(new configItem("extraCore", dynamic_cast<JsonStore *>(extraCore), itemType::jsonStore));
_add(new configItem("user_agent2", &user_agent, itemType::string)); _add(new configItem("user_agent2", &user_agent, itemType::string));
_add(new configItem("test_url", &test_latency_url, itemType::string)); _add(new configItem("test_url", &test_latency_url, itemType::string));
_add(new configItem("current_group", &current_group, itemType::integer)); _add(new configItem("current_group", &current_group, itemType::integer));
@ -355,32 +353,6 @@ namespace NekoGui {
return {"Default"}; return {"Default"};
} }
// NO default extra core
ExtraCore::ExtraCore() : JsonStore() {
_add(new configItem("core_map", &this->core_map, itemType::string));
}
QString ExtraCore::Get(const QString &id) const {
auto obj = QString2QJsonObject(core_map);
for (const auto &c: obj.keys()) {
if (c == id) return obj[id].toString();
}
return "";
}
void ExtraCore::Set(const QString &id, const QString &path) {
auto obj = QString2QJsonObject(core_map);
obj[id] = path;
core_map = QJsonObject2QString(obj, true);
}
void ExtraCore::Delete(const QString &id) {
auto obj = QString2QJsonObject(core_map);
obj.remove(id);
core_map = QJsonObject2QString(obj, true);
}
// System Utils // System Utils
QString FindCoreAsset(const QString &name) { QString FindCoreAsset(const QString &name) {

View File

@ -222,7 +222,7 @@ void DialogEditProfile::typeSelected(const QString &newType) {
auto _innerWidget = new EditSSH(this); auto _innerWidget = new EditSSH(this);
innerWidget = _innerWidget; innerWidget = _innerWidget;
innerEditor = _innerWidget; innerEditor = _innerWidget;
} else if (type == "custom" || type == "internal" || type == "internal-full") { } else if (type == "internal" || type == "internal-full") {
auto _innerWidget = new EditCustom(this); auto _innerWidget = new EditCustom(this);
innerWidget = _innerWidget; innerWidget = _innerWidget;
innerEditor = _innerWidget; innerEditor = _innerWidget;

View File

@ -24,24 +24,10 @@ EditCustom::~EditCustom() {
delete ui; delete ui;
} }
#define SAVE_CUSTOM_BEAN \
P_SAVE_COMBO_STRING(core) \
bean->command = ui->command->text().split(" "); \
P_SAVE_STRING_PLAIN(config_simple) \
P_SAVE_COMBO_STRING(config_suffix) \
P_SAVE_INT(mapping_port) \
P_SAVE_INT(socks_port)
void EditCustom::onStart(std::shared_ptr<NekoGui::ProxyEntity> _ent) { void EditCustom::onStart(std::shared_ptr<NekoGui::ProxyEntity> _ent) {
this->ent = _ent; this->ent = _ent;
auto bean = this->ent->CustomBean(); auto bean = this->ent->CustomBean();
// load known core
auto core_map = QString2QJsonObject(NekoGui::dataStore->extraCore->core_map);
for (const auto &key: core_map.keys()) {
if (key == "naive" || key == "hysteria") continue;
ui->core->addItem(key);
}
if (preset_core == "internal") { if (preset_core == "internal") {
preset_command = preset_config = ""; preset_command = preset_config = "";
ui->config_simple->setPlaceholderText( ui->config_simple->setPlaceholderText(
@ -59,27 +45,10 @@ void EditCustom::onStart(std::shared_ptr<NekoGui::ProxyEntity> _ent) {
} }
// load core ui // load core ui
P_LOAD_COMBO_STRING(core)
ui->command->setText(bean->command.join(" "));
ui->config_simple->setPlainText(bean->config_simple); ui->config_simple->setPlainText(bean->config_simple);
P_LOAD_COMBO_STRING(config_suffix)
P_LOAD_INT(mapping_port)
P_LOAD_INT(socks_port)
// custom external
if (!bean->core.isEmpty()) {
ui->core->setDisabled(true);
} else if (!preset_core.isEmpty()) {
bean->core = preset_core;
ui->core->setDisabled(true);
ui->core->setCurrentText(preset_core);
ui->command->setText(preset_command);
ui->config_simple->setPlainText(preset_config);
}
// custom internal // custom internal
if (preset_core == "internal" || preset_core == "internal-full") { if (preset_core == "internal" || preset_core == "internal-full") {
ui->core->hide();
if (preset_core == "internal") { if (preset_core == "internal") {
ui->core_l->setText(tr("Outbound JSON, please read the documentation.")); ui->core_l->setText(tr("Outbound JSON, please read the documentation."));
} else { } else {
@ -88,33 +57,6 @@ void EditCustom::onStart(std::shared_ptr<NekoGui::ProxyEntity> _ent) {
ui->w_ext1->hide(); ui->w_ext1->hide();
ui->w_ext2->hide(); ui->w_ext2->hide();
} }
// Preview
connect(ui->preview, &QPushButton::clicked, this, [=] {
// CustomBean::BuildExternal
QStringList th;
auto mapping_port = ui->mapping_port->text().toInt();
auto socks_port = ui->socks_port->text().toInt();
th << "%mapping_port% => " + (mapping_port <= 0 ? "Random" : Int2String(mapping_port));
th << "%socks_port% => " + (socks_port <= 0 ? "Random" : Int2String(socks_port));
th << "%server_addr% => " + get_edit_text_serverAddress();
th << "%server_port% => " + get_edit_text_serverPort();
MessageBoxInfo(tr("Preview replace"), th.join("\n"));
// EditCustom::onEnd
auto tmpEnt = NekoGui::ProfileManager::NewProxyEntity("custom");
auto bean = tmpEnt->CustomBean();
SAVE_CUSTOM_BEAN
// 补充
bean->serverAddress = get_edit_text_serverAddress();
bean->serverPort = get_edit_text_serverPort().toInt();
if (bean->core.isEmpty()) return;
//
auto result = NekoGui::BuildConfig(tmpEnt, false, false);
if (!result->error.isEmpty()) {
MessageBoxInfo(software_name, result->error);
return;
}
});
} }
bool EditCustom::onEnd() { bool EditCustom::onEnd() {
@ -122,14 +64,10 @@ bool EditCustom::onEnd() {
MessageBoxWarning(software_name, tr("Name cannot be empty.")); MessageBoxWarning(software_name, tr("Name cannot be empty."));
return false; return false;
} }
if (ui->core->currentText().isEmpty()) {
MessageBoxWarning(software_name, tr("Please pick a core."));
return false;
}
auto bean = this->ent->CustomBean(); auto bean = this->ent->CustomBean();
SAVE_CUSTOM_BEAN P_SAVE_STRING_PLAIN(config_simple)
return true; return true;
} }