mirror of
https://github.com/Qv2ray/Qv2ray.git
synced 2025-05-20 02:40:20 +08:00
fix: this fixed #473
This commit is contained in:
parent
9ca558b2f2
commit
a0fe8fa042
@ -706,7 +706,7 @@ void RouteEditor::on_addOutboundBtn_clicked()
|
||||
LOADINGCHECK
|
||||
ImportConfigWindow w(this);
|
||||
// True here for not keep the inbounds.
|
||||
auto configs = w.OpenImport(true);
|
||||
auto configs = w.SelectConnection(true);
|
||||
|
||||
for (auto i = 0; i < configs.count(); i++)
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include "core/CoreUtils.hpp"
|
||||
#include "core/connection/ConnectionIO.hpp"
|
||||
#include "core/connection/Serialization.hpp"
|
||||
#include "core/handler/ConfigHandler.hpp"
|
||||
#include "core/kernel/KernelInteractions.hpp"
|
||||
#include "ui/editors/w_JsonEditor.hpp"
|
||||
#include "ui/editors/w_OutboundEditor.hpp"
|
||||
@ -44,15 +45,32 @@ ImportConfigWindow::~ImportConfigWindow()
|
||||
{
|
||||
}
|
||||
|
||||
QMultiMap<QString, CONFIGROOT> ImportConfigWindow::OpenImport(bool partialImport)
|
||||
QMultiMap<QString, CONFIGROOT> ImportConfigWindow::SelectConnection(bool outboundsOnly)
|
||||
{
|
||||
keepImportedInboundCheckBox->setEnabled(!outboundsOnly);
|
||||
routeEditBtn->setEnabled(!outboundsOnly);
|
||||
this->exec();
|
||||
return result() == Accepted ? connections : QMultiMap<QString, CONFIGROOT>{};
|
||||
}
|
||||
|
||||
int ImportConfigWindow::ImportConnection()
|
||||
{
|
||||
// partial import means only import as an outbound, will set keepImported to
|
||||
// false and disable the checkbox
|
||||
// keepImportedInboundCheckBox->setChecked(!outboundsOnly);
|
||||
keepImportedInboundCheckBox->setEnabled(!partialImport);
|
||||
routeEditBtn->setEnabled(!partialImport);
|
||||
this->exec();
|
||||
return this->result() == QDialog::Accepted ? connections : QMultiMap<QString, CONFIGROOT>();
|
||||
for (auto conf : connections)
|
||||
{
|
||||
auto name = connections.key(conf, "");
|
||||
|
||||
auto [protocol, host, port] = GetConnectionInfo(conf);
|
||||
if (name.isEmpty())
|
||||
{
|
||||
name = protocol + "/" + host + ":" + QSTRN(port) + "-" + GenerateRandomString(5);
|
||||
}
|
||||
ConnectionManager->CreateConnection(name, DefaultGroupId, conf);
|
||||
}
|
||||
|
||||
return connections.count();
|
||||
}
|
||||
|
||||
void ImportConfigWindow::on_selectFileBtn_clicked()
|
||||
|
@ -17,7 +17,8 @@ class ImportConfigWindow
|
||||
public:
|
||||
explicit ImportConfigWindow(QWidget *parent = nullptr);
|
||||
~ImportConfigWindow();
|
||||
QMultiMap<QString, CONFIGROOT> OpenImport(bool outboundsOnly = false);
|
||||
int ImportConnection();
|
||||
QMultiMap<QString, CONFIGROOT> SelectConnection(bool outboundsOnly);
|
||||
|
||||
private:
|
||||
QvMessageBusSlotDecl;
|
||||
|
@ -525,18 +525,7 @@ void MainWindow::on_action_RCM_DeleteThese_triggered()
|
||||
void MainWindow::on_importConfigButton_clicked()
|
||||
{
|
||||
ImportConfigWindow w(this);
|
||||
auto configs = w.OpenImport();
|
||||
if (!configs.isEmpty())
|
||||
{
|
||||
for (auto conf : configs)
|
||||
{
|
||||
auto name = configs.key(conf, "");
|
||||
|
||||
if (name.isEmpty())
|
||||
continue;
|
||||
ConnectionManager->CreateConnection(name, DefaultGroupId, conf);
|
||||
}
|
||||
}
|
||||
w.ImportConnection();
|
||||
}
|
||||
|
||||
void MainWindow::on_action_RCM_EditAsComplex_triggered()
|
||||
|
Loading…
Reference in New Issue
Block a user