Files
amnezia-client/client/ui/controllers/selfhosted/exportUiController.cpp
T
yp fb5666057b feat: add extended vless configuration (#2566)
* update UI XRay, add new page PageProtocolXrayTransportSettings.qml PageProtocolXrayXmuxSettings.qml PageProtocolXrayXPaddingSettings.qml

* add UI PageProtocolXrayConfigsSettings, PageProtocolXrayFlowSettings, PageProtocolXraySecuritySettings

* add Xray-specific keys

* add vars xray model

* add new qml padding, update model

* update model and export

* rename file & update name class & update list xray

* fixed ui

* add save file in temp

* remove debug macros

* fixed build windows

* fix path Windows

* remove save config

* fixed changes

* fixed conf

* fixed UI

* fixed size & button save

* fixed build iOS

* fix: fixed headers base control

---------

Co-authored-by: vkamn <vk@amnezia.org>
2026-05-18 22:35:01 +08:00

140 lines
3.8 KiB
C++

#include "exportUiController.h"
#include <QDebug>
#include "../systemController.h"
#include "core/utils/qrCodeUtils.h"
ExportUiController::ExportUiController(ExportController* exportController, QObject *parent)
: QObject(parent),
m_exportController(exportController)
{
}
void ExportUiController::generateFullAccessConfig(const QString &serverId)
{
clearPreviousConfig();
auto result = m_exportController->generateFullAccessConfig(serverId);
applyExportResult(result);
}
void ExportUiController::generateConnectionConfig(const QString &serverId, int containerIndex, const QString &clientName)
{
clearPreviousConfig();
auto result = m_exportController->generateConnectionConfig(serverId, containerIndex, clientName);
applyExportResult(result);
}
void ExportUiController::generateOpenVpnConfig(const QString &serverId, const QString &clientName)
{
clearPreviousConfig();
auto result = m_exportController->generateOpenVpnConfig(serverId, clientName);
applyExportResult(result);
}
void ExportUiController::generateWireGuardConfig(const QString &serverId, const QString &clientName)
{
clearPreviousConfig();
auto result = m_exportController->generateWireGuardConfig(serverId, clientName);
applyExportResult(result);
}
void ExportUiController::generateAwgConfig(const QString &serverId, int containerIndex, const QString &clientName)
{
clearPreviousConfig();
auto result = m_exportController->generateAwgConfig(serverId, containerIndex, clientName);
applyExportResult(result);
}
void ExportUiController::generateXrayConfig(const QString &serverId, const QString &clientName)
{
clearPreviousConfig();
auto result = m_exportController->generateXrayConfig(serverId, clientName);
applyExportResult(result);
}
void ExportUiController::generateQrFromString(const QString &text)
{
clearPreviousConfig();
m_config = text;
m_qrCodes = qrCodeUtils::generateQrCodeImageSeries(text.toUtf8());
emit exportConfigChanged();
}
QString ExportUiController::getConfig()
{
return m_config;
}
QString ExportUiController::getNativeConfigString()
{
return m_nativeConfigString;
}
QList<QString> ExportUiController::getQrCodes()
{
return m_qrCodes;
}
void ExportUiController::exportConfig(const QString &fileName)
{
if (!SystemController::saveFile(fileName, m_config)) {
qInfo() << "ExportUiController::exportConfig: save or share was cancelled or failed";
}
}
void ExportUiController::updateClientManagementModel(const QString &serverId, int containerIndex)
{
m_exportController->updateClientManagementModel(serverId, containerIndex);
}
void ExportUiController::revokeConfig(int row, const QString &serverId, int containerIndex)
{
m_exportController->revokeConfig(row, serverId, containerIndex);
emit revokeConfigFinished();
}
void ExportUiController::renameClient(int row, const QString &clientName, const QString &serverId, int containerIndex)
{
m_exportController->renameClient(row, clientName, serverId, containerIndex);
}
int ExportUiController::getQrCodesCount()
{
return m_qrCodes.size();
}
void ExportUiController::clearPreviousConfig()
{
m_config.clear();
m_nativeConfigString.clear();
m_qrCodes.clear();
emit exportConfigChanged();
}
void ExportUiController::applyExportResult(const ExportController::ExportResult &result)
{
if (result.errorCode != ErrorCode::NoError) {
emit exportErrorOccurred(result.errorCode);
return;
}
m_config = result.config;
m_nativeConfigString = result.nativeConfigString;
m_qrCodes = result.qrCodes;
emit exportConfigChanged();
}
void ExportUiController::setConfigFromString(const QString &config, const QString &fileName)
{
clearPreviousConfig();
m_config = config;
emit exportConfigChanged();
if (!fileName.isEmpty()) {
SystemController::saveFile(fileName, m_config);
}
}