mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 10:50:23 +08:00
[add] Added multiple delete support, fixed #147
Former-commit-id: 014d4b2629
This commit is contained in:
parent
0af45dc678
commit
c8a4d2be00
@ -1 +1 @@
|
|||||||
1796
|
1800
|
||||||
|
@ -837,35 +837,33 @@ void MainWindow::on_connectionListWidget_itemChanged(QTreeWidgetItem *item, int)
|
|||||||
}
|
}
|
||||||
void MainWindow::on_removeConfigButton_clicked()
|
void MainWindow::on_removeConfigButton_clicked()
|
||||||
{
|
{
|
||||||
if (!IsSelectionConnectable) return;
|
QStringList connlist;
|
||||||
|
|
||||||
if (QvMessageBoxAsk(this, tr("Removing this Connection"), tr("Are you sure to remove this connection?")) == QMessageBox::Yes) {
|
for (auto item : connectionListWidget->selectedItems()) {
|
||||||
auto connectionName = connectionListWidget->currentItem()->text(0);
|
if (IsConnectableItem(item)) {
|
||||||
SUBSCRIPTION_CONFIG_MODIFY_ASK(connectionName)
|
connlist.append(item->text(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (connectionName == CurrentConnectionName) {
|
LOG(MODULE_UI, "Selected " + to_string(connlist.count()) + " items")
|
||||||
|
|
||||||
|
if (connlist.isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (QvMessageBoxAsk(this, tr("Removing Connection(s)"), tr("Are you sure to remove selected connection(s)?")) != QMessageBox::Yes) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int subscriptionRemovalCheckStatus = -1;
|
||||||
|
|
||||||
|
for (auto name : connlist) {
|
||||||
|
if (name == CurrentConnectionName) {
|
||||||
on_stopButton_clicked();
|
on_stopButton_clicked();
|
||||||
CurrentConnectionName = "";
|
CurrentConnectionName.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto connData = connections[connectionName];
|
auto connData = connections[name];
|
||||||
|
|
||||||
if (connData.configType == CON_REGULAR) {
|
|
||||||
if (!connData.subscriptionName.isEmpty()) {
|
|
||||||
LOG(MODULE_UI, "Unexpected subscription name in a single regular config.")
|
|
||||||
connData.subscriptionName.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
currentConfig.configs.remove(connectionName.toStdString());
|
|
||||||
|
|
||||||
if (!RemoveConnection(connectionName)) {
|
|
||||||
QvMessageBox(this, tr("Removing this Connection"), tr("Failed to delete connection file, please delete manually."));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!RemoveSubscriptionConnection(connData.subscriptionName, connData.connectionName)) {
|
|
||||||
QvMessageBox(this, tr("Removing this Connection"), tr("Failed to delete connection file, please delete manually."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove auto start config.
|
// Remove auto start config.
|
||||||
if (currentConfig.autoStartConfig.subscriptionName == connData.subscriptionName.toStdString() &&
|
if (currentConfig.autoStartConfig.subscriptionName == connData.subscriptionName.toStdString() &&
|
||||||
@ -874,12 +872,41 @@ void MainWindow::on_removeConfigButton_clicked()
|
|||||||
currentConfig.autoStartConfig.connectionName.clear();
|
currentConfig.autoStartConfig.connectionName.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (IsRegularConfig(name)) {
|
||||||
|
// Just remove the regular configs.
|
||||||
|
if (!connData.subscriptionName.isEmpty()) {
|
||||||
|
LOG(MODULE_UI, "Unexpected subscription name in a single regular config.")
|
||||||
|
connData.subscriptionName.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
currentConfig.configs.remove(name.toStdString());
|
||||||
|
|
||||||
|
if (!RemoveConnection(name)) {
|
||||||
|
QvMessageBox(this, tr("Removing this Connection"), tr("Failed to delete connection file, please delete manually."));
|
||||||
|
}
|
||||||
|
} else if (IsSubscription(name)) {
|
||||||
|
if (subscriptionRemovalCheckStatus == -1) {
|
||||||
|
subscriptionRemovalCheckStatus = (QvMessageBoxAsk(this, tr("Removing a subscription config"), tr("Do you want to remove the config loaded from a subscription?")) == QMessageBox::Yes)
|
||||||
|
? 1 // Yes i want
|
||||||
|
: 0; // No please keep
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subscriptionRemovalCheckStatus == 1) {
|
||||||
|
if (!RemoveSubscriptionConnection(connData.subscriptionName, connData.connectionName)) {
|
||||||
|
QvMessageBox(this, tr("Removing this Connection"), tr("Failed to delete connection file, please delete manually."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
LOG(MODULE_CONFIG, "Unknown config type -> Not regular nor subscription...")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LOG(MODULE_UI, "Saving GlobalConfig")
|
LOG(MODULE_UI, "Saving GlobalConfig")
|
||||||
SetGlobalConfig(currentConfig);
|
SetGlobalConfig(currentConfig);
|
||||||
OnConfigListChanged(false);
|
OnConfigListChanged(false);
|
||||||
ShowAndSetConnection(CurrentConnectionName, false, false);
|
ShowAndSetConnection(CurrentConnectionName, false, false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
void MainWindow::on_importConfigButton_clicked()
|
void MainWindow::on_importConfigButton_clicked()
|
||||||
{
|
{
|
||||||
ImportConfigWindow *w = new ImportConfigWindow(this);
|
ImportConfigWindow *w = new ImportConfigWindow(this);
|
||||||
|
Loading…
Reference in New Issue
Block a user