mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +08:00
fix: several enhancements and ping fix
This commit is contained in:
parent
526f74a7fb
commit
056b10b4ca
@ -1 +1 @@
|
||||
2929
|
||||
2939
|
||||
|
@ -74,15 +74,27 @@ namespace Qv2ray
|
||||
bool SaveSubscriptionConfig(CONFIGROOT obj, const QString &subscription, const QString &name)
|
||||
{
|
||||
auto str = JsonToString(obj);
|
||||
QFile *config = new QFile(QV2RAY_SUBSCRIPTION_DIR + subscription + "/" + name + QV2RAY_CONFIG_FILE_EXTENSION);
|
||||
auto fName = name;
|
||||
|
||||
if (!IsValidFileName(fName + QV2RAY_CONFIG_FILE_EXTENSION)) {
|
||||
fName = QObject::tr("Invalid filename") + "_" + GenerateRandomString(6) + QV2RAY_CONFIG_FILE_EXTENSION;
|
||||
}
|
||||
|
||||
QFile *config = new QFile(QV2RAY_SUBSCRIPTION_DIR + subscription + "/" + fName + QV2RAY_CONFIG_FILE_EXTENSION);
|
||||
|
||||
// If there's already a file. THIS IS EXTREMELY RARE
|
||||
if (config->exists()) {
|
||||
LOG(MODULE_FILE, "Trying to overrwrite an existing subscription config file. THIS IS RARE")
|
||||
}
|
||||
|
||||
LOG(MODULE_CONFIG, "Saving a subscription named: " + name)
|
||||
return StringToFile(&str, config);
|
||||
LOG(MODULE_CONFIG, "Saving a subscription named: " + fName)
|
||||
bool result = StringToFile(&str, config);
|
||||
|
||||
if (!result) {
|
||||
LOG(MODULE_FILE, "Failed to save a connection config from subscription: " + subscription + ", name: " + fName)
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool RemoveConnection(const QString &alias)
|
||||
|
@ -237,9 +237,14 @@ void ImportConfigWindow::on_subscriptionButton_clicked()
|
||||
hide();
|
||||
SubscribeEditor w;
|
||||
w.exec();
|
||||
auto _result = w.GetSelectedConfig();
|
||||
auto importToComplex = !keepImportedInboundCheckBox->isEnabled();
|
||||
connections.clear();
|
||||
|
||||
if (importToComplex) {
|
||||
auto _result = w.GetSelectedConfig();
|
||||
connections[_result.first] = _result.second;
|
||||
}
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
|
@ -948,18 +948,18 @@ void MainWindow::on_pingTestBtn_clicked()
|
||||
if (QvMessageBoxAsk(this, tr("Latency Test"), tr("You are about to run latency test on all servers, do you want to continue?")) == QMessageBox::Yes) {
|
||||
aliases.append(connections.keys());
|
||||
}
|
||||
} else if (selection.count() == 1) {
|
||||
if (IsSelectionConnectable) {
|
||||
// Current selection is a config
|
||||
aliases.append(ItemConnectionIdentifier(selection.first()));
|
||||
} else {
|
||||
// Current selection is a subscription or... something else strange.
|
||||
for (auto i = 0; i < selection.count(); i++) {
|
||||
auto thisItem = selection[i];
|
||||
|
||||
if (thisItem->childCount() > 0) {
|
||||
// So we add another check to make sure the selected one is a subscription entry.
|
||||
if (selection.first()->childCount() > 0) {
|
||||
// Loop to add all sub-connections to the list.
|
||||
for (auto i = 0; i < selection.first()->childCount(); i++) {
|
||||
aliases.append(ItemConnectionIdentifier(selection.first()->child(i)));
|
||||
for (auto j = 0; j < thisItem->childCount(); j++) {
|
||||
aliases.append(ItemConnectionIdentifier(thisItem->child(j)));
|
||||
}
|
||||
} else {
|
||||
aliases.append(ItemConnectionIdentifier(thisItem));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -465,7 +465,7 @@
|
||||
<item row="1" column="1">
|
||||
<widget class="QLabel" name="label_15">
|
||||
<property name="text">
|
||||
<string>Assets Directory Path</string>
|
||||
<string>V2ray Assets Directory</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -135,7 +135,10 @@ void SubscribeEditor::StartUpdateSubscription(const QString &subscriptionName)
|
||||
LOG(MODULE_SUBSCRIPTION, "Processing a subscription with following error: " + errMessage)
|
||||
} else {
|
||||
connectionsList->addItem(_alias);
|
||||
SaveSubscriptionConfig(config, subscriptionName, _alias);
|
||||
|
||||
if (!SaveSubscriptionConfig(config, subscriptionName, _alias)) {
|
||||
// Cannot save.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user